这篇文章我们初步介绍.NET POS技术,让您可以编码。
1、POS是如何获取数据的?
虽然您可以使用任何.Net 技术访问数据,但 POS 提供 helper 类,使数据库连接更简单!
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;usingSystem.Data.SqlClient;using LSRetailPosis.DataAccess;using LSRetailPosis.DataAccess.DataUtil; namespaceRahul.Dynamics.Retail.DataAccess{ public class PosIsButtonGrid : DataLayer { public PosIsButtonGrid(SqlConnection connection, string DATAAREAID) : base(connection, DATAAREAID) { } public DataTable GetPosIsButtonGridById(stringBUTTONGRIDID) { SqlSelect sqlUtilSelect = new SqlSelect("POSISBUTTONGRID"); sqlUtilSelect.Select("BUTTONGRIDID"); sqlUtilSelect.Select("NAME"); sqlUtilSelect.Where("DATAAREAID", base.dataAreaId, true); sqlUtilSelect.Where("BUTTONGRIDID", BUTTONGRIDID, false); return base.dbUtil.GetTable(sqlUtilSelect); } public DataTable GetPosIsButtonGridButtonsByGridId(string BUTTONGRIDID) { SqlSelect sqlUtilSelect = newSqlSelect("POSISBUTTONGRIDBUTTONS"); sqlUtilSelect.Select("DISPLAYTEXT"); sqlUtilSelect.Select("ACTIONPROPERTY"); sqlUtilSelect.Where("DATAAREAID", base.dataAreaId, true); sqlUtilSelect.Where("BUTTONGRIDID", BUTTONGRIDID, false); sqlUtilSelect.OrderBy("ROWNUMBER", true); return base.dbUtil.GetTable(sqlUtilSelect); } }}
2、POS如何显示一个对话框?
using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage("Rahul", MessageBoxButtons.OK, MessageBoxIcon.Error)){ LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog); }
3) 将项目添加到当前的销售事务。
//Sale item. Add it to retail transaction
public static void ItemSale(ref PosTransaction posTransaction, string itemID, decimal quantity) { // If the transaction object is not of the type RetailTransaction, it has to be converted to one before an item can be added if (posTransaction.GetType() !=typeof(RetailTransaction)) { posTransaction = newRetailTransaction(LSRetailPosis.Settings.ApplicationSettings.Terminal.StoreId, LSRetailPosis.Settings.ApplicationSettings.Terminal.StoreCurrency, LSRetailPosis.Settings.ApplicationSettings.Terminal.TaxIncludedInPrice, LSRetailPosis.ApplicationServices.IRounding); TransactionSystem transSystem = new TransactionSystem(posTransaction); transSystem.LoadTransactionStatus(); } try { stringselectedItemId = itemID; //if (ApplicationServices.IItem.ItemSearch(ref selectedItemId, 500)) { ItemSystem system = newItemSystem((RetailTransaction)posTransaction); string selectedBarcodeId = ""; DataTable barcodesForItem = system.GetBarcodesForItem(selectedItemId); if (barcodesForItem == null) { selectedBarcodeId = ""; } else if(barcodesForItem.Rows.Count == 0) { selectedBarcodeId = ""; } else if (barcodesForItem.Rows.Count == 1) { selectedBarcodeId = barcodesForItem.Rows[0][0].ToString(); } if (selectedBarcodeId.Length != 0) { OperationInfo o = new OperationInfo(); o.NumpadQuantity = 1; o.NumpadValue = selectedBarcodeId; o.ReturnItems = false; new ItemSale { OperationID = PosisOperations.ItemSale, OperationInfo = o, Barcode = selectedBarcodeId, POSTransaction = posTransaction }.RunOperation(); } else { OperationInfo o = new OperationInfo(); o.NumpadQuantity = 1; o.NumpadValue = selectedItemId; o.ReturnItems = false; new ItemSale { OperationID = PosisOperations.ItemSale, OperationInfo = o, Barcode = selectedItemId, POSTransaction = posTransaction }.RunOperation(); } } } catch (PosisException exception) { using(LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error)) { LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog); } ApplicationExceptionHandler.HandleException("BlankOperation.ItemSale", exception); throw; } catch (Exception exception2) {using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(exception2.Message, MessageBoxButtons.OK, MessageBoxIcon.Error)) { LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog); } ApplicationExceptionHandler.HandleException("BlankOperation.ItemSale", exception2); throw; } }