public bool ProductLocationAdd(string branchCode, string locationCode, string warehouseCode, List <ProductLocation> productLocations) { bool isSaved = false; try { using (SAP.Connector.SAPConnection sapConnection = new SAP.Connector.SAPConnection(GlobalContext.SapDestination)) { using (SAPProxyII.UWProxy prx = new SAPProxyII.UWProxy()) { prx.Connection = sapConnection; SAPProxyII.ZMM_ASSIGNLOCTable productLocationTable = new SAPProxyII.ZMM_ASSIGNLOCTable(); // clear old data in SAP. prx.Zdd_Handheld_Del_Zmm_Assignloc(locationCode, warehouseCode, ref productLocationTable); foreach (var item in productLocations) { if (string.IsNullOrEmpty(item.ProductCode)) { var product = ProductBarcodeGetByProductCodeOrBarcode3(branchCode, item.ProductBarcode); if (product == null) { continue; } item.ProductCode = product.ProductCode; item.ProductUnitCode = product.UnitCode; } productLocationTable = new SAPProxyII.ZMM_ASSIGNLOCTable(); prx.Zdd_Handheld_Set_Zmm_Assignloc(locationCode, "X", item.LocationType, SapProductCodeFormated(item.ProductCode), item.PutLevel, item.PutQuantity, item.DisplayOrder, warehouseCode, item.ProductUnitCode, ref productLocationTable); } isSaved = true; } } } catch { isSaved = false; } return(isSaved); }
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); }
private bool SapLocationGetIsContains(string productCode, string unitCode, string locationCode, string warehouseCode, out int displayOrder) { bool isContain = false; displayOrder = 0; 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 sapProductCode = SapProductCodeFormated(productCode); var condition = new StringBuilder(); condition.AppendFormat(" STORAGE_LOC='{0}'", warehouseCode); condition.AppendFormat(" AND BIN_CODE='{0}'", locationCode); condition.AppendFormat(" AND MATERIAL='{0}'", sapProductCode); condition.AppendFormat(" AND UNITOFMEASURE='{0}'", unitCode); var rows = locationTable.Select(condition.ToString()); if (rows.Length > 0) { isContain = true; displayOrder = Convert.ToInt32(rows[0]["ROWORDER"]); } else { isContain = false; } } } return(isContain); }