Ejemplo n.º 1
0
        public List <ProductPosition> GetProductPosition(string sProductCode, string sWarehouse)
        {
            var ProdReturn = new List <ProductPosition>();

            try
            {
                using (var sapConnection = new SAP.Connector.SAPConnection(GlobalContext.SapDestination))
                {
                    using (var prx = new SAPProxyIII.UWProxy())
                    {
                        prx.Connection = sapConnection;
                        SAPProxyIII.ZMM_ASSIGNLOCTable tables = new SAPProxyIII.ZMM_ASSIGNLOCTable();
                        prx.Zdd_Handheld_Get_Zmm_Assignloc("", sWarehouse, sProductCode, ref tables);
                        DataTable dt = tables.ToADODataTable();
                        foreach (DataRow item in dt.Rows)
                        {
                            if (item["LOCTYPE"].ToString().ToUpper() != "T")
                            {
                                ProdReturn.Add(new ProductPosition {
                                    PositionCode = item["BIN_CODE"].ToString(), ProductCode = item["MATERIAL"].ToString(), UnitCode = item["UNITOFMEASURE"].ToString()
                                });
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
            return(ProdReturn);
        }
Ejemplo n.º 2
0
        //public Location LocationGetByCode(string locationCode)
        //{
        //    using (DbManager db = new DbManager())
        //    {
        //        return db
        //            .SetCommand("SELECT * FROM TBUnit Where Code = @UnitCode;",
        //            db.Parameter("@UnitCode", unitCode))
        //            .ExecuteObject<ProductUnit>();
        //    }
        //}

        public List <ProductLocation> ProductLocationGetByLocation(string branchCode, string locationCode, string warehouseCode)
        {
            using (var sapConnection = new SAP.Connector.SAPConnection(GlobalContext.SapDestination))
            {
                using (var prx = new SAPProxyIII.UWProxy())
                {
                    prx.Connection = sapConnection;

                    var Tables = new SAPProxyIII.ZMM_ASSIGNLOCTable();

                    prx.Zdd_Handheld_Get_Zmm_Assignloc(locationCode, warehouseCode, string.Empty, ref Tables);

                    var locations = (List <SAPProxyIII.ZMM_ASSIGNLOC>)CollectionHelper.ConvertTo <SAPProxyIII.ZMM_ASSIGNLOC>(Tables.ToADODataTable());

                    List <ProductLocation> productLocations = new List <ProductLocation>();
                    var         productCode = string.Empty;
                    Product     product     = null;
                    ProductUnit productUnit = null;
                    foreach (var item in locations)
                    {
                        productCode = SystemProductCodeFormated(item.Material);

                        product     = GetProductByCode(branchCode, productCode);
                        productUnit = ProductUnitGetByCode(branchCode, item.Unitofmeasure);
                        productLocations.Add(new ProductLocation
                        {
                            LocationCode    = item.Bin_Code,
                            ProductCode     = productCode,
                            ProductBarcode  = GetProductBarcodeByProductCode(branchCode, productCode, item.Unitofmeasure),
                            ProductName     = product.NameTh,
                            ProductUnitCode = item.Unitofmeasure,
                            ProductUnitName = productUnit.Name,
                            PutLevel        = item.Putlevel,
                            PutQuantity     = item.Putqty,
                            DisplayOrder    = Convert.ToInt32(item.Roworder)
                        });
                    }

                    productLocations.Sort(delegate(ProductLocation p1, ProductLocation p2) { return(p1.DisplayOrder.CompareTo(p2.DisplayOrder)); });

                    return(productLocations);
                }
            }
        }