Example #1
0
        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)
                        {
                            //item.Unitofmeasure
                            //lastLocation = item.Bin_Code;
                            //var product = ProductLocationGetByProductCode(productCode, warehouseCode, branchCode);
                            var product = ProductInfoGet(branchCode, productCode, item.Unitofmeasure);
                            if (product != null)
                            {
                                products.Add(new HandHeldCounterHold
                                {
                                    Productcode = product.ProductCode,
                                    Productname = product.ProductName,
                                    Location    = item.Bin_Code,
                                    Unitcode    = product.Uom,
                                    Unitname    = product.UomName,
                                    Quantity    = 0
                                });
                            }
                        }
                    }
                }
            }

            return(products);
        }
Example #2
0
        private string SAPGetLocation(string productCode, string unitCode, string wareHouseCode, string branchCode)
        {
            string location = string.Empty;

            using (SAP.Connector.SAPConnection sapConnection = new SAP.Connector.SAPConnection(GlobalContext.SapDestination))
            {
                using (SAPProxy.UWProxy prx = new SAPProxy.UWProxy())
                {
                    productCode = SapProductCodeFormated(productCode);

                    prx.Connection = sapConnection;

                    SAPProxy.ZSTRC_MATERIAL_MASTER strc          = new SAPProxy.ZSTRC_MATERIAL_MASTER();
                    SAPProxy.MEANTable             MeanTB        = new SAPProxy.MEANTable();
                    SAPProxy.MARDTable             MardTB        = new SAPProxy.MARDTable();
                    SAPProxy.MARATable             MaraTB        = new SAPProxy.MARATable();
                    SAPProxy.MARMTable             MarmTB        = new SAPProxy.MARMTable();
                    SAPProxy.ZMM_ASSIGNLOCTable    TB_MMLOCATION = new SAPProxy.ZMM_ASSIGNLOCTable();
                    SAPProxy.MLGTTable             TB_WHLOCATION = new SAPProxy.MLGTTable();

                    var ProductCode            = productCode;
                    var ProductMain            = productCode;
                    SAPProxy.MARATable MaraTB2 = new SAPProxy.MARATable();
                    prx.Zdd_Get_Material_Master(ProductCode, out strc, ref MeanTB, ref TB_MMLOCATION, ref MardTB, ref MaraTB2, ref MarmTB, ref TB_WHLOCATION);

                    foreach (SAPProxy.ZMM_ASSIGNLOC item in TB_MMLOCATION)
                    {
                        string sWH = "11";
                        if (branchCode == "1200")
                        {
                            sWH = "12";
                        }
                        if (item.Unitofmeasure == unitCode && item.Storage_Loc == wareHouseCode)
                        {
                            location = item.Bin_Code;
                            break;
                        }
                        else if (item.Unitofmeasure == unitCode && item.Storage_Loc.Substring(0, 2) == sWH)
                        {
                            location = item.Bin_Code;
                            break;
                        }
                    }

                    foreach (SAPProxy.MLGT item in TB_WHLOCATION)
                    {
                        location = item.Lgpla;
                        break;
                    }
                }
            }

            return(location);
        }
Example #3
0
        private List <Location> SAPGetLocationAllUnit(string productCode, string unitCode, string wareHouseCode)
        {
            List <Location> locations = new List <Location>();

            using (SAP.Connector.SAPConnection sapConnection = new SAP.Connector.SAPConnection(GlobalContext.SapDestination))
            {
                using (SAPProxy.UWProxy prx = new SAPProxy.UWProxy())
                {
                    var sapProductCode = SapProductCodeFormated(productCode);

                    prx.Connection = sapConnection;

                    SAPProxy.ZSTRC_MATERIAL_MASTER strc          = new SAPProxy.ZSTRC_MATERIAL_MASTER();
                    SAPProxy.MEANTable             MeanTB        = new SAPProxy.MEANTable();
                    SAPProxy.MARDTable             MardTB        = new SAPProxy.MARDTable();
                    SAPProxy.MARATable             MaraTB        = new SAPProxy.MARATable();
                    SAPProxy.MARMTable             MarmTB        = new SAPProxy.MARMTable();
                    SAPProxy.ZMM_ASSIGNLOCTable    TB_MMLOCATION = new SAPProxy.ZMM_ASSIGNLOCTable();
                    SAPProxy.MLGTTable             TB_WHLOCATION = new SAPProxy.MLGTTable();

                    var ProductCode            = productCode;
                    var ProductMain            = productCode;
                    SAPProxy.MARATable MaraTB2 = new SAPProxy.MARATable();
                    prx.Zdd_Get_Material_Master(sapProductCode, out strc, ref MeanTB, ref TB_MMLOCATION, ref MardTB, ref MaraTB2, ref MarmTB, ref TB_WHLOCATION);

                    DataTable dt = TB_MMLOCATION.ToADODataTable();
                    //เอาหน่วยออก พี่เอ็มแจ้งให้แสดงทุกหน่วยของสินค้า 2012-11-09
                    //string condition = string.Format("Storage_Loc='{0}' AND Unitofmeasure='{1}'", wareHouseCode, unitCode);
                    string    condition = string.Format("Storage_Loc='{0}'", wareHouseCode);
                    DataRow[] rows      = dt.Select(condition);
                    foreach (DataRow row in rows)
                    {
                        Location location = new Location();
                        location.Code = row["bin_code"] as string;
                        locations.Add(location);
                    }
                }
            }

            return(locations);
        }