예제 #1
0
        /// <summary>
        /// Get Line Kits
        /// </summary>
        /// <param name="saleNumber"></param>
        /// <param name="lineNumber"></param>
        /// <param name="dataSource"></param>
        /// <returns></returns>
        private Line_Kits GetLineKits(int saleNumber, int lineNumber, DataSource dataSource)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,ReturnSaleService,GetLineKits,{string.Empty},{dateStart:hh.mm.ss.ffffff}");

            Line_Kits lineKits = new Line_Kits();

            // Get the kit items in the line
            var rsLineKit = GetRecords("Select *  FROM   SaleKit  WHERE  SaleKit.Sale_No = " + CommonUtility.GetStringValue(saleNumber) + " AND  SaleKit.Line_No = " + CommonUtility.GetStringValue(lineNumber) + " ", dataSource);

            foreach (DataRow rsLineKitFields in rsLineKit.Rows)
            {
                // Charges on Kit items
                var rsLineKitChg = GetRecords("Select * From   SaleKitChg Where  SaleKitChg.Sale_No = " + CommonUtility.GetStringValue(saleNumber) + " AND  SaleKitChg.Line_No = " + CommonUtility.GetStringValue(lineNumber) + " AND  SaleKitChg.Kit_Item = \'" + CommonUtility.GetStringValue(rsLineKitFields["Kit_Item"]) + "\' ", dataSource);
                var lkc          = new K_Charges();
                foreach (DataRow rsLineKitChgFields in rsLineKitChg.Rows)
                {
                    // Taxes on Charges on Kit items
                    var rsCgt = GetRecords("Select * From   SaleKitChgTax Where  SaleKitChgTax.Sale_No  = " + CommonUtility.GetStringValue(saleNumber) + " AND  SaleKitChgTax.Line_No  = " + CommonUtility.GetStringValue(lineNumber) + " AND SaleKitChgTax.Kit_Item = \'" + CommonUtility.GetStringValue(rsLineKitFields["Kit_Item"]) + "\' AND  SaleKitChgTax.As_Code  = \'" + CommonUtility.GetStringValue(rsLineKitChgFields["As_Code"]) + "\' ", dataSource);
                    var cgt   = new Charge_Taxes();
                    foreach (DataRow rsCgtFields in rsCgt.Rows)
                    {
                        cgt.Add(CommonUtility.GetStringValue(rsCgtFields["Tax_Name"]), CommonUtility.GetStringValue(rsCgtFields["Tax_Code"]), CommonUtility.GetFloatValue(rsCgtFields["Tax_Rate"]), CommonUtility.GetBooleanValue(rsCgtFields["Tax_Included"]), "");
                    }
                    lkc.Add(CommonUtility.GetDoubleValue(rsLineKitChgFields["price"]), CommonUtility.GetStringValue(rsLineKitChgFields["Description"]), CommonUtility.GetStringValue(rsLineKitChgFields["As_Code"]), cgt, "");
                }
                lineKits.Add(CommonUtility.GetStringValue(rsLineKitFields["Kit_Item"]), CommonUtility.GetStringValue(rsLineKitFields["Descript"]), CommonUtility.GetFloatValue(rsLineKitFields["Quantity"]), CommonUtility.GetFloatValue(rsLineKitFields["Base"]), CommonUtility.GetFloatValue(rsLineKitFields["Fraction"]), CommonUtility.GetFloatValue(rsLineKitFields["Alloc"]), CommonUtility.GetStringValue(rsLineKitFields["Serial"]), lkc, "");
            }
            _performancelog.Debug($"End,ReturnSaleService,GetLineKits,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(lineKits);
        }
예제 #2
0
        /// <summary>
        /// Method to get line kit
        /// </summary>
        /// <param name="db">Data source</param>
        /// <param name="sn">Sale number</param>
        /// <param name="ln">Line number</param>
        /// <returns>Line kits</returns>
        public Line_Kits Get_Line_Kit(DataSource db, int sn, int ln)
        {
            Line_Kits lk = new Line_Kits();

            // Get the kit items in the line
            var rsLineKit = GetRecords("Select *  FROM   SaleKit  WHERE  SaleKit.Sale_No = " + Convert.ToString(sn)
                                       + " AND " + "       SaleKit.Line_No = " + Convert.ToString(ln) + " ", db);

            foreach (DataRow lineKit in rsLineKit.Rows)
            {
                // Charges on Kit items
                var rsLineKitChg = GetRecords("Select *  FROM   SaleKitChg  WHERE  SaleKitChg.Sale_No = "
                                              + Convert.ToString(sn) + " AND " + "       SaleKitChg.Line_No = " + Convert.ToString(ln)
                                              + " AND " + "       SaleKitChg.Kit_Item = \'" + CommonUtility.GetStringValue(lineKit["Kit_Item"]) + "\' ", db);

                var lkc = new K_Charges();
                foreach (DataRow kitCharge in rsLineKitChg.Rows)
                {
                    // Taxes on Charges on Kit items
                    var rsCgt = GetRecords("Select *  FROM   SaleKitChgTax  WHERE  SaleKitChgTax.Sale_No  = "
                                           + Convert.ToString(sn) + " AND " + "       SaleKitChgTax.Line_No  = "
                                           + Convert.ToString(ln) + " AND " + "       SaleKitChgTax.Kit_Item = \'"
                                           + CommonUtility.GetStringValue(lineKit["Kit_Item"]) + "\' AND " + "       SaleKitChgTax.As_Code  = \'"
                                           + CommonUtility.GetStringValue(kitCharge["As_Code"]) + "\' ", db);

                    var cgt = new Charge_Taxes();
                    foreach (DataRow tax in rsCgt.Rows)
                    {
                        cgt.Add(CommonUtility.GetStringValue(tax["Tax_Name"]),
                                CommonUtility.GetStringValue(tax["Tax_Code"]),
                                CommonUtility.GetFloatValue(tax["Tax_Rate"]),
                                CommonUtility.GetBooleanValue(tax["Tax_Included"]), "");
                    }
                    lkc.Add(CommonUtility.GetDoubleValue(kitCharge["price"]),
                            CommonUtility.GetStringValue(kitCharge["Description"]),
                            CommonUtility.GetStringValue(kitCharge["As_Code"]), cgt, "");
                }

                lk.Add(CommonUtility.GetStringValue(lineKit["Kit_Item"]),
                       CommonUtility.GetStringValue(lineKit["Descript"]),
                       CommonUtility.GetFloatValue(lineKit["Quantity"]),
                       CommonUtility.GetFloatValue(lineKit["Base"]),
                       CommonUtility.GetFloatValue(lineKit["Fraction"]),
                       CommonUtility.GetFloatValue(lineKit["Alloc"]),
                       CommonUtility.GetStringValue(lineKit["Serial"]), lkc, "");
            }

            var returnValue = lk;

            return(returnValue);
        }
예제 #3
0
        /// <summary>
        /// Method to make kits
        /// </summary>
        /// <param name="stockCode">Stock code</param>
        /// <param name="stockType">Stock type</param>
        /// <param name="description">Description</param>
        /// <param name="vendor">Vendor</param>
        /// <returns>Line kits</returns>
        private Line_Kits GetLineKits(string stockCode, char stockType, string description
                                      , string vendor)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,StockManager,GetLineKits,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

            Charge_Taxes cts             = default(Charge_Taxes);
            var          kitCharges      = new K_Charges();
            var          lineKitsRenamed = new Line_Kits();

            if (stockType == 'G')
            {
                return(null);
            }

            if (_stockService.IsKitPresent(stockCode))
            {
                var kits = _stockService.GetKitIems(stockCode);
                if (kits != null && kits.Count != 0)
                {
                    foreach (var kit in kits)
                    {
                        var allPrices = _stockService.GetStockPricesByCode(kit.StockCode);
                        var price     = allPrices.FirstOrDefault(p => p.Vendor == vendor) ??
                                        allPrices.FirstOrDefault(p => p.Vendor == "ALL");
                        var stockDescription = _stockService.GetKitDescription(kit.StockCode);
                        if (price != null)
                        {
                            var allTaxes = _taxService.GetAllTaxes();
                            // Get Charges on Kit Items
                            // Build the collection of charges
                            var charges = _stockService.GetAssociateCharges(kit.StockCode);

                            if (charges != null && charges.Count != 0)
                            {
                                var firstOrDefault = charges.FirstOrDefault();
                                if (firstOrDefault != null)
                                {
                                    var taxes = _stockService.GetTax(firstOrDefault.AsCode);

                                    if (taxes != null && taxes.Count != 0)
                                    {
                                        var saleTax = taxes.FirstOrDefault();
                                        if (allTaxes.FirstOrDefault(t => saleTax != null && t.TaxName == saleTax.Tax_Name) != null)
                                        {
                                            cts = new Charge_Taxes();
                                            foreach (var tax in taxes)
                                            {
                                                cts.Add(Convert.ToString(tax.Tax_Name), Convert.ToString(tax.Tax_Code),
                                                        Convert.ToSingle(tax.Tax_Rate),
                                                        Convert.ToBoolean(tax.Tax_Included), "");
                                            }
                                        }
                                    }
                                }
                                kitCharges = new K_Charges();
                                foreach (var charge in charges)
                                {
                                    kitCharges.Add(Convert.ToDouble(charge.Price), charge.Description,
                                                   charge.AsCode, cts, "");
                                }
                            }

                            // Add the kit item & charges to the kits collection
                            lineKitsRenamed.Add(kit.StockCode, Convert.ToString(stockDescription),
                                                Convert.ToSingle(kit.Quantity), Convert.ToSingle(price.Price),
                                                0, 0, "", kitCharges, "");

                            kitCharges = null;
                        }
                        else
                        {
                            //TIMsgbox "Kit Item " & Kits![Stock_Code] & " not found in stock master.", vbInformation + vbOKOnly, "Missing Kit Item"
                            var         offSet       = _policyManager.LoadStoreInfo().OffSet;
                            MessageType type         = (int)MessageType.Critical + MessageType.OkOnly;
                            var         messageStyle = _resourceManager.CreateMessage(offSet, 0, 8113, kit.StockCode, type);
                        }
                    }
                }
            }
            var returnValue = lineKitsRenamed;

            Performancelog.Debug($"End,StockManager,GetLineKits,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(returnValue);
        }