/// <summary>
        /// Method to check whether an age restriction exists
        /// </summary>
        /// <param name="intRestr">Restriction code</param>
        /// <returns>Restriction</returns>
        public Restriction ExistsRestriction(short intRestr)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,UtilityService,ExistsRestriction,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");
            var restriction = new Restriction {
                Code = intRestr
            };
            var query = "SELECT * FROM [Restrictions]  WHERE Code=" + Convert.ToString(intRestr);

            var rs = GetRecords(query, DataSource.CSCMaster);

            if (rs.Rows.Count == 0)
            {
                restriction.Exist_Restriction = false;
            }
            else
            {
                restriction.Exist_Restriction = true;
                short ageLimit = CommonUtility.GetShortValue(rs.Rows[0]["AgeLimit"]);
                if (ageLimit == 0)
                {
                    restriction.Description = CommonUtility.GetStringValue(rs.Rows[0]["Restriction"]);
                }
                else
                {
                    restriction.Description = CommonUtility.GetStringValue(rs.Rows[0]["Restriction"]) + " " + DateAndTime.DateAdd(DateInterval.Year, -1 * ageLimit, DateAndTime.Today).ToString("MM/dd/yyyy");
                }
            }
            _performancelog.Debug($"End,UtilityService,ExistsRestriction,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(restriction);
        }
Example #2
0
        /// <summary>
        /// Method to get all tax mast
        /// </summary>
        /// <returns>List of tax mast</returns>
        public List <TaxMast> GetTaxMast()
        {
            var dateStart = DateTime.Now;

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

            var taxMastRecordSet = GetRecords("SELECT * FROM TaxMast ORDER BY TaxMast.Tax_Ord ", DataSource.CSCMaster);
            var taxes            = new List <TaxMast>();

            foreach (DataRow dataRow in taxMastRecordSet.Rows)
            {
                var taxMast = new TaxMast
                {
                    TaxOrd         = CommonUtility.GetShortValue(dataRow["TAX_ORD"]),
                    Active         = CommonUtility.GetBooleanValue(dataRow["TAX_ACTIVE"]),
                    TaxApply       = CommonUtility.GetStringValue(dataRow["TAX_APPLY"]),
                    TaxDefination  = CommonUtility.GetStringValue(dataRow["TAX_DEF"]),
                    TaxDescription = CommonUtility.GetStringValue(dataRow["TAX_DESC"]),
                    TaxName        = CommonUtility.GetStringValue(dataRow["TAX_NAME"])
                };
                taxes.Add(taxMast);
            }
            _performancelog.Debug($"End,TaxService,GetTaxMast,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(taxes);
        }
Example #3
0
        /// <summary>
        /// Method to get prepay global
        /// </summary>
        /// <param name="pumpId">Pump id</param>
        /// <returns>Prepay</returns>
        public recPump GetPrepayGlobal(int pumpId)
        {
            var rec     = new recPump();
            var dRecset = GetRecords("SELECT * FROM PrepayGlobal  WHERE pumpID = " + Convert.ToString(pumpId), DataSource.CSCTrans);

            if (dRecset.Rows.Count == 0)
            {
                rec.IsPrepay       = false;
                rec.IsPrepayLocked = false;



                if (!(rec.IsHoldPrepay && rec.PrepayAmount > 0))
                {
                    rec.PrepayAmount    = 0;
                    rec.PrepayInvoiceID = 0;
                    rec.PrepayPosition  = 0;
                }
            }
            else
            {
                rec.PrepayAmount    = CommonUtility.GetFloatValue(dRecset.Rows[0]["Amount"]);
                rec.IsPrepayLocked  = CommonUtility.GetBooleanValue(dRecset.Rows[0]["Locked"]);
                rec.PrepayInvoiceID = CommonUtility.GetIntergerValue(dRecset.Rows[0]["InvoiceID"]);
                rec.PrepayPosition  = CommonUtility.GetShortValue(dRecset.Rows[0]["PositionID"]);
                rec.IsPrepay        = true;
            }
            return(rec);
        }
Example #4
0
        /// <summary>
        /// Get the active tills for a given user
        /// </summary>
        /// <param name="active">Active</param>
        /// <param name="payAtPumpTill">Pay at pump till</param>
        /// <param name="userLoggedOn">User logged on</param>
        /// <returns>Tills</returns>
        public List <Till> GetTillForUser(int active, int payAtPumpTill, string userLoggedOn)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,TillService,GetTillForUser,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

            var strSql = "Select * From Tills Where  Tills.Active = " + active + " AND Tills.Till_Num <> " + payAtPumpTill + " and Tills.UserLoggedON=\'" + userLoggedOn + "\'";
            var sTills = GetRecords(strSql, DataSource.CSCMaster);

            var tills = (from DataRow row in sTills.Rows
                         select new Till
            {
                Number = CommonUtility.GetShortValue(row["TILL_NUM"]),
                Active = CommonUtility.GetBooleanValue(row["ACTIVE"]),
                Processing = CommonUtility.GetBooleanValue(row["PROCESS"]),
                Float = CommonUtility.GetDecimalValue(row["FLOAT"]),
                BonusFloat = CommonUtility.GetDecimalValue(row["CashBonusFloat"]),
                Cash = CommonUtility.GetDecimalValue(row["CASH"]),
                Date_Open = CommonUtility.GetDateTimeValue(row["DATE_OPEN"]),
                Time_Open = CommonUtility.GetDateTimeValue(row["TIME_OPEN"]),
                ShiftDate = CommonUtility.GetDateTimeValue(row["ShiftDate"]),
                Shift = CommonUtility.GetShortValue(row["ShiftNumber"]),
                UserLoggedOn = CommonUtility.GetStringValue(row["UserLoggedOn"]),
                POSId = CommonUtility.GetIntergerValue(row["POSID"]),
                CashBonus = CommonUtility.GetDecimalValue(row["CashBonus"])
            }).ToList();

            _performancelog.Debug($"End,TillService,GetTillForUser,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(tills);
        }
Example #5
0
        /// <summary>
        /// Get the Till by Till Number
        /// </summary>
        /// <param name="tillNumber">Till number</param>
        /// <returns>Till</returns>
        public Till GetTill(int tillNumber)
        {
            var sTill = GetRecords("Select * From Tills where till_num=" + tillNumber, DataSource.CSCMaster);

            if (sTill.Rows.Count > 0)
            {
                var row  = sTill.Rows[0];
                var till = new Till
                {
                    Number       = CommonUtility.GetShortValue(row["TILL_NUM"]),
                    Active       = CommonUtility.GetBooleanValue(row["ACTIVE"]),
                    Processing   = CommonUtility.GetBooleanValue(row["PROCESS"]),
                    Float        = CommonUtility.GetDecimalValue(row["FLOAT"]),
                    BonusFloat   = CommonUtility.GetDecimalValue(row["CashBonusFloat"]),
                    Cash         = CommonUtility.GetDecimalValue(row["CASH"]),
                    Date_Open    = CommonUtility.GetDateTimeValue(row["DATE_OPEN"]),
                    Time_Open    = CommonUtility.GetDateTimeValue(row["TIME_OPEN"]),
                    ShiftDate    = CommonUtility.GetDateTimeValue(row["ShiftDate"]),
                    Shift        = CommonUtility.GetShortValue(row["ShiftNumber"]),
                    UserLoggedOn = CommonUtility.GetStringValue(row["UserLoggedOn"]),
                    POSId        = CommonUtility.GetIntergerValue(row["POSID"]),
                    CashBonus    = CommonUtility.GetDecimalValue(row["CashBonus"])
                };
                return(till);
            }
            return(null);
        }
Example #6
0
        /// <summary>
        /// Get the tills which are not pay at pump
        /// </summary>
        /// <param name="payAtPumpTill">aPay at pump till</param>
        /// <returns>Tills</returns>
        public List <Till> GetnotPayAtPumpTill(int payAtPumpTill)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,TillService,GetnotPayAtPumpTill,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

            var strSql = "Select *  FROM   Tills  WHERE Tills.Till_Num <> " + payAtPumpTill + "";

            var sTills = GetRecords(strSql, DataSource.CSCMaster);
            var tills  = new List <Till>();

            foreach (DataRow row in sTills.Rows)
            {
                var till = new Till
                {
                    Number       = CommonUtility.GetShortValue(row["TILL_NUM"]),
                    Active       = CommonUtility.GetBooleanValue(row["ACTIVE"]),
                    Processing   = CommonUtility.GetBooleanValue(row["PROCESS"]),
                    Float        = CommonUtility.GetDecimalValue(row["FLOAT"]),
                    BonusFloat   = CommonUtility.GetDecimalValue(row["CashBonusFloat"]),
                    Cash         = CommonUtility.GetDecimalValue(row["CASH"]),
                    Date_Open    = CommonUtility.GetDateTimeValue(row["DATE_OPEN"]),
                    Time_Open    = CommonUtility.GetDateTimeValue(row["TIME_OPEN"]),
                    ShiftDate    = CommonUtility.GetDateTimeValue(row["ShiftDate"]),
                    Shift        = CommonUtility.GetShortValue(row["ShiftNumber"]),
                    UserLoggedOn = CommonUtility.GetStringValue(row["UserLoggedOn"]),
                    POSId        = CommonUtility.GetIntergerValue(row["POSID"]),
                    CashBonus    = CommonUtility.GetDecimalValue(row["CashBonus"])
                };
                tills.Add(till);
            }
            _performancelog.Debug($"End,TillService,GetnotPayAtPumpTill,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(tills);
        }
Example #7
0
        /// <summary>
        /// Method to get purchase items
        /// </summary>
        /// <param name="saleNumber">Sale number</param>
        /// <param name="tillNumber">Till number</param>
        /// <returns>Purchase items</returns>
        public List <tePurchaseItem> GetPurchaseItems(int saleNumber, int tillNumber)
        {
            var dateStart = DateTime.Now;

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

            var purchaseItems = new List <tePurchaseItem>();
            var rsSite        = GetRecords("select * from purchaseitem inner join cscmaster.dbo.ProductTaxExempt b " + " on purchaseitem.CscPurchaseItemKey = b.UpcCode Where sale_no =" + Convert.ToString(saleNumber) + " and Till_no =" + Convert.ToString(tillNumber), DataSource.CSCTills);


            foreach (DataRow row in rsSite.Rows)
            {
                purchaseItems.Add(new tePurchaseItem
                {
                    TreatyNo    = CommonUtility.GetStringValue(row["TreatyNo"]),
                    ProductType = CommonUtility.GetStringValue(row["CategoryCodeFK"]),
                    Quantity    = CommonUtility.GetShortValue(row["Quantity"]),
                    UnitsPerPkg = CommonUtility.GetFloatValue(row["UnitsPerPkg"])
                });
            }

            _performancelog.Debug($"End,TaxService,GetPurchaseItems,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(purchaseItems);
        }
        /// <summary>
        /// Method to get promos for today
        /// </summary>
        /// <returns>List of promos</returns>
        public List <Promo> GetPromosForToday()
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,PromoService,GetPromosForToday,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

            // August 21, 2008 took out the quantity validation to implement mix and match promotions
            var strSql  = "SELECT DISTINCT [PromoHeader].[PromoID] AS PromoID, [PromoHeader].[Day] AS Day,[PromoDetail].[Qty] AS Qty, [PromoDetail].[Link] AS Link, [PromoDetail].[Amount] AS Amount,[PromoDetail].[Stock_Code],[PromoDetail].[Dept],[PromoDetail].[Sub_Dept],[PromoDetail].[SubDetail] FROM PromoHeader LEFT JOIN PromoDetail ON [PromoHeader].[PromoID] =[PromoDetail].[PromoID]  WHERE (Day IS NULL OR Day=0 OR Day=" + Convert.ToString(DateAndTime.Weekday(DateAndTime.Today)) + ") AND [PromoHeader].[EndDate]>= \'" + DateTime.Now.ToString("yyyyMMdd") + "\' AND [PromoHeader].[StartDate]<= \'" + DateTime.Now.ToString("yyyyMMdd") + "\'";
            var rsPromo = GetRecords(strSql, DataSource.CSCMaster);
            var promos  = (from DataRow fields in rsPromo.Rows
                           select new Promo
            {
                StockCode = CommonUtility.GetStringValue(fields["Stock_Code"]),
                Dept = CommonUtility.GetStringValue(fields["Dept"]),
                SubDept = CommonUtility.GetStringValue(fields["Sub_Dept"]),
                SubDetail = CommonUtility.GetStringValue(fields["SubDetail"]),
                PromoID = CommonUtility.GetStringValue(fields["PromoID"]),
                Day = CommonUtility.GetByteValue(fields["Day"]),
                TotalQty = CommonUtility.GetShortValue(fields["Qty"]),
                MaxLink = CommonUtility.GetShortValue(fields["Link"]),
                Amount = CommonUtility.GetDoubleValue(fields["Amount"])
            }).ToList();

            _performancelog.Debug($"End,PromoService,GetPromosForToday,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(promos);
        }
Example #9
0
        /// <summary>
        /// Method to load prepay
        /// </summary>
        /// <param name="pumpId">Pump Id</param>
        /// <returns>Prepay</returns>
        public recPump LoadPrepay(int pumpId)
        {
            recPump rec;
            var     dRecset = GetRecords("SELECT * FROM PrepayGlobal  WHERE pumpID = " + Convert.ToString(pumpId), DataSource.CSCTrans);

            if (dRecset.Rows.Count == 0)
            {
                rec = new recPump
                {
                    IsHoldPrepay    = false,
                    IsPrepay        = false,
                    PrepayAmount    = 0,
                    IsPrepayLocked  = false,
                    PrepayInvoiceID = 0,
                    PrepayPosition  = 0
                };
            }
            else
            {
                rec = new recPump
                {
                    IsHoldPrepay    = true,
                    IsPrepay        = true,
                    PrepayAmount    = CommonUtility.GetFloatValue(dRecset.Rows[0]["Amount"]),
                    IsPrepayLocked  = CommonUtility.GetBooleanValue(dRecset.Rows[0]["Locked"]),
                    PrepayInvoiceID = CommonUtility.GetIntergerValue(dRecset.Rows[0]["InvoiceID"]),
                    PrepayPosition  = CommonUtility.GetShortValue(dRecset.Rows[0]["PositionID"])
                };
            }
            return(rec);
        }
        /// <summary>
        /// Method to load GST exempt
        /// </summary>
        /// <param name="taxExemptSale">Tax exempt sale</param>
        /// <param name="sn">Sale number</param>
        /// <param name="tillId">Till number</param>
        /// <param name="db">Data source</param>
        /// <returns>True or false</returns>
        public bool LoadGstExempt(ref TaxExemptSale taxExemptSale, int sn, byte tillId,
                                  DataSource db)
        {
            var rsLine = GetRecords("select * from SALELINE " + " where SALE_NO=" + Convert.ToString(sn) + " AND TILL_NUM=" + Convert.ToString(tillId), db);

            if (rsLine.Rows.Count == 0)
            {
                return(false);
            }

            foreach (DataRow line in rsLine.Rows)
            {
                var rsTaxCreditLine = GetRecords("SELECT * from TaxCreditLine where TILL_NUM=" + Convert.ToString(tillId) + " AND SALE_NO=" + Convert.ToString(sn) + " AND Line_No=" + Convert.ToString(line["Line_Num"]), db);
                if (rsTaxCreditLine.Rows.Count == 0)
                {
                    continue;
                }
                var tx = new TaxCreditLine {
                    Line_Num = CommonUtility.GetShortValue(line["Line_Num"])
                };
                foreach (DataRow taxCreditLine in rsTaxCreditLine.Rows)
                {
                    var lt = new Line_Tax
                    {
                        Tax_Name         = CommonUtility.GetStringValue(taxCreditLine["Tax_Name"]),
                        Tax_Code         = CommonUtility.GetStringValue(taxCreditLine["Tax_Code"]),
                        Tax_Rate         = CommonUtility.GetFloatValue(taxCreditLine["Tax_Rate"]),
                        Tax_Included     = CommonUtility.GetBooleanValue(taxCreditLine["Tax_Included"]),
                        Tax_Added_Amount = CommonUtility.GetFloatValue(taxCreditLine["Tax_Added_Amount"]),
                        Tax_Incl_Amount  = CommonUtility.GetFloatValue(taxCreditLine["Tax_Included_Amount"])
                    };
                    tx.Line_Taxes.AddTaxLine(lt, "");
                }
                taxExemptSale.TaxCreditLines.AddLine(tx.Line_Num, tx, "");
            }


            var rsTaxCredit = GetRecords("SELECT * from TaxCredit where TILL_NUM=" + Convert.ToString(tillId)
                                         + " AND SALE_NO=" + Convert.ToString(sn), db);

            foreach (DataRow taxCredit in rsTaxCredit.Rows)
            {
                var sx = new Sale_Tax
                {
                    Tax_Name            = CommonUtility.GetStringValue(taxCredit["Tax_Name"]),
                    Tax_Code            = CommonUtility.GetStringValue(taxCredit["Tax_Code"]),
                    Tax_Rate            = CommonUtility.GetFloatValue(taxCredit["Tax_Rate"]),
                    Taxable_Amount      = CommonUtility.GetDecimalValue(taxCredit["Taxable_Amount"]),
                    Tax_Added_Amount    = CommonUtility.GetDecimalValue(taxCredit["Tax_Added_Amount"]),
                    Tax_Included_Amount = CommonUtility.GetDecimalValue(taxCredit["Tax_Included_Amount"]),
                    Tax_Included_Total  = CommonUtility.GetDecimalValue(taxCredit["Tax_Included_Total"])
                };
                taxExemptSale.TaxCredit.Add(sx.Tax_Name, sx.Tax_Code, sx.Tax_Rate, sx.Taxable_Amount, sx.Tax_Added_Amount, sx.Tax_Included_Amount, sx.Tax_Included_Amount, sx.Tax_Rebate_Rate, sx.Tax_Rebate, sx.Tax_Name + sx.Tax_Code); //   - gave mismatch type error for AITE
            }
            return(true);
        }
Example #11
0
        /// <summary>
        /// Method to get original position Id
        /// </summary>
        /// <param name="saleNumber">Sale number</param>
        /// <param name="tillNumber">Till number</param>
        /// <param name="dataSource">Data source</param>
        /// <returns></returns>
        public short?GetOrginalPositionId(int saleNumber, int tillNumber, DataSource dataSource)
        {
            var rsTemp = GetRecords(" SELECT * FROM SaleLine " + " WHERE SaleLine.Sale_No = " + Convert.ToString(saleNumber)
                                    + " " + " and TILL_NUM=" + tillNumber + " and Prepay=1" + " ORDER BY SaleLine.Line_Num ", dataSource);

            if (rsTemp.Rows.Count == 0)
            {
                return(null);
            }
            return(CommonUtility.GetShortValue(rsTemp.Rows[0]["PositionID"])); //
        }
Example #12
0
        /// <summary>
        /// Method to get list of treaty numbers
        /// </summary>
        /// <param name="query">Query</param>
        /// <returns>List of treaty numbers</returns>
        public List <TreatyNo> GetTreatyNumbers(string query)
        {
            var oRecs = GetRecords(query, DataSource.CSCMaster);

            return((from DataRow treaty in oRecs.Rows
                    select new TreatyNo
            {
                TreatyNumber = CommonUtility.GetStringValue(treaty["TreatyNo"]),
                AltTreatyNo = CommonUtility.GetShortValue(treaty["AltTreatyNo"]),
                TobaccoQuota = CommonUtility.GetIntergerValue(treaty["TobaccoQuota"]),
                GasQuota = CommonUtility.GetFloatValue(treaty["GasQuota"]),
                TreatyName = CommonUtility.GetStringValue(treaty["TreatyName"])
            }).ToList());
        }
Example #13
0
        /// <summary>
        /// Method to get product tax exempt
        /// </summary>
        /// <param name="stockCode">Stock code</param>
        /// <returns></returns>
        public ProductTaxExempt GetProductTaxExemptForStock(string stockCode)
        {
            var rsPte = GetRecords("SELECT * FROM ProductTaxExempt " + " WHERE ProductKey=\'" + stockCode + "\'", DataSource.CSCMaster);

            if (rsPte.Rows.Count != 0)
            {
                return(new ProductTaxExempt
                {
                    TEVendor = CommonUtility.GetStringValue(rsPte.Rows[0]["ProductCode"]),
                    CategoryFK = CommonUtility.GetShortValue(rsPte.Rows[0]["CategoryFK"])
                });
            }
            return(null);
        }
        ///// <summary>
        ///// Method to get max link
        ///// </summary>
        ///// <param name="promoId"></param>
        ///// <returns>Max link</returns>
        //public short GetMaxLink(string promoId)
        //{
        //    var dateStart = DateTime.Now;
        //    _performancelog.Debug($"Start,PromoService,GetMaxLink,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

        //    var rsTemp = GetRecords("SELECT MAX(Link) AS MaxLink FROM PromoDetail WHERE PromoID=\'" + promoId + "\'", DataSource.CSCMaster);
        //    if (rsTemp.Rows.Count != 0)
        //    {
        //        var fields = rsTemp.Rows[0];
        //        _performancelog.Debug($"End,PromoService,GetMaxLink,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
        //        return CommonUtility.GetShortValue(fields["MaxLink"]);
        //    }
        //    _performancelog.Debug($"End,PromoService,GetMaxLink,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

        //    return 0;
        //}

        ///// <summary>
        ///// Method to get number of links
        ///// </summary>
        ///// <param name="promoId">Promo id</param>
        ///// <returns>Number of links</returns>
        //public List<int> GetNumberOfLinks(string promoId)
        //{
        //    var dateStart = DateTime.Now;
        //    _performancelog.Debug($"Start,PromoService,GetNumberOfLinks,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

        //    var rsTemp = GetRecords("SELECT SUM(Link)/Link AS NrOfLinks, Link FROM PromoDetail WHERE PromoID=\'" + promoId + "\' GROUP BY Link ORDER BY Link", DataSource.CSCMaster);
        //    var links = (from DataRow fields in rsTemp.Rows select CommonUtility.GetShortValue(fields["NrOfLinks"])).Select(dummy => (int)dummy).ToList();
        //    _performancelog.Debug($"End,PromoService,GetNumberOfLinks,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

        //    return links;
        //}

        /// <summary>
        /// Method to get all promos for today
        /// </summary>
        /// <param name="optPromoId">Promo id</param>
        /// <returns>Promo headers</returns>
        public List <Promo> GetPromoHeadersForToday(string optPromoId)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,PromoService,GetPromoHeadersForToday,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");
            var promos = new List <Promo>();

            _connection = new SqlConnection(GetConnectionString(DataSource.CSCMaster));
            if (_connection.State == ConnectionState.Closed)
            {
                _connection.Open();
            }
            SqlCommand cmd = new SqlCommand("GetPromoHeaders", _connection)
            {
                CommandType = CommandType.StoredProcedure
            };

            cmd.Parameters.Add(new SqlParameter {
                ParameterName = "@optPromoId", Value = optPromoId
            });
            cmd.Parameters.Add(new SqlParameter {
                ParameterName = "@dt", Value = DateTime.Now.ToString("yyyyMMdd")
            });
            var rdr = cmd.ExecuteReader();

            if (!rdr.HasRows)
            {
                return(promos);
            }
            var stockInfo = new Sale_Line();

            while (rdr.Read())
            {
                Promo promo = new Promo();
                promo.PromoID     = CommonUtility.GetStringValue(rdr["PromoID"]);
                promo.Description = CommonUtility.GetStringValue(rdr["Description"]);
                promo.DiscType    = CommonUtility.GetStringValue(rdr["DiscType"]);
                promo.Amount      = CommonUtility.GetDoubleValue(rdr["price"]);
                promo.PrType      = CommonUtility.GetStringValue(rdr["PrType"]);
                promo.MaxLink     = CommonUtility.GetShortValue(rdr["MaxLink"]);
                promo.MultiLink   = CommonUtility.GetIntergerValue(rdr["NrOfLinks"]) > 1 ? true : false;
                promos.Add(promo);
            }

            _performancelog.Debug($"End,PromoService,GetPromoHeadersForToday,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(promos);
        }
Example #15
0
        /// <summary>
        /// Method to get tax free price
        /// </summary>
        /// <param name="blForFuel">For fule price or not</param>
        /// <param name="sProductKey">Product key</param>
        /// <param name="stockcode">Stock code</param>
        /// <param name="quantityPerPkg">Quantity per kg</param>
        /// <param name="baseUnitQty">Base unit quantity</param>
        /// <param name="taxExemptTaxCode">tax code</param>
        /// <param name="productCode">Product code</param>
        /// <param name="eOutCategory">Category</param>
        /// <param name="dOutUnitsPerPkg">Units per kg</param>
        /// <param name="sOutUpcCode">Out up code</param>
        /// <param name="isError">Is error or not</param>
        /// <returns>True or false</returns>
        public bool TeGetTaxFreePriceByRate(bool blForFuel, ref string sProductKey, string stockcode,
                                            ref short quantityPerPkg, ref short baseUnitQty,
                                            ref short taxExemptTaxCode, ref string productCode,
                                            ref mPrivateGlobals.teProductEnum eOutCategory,
                                            ref float dOutUnitsPerPkg, ref string sOutUpcCode,
                                            out bool isError)
        {
            var dateStart = DateTime.Now;

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

            DataTable oRecs;

            if (blForFuel)
            {
                oRecs = GetRecords("SELECT CategoryFK,ProductCode,TAX_CODE,  QuantityPerPkg, BaseUnitQty,  1 As UnitsPerPkg, \'\' As UpcCode  from ProductTaxExempt Where ProductKey =\'" + stockcode + "\' ", DataSource.CSCMaster);
            }
            else
            {
                oRecs = GetRecords("SELECT CategoryFK, ProductCode,UnitsPerPkg, TAX_CODE, QuantityPerPkg, BaseUnitQty, UpcCode FROM ProductTaxExempt Where ProductKey=\'" + sProductKey + "\'", DataSource.CSCMaster);
            }
            if (oRecs.Rows.Count == 0)
            {
                isError = false;
                return(false);
            }

            taxExemptTaxCode = CommonUtility.GetShortValue(oRecs.Rows[0]["Tax_Code"]);
            productCode      = CommonUtility.GetStringValue(oRecs.Rows[0]["ProductCode"]);
            if (CommonUtility.GetBooleanValue(oRecs.Rows[0]["CategoryFK"]))
            {
                eOutCategory = (mPrivateGlobals.teProductEnum)CommonUtility.GetIntergerValue(oRecs.Rows[0]["CategoryFK"]);
            }
            else
            {
                isError = true;
                return(true);
            }
            isError         = false;
            dOutUnitsPerPkg = CommonUtility.GetFloatValue(oRecs.Rows[0]["UnitsPerPkg"]);
            sOutUpcCode     = CommonUtility.GetStringValue(oRecs.Rows[0]["UpcCode"]);
            quantityPerPkg  = CommonUtility.GetShortValue(oRecs.Rows[0]["QuantityPerPkg"]);
            baseUnitQty     = CommonUtility.GetShortValue(oRecs.Rows[0]["BaseUnitQty"]);
            _performancelog.Debug($"End,TaxService,TeGetTaxFreePriceByRate,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(true);
        }
Example #16
0
        /// <summary>
        /// Method to get orginal saleLines
        /// </summary>
        /// <param name="invoiceId">Sale number</param>
        /// <param name="tillNumber">Till number</param>
        /// <param name="dataSource">Data source</param>
        /// <returns>List of sale lines</returns>
        public List <Sale_Line> GetOrginalSaleLines(int invoiceId, int tillNumber, DataSource dataSource)
        {
            var saleLines = new List <Sale_Line>();

            var rsDetail = GetRecords(" SELECT * FROM SaleLine " + " WHERE SaleLine.Sale_No = " + Convert.ToString(invoiceId) + " " + " and TILL_NUM=" + tillNumber + " ORDER BY SaleLine.Line_Num ", dataSource);

            foreach (DataRow row in rsDetail.Rows)
            {
                saleLines.Add(new Sale_Line
                {
                    Dept               = CommonUtility.GetStringValue(row["Dept"]),
                    Sub_Dept           = CommonUtility.GetStringValue(row["Sub_Dept"]),
                    Sub_Detail         = CommonUtility.GetStringValue(row["Sub_Detail"]),
                    Stock_Code         = CommonUtility.GetStringValue(row["Stock_Code"]),
                    PLU_Code           = CommonUtility.GetStringValue(row["PLU_Code"]),
                    Line_Num           = CommonUtility.GetShortValue(row["Line_Num"]),
                    Price_Type         = CommonUtility.GetCharValue(row["Price_Type"]),
                    Quantity           = CommonUtility.GetFloatValue(row["Quantity"]),
                    Amount             = CommonUtility.GetDecimalValue(row["Amount"]),
                    Discount_Adjust    = CommonUtility.GetDoubleValue(row["Disc_adj"]),
                    Line_Discount      = CommonUtility.GetDoubleValue(row["Discount"]),
                    Discount_Type      = CommonUtility.GetStringValue(row["Disc_Type"]),
                    Discount_Code      = CommonUtility.GetStringValue(row["Disc_Code"]),
                    Discount_Rate      = CommonUtility.GetFloatValue(row["Disc_Rate"]),
                    DiscountName       = CommonUtility.GetStringValue(row["DiscountName"]),
                    Associate_Amount   = CommonUtility.GetDecimalValue(row["Assoc_Amt"]),
                    User               = CommonUtility.GetStringValue(row["User"]),
                    Description        = CommonUtility.GetStringValue(row["Descript"]),
                    Loyalty_Save       = CommonUtility.GetFloatValue(row["Loyl_Save"]),
                    Units              = CommonUtility.GetStringValue(row["Units"]),
                    Serial_No          = CommonUtility.GetStringValue(row["Serial_No"]),
                    Prepay             = Convert.ToBoolean(row["Prepay"]),
                    pumpID             = CommonUtility.GetByteValue(row["pumpID"]),
                    GradeID            = CommonUtility.GetByteValue(row["GradeID"]),
                    PositionID         = CommonUtility.GetByteValue(row["PositionID"]),
                    IsTaxExemptItem    = CommonUtility.GetBooleanValue(row["TaxExempt"]),
                    Total_Amount       = CommonUtility.GetDecimalValue(row["Total_Amt"]),
                    Regular_Price      = CommonUtility.GetDoubleValue(row["Reg_Price"]),
                    price              = CommonUtility.GetDoubleValue(row["price"]),
                    FuelRebateEligible = CommonUtility.GetBooleanValue(row["FuelRebateUsed"]),
                    FuelRebate         = CommonUtility.GetDecimalValue(row["RebateDiscount"]),
                    PromoID            = CommonUtility.GetStringValue(row["PromoID"])
                });
            }
            return(saleLines);
        }
        /// <summary>
        /// Method to get tax purchase item
        /// </summary>
        /// <param name="saleNo">Sale numvber</param>
        /// <param name="lineNo">Line number</param>
        /// <returns>Tax exempt purchase item</returns>
        public tePurchaseItem GetPurchaseItem(int saleNo, int lineNo)
        {
            tePurchaseItem teItem = null;
            var            rs     = GetRecords("select * from PurchaseItem where Sale_No=" + Convert.ToString(saleNo) + " AND Line_No=" + Convert.ToString(lineNo), DataSource.CSCTills);

            if (rs.Rows.Count > 0)
            {
                teItem                 = new tePurchaseItem();
                teItem.TreatyNo        = CommonUtility.GetStringValue(rs.Rows[0]["TreatyNo"]);
                teItem.PsTierID        = CommonUtility.GetShortValue(rs.Rows[0]["TierID"]);
                teItem.PsLevelID       = CommonUtility.GetShortValue(rs.Rows[0]["LevelID"]);
                teItem.PdOriginalPrice = CommonUtility.GetFloatValue(rs.Rows[0]["OriginalPrice"]);
                teItem.TaxFreePrice    = CommonUtility.GetFloatValue(rs.Rows[0]["Amount"]);
                teItem.petaxInclPrice  = -1 * CommonUtility.GetFloatValue(teItem.TaxFreePrice + CommonUtility.GetFloatValue(rs.Rows[0]["TotalTaxSaved"]));
            }
            return(teItem);
        }
Example #18
0
        /// <summary>
        /// Get the IP address of the POS
        /// </summary>
        /// <param name="ipAddress"></param>
        /// <returns></returns>
        public short GetPosId(string ipAddress)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,LoginService,GetPosId,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

            short posId       = 0;
            var   rsChapsMain = GetRecords("Select ID From POS_IP_Address where IP_Address= \'" + ipAddress + "\'", DataSource.CSCAdmin);

            if (rsChapsMain != null && rsChapsMain.Rows.Count > 0)
            {
                var fields = rsChapsMain.Rows[0];
                posId = CommonUtility.GetShortValue(fields["ID"]);
            }
            _performancelog.Debug(
                $"End,LoginService,GetPosId,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            return(posId);
        }
Example #19
0
        /// <summary>
        /// Method to get tax exemption reasons
        /// </summary>
        /// <param name="reasonType">Reason type</param>
        /// <returns>Tax exemption reasons</returns>
        public List <TaxExemptReason> GetTaxExemptReasons(string reasonType)
        {
            var reasons  = new List <TaxExemptReason>();
            var rsReason = GetRecords("select * from TaxExemptReasons Where ReasonType=\'" + reasonType + "\'", DataSource.CSCMaster);

            foreach (DataRow fields in rsReason.Rows)
            {
                var ter = new TaxExemptReason
                {
                    Code            = CommonUtility.GetStringValue(fields["ReasonCode"]),
                    Description     = CommonUtility.GetStringValue(fields["ReasonDescription"]),
                    ExplanationCode = CommonUtility.GetShortValue(fields["ExplanationCode"]),
                    Explanation     =
                        string.IsNullOrEmpty(CommonUtility.GetStringValue(fields["Explanation"]))
                            ? "0"
                            : CommonUtility.GetStringValue(fields["Explanation"])
                };
                reasons.Add(ter);
            }
            return(reasons);
        }
Example #20
0
        /// <summary>
        /// method to get the prompts associated with the cards
        /// </summary>
        /// <param name="prompts"></param>
        /// <param name="promptString"></param>
        /// <param name="profileId"></param>
        public void GetCardProfilePrompts(ref CardPrompts prompts, string promptString, string profileId)
        {
            var query = "SELECT MaxLength, MinLength, PromptMessage, PromptSeq, A.PromptID  FROM CardProfilePrompts AS A INNER JOIN CardFuelPrompts AS B ON A.PromptID = B.PromptID AND A.Type=B.Type  WHERE A.Type =\'O\' AND ProfileID = \'" + profileId + "\' " + "AND A.PromptID in ( Select PromptID from CardProfilePrompts " + " where PromptID in (select[PromptID] from " + " CardProfilePromptLink where CardPromptID =\'" + promptString + "\' " + " and ProfileID = \'" + profileId + "\') " + " and ProfileID = \'" + profileId + "\')" + "ORDER BY PromptSeq ";

            var dt = GetRecords(query, DataSource.CSCMaster);

            var cardPrompts = new List <CardPrompt>();

            foreach (DataRow dr in dt.Rows)
            {
                cardPrompts.Add(new CardPrompt
                {
                    MaxLength = CommonUtility.GetShortValue(dr["MaxLength"]),
                    MinLength = CommonUtility.GetShortValue(dr["MinLength"]),

                    PromptMessage = CommonUtility.GetStringValue(dr["PromptMessage"]),
                    PromptSeq     = CommonUtility.GetByteValue(dr["PromptSeq"]),
                    PromptID      = CommonUtility.GetShortValue(dr["PromptID"])
                });
            }
            prompts = cardPrompts;
        }
        /// <summary>
        /// Get All Suspended Sales
        /// </summary>
        /// <param name="sqlQuery">Query</param>
        /// <returns>List of suspended sales</returns>
        public List <SusHead> GetAllSuspendedSale(string sqlQuery)
        {
            var dateStart = DateTime.Now;

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

            var susHeadRs = GetRecords(sqlQuery, DataSource.CSCTills);
            var susHead   = new List <SusHead>();

            foreach (DataRow row in susHeadRs.Rows)
            {
                susHead.Add(new SusHead
                {
                    SaleNumber = CommonUtility.GetIntergerValue(row["SALE_NO"]),
                    Client     = CommonUtility.GetStringValue(row["CLIENT"]),
                    TillNumber = CommonUtility.GetShortValue(row["TILL"])
                });
            }
            _performancelog.Debug($"End,SuspendedSaleService,GetAllSuspendedSale,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(susHead);
        }
Example #22
0
        /// <summary>
        /// Get purchase items
        /// </summary>
        /// <param name="db">Data source</param>
        /// <param name="saleNumber">Sale number</param>
        /// <returns>Purchase items</returns>
        public List <tePurchaseItem> GetPurchaseItems(DataSource db, int saleNumber)
        {
            var purchaseItems = new List <tePurchaseItem>();
            var rs            = GetRecords("select saleline.gradeid, purchaseitem.* from PurchaseItem  " + " INNER JOIN Saleline on Saleline.Sale_no = Purchaseitem.sale_No and Saleline.line_num = purchaseitem.line_no " + " where purchaseitem.Sale_No=" + Convert.ToString(saleNumber), db);

            foreach (DataRow row in rs.Rows)
            {
                purchaseItems.Add(new tePurchaseItem
                {
                    TreatyNo            = CommonUtility.GetStringValue(row["TreatyNo"]),
                    PsTierID            = CommonUtility.GetShortValue(row["TierID"]),
                    PsLevelID           = CommonUtility.GetShortValue(row["LevelID"]),
                    PsGradeIDpsTreatyNo = CommonUtility.GetShortValue(row["GradeID"]),
                    PdOriginalPrice     = CommonUtility.GetFloatValue(row["OriginalPrice"]),
                    TaxFreePrice        = CommonUtility.GetFloatValue(row["Amount"]),
                    pdTaxFreePrice      = CommonUtility.GetFloatValue(row["TotalTaxSaved"]),
                    Quantity            = CommonUtility.GetFloatValue(row["Quantity"]),
                    LineItem            = CommonUtility.GetShortValue(row["Line_No"]),
                    stockcode           = CommonUtility.GetStringValue(row["cscpurchaseitemkey"]),
                });
            }
            return(purchaseItems);
        }
        /// <summary>
        /// Method to load tax exempt
        /// </summary>
        /// <param name="teType">Tax exemption type</param>
        /// <param name="sn">Sale number</param>
        /// <param name="tillId">Till Number</param>
        /// <param name="db">Data base</param>
        /// <param name="checkQuota">Check Quota or not</param>
        /// <returns>Tax exempt sale</returns>
        public TaxExemptSale LoadTaxExempt(string teType, int sn, byte tillId, DataSource db,
                                           bool checkQuota = true)
        {
            var taxExemptSale = new TaxExemptSale();

            if (LoadGstExempt(ref taxExemptSale, sn, tillId, db))
            {
                taxExemptSale.Sale_Num   = sn;
                taxExemptSale.TillNumber = tillId;
            }

            var rsHead = GetRecords("select * from TaxExemptSaleHead " + " where SALE_NO=" + Convert.ToString(sn) + " AND TILL_NUM=" + Convert.ToString(tillId), db);
            var rsLine = GetRecords("select * from TaxExemptSaleLine " + " where SALE_NO=" + Convert.ToString(sn) + " AND TILL_NUM=" + Convert.ToString(tillId), db);

            if (teType == "QITE")
            {
                if (rsHead.Rows.Count == 0)
                {
                    return(null);
                }
            }
            else
            {
                if (rsHead.Rows.Count == 0 || rsLine.Rows.Count == 0)
                {
                    return(null);
                }
            }
            var rsHeadField = rsHead.Rows[0];

            taxExemptSale.Sale_Num   = sn;
            taxExemptSale.TillNumber = tillId;

            foreach (DataRow fields in rsLine.Rows)
            {
                var mTeLine = new TaxExemptSaleLine
                {
                    Quantity      = CommonUtility.GetFloatValue(fields["Quantity"]),
                    UnitsPerPkg   = CommonUtility.GetFloatValue(fields["UnitQuantity"]),
                    EquvQuantity  = CommonUtility.GetFloatValue(fields["EquvQuantity"]),
                    OriginalPrice = CommonUtility.GetFloatValue(fields["OriginalPrice"]),
                    TaxFreePrice  = CommonUtility.GetFloatValue(fields["price"]),
                    Line_Num      = CommonUtility.GetShortValue(fields["Line_Num"]),
                    StockCode     = CommonUtility.GetStringValue(fields["Stock_Code"]),
                    TaxInclPrice  = CommonUtility.GetFloatValue(fields["TaxIncludedAmount"]),
                    Amount        = CommonUtility.GetFloatValue(fields["Amount"]),
                    ExemptedTax   = CommonUtility.GetFloatValue(fields["ExemptedTax"]),
                    Description   = CommonUtility.GetStringValue(fields["Description"]),
                    ProductCode   = CommonUtility.GetStringValue(fields["ProductCode"])
                };
                mPrivateGlobals.teProductEnum productType;
                Enum.TryParse(CommonUtility.GetStringValue(fields["ProductType"]), out productType);
                mTeLine.ProductType  = productType;
                mTeLine.RunningQuota = CommonUtility.GetFloatValue(fields["RunningQuota"]);

                mTeLine.OverLimit = CommonUtility.GetBooleanValue(fields["OverLimit"]);

                mTeLine.TaxExemptRate = CommonUtility.GetFloatValue(fields["TaxExemptRate"]);
                var tempCheckOverLimit = false;
                taxExemptSale.Add_a_Line(mTeLine, ref tempCheckOverLimit, ref checkQuota);
                if (!mTeLine.OverLimit)
                {
                    continue;
                }
                switch (mTeLine.ProductType)
                {
                case mPrivateGlobals.teProductEnum.eCigarette:
                case mPrivateGlobals.teProductEnum.eCigar:
                case mPrivateGlobals.teProductEnum.eLooseTobacco:
                    taxExemptSale.TobaccoOverLimit = true;
                    break;

                case mPrivateGlobals.teProductEnum.eGasoline:
                case mPrivateGlobals.teProductEnum.eDiesel:
                case mPrivateGlobals.teProductEnum.emarkedGas:
                case mPrivateGlobals.teProductEnum.emarkedDiesel:

                    taxExemptSale.GasOverLimit = true;
                    break;

                case mPrivateGlobals.teProductEnum.ePropane:
                    taxExemptSale.PropaneOverLimit = true;
                    break;

                case mPrivateGlobals.teProductEnum.eNone:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            taxExemptSale.Amount              = CommonUtility.GetFloatValue(rsHeadField["SaleAmount"]);
            taxExemptSale.ShiftDate           = CommonUtility.GetDateTimeValue(rsHeadField["ShiftDate"]);
            taxExemptSale.Sale_Time           = CommonUtility.GetDateTimeValue(rsHeadField["SaleTime"]);
            taxExemptSale.GasReason           = CommonUtility.GetStringValue(rsHeadField["GasReason"]);
            taxExemptSale.GasReasonDesp       = CommonUtility.GetStringValue(rsHeadField["GasReasonDesp"]);
            taxExemptSale.GasReasonDetail     = CommonUtility.GetStringValue(rsHeadField["GasReasonDetail"]);
            taxExemptSale.PropaneReason       = CommonUtility.GetStringValue(rsHeadField["PropaneReason"]);
            taxExemptSale.PropaneReasonDesp   = CommonUtility.GetStringValue(rsHeadField["PropaneReasonDesp"]);
            taxExemptSale.PropaneReasonDetail = CommonUtility.GetStringValue(rsHeadField["PropaneReasonDetail"]);
            taxExemptSale.TobaccoReason       = CommonUtility.GetStringValue(rsHeadField["TobaccoReason"]);
            taxExemptSale.TobaccoReasonDesp   = CommonUtility.GetStringValue(rsHeadField["TobaccoReasonDesp"]);
            taxExemptSale.TobaccoReasonDetail = CommonUtility.GetStringValue(rsHeadField["TobaccoReasonDetail"]);
            taxExemptSale.Shift    = CommonUtility.GetShortValue(rsHeadField["Shift"]);
            taxExemptSale.UserCode = CommonUtility.GetStringValue(rsHeadField["User"]);
            taxExemptSale.teCardholder.CardholderID = CommonUtility.GetStringValue(rsHeadField["CardholderID"]);
            taxExemptSale.teCardholder.Barcode      = CommonUtility.GetStringValue(rsHeadField["Barcode"]);
            taxExemptSale.teCardholder.CardNumber   = CommonUtility.GetStringValue(rsHeadField["cardnumber"]);
            if (teType == "QITE")
            {
                var rsCardHolder = GetRecords("select * from CLIENT " + " where CL_CODE=\'" + taxExemptSale.teCardholder.CardholderID + "\'", DataSource.CSCMaster);
                if (rsCardHolder.Rows.Count > 0)
                {
                    taxExemptSale.teCardholder.Name        = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["Cl_Name"]);
                    taxExemptSale.teCardholder.Address     = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["CL_Add1"]);
                    taxExemptSale.teCardholder.City        = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["CL_City"]);
                    taxExemptSale.teCardholder.PlateNumber = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["PlateNumber"]);
                    taxExemptSale.teCardholder.PostalCode  = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["CL_Postal"]);
                }
            }
            else // For AITE
            {
                var rsCardHolder = GetRecords("select * from TaxExemptCardRegistry " + " where CardholderID=\'" + taxExemptSale.teCardholder.CardholderID + "\'", DataSource.CSCMaster);
                if (rsCardHolder.Rows.Count > 0)
                {
                    taxExemptSale.teCardholder.Name = CommonUtility.GetStringValue(rsCardHolder.Rows[0]["Name"]);
                }
            }
            return(taxExemptSale);
        }
        /// <summary>
        /// Search Customers
        /// </summary>
        /// <param name="searchCriteria"></param>
        /// <param name="totalrecords"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public List <Customer> Search(string searchCriteria, out int totalrecords, int pageIndex = 1, int pageSize = 100)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,CustomerService,Search,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");
            totalrecords = 0;
            var customers = new List <Customer>();
            var query     = "Select * from Client " +
                            " WHERE  (Client.CL_Status IS NULL " +
                            " OR Client.CL_Status IN (\'A\',\'F\',\'\')) " +
                            " AND (CL_NAME like \'%" + searchCriteria + "%\' OR " +
                            " CL_CODE like \'%" + searchCriteria + "%\' OR " +
                            " CL_PHONE like \'%" + searchCriteria + "%\' )" +
                            "ORDER BY CLIENT.CL_CODE, CLIENT.CL_NAME, CLIENT.CL_PHONE";
            var dt = GetPagedRecords(query, DataSource.CSCMaster, pageIndex, pageSize);

            if (dt != null)
            {
                totalrecords = dt.Rows.Count;

                customers.AddRange(from DataRow fields in dt.Rows
                                   select new Customer
                {
                    Code                  = CommonUtility.GetStringValue(fields["CL_CODE"]),
                    Name                  = CommonUtility.GetStringValue(fields["CL_NAME"]),
                    Category              = CommonUtility.GetStringValue(fields["CL_CATEG"]),
                    Address_1             = CommonUtility.GetStringValue(fields["CL_ADD1"]),
                    Address_2             = CommonUtility.GetStringValue(fields["CL_ADD2"]),
                    City                  = CommonUtility.GetStringValue(fields["CL_CITY"]),
                    Province              = CommonUtility.GetStringValue(fields["CL_PROV"]),
                    Country               = CommonUtility.GetStringValue(fields["CL_COUNTRY"]),
                    Postal_Code           = CommonUtility.GetStringValue(fields["CL_POSTAL"]),
                    Area_Code             = CommonUtility.GetStringValue(fields["CL_ACODE"]),
                    Phone                 = CommonUtility.GetStringValue(fields["CL_PHONE"]),
                    Cell_Phone            = CommonUtility.GetStringValue(fields["CL_CELL"]),
                    Fax                   = CommonUtility.GetStringValue(fields["CL_FAX"]),
                    Toll_Free             = CommonUtility.GetStringValue(fields["CL_TOLL"]),
                    E_Mail                = CommonUtility.GetStringValue(fields["CL_EMAIL"]),
                    Contact_1             = CommonUtility.GetStringValue(fields["CL_CONT1"]),
                    Contact_2             = CommonUtility.GetStringValue(fields["CL_CONT2"]),
                    Loyalty_Code          = CommonUtility.GetStringValue(fields["LO_NUM"]),
                    Loyalty_Points        = CommonUtility.GetDoubleValue(fields["LO_POINTS"]),
                    AR_Customer           = CommonUtility.GetBooleanValue(fields["CL_ARCUST"]),
                    Customer_Type         = CommonUtility.GetStringValue(fields["CL_TYPE"]),
                    Terms                 = CommonUtility.GetShortValue(fields["TERMS"]),
                    Credit_Limit          = CommonUtility.GetDoubleValue(fields["CL_LIMIT"]),
                    Current_Balance       = CommonUtility.GetDoubleValue(fields["CL_CURBAL"]),
                    CL_Status             = CommonUtility.GetStringValue(fields["CL_STATUS"]),
                    UsePO                 = CommonUtility.GetBooleanValue(fields["UsePO"]),
                    GroupID               = CommonUtility.GetStringValue(fields["GroupID"]),
                    UseFuelRebate         = CommonUtility.GetBooleanValue(fields["UseFuelRebate"]),
                    UseFuelRebateDiscount = CommonUtility.GetBooleanValue(fields["UseFuelRebateDiscount"]),
                    CL_Note               = CommonUtility.GetStringValue(fields["CL_Note"]),
                    TaxExempt             = CommonUtility.GetBooleanValue(fields["TaxExempt"]),
                    PlateNumber           = CommonUtility.GetStringValue(fields["PlateNumber"]),
                    MultiUse_PO           = CommonUtility.GetBooleanValue(fields["MultiUse_PO"]),
                    TECardNumber          = CommonUtility.GetStringValue(fields["TECardNumber"]),
                    Discount_Code         = CommonUtility.GetByteValue(fields["CUST_DISC"])
                });
            }

            _performancelog.Debug($"End,CustomerService,Search,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            return(customers);
        }
        /// <summary>
        /// Get Customer By Client Code
        /// </summary>
        /// <param name="clientCode">code</param>
        /// <returns>Customer</returns>
        public Customer GetClientByClientCode(string clientCode)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,CustomerService,GetClientByClientCode,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");
            Customer customer = null;

            var dt = GetRecords(" SELECT * FROM   Client WHERE Client.CL_Code = \'" + clientCode + "\'", DataSource.CSCMaster);

            if (dt != null && dt.Rows.Count > 0)
            {
                _performancelog.Debug($"End,CustomerService,GetClientByClientCode,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
                customer = new Customer
                {
                    Code                  = CommonUtility.GetStringValue(dt.Rows[0]["CL_CODE"]),
                    Name                  = CommonUtility.GetStringValue(dt.Rows[0]["CL_NAME"]),
                    Category              = CommonUtility.GetStringValue(dt.Rows[0]["CL_CATEG"]),
                    Address_1             = CommonUtility.GetStringValue(dt.Rows[0]["CL_ADD1"]),
                    Address_2             = CommonUtility.GetStringValue(dt.Rows[0]["CL_ADD2"]),
                    City                  = CommonUtility.GetStringValue(dt.Rows[0]["CL_CITY"]),
                    Province              = CommonUtility.GetStringValue(dt.Rows[0]["CL_PROV"]),
                    Country               = CommonUtility.GetStringValue(dt.Rows[0]["CL_COUNTRY"]),
                    Postal_Code           = CommonUtility.GetStringValue(dt.Rows[0]["CL_POSTAL"]),
                    Area_Code             = CommonUtility.GetStringValue(dt.Rows[0]["CL_ACODE"]),
                    Phone                 = CommonUtility.GetStringValue(dt.Rows[0]["CL_PHONE"]),
                    Cell_Phone            = CommonUtility.GetStringValue(dt.Rows[0]["CL_CELL"]),
                    Fax                   = CommonUtility.GetStringValue(dt.Rows[0]["CL_FAX"]),
                    Toll_Free             = CommonUtility.GetStringValue(dt.Rows[0]["CL_TOLL"]),
                    E_Mail                = CommonUtility.GetStringValue(dt.Rows[0]["CL_EMAIL"]),
                    Contact_1             = CommonUtility.GetStringValue(dt.Rows[0]["CL_CONT1"]),
                    Contact_2             = CommonUtility.GetStringValue(dt.Rows[0]["CL_CONT2"]),
                    Loyalty_Code          = CommonUtility.GetStringValue(dt.Rows[0]["LO_NUM"]),
                    Loyalty_Points        = CommonUtility.GetDoubleValue(dt.Rows[0]["LO_POINTS"]),
                    AR_Customer           = CommonUtility.GetBooleanValue(dt.Rows[0]["CL_ARCUST"]),
                    Customer_Type         = CommonUtility.GetStringValue(dt.Rows[0]["CL_TYPE"]),
                    Terms                 = CommonUtility.GetShortValue(dt.Rows[0]["TERMS"]),
                    Credit_Limit          = CommonUtility.GetDoubleValue(dt.Rows[0]["CL_LIMIT"]),
                    Current_Balance       = CommonUtility.GetDoubleValue(dt.Rows[0]["CL_CURBAL"]),
                    CL_Status             = CommonUtility.GetStringValue(dt.Rows[0]["CL_STATUS"]),
                    UsePO                 = CommonUtility.GetBooleanValue(dt.Rows[0]["UsePO"]),
                    GroupID               = CommonUtility.GetStringValue(dt.Rows[0]["GroupID"]),
                    UseFuelRebate         = CommonUtility.GetBooleanValue(dt.Rows[0]["UseFuelRebate"]),
                    UseFuelRebateDiscount = CommonUtility.GetBooleanValue(dt.Rows[0]["UseFuelRebateDiscount"]),
                    CL_Note               = CommonUtility.GetStringValue(dt.Rows[0]["CL_Note"]),
                    TaxExempt             = CommonUtility.GetBooleanValue(dt.Rows[0]["TaxExempt"]),
                    PlateNumber           = CommonUtility.GetStringValue(dt.Rows[0]["PlateNumber"]),
                    TECardNumber          = CommonUtility.GetStringValue(dt.Rows[0]["TECardNumber"]),
                    Discount_Code         = CommonUtility.GetByteValue(dt.Rows[0]["CUST_DISC"]),
                    Price_Code            = CommonUtility.GetByteValue(dt.Rows[0]["Price_Code"]),
                    MultiUse_PO           = CommonUtility.GetBooleanValue(dt.Rows[0]["UsePO"]) && CommonUtility.GetBooleanValue(dt.Rows[0]["MultiUse_PO"]),
                };

                if (!string.IsNullOrEmpty(customer.GroupID))
                {
                    var clientDt = GetRecords("select * from ClientGroup  where GroupID=\'" + customer.GroupID + "\'", DataSource.CSCMaster);
                    if (clientDt == null || clientDt.Rows.Count == 0)
                    {
                        customer.GroupID = "";
                    }
                    else
                    {
                        customer.GroupName    = CommonUtility.GetStringValue(clientDt.Rows[0]["GroupName"]);
                        customer.DiscountType = CommonUtility.GetStringValue(clientDt.Rows[0]["DiscountType"]);
                        customer.DiscountRate = CommonUtility.GetFloatValue(clientDt.Rows[0]["DiscountRate"]);
                        customer.Footer       = CommonUtility.GetStringValue(clientDt.Rows[0]["LoyaltyFooter"]);
                        customer.DiscountName = CommonUtility.GetStringValue(clientDt.Rows[0]["DiscountName"]);
                    }
                }
                // var clientCard = GetClientCardForCustomer()
            }
            _performancelog.Debug($"End,CustomerService,GetClientByClientCode,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            return(customer);
        }
Example #26
0
        /// <summary>
        /// Gets the List of Sale Lines
        /// </summary>
        /// <param name="saleNumber">Sale number</param>
        /// <param name="tillNumber">Till number</param>
        /// <param name="saleDate">Sale date</param>
        /// <param name="discountType">Discount type</param>
        /// <param name="teType">Tax exempt type</param>
        /// <param name="taxExempt">Tax exempt name</param>
        /// <returns>List of sale lines</returns>
        public List <Sale_Line> GetSaleLineBySaleNumber(int saleNumber, int tillNumber, DateTime saleDate, string discountType, string teType, bool taxExempt)
        {
            var dateStart = DateTime.Now;

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

            List <Sale_Line> saleLines = new List <Sale_Line>();
            DataSource       db        = DataSource.CSCTrans;

            var strSqlHead = " SELECT * FROM   SaleHead Where  SaleHead.Sale_No = " + CommonUtility.GetStringValue(saleNumber) + " AND SaleHead.TILL = " + CommonUtility.GetStringValue(tillNumber) + " AND SaleHead.T_Type IN ( \'SALE\' ,\'REFUND\', \'RUNAWAY\',\'PUMPTEST\' ) and SaleHead.SALE_AMT <> 0 ";
            var strSqlLine = " SELECT * FROM   SaleLine Where SaleLine.Sale_No = " + CommonUtility.GetStringValue(saleNumber) + " AND SaleLine.TILL_NUM = " + CommonUtility.GetStringValue(tillNumber) + "ORDER BY SaleLine.Line_Num ";

            var rsHead = GetRecords(strSqlHead, DataSource.CSCTrans);
            var rsLine = GetRecords(strSqlLine, DataSource.CSCTrans);

            // If SaleNo is not found in Trans.mdb database, then
            // look for this SaleNo in all active Tills
            if (rsHead == null || rsHead.Rows.Count == 0)
            {
                rsHead = GetRecords(strSqlHead, DataSource.CSCTills);
                rsLine = GetRecords(strSqlLine, DataSource.CSCTills);
                // If sale number is found exit for do and use this recordset
                if (rsHead != null && rsHead.Rows.Count != 0)
                {
                    db = DataSource.CSCTills;
                }
            }
            else
            {
                db = DataSource.CSCTrans;
            }
            foreach (DataRow rsLineFields in rsLine.Rows)
            {
                var saleLine = new Sale_Line
                {
                    No_Loading    = true,
                    Stock_Code    = CommonUtility.GetStringValue(rsLineFields["Stock_Code"]),
                    PLU_Code      = CommonUtility.GetStringValue(rsLineFields["PLU_Code"]),
                    Line_Num      = CommonUtility.GetShortValue(rsLineFields["Line_Num"]),
                    Price_Type    = CommonUtility.GetCharValue(rsLineFields["Price_Type"]),
                    Dept          = CommonUtility.GetStringValue(rsLineFields["Dept"]),
                    Sub_Detail    = CommonUtility.GetStringValue(rsLineFields["Sub_Detail"]),
                    Sub_Dept      = CommonUtility.GetStringValue(rsLineFields["Sub_Dept"]),
                    Quantity      = CommonUtility.GetFloatValue(rsLineFields["Quantity"]) * -1,
                    price         = CommonUtility.GetDoubleValue(rsLineFields["price"]),
                    Regular_Price = CommonUtility.GetDoubleValue(rsLineFields["Reg_Price"]),
                    Cost          = CommonUtility.GetDoubleValue(rsLineFields["Cost"]),
                    Amount        = CommonUtility.GetDecimalValue(rsLineFields["Amount"]) * -1,
                    Total_Amount  = CommonUtility.GetDecimalValue(rsLineFields["Total_Amt"]) * -1
                };

                if (!(teType == "QITE" && discountType == "D"))
                {
                    saleLine.Line_Discount = CommonUtility.GetDoubleValue(rsLineFields["Discount"]) * -1;
                }
                saleLine.Discount_Type = CommonUtility.GetStringValue(rsLineFields["Disc_Type"]);
                saleLine.Discount_Code = CommonUtility.GetStringValue(rsLineFields["Disc_Code"]);
                if (!(teType == "QITE" && discountType == "D"))
                {
                    SetDiscountRate(ref saleLine, CommonUtility.GetFloatValue(rsLineFields["Disc_Rate"]));
                }
                saleLine.Associate_Amount = CommonUtility.GetDecimalValue(rsLineFields["Assoc_Amt"]);
                saleLine.Description      = CommonUtility.GetStringValue(rsLineFields["Descript"]);
                saleLine.Loyalty_Save     = CommonUtility.GetFloatValue(rsLineFields["Loyl_Save"]);
                saleLine.Units            = CommonUtility.GetStringValue(rsLineFields["Units"]);
                saleLine.Serial_No        = CommonUtility.GetStringValue(rsLineFields["Serial_No"]);

                saleLine.Stock_Code = CommonUtility.GetStringValue(rsLineFields["Stock_Code"]);
                saleLine.pumpID     = CommonUtility.GetByteValue(rsLineFields["pumpID"]);
                saleLine.PositionID = CommonUtility.GetByteValue(rsLineFields["PositionID"]);

                saleLine.GradeID = CommonUtility.GetByteValue(rsLineFields["GradeID"]);

                saleLine.Prepay = CommonUtility.GetBooleanValue(rsLineFields["Prepay"]);

                saleLine.ManualFuel = CommonUtility.GetBooleanValue(rsLineFields["ManualFuel"]);

                saleLine.IsTaxExemptItem = CommonUtility.GetBooleanValue(rsLineFields["TaxExempt"]);

                saleLine.Gift_Num = CommonUtility.GetStringValue(rsLineFields["GC_Num"]);

                saleLine.FuelRebateEligible = CommonUtility.GetBooleanValue(rsLineFields["FuelRebateUsed"]);

                saleLine.FuelRebate = CommonUtility.GetDecimalValue(rsLineFields["RebateDiscount"]);

                saleLine.EligibleTaxEx = CommonUtility.GetBooleanValue(rsLineFields["ElgTaxExemption"]);

                saleLine.CarwashCode = CommonUtility.GetStringValue(rsLineFields["CarwashCode"]);

                if (saleLine.CarwashCode != "")
                {
                    saleLine.IsCarwashProduct = true;
                }

                if (saleLine.IsTaxExemptItem)
                {
                    if (teType == "SITE")
                    {
                        var rsPurchaseItem = GetRecords(
                            "select * from PurchaseItem Where Sale_No=" + CommonUtility.GetStringValue(saleNumber) +
                            " AND Line_No=" + CommonUtility.GetStringValue(saleLine.Line_Num), db);
                        if (rsPurchaseItem != null && rsPurchaseItem.Rows.Count != 0)
                        {
                            var rsPurchaseItemFields = rsPurchaseItem.Rows[0];

                            saleLine.OriginalPrice =
                                CommonUtility.GetFloatValue(rsPurchaseItemFields["OriginalPrice"]);
                            saleLine.TaxInclPrice = CommonUtility.GetFloatValue(rsPurchaseItemFields["Amount"]);
                        }
                        else
                        {
                            saleLine.OriginalPrice = (float)saleLine.price;
                            saleLine.TaxInclPrice  = (float)(-1 * saleLine.Amount);
                        }
                    }
                    else
                    {
                        var rsTeSaleLine = GetRecords(
                            "select * from TaxExemptSaleLine Where SALE_NO=" +
                            CommonUtility.GetStringValue(saleNumber) + " AND LINE_NUM=" +
                            CommonUtility.GetStringValue(saleLine.Line_Num), db);

                        if (rsTeSaleLine != null && rsTeSaleLine.Rows.Count != 0)
                        {
                            var rsTeSaleLineFields = rsTeSaleLine.Rows[0];

                            saleLine.OriginalPrice =
                                CommonUtility.GetFloatValue(rsTeSaleLineFields["OriginalPrice"]);

                            saleLine.TaxInclPrice =
                                CommonUtility.GetFloatValue(-1 *
                                                            CommonUtility.GetIntergerValue(
                                                                rsTeSaleLineFields["TaxIncludedAmount"]));
                        }
                        else
                        {
                            saleLine.OriginalPrice = (float)saleLine.price;
                            saleLine.TaxInclPrice  = (float)(-1 * saleLine.Amount);
                        }

                        saleLine.IsTaxExemptItem = false;
                    }
                }


                string strPromo = CommonUtility.GetStringValue(rsLineFields["PromoID"]);
                if (strPromo.Length != 0)
                {
                    saleLine.PromoID = strPromo;
                }


                saleLine.Line_Taxes = null;
                var rsLineTax =
                    GetRecords(
                        "Select * From   S_LineTax  WHERE  S_LineTax.Sale_No = " +
                        CommonUtility.GetStringValue(saleNumber) + " AND  S_LineTax.Line_No = " +
                        CommonUtility.GetStringValue(rsLineFields["Line_Num"]) + " " +
                        "Order By S_LineTax.Tax_Name ", db);
                if (rsLineTax == null || rsLineTax.Rows.Count == 0)
                {
                    if (taxExempt && (teType == "AITE" || teType == "QITE"))
                    {
                        rsLineTax =
                            GetRecords(
                                "Select * From   TaxCreditLine  WHERE  TaxCreditLine.Sale_No = " +
                                CommonUtility.GetStringValue(saleNumber) + " AND  TaxCreditLine.Line_No = " +
                                CommonUtility.GetStringValue(rsLineFields["Line_Num"]) + " " +
                                "Order By TaxCreditLine.Tax_Name ", db);
                        if (!saleLine.IsTaxExemptItem && rsLineTax.Rows.Count != 0)
                        {
                        }
                    }
                }

                foreach (DataRow rsLineTaxFields in rsLineTax.Rows)
                {
                    saleLine.Line_Taxes.Add(CommonUtility.GetStringValue(rsLineTaxFields["Tax_Name"]),
                                            CommonUtility.GetStringValue(rsLineTaxFields["Tax_Code"]),
                                            CommonUtility.GetFloatValue(rsLineTaxFields["Tax_Rate"]),
                                            CommonUtility.GetBooleanValue(rsLineTaxFields["Tax_Included"]),
                                            CommonUtility.GetFloatValue(rsLineTaxFields["Tax_Rebate_Rate"]),
                                            CommonUtility.GetDecimalValue(rsLineTaxFields["Tax_Rebate"]), "");
                }

                // Similarly, pick up the charges associated with the line.
                saleLine.Charges = null;
                var rsLineChg =
                    GetRecords(
                        "Select *  FROM   SaleChg  WHERE  SaleChg.Sale_No = " +
                        CommonUtility.GetStringValue(saleNumber) + " AND SaleChg.Line_No = " +
                        CommonUtility.GetStringValue(rsLineFields["Line_Num"]) + " Order By SaleChg.As_Code ",
                        db);
                foreach (DataRow linChrField in rsLineChg.Rows)
                {
                    var rsLcTax =
                        GetRecords(
                            "Select *  FROM   ChargeTax  WHERE  ChargeTax.Sale_No = " +
                            CommonUtility.GetStringValue(saleNumber) + " AND ChargeTax.Line_No = " +
                            CommonUtility.GetStringValue(rsLineFields["Line_Num"]) + " AND ChargeTax.As_Code = \'" +
                            CommonUtility.GetStringValue(linChrField["As_Code"]) + "\' ", db);
                    // Find any taxes that applied to those charges.
                    var lct = new Charge_Taxes();
                    foreach (DataRow rsLcTaxFields in rsLcTax.Rows)
                    {
                        lct.Add(CommonUtility.GetStringValue(rsLcTaxFields["Tax_Name"]),
                                CommonUtility.GetStringValue(rsLcTaxFields["Tax_Code"]),
                                CommonUtility.GetFloatValue(rsLcTaxFields["Tax_Rate"]),
                                CommonUtility.GetBooleanValue(rsLcTaxFields["Tax_Included"]), "");
                    }

                    saleLine.Charges.Add(CommonUtility.GetStringValue(linChrField["As_Code"]),
                                         CommonUtility.GetStringValue(linChrField["Description"]),
                                         CommonUtility.GetFloatValue(linChrField["price"]), lct, "");
                }


                saleLine.Line_Kits = GetLineKits(saleNumber,
                                                 CommonUtility.GetIntergerValue(rsLineFields["Line_Num"]), db);
                saleLines.Add(saleLine);
            }
            _performancelog.Debug($"End,ReturnSaleService,GetSaleLineBySaleNumber,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(saleLines);
        }
Example #27
0
        /// <summary>
        /// Load Store information
        /// </summary>
        /// <returns></returns>
        public Store LoadStoreInfo()
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,LoginService,LoadStoreInfo,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");
            var store = new Store();
            var rs    = GetRecords("Select * from Setup_C", DataSource.CSCAdmin);

            if (rs != null && rs.Rows.Count > 0)
            {
                var fields = rs.Rows[0];
                store.Name       = CommonUtility.GetStringValue(fields["Company_Name"]);
                store.RegName    = CommonUtility.GetStringValue(fields["Reg_Name"]);
                store.RegNum     = CommonUtility.GetStringValue(fields["Reg_Num"]);
                store.SecRegName = CommonUtility.GetStringValue(fields["Sec_Reg_Name"]);
                store.SecRegNum  = CommonUtility.GetStringValue(fields["Sec_Reg_Num"]);
                store.Language   = CommonUtility.GetStringValue(fields["Language"]);
                // Store.Code is used in till close to set Store field in SaleHead table
                // With a null value in Store field in SaleHead after the till was closed, DTS package that transfers data from Bo to Ho will fail
                // BackOffice has this property set, so for tills closed from BO there is no problem
                store.Code               = CommonUtility.GetStringValue(fields["Store"]);
                store.Address.Street1    = CommonUtility.GetStringValue(fields["Address_1"]);
                store.Address.Street2    = CommonUtility.GetStringValue(fields["Address_2"]);
                store.Address.City       = CommonUtility.GetStringValue(fields["City"]);
                store.Address.ProvState  = CommonUtility.GetStringValue(fields["Province"]);
                store.Address.Country    = CommonUtility.GetStringValue(fields["Country"]);
                store.Address.PostalCode = CommonUtility.GetStringValue(fields["Postal_Code"]);
                store.Address.Phones.Add("Tel", "Phone", "", CommonUtility.GetStringValue(fields["Tel_Num"]), "");
                store.Address.Phones.Add("Fax", "Fax", "", CommonUtility.GetStringValue(fields["Fax_Num"]), ""); //"Fax","Fax"
            }

            if (!string.IsNullOrEmpty(store.Language))
            {
                rs = GetRecords("Select * From Languages  WHERE Languages.Language = \'" + store.Language + "\'", DataSource.CSCMaster);
                if (rs.Rows.Count != 0)
                {
                    store.OffSet = CommonUtility.GetShortValue(rs.Rows[0]["OffSet"]);
                }
                else
                {
                    store.OffSet = 0;
                }
            }
            else
            {
                store.OffSet = 0;
            }

            rs = GetRecords("SELECT * FROM Receipt where ID=\'1\'", DataSource.CSCMaster);
            if (rs != null && rs.Rows.Count > 0)
            {
                var fields = rs.Rows[0];

                store.Sale_Footer   = CommonUtility.GetStringValue(fields["Sale_Foot"]);
                store.Refund_Footer = CommonUtility.GetStringValue(fields["Ref_Foot"]);
            }
            rs = GetRecords("SELECT * FROM Receipt where ID=\'2\'", DataSource.CSCMaster);
            if (rs == null || rs.Rows.Count == 0)
            {
                return(store);
            }
            {
                var fields = rs.Rows[0];

                store.TaxExempt_Footer = CommonUtility.GetStringValue(fields["Sale_Foot"]);
            }
            _performancelog.Debug($"End,LoginService,LoadStoreInfo,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            return(store);
        }
Example #28
0
        /// <summary>
        /// Get the list of tills
        /// </summary>
        /// <param name="posId">Pos id</param>
        /// <param name="tillNumber">Till number</param>
        /// <param name="shiftDate">Shift date</param>
        /// <param name="userCode">User code</param>
        /// <param name="active">Is active or not</param>
        /// <param name="process">Is processing or not</param>
        /// <returns>Tills</returns>
        public List <Till> GetTills(int?posId, int?tillNumber, DateTime?shiftDate,
                                    string userCode, int?active, int?process)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,TillService,GetTills,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

            var    whereClause = new StringBuilder();
            string query;

            if (posId.HasValue)
            {
                whereClause.Append($" AND POSID={posId.Value}");
            }

            if (tillNumber.HasValue)
            {
                whereClause.Append($" AND TILL_NUM={tillNumber.Value} ");
            }

            if (shiftDate.HasValue)
            {
                whereClause.Append($" AND ShiftDate={shiftDate.Value}");
            }

            if (!string.IsNullOrEmpty(userCode))
            {
                whereClause.Append($" AND UserLoggedOn='{userCode}'");
            }
            if (active.HasValue)
            {
                whereClause.Append($" AND ACTIVE={active.Value}");
            }
            if (process.HasValue)
            {
                whereClause.Append($" AND PROCESS={process.Value}");
            }
            if (whereClause.Length != 0)
            {
                var condition = whereClause.ToString().Substring(5, whereClause.Length - 5);
                query = $"Select * from Tills where {condition}";
            }
            else
            {
                query = "Select * from Tills";
            }
            var sTills = GetRecords(query, DataSource.CSCMaster);

            var tills = new List <Till>();

            foreach (DataRow row in sTills.Rows)
            {
                var till = new Till
                {
                    Number       = CommonUtility.GetShortValue(row["TILL_NUM"]),
                    Active       = CommonUtility.GetBooleanValue(row["ACTIVE"]),
                    Processing   = CommonUtility.GetBooleanValue(row["PROCESS"]),
                    Float        = CommonUtility.GetDecimalValue(row["FLOAT"]),
                    BonusFloat   = CommonUtility.GetDecimalValue(row["CashBonusFloat"]),
                    Cash         = CommonUtility.GetDecimalValue(row["CASH"]),
                    Date_Open    = CommonUtility.GetDateTimeValue(row["DATE_OPEN"]),
                    Time_Open    = CommonUtility.GetDateTimeValue(row["TIME_OPEN"]),
                    ShiftDate    = CommonUtility.GetDateTimeValue(row["ShiftDate"]),
                    Shift        = CommonUtility.GetShortValue(row["ShiftNumber"]),
                    UserLoggedOn = CommonUtility.GetStringValue(row["UserLoggedOn"]),
                    POSId        = CommonUtility.GetIntergerValue(row["POSID"]),
                    CashBonus    = CommonUtility.GetDecimalValue(row["CashBonus"])
                };
                tills.Add(till);
            }

            _performancelog.Debug($"End,TillService,GetTills,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            return(tills);
        }
        /// <summary>
        /// Method to set register info
        /// </summary>
        /// <param name="registerNumber">Register number</param>
        /// <param name="device">Device</param>
        /// <returns>Register</returns>
        public Register SetRegisterInfo(short registerNumber, Device device)
        {
            var rs = GetRecords("Select *  FROM Register  WHERE Register.Reg_No = " + Convert.ToString(registerNumber), DataSource.CSCAdmin);

            if (rs.Rows.Count == 0)
            {
                return(null);
            }
            var register = new Register {
                Register_Num = registerNumber
            };

            foreach (DataRow row in rs.Rows)
            {
                if (CommonUtility.GetByteValue(row["DeviceID"]) == device.ScannerID)
                {
                    register.Scanner         = CommonUtility.GetBooleanValue(row["Active"]);
                    register.Opos_Scanner    = CommonUtility.GetBooleanValue(row["UseOPOS"]);
                    register.Scanner_Name    = CommonUtility.GetStringValue(row["DeviceName"]);
                    register.Scanner_Port    = CommonUtility.GetStringValue(row["PortNum"]);
                    register.Scanner_Setting = CommonUtility.GetStringValue(row["PortSetting"]);
                }
                else if (CommonUtility.GetByteValue(row["DeviceID"]) == device.CashDrawerID)
                {
                    register.Cash_Drawer           = CommonUtility.GetBooleanValue(row["Active"]);
                    register.Opos_Cash_Drawer      = CommonUtility.GetBooleanValue(row["UseOPOS"]);
                    register.Cash_Drawer_Name      = CommonUtility.GetStringValue(row["DeviceName"]);
                    register.Cash_Drawer_Open_Code = CommonUtility.GetShortValue(row["PortNum"]);
                }
                else if (CommonUtility.GetByteValue(row["DeviceID"]) == device.CustomerDisplayID)
                {
                    register.Customer_Display      = CommonUtility.GetBooleanValue(row["Active"]);
                    register.Opos_Customer_Display = CommonUtility.GetBooleanValue(row["UseOPOS"]);
                    register.Customer_Display_Name = CommonUtility.GetStringValue(row["DeviceName"]);
                    if (CommonUtility.GetStringValue(row["DriverName"]).Length == 0)
                    {
                        register.Customer_Display_Code = 0;
                    }
                    else
                    {
                        register.Customer_Display_Code = (byte)(Conversion.Val(Strings.Left(CommonUtility.GetStringValue(row["DriverName"]), 1)));
                    }
                    register.Customer_Display_Port = CommonUtility.GetByteValue(row["PortNum"]);
                    if (CommonUtility.GetBooleanValue(row["UseOPOS"]))
                    {
                        register.Customer_Display_Len = 20;
                    }
                }
                else if (CommonUtility.GetByteValue(row["DeviceID"]) == device.ReceiptPrinterID)
                {
                    register.Receipt_Printer      = CommonUtility.GetBooleanValue(row["Active"]);
                    register.Opos_Receipt_Printer = CommonUtility.GetBooleanValue(row["UseOPOS"]);
                    register.ReceiptPrinterName   = CommonUtility.GetStringValue(row["DeviceName"]);
                    register.ReceiptDriver        = CommonUtility.GetStringValue(row["DriverName"]);
                }
                else if (CommonUtility.GetByteValue(row["DeviceID"]) == device.ReportPrinterID)
                {
                    register.Report_Printer           = CommonUtility.GetBooleanValue(row["Active"]);
                    register.Opos_Report_Printer      = CommonUtility.GetBooleanValue(row["UseOPOS"]);
                    register.Report_Printer_Name      = CommonUtility.GetStringValue(row["DeviceName"]);
                    register.Report_Printer_Driver    = CommonUtility.GetStringValue(row["DriverName"]);
                    register.Report_Printer_font      = CommonUtility.GetStringValue(row["FontName"]);
                    register.Report_Printer_font_size = CommonUtility.GetIntergerValue(row["FontSize"]);
                }
                else if (CommonUtility.GetByteValue(row["DeviceID"]) == device.MSRID)
                {
                    register.MSR      = CommonUtility.GetBooleanValue(row["Active"]);
                    register.Opos_MSR = CommonUtility.GetBooleanValue(row["UseOPOS"]);
                    register.MSR_Name = CommonUtility.GetStringValue(row["DeviceName"]);
                }
                else if (CommonUtility.GetByteValue(row["DeviceID"]) == device.ScaleID)
                {
                    register.UseScale   = CommonUtility.GetBooleanValue(row["Active"]);
                    register.OPOS_Scale = CommonUtility.GetBooleanValue(row["UseOPOS"]);
                    register.SCALE_Name = CommonUtility.GetStringValue(row["DeviceName"]);
                }
            }
            return(register);
        }