private List <HandHeldCounterHold> SAPHandHeldCounterHoldGetLocation(string productCode, string sapProductCode, string warehouseCode, string branchCode) { List <HandHeldCounterHold> products = new List <HandHeldCounterHold>(); //Zdd_Get_Material_Master using (var sapConnection = new SAPConnection(GlobalContext.SapDestination)) { using (var proxy = new SAPProxy.UWProxy()) { proxy.Connection = sapConnection; SAPProxy.ZSTRC_MATERIAL_MASTER e_mat_strc = new SAPProxy.ZSTRC_MATERIAL_MASTER(); SAPProxy.MEANTable tb_barcode = new SAPProxy.MEANTable(); SAPProxy.ZMM_ASSIGNLOCTable assign_loc = new SAPProxy.ZMM_ASSIGNLOCTable(); SAPProxy.MARDTable mard = new SAPProxy.MARDTable(); SAPProxy.MARATable mara = new SAPProxy.MARATable(); SAPProxy.MARMTable marm = new SAPProxy.MARMTable(); SAPProxy.MLGTTable mlgt = new SAPProxy.MLGTTable(); proxy.Zdd_Get_Material_Master(sapProductCode , out e_mat_strc , ref tb_barcode , ref assign_loc , ref mard , ref mara , ref marm , ref mlgt); assign_loc.SortBy("Bin_code", "ASC"); string lastLocation = string.Empty; foreach (SAPProxy.ZMM_ASSIGNLOC item in assign_loc) { if (item.Storage_Loc == warehouseCode && lastLocation != item.Bin_Code) { lastLocation = item.Bin_Code; ProductLocation product = ProductLocationGetByProductCode(productCode, warehouseCode, branchCode); if (product != null) { products.Add(new HandHeldCounterHold { Productcode = product.ProductCode, Productname = product.ProductName, Location = item.Bin_Code, Unitcode = product.ProductUnitCode, Unitname = product.ProductUnitName, Quantity = 0 }); } } } } } return(products); }
public ProductLocation ProductLocationGetByProductCodeOrBarcode(string productCodeOrBarcode, string warehouseCode, string branchCode) { ProductLocation product = null; product = ProductLocationGetInfomationByBarcode(productCodeOrBarcode, warehouseCode, branchCode); if (product == null) { product = ProductLocationGetByProductCode(productCodeOrBarcode, warehouseCode, branchCode); } return(product); }
public ProductLocation ProductLocationGetByBarcode(string barcode, string locationCode, string warehouseCode, string branchCode) { var product = ProductBarcodeGetByProductCodeOrBarcode3(branchCode, barcode); if (product == null) { return(null); } ProductLocation productLocation = new ProductLocation(); using (SAP.Connector.SAPConnection sapConnection = new SAP.Connector.SAPConnection(GlobalContext.SapDestination)) { using (SAPProxyII.UWProxy prx = new SAPProxyII.UWProxy()) { prx.Connection = sapConnection; SAPProxyII.ZMM_ASSIGNLOCTable tables = new SAPProxyII.ZMM_ASSIGNLOCTable(); prx.Zdd_Handheld_Set_Zmm_Assignloc(locationCode, "", "", "", 0, 0, 0, "", "", ref tables); DataTable locationTable = tables.ToADODataTable(); string productCode = SapProductCodeFormated(product.ProductCode); var condition = new StringBuilder(); condition.AppendFormat(" STORAGE_LOC='{0}'", warehouseCode); condition.AppendFormat(" AND BIN_CODE='{0}'", locationCode); condition.AppendFormat(" AND MATERIAL='{0}'", productCode); condition.AppendFormat(" AND UNITOFMEASURE='{0}'", product.UnitCode); var rows = locationTable.Select(condition.ToString()); if (rows.Length > 0) { productLocation.StatusText = "พบ"; } else { productLocation.StatusText = "ไม่พบ"; } } } productLocation.LocationCode = locationCode; productLocation.ProductCode = product.ProductCode; productLocation.ProductName = product.ProductName; productLocation.ProductBarcode = product.Barcode; productLocation.ProductUnitCode = product.UnitCode; productLocation.ProductUnitName = product.UnitName; return(productLocation); }
public ProductLocation ProductLocationGetInfomationByBarcode(string barcode, string warehouseCode, string branchCode) { ProductLocation product = null; using (DbManager db = new DbManager(branchCode)) { try { product = db.SetCommand(GetSql(15), db.Parameter("@Barcode", barcode)).ExecuteObject <ProductLocation>(); if (product != null) { product.SalePrice = GetProductPrice(product.ProductCode, product.ProductUnitCode, branchCode); product.LocationCode = SAPGetLocation(product.ProductCode, product.ProductUnitCode, warehouseCode, branchCode); product.RandomText = "********"; } } catch (Exception ex) { throw ex; } return(product); } }
public List <ProductLocation> ProductLocationGetAllByBarcode(string barcode, string branchCode, string warehouseCode) { List <ProductLocation> productLocations = new List <ProductLocation>(); using (SAP.Connector.SAPConnection sapConnection = new SAP.Connector.SAPConnection(GlobalContext.SapDestination)) { using (SAPProxyII.UWProxy prx = new SAPProxyII.UWProxy()) { prx.Connection = sapConnection; var productBarcode = ProductBarcodeGetByBarcode(barcode, branchCode); var sapProductCode = SapProductCodeFormated(productBarcode.ProductCode); SAPProxyII.MARDTable Tables = new SAPProxyII.MARDTable(); prx.Zdd_Handheld_Get_Mard(sapProductCode, ref Tables); string branchCodePrefix = branchCode.Substring(0, 2); double balanceQuantity1 = 0; double balanceQuantity2 = 0; List <Location> locations = null; int index = 0; // old logic by P' Tommy foreach (SAPProxyII.MARD tbl in Tables) { if (tbl.Werks.Substring(2, 2) != "99" && tbl.Werks.Substring(0, 2) == branchCodePrefix) { var productLocation = new ProductLocation(); productLocation.ProductUnitCode = productBarcode.UnitCode; productLocation.ProductUnitName = productBarcode.UnitName; productLocation.WarehouseCode = tbl.Lgort; productLocation.WarehouseName = WareHouseGetSingle(tbl.Lgort, branchCode).Name; balanceQuantity1 = SAPGetBalanceQuantity(productBarcode.ProductCode, tbl.Lgort, productBarcode.UnitCode, branchCodePrefix + "00"); balanceQuantity2 = SAPGetBalanceQuantity(productBarcode.ProductCode, tbl.Lgort, productBarcode.UnitCode, branchCodePrefix + "99"); //productLocation.LocationCode = location.Code; productLocation.BalanceQuantity = (balanceQuantity1 + balanceQuantity2); productLocation.BalanceQuantityText = productLocation.BalanceQuantity.ToString("N2"); productLocations.Add(productLocation); locations = SAPGetLocation(productBarcode.ProductCode, productBarcode.UnitCode, tbl.Lgort); index = 0; foreach (var location in locations) { //productLocation = productLocations.Find(p => p.WarehouseCode == location.Code); if (index == 0) { productLocation.LocationCode = location.Code; //balanceQuantity1 = SAPGetBalanceQuantity(productBarcode.ProductCode, location.Code, productBarcode.UnitCode, branchCodePrefix + "00"); //balanceQuantity2 = SAPGetBalanceQuantity(productBarcode.ProductCode, location.Code, productBarcode.UnitCode, branchCodePrefix + "99"); //productLocation.BalanceQuantity = (balanceQuantity1 + balanceQuantity2); } else { productLocation = new ProductLocation(); productLocation.BalanceQuantityText = string.Empty; //productLocation.WarehouseCode = tbl.Lgort; //productLocation.WarehouseName = WareHouseGetSingle(tbl.Lgort, branchCode).Name; productLocation.LocationCode = location.Code; //balanceQuantity1 = SAPGetBalanceQuantity(productBarcode.ProductCode, location.Code, productBarcode.UnitCode, branchCodePrefix + "00"); //balanceQuantity2 = SAPGetBalanceQuantity(productBarcode.ProductCode, location.Code, productBarcode.UnitCode, branchCodePrefix + "99"); //productLocation.BalanceQuantity = (balanceQuantity1 + balanceQuantity2); productLocations.Add(productLocation); } //if (index == 0) //{ // productLocation = productLocations.Find(p => p.WarehouseCode == location.Code); //} //else { // productLocation = new ProductLocation(); // productLocation.WarehouseCode = tbl.Lgort; // productLocation.WarehouseName = WareHouseGetSingle(tbl.Lgort, branchCode).Name; // balanceQuantity1 = SAPGetBalanceQuantity(productBarcode.ProductCode, location.Code, productBarcode.UnitCode, branchCodePrefix + "00"); // balanceQuantity2 = SAPGetBalanceQuantity(productBarcode.ProductCode, location.Code, productBarcode.UnitCode, branchCodePrefix + "99"); // productLocation.LocationCode = location.Code; // productLocation.BalanceQuantity = (balanceQuantity1 + balanceQuantity2); // productLocations.Add(productLocation); //} index++; } } } } } //var productBarcode = ProductBarcodeGetByBarcode(barcode); //List<ProductLocation> productLocations = new List<ProductLocation>(); //var productLocation = new ProductLocation(); //productLocation.LocationCode = SAPGetLocation(productBarcode.ProductCode, productBarcode.UnitCode, warehouseCode, branchCode); //productLocation.BalanceQuantity = SAPGetBalanceQuantity(productBarcode.ProductCode, warehouseCode, productBarcode.UnitCode, branchCode); //productLocation.ProductUnitCode = productBarcode.UnitCode; //productLocation.ProductUnitName = productBarcode.UnitName; //productLocations.Add(productLocation); return(productLocations); }
public void ProductLocationMixItemAdd(string branchCode, string warehouseCode, string userCode, ProductLocation productLocation) { using (DbManager db = new DbManager(branchCode)) { try { int displayOrder = db.SetCommand(GetSql(3)).ExecuteScalar <int>(); db.BeginTransaction(); db.SetCommand(GetSql(2), db.Parameter("@BRANCHCODE", branchCode), db.Parameter("@WAREHOUSE", warehouseCode), db.Parameter("@LOCATION", productLocation.LocationCode), db.Parameter("@ROWORDER", displayOrder), db.Parameter("@PRODUCTCODE", productLocation.ProductCode), db.Parameter("@PRODUCTNAME", productLocation.ProductName), db.Parameter("@UNITCODE", productLocation.ProductUnitCode), db.Parameter("@BARCODE", productLocation.ProductBarcode), db.Parameter("@DOCDATE", DateTime.Today), db.Parameter("@STATUS", productLocation.StatusText == "พบ" ? "FOUND" : "NOT FOUND"), db.Parameter("@OFFICERID", null), db.Parameter("@CREATEUSER", userCode)) .ExecuteNonQuery(); db.CommitTransaction(); } catch (Exception ex) { db.RollbackTransaction(); throw ex; } } }