コード例 #1
0
        public void LabelPrintProductDetailAdd(string branchCode, string docno, List <LabelPrintProductDetail> details)
        {
            var provider = ProviderFactory.GetProvider(branchCode, "System.Data.SqlClient");
            var repo     = new SimpleRepository(provider);

            var labelPrintProduct = repo.Single <LabelPrintProduct>(docno);

            var            displayOrder         = 0;
            string         productCodeOrBarcode = "";
            ProductBarcode product      = null;
            ProductPrice   productPrice = null;

            foreach (var item in details)
            {
                item.Docno              = docno;
                item.Docdate            = DateTime.Now.Date;
                item.Roworder           = displayOrder.ToString();
                item.PrintLabelTypeCode = labelPrintProduct.Printlabeltype;
                if (!string.IsNullOrEmpty(item.Barcode))
                {
                    productCodeOrBarcode = item.Barcode;
                }
                else
                {
                    productCodeOrBarcode = item.Productcode;
                }

                product = ProductBarcodeGetByProductCodeOrBarcode3(branchCode, productCodeOrBarcode);
                if (product != null)
                {
                    item.Productcode = product.ProductCode;
                    item.Productname = product.ProductName;
                    item.Barcode     = product.Barcode;
                    item.Unitcode    = product.UnitCode;
                    item.Unitname    = product.UnitName;
                    item.OthUnitcode = item.Unitcode;
                    item.OthUnitname = item.Unitname;
                    productPrice     = ProductPriceGetCurrentPrice(branchCode, item.Productcode, item.Unitcode);
                    if (productPrice != null)
                    {
                        item.Sellprice    = productPrice.Saleprice;
                        item.Pricedate    = productPrice.Begindate;
                        item.OthUnitprice = item.Sellprice;
                    }
                }

                displayOrder++;
            }

            using (System.Transactions.TransactionScope ts = new TransactionScope())
            {
                using (SharedDbConnectionScope scs = new SharedDbConnectionScope(provider))
                {
                    repo.DeleteMany <LabelPrintProductDetail>(p => p.Docno == docno);
                    repo.AddMany <LabelPrintProductDetail>(details);
                    ts.Complete();
                }
            }
        }
コード例 #2
0
        public ProductBarcode ProductBarcodeGetByBarcode(string barcode, string branchCode)
        {
            ProductBarcode productBarcode = null;

            using (DbManager db = new DbManager(branchCode))
            {
                productBarcode = db
                                 .SetCommand(GetSql(4),
                                             db.Parameter("@Barcode", barcode))
                                 .ExecuteObject <ProductBarcode>();

                if (productBarcode != null)
                {
                    productBarcode.ProductPrice     = GetProductPrice(productBarcode.ProductCode, productBarcode.UnitCode, branchCode);
                    productBarcode.ProductPriceText = productBarcode.ProductPrice.ToString("N2");
                }
            }

            return(productBarcode);
        }
コード例 #3
0
        public List <ProductBarcode> ProductBarcodeGetByProductCodeOrBarcode5(string branchCode, string productCodeOrBarcode, string warehouseCode)
        {
            var product    = new List <ProductBarcode>();
            var tmpproduct = new List <ProductBarcode>();

            using (DbManager db = new DbManager(branchCode))
            {
                product = db
                          .SetCommand(GetSql(104),
                                      db.Parameter("@Barcode", productCodeOrBarcode),
                                      db.Parameter("@Branchcode", branchCode),
                                      db.Parameter("@Warehousecode", warehouseCode)
                                      )
                          .ExecuteList <ProductBarcode>();

                if (product != null)
                {
                    var Result = product.Where(x => x.Barcode == productCodeOrBarcode && x.ProductCode != productCodeOrBarcode).Take(1).ToList();
                    if (Result.Count > 0)
                    {
                        product = product.Where(x => x.UnitCode != Result.First().UnitCode).ToList();
                        product.Add(Result.First());
                    }

                    //List<UnitBarcode> barcode = new List<UnitBarcode>();
                    //var results = (product.GroupBy(p => p.UnitCode, (key, g) => new { Unit = key, Products = g.ToList() })).ToList();
                    //foreach (var item in results)
                    //{
                    //    if (item.Products.Count>1)
                    //    {
                    //        foreach (var itemin in item.Products)
                    //        {
                    //            if (itemin.Barcode == productCodeOrBarcode)
                    //            {
                    //                barcode.Add(new UnitBarcode { BarCode = itemin.Barcode, UnitCode = itemin.UnitCode });
                    //            }
                    //        }
                    //        if (barcode.Count> 1)
                    //        {
                    //            //product = from o in product where o.Barcode != productCodeOrBarcode  select o;
                    //        }
                    //    }
                    //}
                    //tmpproduct.Clear();
                    SAPProxyII.UWProxy          prx    = new SAPProxyII.UWProxy();
                    SAP.Connector.SAPConnection cnnSAP = new SAP.Connector.SAPConnection(GlobalContext.SapDestination);
                    cnnSAP.Open();
                    prx.Connection = cnnSAP;
                    SAPProxyII.MARCTable  marcs  = new SAPProxyII.MARCTable();
                    SAPProxyII.TLOGTTable tlogts = new SAPProxyII.TLOGTTable();
                    SAPProxyII.WERKS      werks  = new SAPProxyII.WERKS();
                    werks.Werks = branchCode;
                    foreach (var item in product)
                    {
                        var price = ProductPriceGetCurrentPrice(branchCode, item.ProductCode, item.UnitCode);
                        if (price != null)
                        {
                            item.ProductPrice     = price.Saleprice;
                            item.ProductPriceText = price.Saleprice.ToString("N2");
                        }
                        var Li = product.Where(x => x.ProductCode == item.ProductCode && x.LOGGR != null).ToList();
                        if (Li.Count == 0)
                        {
                            try
                            {
                                prx.Zdd_Export_Pos_Marc(AddZero(item.ProductCode, 18), werks, ref marcs, ref tlogts);
                                foreach (SAPProxyII.TLOGT itemin in tlogts)
                                {
                                    item.LOGGR = itemin.Loggr + "-" + itemin.Ltext;
                                    break;
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                        else
                        {
                            item.LOGGR = Li.First().LOGGR;
                        }
                        try
                        {
                            var Position = GetProductPosition(item.ProductCode, warehouseCode, item.UnitCode);
                            var i        = 0;
                            foreach (var items in Position)
                            {
                                if (i == 0)
                                {
                                    item.PositionCode = items.PositionCode;
                                }
                                else
                                {
                                    var TmpItem = new ProductBarcode()
                                    {
                                        Barcode          = item.Barcode,
                                        BinCode          = item.BinCode,
                                        LOGGR            = item.LOGGR,
                                        PositionCode     = item.PositionCode,
                                        ProductCode      = item.ProductCode,
                                        ProductName      = item.ProductName,
                                        ProductPrice     = item.ProductPrice,
                                        ProductPriceText = item.ProductPriceText,
                                        Quantity         = item.Quantity,
                                        Status           = item.Status,
                                        StockQuantity    = item.StockQuantity,
                                        StoreLocation    = item.StoreLocation,
                                        UnitCode         = item.UnitCode,
                                        UnitName         = item.UnitName,
                                        UnitRate         = item.UnitRate
                                    };
                                    TmpItem.PositionCode = items.PositionCode;
                                    tmpproduct.Add(TmpItem);
                                }
                                i += 1;
                            }
                            //if (Position != null)
                            //{
                            //    item.PositionCode = Position.PositionCode;
                            //}
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                foreach (var item in tmpproduct)
                {
                    product.Add(item);
                }
                return(product);
            }
        }