Exemple #1
0
        private string CreateHourlySales(Int32 BranchID, string TerminalNo, DateTime ProcessDate, Data.TerminalReportDetails TerminalReportDetails)
        {
            string strRetValue = "";

            DateTime dteDateFrom = ProcessDate;

            Data.TerminalReportHistory clsTerminalReportHistory = new Data.TerminalReportHistory();
            DateTime dteDateTo = DateTime.MinValue;

            try
            {
                dteDateTo = clsTerminalReportHistory.NEXTDateLastInitialized(BranchID, TerminalNo, ProcessDate);
            }
            catch { }

            if (dteDateTo == DateTime.MinValue)
            {
                Event clsEvent = new Event();
                clsEvent.AddEventLn("HourlySales: Did not found MAXDateLastInitialized from Terminal Report History. Using the MAXDateLastInitialized from terminal report", true);
                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(clsTerminalReportHistory.Connection, clsTerminalReportHistory.Transaction);
                dteDateTo = clsTerminalReport.MAXDateLastInitialized(BranchID, TerminalNo, ProcessDate);
            }

            System.Data.DataTable dtHourlyReport = clsTerminalReportHistory.HourlyReport(BranchID, TerminalNo, dteDateFrom, dteDateTo);
            clsTerminalReportHistory.CommitAndDispose();

            string stHourlyTableName = mclsFSIDetails.OutputDirectory + "\\H" + mclsFSIDetails.TenantName.Substring(0, 4) + TerminalReportDetails.TerminalNo + TerminalReportDetails.BatchCounter.ToString() + "." + TerminalReportDetails.DateLastInitializedToDisplay.ToString("MM").Replace("10", "A").Replace("11", "B").Replace("12", "C").Replace("0", "") + TerminalReportDetails.DateLastInitializedToDisplay.ToString("dd");

            if (File.Exists(stHourlyTableName))
            {
                File.Delete(stHourlyTableName);
            }

            writer = File.AppendText(stHourlyTableName);
            writer.WriteLine("01{0}", mclsFSIDetails.TenantCode);
            writer.WriteLine("02{0}", TerminalNo);

            DateTime dtePreviousTransactionDate = DateTime.MinValue;

            foreach (System.Data.DataRow dr in dtHourlyReport.Rows)
            {
                if (dtePreviousTransactionDate != Convert.ToDateTime(dr["TransactionDate"]))
                {
                    writer.WriteLine("03{0}", Convert.ToDateTime(dr["TransactionDate"]).ToString("MMddyyyy"));
                    dtePreviousTransactionDate = Convert.ToDateTime(dr["TransactionDate"]);
                }
                writer.WriteLine("04{0}", dr["Time"].ToString().Substring(0, 2));
                writer.WriteLine("05{0}", Convert.ToDecimal(Convert.ToDecimal(dr["Amount"]) - Convert.ToDecimal(dr["VAT"])).ToString("####.#0").Replace(".", ""));
                writer.WriteLine("06{0}", Convert.ToInt64(dr["TranCount"]).ToString("####"));
            }
            writer.WriteLine("07{0}", TerminalReportDetails.DailySales.ToString("####.#0").Replace(".", ""));
            writer.WriteLine("08{0}", TerminalReportDetails.NoOfClosedTransactions.ToString("####"));

            writer.Flush();
            writer.Close();

            strRetValue = stHourlyTableName;

            return(strRetValue);
        }
Exemple #2
0
        private void SetDataSource(ReportDocument Report)
        {
            ReportDataset rptds = new ReportDataset();

            Data.TerminalReport  clsTerminalReport  = new Data.TerminalReport();
            Data.Terminal        clsTerminal        = new Data.Terminal(clsTerminalReport.Connection, clsTerminalReport.Transaction);
            Data.TerminalDetails clsTerminalDetails = clsTerminal.Details(txtTerminalNo.Text);
            clsTerminalReport.SyncTransactionSales(clsTerminalDetails.BranchDetails.BranchID, txtTerminalNo.Text);
            System.Data.DataTable dt = clsTerminalReport.List(txtTerminalNo.Text);
            clsTerminalReport.CommitAndDispose();

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                DataRow drNew = rptds.TerminalReport.NewRow();

                foreach (DataColumn dc in rptds.TerminalReport.Columns)
                {
                    drNew[dc] = dr[dc.ColumnName];
                }

                rptds.TerminalReport.Rows.Add(drNew);
            }

            Report.SetDataSource(rptds);
            SetParameters(Report);
        }
Exemple #3
0
        public Int64 UpdateBeginningBalance(CashierLogsDetails Details, decimal BeginningBalanceAmount)
        {
            Int64 iRetValue = Insert(Details);

            Data.CashierReports clsCashierReport = new Data.CashierReports(base.Connection, base.Transaction);
            clsCashierReport.UpdateBeginningBalance(Details.BranchID, Details.TerminalNo, Details.CashierID, BeginningBalanceAmount);

            Data.TerminalReport clsTerminalReport = new Data.TerminalReport(base.Connection, base.Transaction);
            clsTerminalReport.UpdateBeginningBalance(Details.BranchID, Details.TerminalNo, BeginningBalanceAmount);

            return(iRetValue);
        }
Exemple #4
0
        private bool isValuesAssigned()
        {
            bool boRetValue = false;

            try { Convert.ToDecimal(txtAmount.Text); }
            catch
            {
                MessageBox.Show("Sorry, the amount you entered is not valid." +
                                "Please check the amount you entered.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            if (Convert.ToDecimal(txtAmount.Text) > 0)
            {
                mclsDisburseDetails.Amount        = Convert.ToDecimal(txtAmount.Text);
                mclsDisburseDetails.PaymentType   = (PaymentTypes)Enum.Parse(typeof(PaymentTypes), cboType.Text, true);
                mclsDisburseDetails.DateCreated   = DateTime.Now;
                mclsDisburseDetails.TerminalNo    = CompanyDetails.TerminalNo;
                mclsDisburseDetails.CashierID     = mintCashierID;
                mclsDisburseDetails.BranchDetails = mclsTerminalDetails.BranchDetails;
                mclsDisburseDetails.Remarks       = txtRemarks.Text;

                // boRetValue = true;
                // 15Apr2015 No need to check for this coz Disburse is based on actual cash.

                Data.CashierReports clsCashierReport  = new Data.CashierReports();
                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(clsCashierReport.Connection, clsCashierReport.Transaction);
                clsTerminalReport.SyncTransactionSales(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
                if (!clsCashierReport.IsDisburseAmountValid(mclsDisburseDetails))
                {
                    MessageBox.Show("Sorry, the amount you entered is greater than the " + cboType.Text + " sales." +
                                    "Please check the amount you entered.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    boRetValue = false;
                }
                else
                {
                    boRetValue = true;
                }
                clsCashierReport.CommitAndDispose();
            }
            else
            {
                MessageBox.Show("Sorry, amount must be greater than zero." +
                                "Please enter amount that is greater than zero.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                boRetValue = false;
            }
            return(boRetValue);
        }
Exemple #5
0
        private string CreateHourlySales(int BranchID, string TerminalNo, DateTime pvtProcessDate)
        {
            string   strRetValue = "";
            DateTime dteDateFrom = pvtProcessDate;

            Data.TerminalReportHistory clsTerminalReportHistory = new Data.TerminalReportHistory();
            DateTime dteDateTo = DateTime.MinValue;

            try
            {
                dteDateTo = clsTerminalReportHistory.NEXTDateLastInitialized(BranchID, TerminalNo, pvtProcessDate);
            }
            catch { }

            if (dteDateTo == DateTime.MinValue)
            {
                Event clsEvent = new Event();
                clsEvent.AddEventLn("HourlySales: Did not found MAXDateLastInitialized from Terminal Report History. Using the MAXDateLastInitialized from terminal report", true);
                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(clsTerminalReportHistory.Connection, clsTerminalReportHistory.Transaction);
                dteDateTo = clsTerminalReport.MAXDateLastInitialized(Constants.TerminalBranchID, TerminalNo, pvtProcessDate);
            }

            System.Data.DataTable dthreport = clsTerminalReportHistory.HourlyReport(BranchID, TerminalNo, dteDateFrom, dteDateTo);
            clsTerminalReportHistory.CommitAndDispose();

            string stHourlyTableName = mclsAyalaDetails.TenantCode.Substring(0, 3) + pvtProcessDate.ToString("MMdd") + "H";
            string stHourlyFileName  = mclsAyalaDetails.OutputDirectory + "\\" + stHourlyTableName + ".dbf";

            if (File.Exists(stHourlyFileName))
            {
                File.Delete(stHourlyFileName);
            }

            CreateHourlySalesTable(stHourlyTableName);
            InsertHourlySales(stHourlyTableName, dthreport);

            strRetValue = stHourlyFileName;

            return(strRetValue);
        }
Exemple #6
0
        public RegistrationType IsDemoExpired(out string SerialNumber)
        {
            SerialNumber = null;
            try
            {
                RegistrationType regIsDemoExpired = RegistrationType.DEMO_Unexpired;

                SerialNumber = GetHDSerialNo();

                if (SerialNumber == "W50SJSHQ" || SerialNumber == "K834T9A2BJNB" || SerialNumber == "K10HT77258WN" || SerialNumber == "587OCI98T" || SerialNumber == "MRG3W9KKH9S45H" || SerialNumber == "9546305796063968058" || SerialNumber == "9VP7QL84")
                {
                    // K10HT77258WN - Lemuel
                    // 587OCI98T - Darius
                    // MRG3W9KKH9S45H - Rico
                    // 9546305796063968058 - Grace
                    // 9VP7QL84 - Lemuel
                    // WD-WXTY08TPJ153
                    return(RegistrationType.Registered);
                }

                try
                {
                    Data.Terminal clsTerminal = new Data.Terminal();
                    string        cipherText  = clsTerminal.getTerminalKey(SerialNumber);
                    clsTerminal.CommitAndDispose();

                    if (cipherText != string.Empty)
                    {
                        string plainText = CompanyDetails.CompanyCode + SerialNumber.ToString().Trim(); // original plaintext
                        //string  cipherText = System.Configuration.ConfigurationManager.AppSettings["RegistrationKey"].ToString();	// encrypted text
                        string passPhrase = CompanyDetails.TIN;                                         // can be any string
                        string initVector = "%@skmelaT3rsh1t!";                                         // must be 16 bytes

                        // Before encrypting data, we will append plain text to a random
                        // salt value, which will be between 4 and 8 bytes long (implicitly
                        // used defaults).
                        AceSoft.Cryptor clsCryptor = new AceSoft.Cryptor(passPhrase, initVector);

                        if (plainText == clsCryptor.Decrypt(cipherText))
                        {
                            return(RegistrationType.Registered);
                        }
                    }
                }
                catch { }

                Data.TerminalReport clsTerminalReport = new Data.TerminalReport();
                string EndingTransactionNo            = clsTerminalReport.EndingTransactioNo(Constants.TerminalBranchID, CompanyDetails.TerminalNo);
                clsTerminalReport.CommitAndDispose();

                if (Convert.ToInt64(EndingTransactionNo) > 1000)
                {
                    regIsDemoExpired = RegistrationType.DEMO_Expired;
                }

                return(regIsDemoExpired);
            }
            catch (Exception ex)
            {
                SerialNumber = ex.ToString();
                return(RegistrationType.Error);
            }
        }
Exemple #7
0
        private string CreateHourlySales(int BranchID, string TerminalNo, DateTime pvtProcessDate)
        {
            string strRetValue = "";
            DateTime dteDateFrom = pvtProcessDate;

            Data.TerminalReportHistory clsTerminalReportHistory = new Data.TerminalReportHistory();
            DateTime dteDateTo = DateTime.MinValue;
            try
            {
                dteDateTo = clsTerminalReportHistory.NEXTDateLastInitialized(BranchID, TerminalNo, pvtProcessDate);
            }
            catch { }

            if (dteDateTo == DateTime.MinValue)
            {
                Event clsEvent = new Event();
                clsEvent.AddEventLn("HourlySales: Did not found MAXDateLastInitialized from Terminal Report History. Using the MAXDateLastInitialized from terminal report", true);
                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(clsTerminalReportHistory.Connection, clsTerminalReportHistory.Transaction);
                dteDateTo = clsTerminalReport.MAXDateLastInitialized(Constants.TerminalBranchID, TerminalNo, pvtProcessDate);
            }

            System.Data.DataTable dthreport = clsTerminalReportHistory.HourlyReport(BranchID, TerminalNo, dteDateFrom, dteDateTo);
            clsTerminalReportHistory.CommitAndDispose();

            string stHourlyTableName = mclsAyalaDetails.TenantCode.Substring(0, 3) + pvtProcessDate.ToString("MMdd") + "H";
            string stHourlyFileName = mclsAyalaDetails.OutputDirectory + "\\" + stHourlyTableName + ".dbf";
            if (File.Exists(stHourlyFileName)) File.Delete(stHourlyFileName);

            CreateHourlySalesTable(stHourlyTableName);
            InsertHourlySales(stHourlyTableName, dthreport);

            strRetValue = stHourlyFileName;

            return strRetValue;
        }
        public void PrintCashiersReport(Data.CashierReportDetails Details)
        {
            Cursor.Current = Cursors.WaitCursor;
            //OpenDrawerDelegate opendrawerDel = new OpenDrawerDelegate(OpenDrawer);
            //Invoke(opendrawerDel);
            OpenDrawer();

            try
            {
                decimal TrustFund = 0; //always put this as zero
                
                PrintingPreference oldCONFIG_AutoPrint = mclsTerminalDetails.AutoPrint;
                mclsTerminalDetails.AutoPrint = PrintingPreference.Normal;

                PrintReportHeadersSection(false);

                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append(CenterString("Cashier's Report : " + mCashierName, mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);

                msbToPrint.Append("Gross Sales".PadRight(21) + ":" + ((Details.GrossSales + Details.TotalCharge) * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("(-) Service Charge".PadRight(21) + ":" + (Details.TotalCharge * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("".PadRight(21) + ":" + "------------".PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22, ' ') + Environment.NewLine);
                msbToPrint.Append("Total Amount".PadRight(21) + ":" + (Details.GrossSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append(("(-) " + mclsTerminalDetails.VAT.ToString("##") + "% VAT Exempt").PadRight(21) + ":" + (Details.VATExempt * (mclsTerminalDetails.VAT / 100) * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("(-) Discount".PadRight(21) + ":" + ((Details.SubTotalDiscount + Details.ItemsDiscount) * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("".PadRight(21) + ":" + "------------".PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22, ' ') + Environment.NewLine);
                msbToPrint.Append("Net Sales".PadRight(21) + ":" + (Details.NetSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append(CenterString("Taxables Breakdown", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append("VAT Exempt".PadRight(21) + ":" + (Details.VATExempt * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("VAT Zero Rated".PadRight(21) + ":" + (Details.ZeroRatedSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("NonVATable Amount".PadRight(21) + ":" + (Details.NonVATableAmount * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("VATable Amount".PadRight(21) + ":" + (Details.VATableAmount * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("VAT".PadRight(21) + ":" + (Details.VAT * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Local Tax".PadRight(21) + ":" + (Details.LocalTax * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append(CenterString("Total Amount Breakdown", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append("Cash Sales".PadRight(21) + ":" + (Details.CashSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Cheque Sales".PadRight(21) + ":" + (Details.ChequeSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit Card Sales".PadRight(21) + ":" + (Details.CreditCardSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit (Charge)".PadRight(21) + ":" + (Details.CreditSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit Payment".PadRight(21) + ":" + (Details.CreditPayment * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                msbToPrint.Append("      Cash".PadRight(21) + ":" + (Details.CreditPaymentCash * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Cheque".PadRight(21) + ":" + (Details.CreditPaymentCheque * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Credit Card".PadRight(21) + ":" + (Details.CreditPaymentCreditCard * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Debit".PadRight(21) + ":" + (Details.CreditPaymentDebit * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                msbToPrint.Append("Debit  Sales".PadRight(21) + ":" + (Details.DebitPayment * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("RewardPoints Redeemd".PadRight(21) + ":" + Details.RewardPointsPayment.ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("     Cash Equivalent".PadRight(21) + ":" + (Details.RewardConvertedPayment * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Employee Acct.".PadRight(21) + ":" + "0.00".PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Void Sales".PadRight(21) + ":" + (Details.VoidSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Refund Sales".PadRight(21) + ":" + (Details.RefundSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Cash".PadRight(21) + ":" + (Details.RefundCash * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Cheque".PadRight(21) + ":" + (Details.RefundCheque * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Credit Card".PadRight(21) + ":" + (Details.RefundCreditCard * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Credit".PadRight(21) + ":" + (Details.RefundCredit * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Debit".PadRight(21) + ":" + (Details.RefundDebit * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                Data.TerminalReportDetails clsTerminalReportDetails = clsTerminalReport.Details(Details.BranchID, Details.TerminalNo);

                System.Data.DataTable dt = clsSalesTransactions.SalesPerCreditCard(Details.BranchID, Details.TerminalNo, Details.CashierID, clsTerminalReportDetails.DateLastInitialized, clsTerminalReportDetails.NEXTDateLastInitialized);
                clsSalesTransactions.CommitAndDispose();

                if (dt.Rows.Count > 0)
                {
                    msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                    msbToPrint.Append(CenterString("Credit Card Breakdown", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                    msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                    foreach (System.Data.DataRow dr in dt.Rows)
                    { msbToPrint.Append(dr["CardTypeCode"].ToString().PadRight(21) + ":" + (Convert.ToDecimal(dr["Amount"].ToString()) * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine); }
                    msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                }

                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append(CenterString("Discounts", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append("Items Discount".PadRight(21) + ":" + (Details.ItemsDiscount * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("     Senior Citizen".PadRight(21) + ":" + (Details.SNRItemsDiscount * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("     PWD".PadRight(21) + ":" + (Details.PWDItemsDiscount * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("     Others".PadRight(21) + ":" + (Details.OtherItemsDiscount * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Subtotal Discount".PadRight(21) + ":" + (Details.SubTotalDiscount * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("     Senior Citizen".PadRight(21) + ":" + (Details.SNRDiscount * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("     PWD".PadRight(21) + ":" + (Details.PWDDiscount * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("     Others".PadRight(21) + ":" + (Details.OtherDiscount * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("".PadRight(21) + ":" + "------------".PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22, ' ') + Environment.NewLine);
                msbToPrint.Append("Total Discounts".PadRight(21) + ":" + (Details.TotalDiscount * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;
                dt = clsSalesTransactions.Discounts(Details.BranchID, Details.TerminalNo, clsTerminalReportDetails.BeginningTransactionNo, clsTerminalReportDetails.EndingTransactionNo, Details.CashierID);
                clsSalesTransactions.CommitAndDispose();
                if (dt.Rows.Count > 0)
                {
                    msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                    msbToPrint.Append(CenterString("Subtotal Discounts Breakdown", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                    msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                    foreach (System.Data.DataRow dr in dt.Rows)
                    { msbToPrint.Append(dr["DiscountCode"].ToString().PadRight(21) + ":" + (Convert.ToDecimal(dr["Discount"].ToString()) * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine); }
                }

                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append(CenterString("Drawer Information", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append("Beginning Balance".PadRight(21) + ":" + (Details.BeginningBalance).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Cash-In-Drawer".PadRight(21) + ":" + (Details.BeginningBalance + ((Details.CashInDrawer - Details.BeginningBalance) * ((100 - TrustFund) / 100))).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append(CenterString("Paid Out", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append("Paid Out".PadRight(21) + ":" + (Details.TotalPaidOut * ((100 - TrustFund) / 100)).ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append(CenterString("PICK UP / Disburstment", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append("Cash".PadRight(21) + ":" + (Details.CashDisburse * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Cheque".PadRight(21) + ":" + (Details.ChequeDisburse * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit Card".PadRight(21) + ":" + (Details.CreditCardDisburse * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append(CenterString("Receive on Account", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append("Cash".PadRight(21) + ":" + (Details.CashWithHold * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Cheque".PadRight(21) + ":" + (Details.ChequeWithHold * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit Card".PadRight(21) + ":" + (Details.CreditCardWithHold * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append(CenterString("Customer Deposits", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append("Cash".PadRight(21) + ":" + (Details.CashDeposit * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Cheque".PadRight(21) + ":" + (Details.ChequeDeposit * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit Card".PadRight(21) + ":" + (Details.CreditCardDeposit * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append(CenterString("Transaction Count Breakdown", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append("Cash Transactions".PadRight(21) + ":" + Details.NoOfCashTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Cheque Transactions".PadRight(21) + ":" + Details.NoOfChequeTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit Card Trans.".PadRight(21) + ":" + Details.NoOfCreditCardTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit Transactions".PadRight(21) + ":" + Details.NoOfCreditTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Debit Payment Trans.".PadRight(21) + ":" + Details.NoOfDebitPaymentTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Refund Transactions".PadRight(21) + ":" + Details.NoOfRefundTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Void Transactions".PadRight(21) + ":" + Details.NoOfVoidTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Combination Tran".PadRight(21) + ":" + Details.NoOfCombinationPaymentTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit Payment Trans".PadRight(21) + ":" + Details.NoOfCreditPaymentTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Reward Points  Trans".PadRight(21) + ":" + Details.NoOfRewardPointsPayment.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                //				msbToPrint.Append("Employees Acct Trans".PadRight(21) + ":" + "0".PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22)  + Environment.NewLine);
                msbToPrint.Append("".PadRight(21) + ":" + "------------".PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22, ' ') + Environment.NewLine);
                msbToPrint.Append("Total Transactions".PadRight(21) + ":" + Details.NoOfTotalTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append(CenterString("Cash Count", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append("Cash In Drawer".PadRight(21) + ":" + (Details.CashInDrawer * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Cash Count".PadRight(21) + ":" + (Details.CashCount * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                if (Details.CashInDrawer > Details.CashCount)
                {
                    decimal decShort = Details.CashInDrawer - Details.CashCount;
                    msbToPrint.Append("Short".PadRight(21) + ":" + decShort.ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                }
                else if (Details.CashCount > Details.CashInDrawer)
                {
                    decimal decOver = Details.CashCount - Details.CashInDrawer;
                    msbToPrint.Append("Over".PadRight(21) + ":" + decOver.ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                }
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append(CenterString("Misc Amount Breakdown", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append("Consignment".PadRight(21) + ":" + (Details.ConsignmentSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Walk-In".PadRight(21) + ":" + (Details.WalkInSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Out Of Stock".PadRight(21) + ":" + (Details.OutOfStockSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Refund:" + Environment.NewLine);
                msbToPrint.Append("Consignment".PadRight(21) + ":" + (Details.ConsignmentRefundSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Walk-In".PadRight(21) + ":" + (Details.WalkInRefundSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Out Of Stock".PadRight(21) + ":" + (Details.OutOfStockRefundSales * ((100 - TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append(CenterString("Misc Trans Count Breakdown", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append("Consignment Trans".PadRight(21) + ":" + Details.NoOfConsignmentTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Walk-In Trans".PadRight(21) + ":" + Details.NoOfWalkInTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Out Of Stock Trans".PadRight(21) + ":" + Details.NoOfOutOfStockTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Refund:" + Environment.NewLine);
                msbToPrint.Append("Consignment Trans".PadRight(21) + ":" + Details.NoOfConsignmentRefundTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Walk-In Trans".PadRight(21) + ":" + Details.NoOfWalkInRefundTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Out Of Stock Trans".PadRight(21) + ":" + Details.NoOfOutOfStockRefundTransactions.ToString("#,##0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);

                PrintPageAndReportFooterSection(false, DateTime.MinValue);

                mclsTerminalDetails.AutoPrint = oldCONFIG_AutoPrint;

                InsertAuditLog(AccessTypes.PrintCashierReport, "Print cashier report: CashInDrawer=" + Details.CashInDrawer.ToString("#,##0.#0") + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
            }
            catch (Exception ex)
            {
                InsertErrorLogToFile(ex, "ERROR!!! Printing cashier report data. Err Description: ");
            }
            Cursor.Current = Cursors.Default;
        }
        public void PrintGroupReport()
        {
            Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
            mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

            Data.TerminalReportDetails clsTerminalReportDetails = clsTerminalReport.Details(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
            System.Data.DataTable dtGroupReport = clsTerminalReport.GroupReport(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
            clsTerminalReport.CommitAndDispose();

            DialogResult result = DialogResult.OK;

            if (mclsTerminalDetails.PreviewTerminalReport)
            {
                GroupReportWnd clsGroupReportWnd = new GroupReportWnd();
                clsGroupReportWnd.TerminalDetails = mclsTerminalDetails;
                clsGroupReportWnd.CashierName = mCashierName;
                clsGroupReportWnd.dtGroupReport = dtGroupReport;
                clsGroupReportWnd.TerminalReportDetails = clsTerminalReportDetails;
                clsGroupReportWnd.ShowDialog(this);
                result = clsGroupReportWnd.Result;
                clsGroupReportWnd.Close();
                clsGroupReportWnd.Dispose();
            }

            if (result == DialogResult.OK)
            {
                //PrintGroupReportDelegate groupreportDel = new PrintGroupReportDelegate(PrintGroupReport);
                PrintGroupReport(dtGroupReport, clsTerminalReportDetails);
            }
        }
        public void PrintTerminalReport()
        {
            DialogResult loginresult = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.PrintTerminalReport);

            if (loginresult == DialogResult.None)
            {
                LogInWnd login = new LogInWnd();

                login.AccessType = AccessTypes.PrintTerminalReport;
                login.Header = "Print Terminal Report";
                login.TerminalDetails = mclsTerminalDetails;
                login.ShowDialog(this);
                loginresult = login.Result;
                login.Close();
                login.Dispose();
            }

            if (loginresult == DialogResult.OK)
            {
                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

                Data.TerminalReportDetails Details = clsTerminalReport.Details(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
                Details.InitializedBy = mclsSalesTransactionDetails.CashierName;
                clsTerminalReport.CommitAndDispose();
                
                // always set to zero for BIR purposes
                Details.TrustFund = 0;

                DialogResult result = DialogResult.OK;

                if (mclsTerminalDetails.PreviewTerminalReport)
                {
                    TerminalReportWnd clsTerminalReportWnd = new TerminalReportWnd();
                    clsTerminalReportWnd.SysConfigDetails = mclsSysConfigDetails;
                    clsTerminalReportWnd.TerminalDetails = mclsTerminalDetails;
                    clsTerminalReportWnd.Details = Details;
                    clsTerminalReportWnd.CashierName = mCashierName;
                    clsTerminalReportWnd.TerminalReportType = TerminalReportType.TerminalReport;
                    clsTerminalReportWnd.ShowDialog(this);
                    result = clsTerminalReportWnd.Result;
                    clsTerminalReportWnd.Close();
                    clsTerminalReportWnd.Dispose();
                }
                if (result == DialogResult.OK)
                {
                    //PrintTerminalReportDelegate terminalreportDel = new PrintTerminalReportDelegate(PrintTerminalReport);
                    //terminalreportDel.BeginInvoke(Details, null, null);
                    PrintTerminalReport(Details);
                }
            }
        }
        public void PrintXRead()
        {
            mclsTerminalDetails.TrustFund = 0;

            Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
            mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

            clsTerminalReport.UpdateTrustFund(mclsTerminalDetails.BranchID, mclsTerminalDetails.TerminalNo, 0, mclsSalesTransactionDetails.CashierName, Constants.TRUSTFUND_UPDATE_REASON_XREAD);

            Data.TerminalReportDetails Details = clsTerminalReport.Details(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
            Details.InitializedBy = mclsSalesTransactionDetails.CashierName;
            clsTerminalReport.CommitAndDispose();

            DialogResult result = DialogResult.OK;

            if (mclsTerminalDetails.PreviewTerminalReport)
            {
                TerminalReportWnd clsTerminalReportWnd = new TerminalReportWnd();
                clsTerminalReportWnd.SysConfigDetails = mclsSysConfigDetails;
                clsTerminalReportWnd.TerminalDetails = mclsTerminalDetails;
                clsTerminalReportWnd.Details = Details;
                clsTerminalReportWnd.CashierName = mCashierName;
                clsTerminalReportWnd.TerminalReportType = TerminalReportType.XRead;
                clsTerminalReportWnd.ShowDialog(this);
                result = clsTerminalReportWnd.Result;
                clsTerminalReportWnd.Close();
                clsTerminalReportWnd.Dispose();
            }

            if (result == DialogResult.OK)
            {
                //PrintXReadDelegate printxreadDel = new PrintXReadDelegate(PrintXRead);
                PrintXRead(Details);
            }
        }
        public void PrintPageAndReportFooterSection(bool IsReceipt, DateTime OverRidingPrintDate, bool boPrintTermsAndConditions = false)
        {
            //if (mclsTerminalDetails.AutoPrint != PrintingPreference.AskFirst)
            //{
            int iCtr = 0;
            string stModule = "";
            Receipt clsReceipt = new Receipt(mConnection, mTransaction);
            ReceiptDetails clsReceiptDetails;

            if (IsReceipt)
            {
                // print page footer
                for (iCtr = 1; iCtr <= 20; iCtr++)
                {
                    stModule = "PageFooterA" + iCtr;
                    clsReceiptDetails = clsReceipt.Details(stModule);

                    PrintReportValue(clsReceiptDetails, IsReceipt, OverRidingPrintDate);
                }
                // print page footer
                for (iCtr = 1; iCtr <= 5; iCtr++)
                {
                    stModule = "PageFooterB" + iCtr;
                    clsReceiptDetails = clsReceipt.Details(stModule);

                    PrintReportValue(clsReceiptDetails, IsReceipt, OverRidingPrintDate);
                }
            }

            // print report footer
            for (iCtr = 1; iCtr <= 5; iCtr++)
            {
                stModule = "ReportFooter" + iCtr;
                clsReceiptDetails = clsReceipt.Details(stModule);

                PrintReportValue(clsReceiptDetails, IsReceipt, OverRidingPrintDate);
            }

            if (mclsTerminalDetails.IncludeTermsAndConditions & boPrintTermsAndConditions)
                PrintTermsAndConditions();

            // Sep 14, 2014 get the msbToPrint to remove the spacers.
            msbEJournalToPrint = msbToPrint;

            // print report footer Spacer
            clsReceiptDetails = clsReceipt.Details(ReportFormatModule.ReportFooterSpacer);
            for (int i = 0; i < Convert.ToInt32(clsReceiptDetails.Value); i++)
            { msbToPrint.Append(Environment.NewLine); }
            clsReceipt.CommitAndDispose();

            // do the actual print
            if (mclsTerminalDetails.AutoPrint != PrintingPreference.AskFirst)
            {
                this.bgwPOSPrinter.RunWorkerAsync();

                // Wait for the BackgroundWorker to finish the download.
                while (this.bgwPOSPrinter.IsBusy)
                {
                    Application.DoEvents();
                }

                //mclsFilePrinter.Write(msbToPrint);
                //RawPrinterHelper.SendFileToPrinter(mclsTerminalDetails.PrinterName, mclsFilePrinter.FileName, "RetailPlus " + mclsFilePrinter.FileName);
                //mclsFilePrinter.DeleteFile();

                ////print the first part of transaction header if autocutter
                //if (mclsTerminalDetails.IsPrinterAutoCutter)
                //    //cut the paper if printer is auto cutter
                //    CutPrinterPaper(mclsTerminalDetails.PrinterName);
            }

            // Sep 14, 2014 add electronic journal only for all valid transactions with transaction no
            if (mclsSalesTransactionDetails.TransactionID != 0)
            {
                msbEJournalToPrint.Append("-".PadLeft(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                mclsEJournal = new EJournalPrinter();
                if (string.IsNullOrEmpty(mstrBeginningTransactionNo))
                {
                    Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                    mstrBeginningTransactionNo = clsTerminalReport.BeginningTransactionNo(mclsTerminalDetails.BranchID, mclsTerminalDetails.TerminalNo);
                    //mstrBeginningTransactionNo = clsTerminalReport.Details(mclsTerminalDetails.BranchID, mclsTerminalDetails.TerminalNo).BeginningTransactionNo;
                    clsTerminalReport.CommitAndDispose();
                }
                mclsEJournal.FileName = mstrBeginningTransactionNo;
                mclsEJournal.Write(msbEJournalToPrint);
            }
        }
        public void AddToReprintedTransaction(string strTransactionNo, string pstrTerminalNo)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                clsEvent.AddEvent("Adding To no of reprinted transaction : " + strTransactionNo);

                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

                clsTerminalReport.UpdateReprintedTransaction(mclsTerminalDetails.BranchID, pstrTerminalNo, strTransactionNo);

                clsTerminalReport.CommitAndDispose();

                clsEvent.AddEventLn("Done");
            }
            catch (Exception ex)
            {
                InsertErrorLogToFile(ex, "ERROR!!! adding to reprinted transaction. TRACE: ");
            }
            Cursor.Current = Cursors.Default;
        }
Exemple #14
0
        private string CreateHourlySales(Int32 BranchID, string TerminalNo, DateTime ProcessDate, Data.TerminalReportDetails TerminalReportDetails)
        {
            string strRetValue = "";

            DateTime dteDateFrom = ProcessDate;

            Data.TerminalReportHistory clsTerminalReportHistory = new Data.TerminalReportHistory();
            DateTime dteDateTo = DateTime.MinValue;
            try
            {
                dteDateTo = clsTerminalReportHistory.NEXTDateLastInitialized(BranchID, TerminalNo, ProcessDate);
            }
            catch { }

            if (dteDateTo == DateTime.MinValue)
            {
                Event clsEvent = new Event();
                clsEvent.AddEventLn("HourlySales: Did not found MAXDateLastInitialized from Terminal Report History. Using the MAXDateLastInitialized from terminal report", true);
                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(clsTerminalReportHistory.Connection, clsTerminalReportHistory.Transaction);
                dteDateTo = clsTerminalReport.MAXDateLastInitialized(BranchID, TerminalNo, ProcessDate);
            }

            System.Data.DataTable dtHourlyReport = clsTerminalReportHistory.HourlyReport(BranchID, TerminalNo, dteDateFrom, dteDateTo);
            clsTerminalReportHistory.CommitAndDispose();

            string stHourlyTableName = mclsFSIDetails.OutputDirectory + "\\H" + mclsFSIDetails.TenantName.Substring(0, 4) + TerminalReportDetails.TerminalNo + TerminalReportDetails.BatchCounter.ToString() + "." + TerminalReportDetails.DateLastInitializedToDisplay.ToString("MM").Replace("10", "A").Replace("11", "B").Replace("12", "C").Replace("0", "") + TerminalReportDetails.DateLastInitializedToDisplay.ToString("dd");
            if (File.Exists(stHourlyTableName)) File.Delete(stHourlyTableName);

            writer = File.AppendText(stHourlyTableName);
            writer.WriteLine("01{0}", mclsFSIDetails.TenantCode);
            writer.WriteLine("02{0}", TerminalNo);

            DateTime dtePreviousTransactionDate = DateTime.MinValue;
            foreach (System.Data.DataRow dr in dtHourlyReport.Rows)
            {
                if (dtePreviousTransactionDate != Convert.ToDateTime(dr["TransactionDate"]))
                {
                    writer.WriteLine("03{0}", Convert.ToDateTime(dr["TransactionDate"]).ToString("MMddyyyy"));
                    dtePreviousTransactionDate = Convert.ToDateTime(dr["TransactionDate"]);
                }
                writer.WriteLine("04{0}", dr["Time"].ToString().Substring(0,2));
                writer.WriteLine("05{0}", Convert.ToDecimal(Convert.ToDecimal(dr["Amount"]) - Convert.ToDecimal(dr["VAT"])).ToString("####.#0").Replace(".", ""));
                writer.WriteLine("06{0}", Convert.ToInt64(dr["TranCount"]).ToString("####"));
            }
            writer.WriteLine("07{0}", TerminalReportDetails.DailySales.ToString("####.#0").Replace(".", ""));
            writer.WriteLine("08{0}", TerminalReportDetails.NoOfClosedTransactions.ToString("####"));

            writer.Flush();
            writer.Close();

            strRetValue = stHourlyTableName;

            return strRetValue;
        }
        private void PopulateCashiersReport()
        {
            Receipt clsReceipt = new Receipt();
            clsReceipt.GetConnection();

            Data.TerminalReportDetails clsTerminalReportDetails = new Data.TerminalReport(clsReceipt.Connection, clsReceipt.Transaction).Details(mclsDetails.BranchID, mclsDetails.TerminalNo);

            mclsTerminalDetails.MaxReceiptWidth = 94;

            System.Data.DataTable dt = new System.Data.DataTable("tblTerminalReport");
            dt.Columns.Add("Module");
            dt.Columns.Add("Separator");
            dt.Columns.Add("Value");
            //dt.Rows.Add(CenterString(CompanyDetails.CompanyCode, mclsTerminalDetails.MaxReceiptWidth));
            //dt.Rows.Add("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-'));
            //dt.Rows.Add(CenterString("Terminal Report", mclsTerminalDetails.MaxReceiptWidth));
            //dt.Rows.Add("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-'));

            //string strReportHeader1 = clsReceipt.Details("ReportHeader1").Value;
            //string strReportHeader2 = clsReceipt.Details("ReportHeader2").Value;
            //string strReportHeader3 = clsReceipt.Details("ReportHeader3").Value;
            //string strReportHeader4 = clsReceipt.Details("ReportHeader4").Value;
            //if (!string.IsNullOrEmpty(strReportHeader1)) dt.Rows.Add(CenterString(GetReceiptFormatParameter(strReportHeader1), mclsTerminalDetails.MaxReceiptWidth));
            //if (!string.IsNullOrEmpty(strReportHeader2)) dt.Rows.Add(CenterString(GetReceiptFormatParameter(strReportHeader2), mclsTerminalDetails.MaxReceiptWidth));
            //if (!string.IsNullOrEmpty(strReportHeader3)) dt.Rows.Add(CenterString(GetReceiptFormatParameter(strReportHeader3), mclsTerminalDetails.MaxReceiptWidth));
            //if (!string.IsNullOrEmpty(strReportHeader4)) dt.Rows.Add(CenterString(GetReceiptFormatParameter(strReportHeader4), mclsTerminalDetails.MaxReceiptWidth));

            dt.Rows.Add("Gross Sales", ":", (mclsDetails.GrossSales + mclsDetails.TotalCharge).ToString("#,##0.#0"));
            dt.Rows.Add("(-) Service Charge", ":", mclsDetails.TotalCharge.ToString("#,##0.#0"));
            dt.Rows.Add("", ":", "------------".PadLeft(mclsTerminalDetails.MaxReceiptWidth - 66, '-'));
            dt.Rows.Add("Total Amount", ":", mclsDetails.GrossSales.ToString("#,##0.#0"));
            dt.Rows.Add("(-) " + mclsTerminalDetails.VAT.ToString("##") + "% VAT Exempt ", ":", (mclsDetails.VATExempt * (mclsTerminalDetails.VAT / 100)).ToString("#,##0.#0"));
            dt.Rows.Add("(-) Subtotal Discount", ":", mclsDetails.SubTotalDiscount.ToString("#,##0.#0"));
            dt.Rows.Add("", ":", "------------".PadLeft(mclsTerminalDetails.MaxReceiptWidth - 66, '-'));
            dt.Rows.Add("Net Sales", ":", mclsDetails.NetSales.ToString("#,##0.#0"));

            dt.Rows.Add("Taxables Breakdown", "", "");
            dt.Rows.Add("VAT Exempt", ":", mclsDetails.VATExempt.ToString("#,##0.00"));
            dt.Rows.Add("VAT Zero Rated", ":", mclsDetails.ZeroRatedSales.ToString("#,##0.00"));
            dt.Rows.Add("NonVATable Amount", ":", mclsDetails.NonVATableAmount.ToString("#,##0.00"));
            dt.Rows.Add("VATable Amount", ":", mclsDetails.VATableAmount.ToString("#,##0.00"));
            dt.Rows.Add(mclsTerminalDetails.VAT.ToString("##") + "% VAT", ":", mclsDetails.VAT.ToString("#,##0.00"));
            dt.Rows.Add("Local Tax", ":", mclsDetails.LocalTax.ToString("#,##0.00"));

            dt.Rows.Add("Total Amount Breakdown", "", "");
            dt.Rows.Add("Cash Sales", ":", mclsDetails.CashSales.ToString("#,##0.00"));
            dt.Rows.Add("Cheque Sales", ":", mclsDetails.ChequeSales.ToString("#,##0.00"));
            dt.Rows.Add("Credit Card Sales", ":", mclsDetails.CreditCardSales.ToString("#,##0.00"));
            dt.Rows.Add("Credit (Charge)", ":", mclsDetails.CreditSales.ToString("#,##0.00"));
            dt.Rows.Add("Credit Payment", ":", mclsDetails.CreditPayment.ToString("#,##0.00"));
            dt.Rows.Add("      Cash", ":", mclsDetails.CreditPaymentCash.ToString("#,##0.00"));
            dt.Rows.Add("      Cheque", ":", mclsDetails.CreditPaymentCheque.ToString("#,##0.00"));
            dt.Rows.Add("      Credit Card", ":", mclsDetails.CreditPaymentCreditCard.ToString("#,##0.00"));
            dt.Rows.Add("      Debit", ":", mclsDetails.CreditPaymentDebit.ToString("#,##0.00"));
            dt.Rows.Add("Debit Sales", ":", mclsDetails.DebitPayment.ToString("#,##0.00"));
            dt.Rows.Add("     Rewards Points Redeemed", ":", mclsDetails.RewardPointsPayment.ToString("#,##0.00"));
            dt.Rows.Add("Employee Acct.", ":", "0.00");
            dt.Rows.Add("Void Sales", ":", mclsDetails.VoidSales.ToString("#,##0.00"));
            dt.Rows.Add("Refund Sales", ":", mclsDetails.RefundSales.ToString("#,##0.00"));
            dt.Rows.Add("      Cash", ":", mclsDetails.RefundCash.ToString("#,##0.00"));
            dt.Rows.Add("      Cheque", ":", mclsDetails.RefundCheque.ToString("#,##0.00"));
            dt.Rows.Add("      Credit Card", ":", mclsDetails.RefundCreditCard.ToString("#,##0.00"));
            dt.Rows.Add("      Credit", ":", mclsDetails.RefundCredit.ToString("#,##0.00"));
            dt.Rows.Add("      Debit", ":", mclsDetails.RefundDebit.ToString("#,##0.00"));

            Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(clsReceipt.Connection, clsReceipt.Transaction);
            // CashierID = 0 ALL

            Data.TerminalReport clsTerminalReport = new Data.TerminalReport(clsReceipt.Connection, clsReceipt.Transaction);
            System.Data.DataTable dtCreditCards = clsSalesTransactions.SalesPerCreditCard(mclsDetails.BranchID, mclsDetails.TerminalNo, mclsDetails.CashierID, clsTerminalReportDetails.DateLastInitialized, clsTerminalReportDetails.NEXTDateLastInitialized);

            if (dtCreditCards.Rows.Count > 0)
            {
                dt.Rows.Add("-", "-", "-");
                dt.Rows.Add("Credit Card Breakdown", "", "");
                dt.Rows.Add("-", "-", "-");
                foreach (System.Data.DataRow dr in dtCreditCards.Rows)
                {
                    dt.Rows.Add(dr["CardTypeCode"].ToString(), ":", decimal.Parse(dr["Amount"].ToString()).ToString("#,##0.00"));
                }
            }

            dt.Rows.Add("Discounts", "", "");
            dt.Rows.Add("Items Discount", ":", mclsDetails.ItemsDiscount.ToString("#,##0.00"));
            dt.Rows.Add("Subtotal Discount", ":", mclsDetails.SubTotalDiscount.ToString("#,##0.00"));
            dt.Rows.Add("     Senior Citizen", ":", mclsDetails.SNRDiscount.ToString("#,##0.00"));
            dt.Rows.Add("     PWD", ":", mclsDetails.PWDDiscount.ToString("#,##0.00"));
            dt.Rows.Add("     Others", ":", mclsDetails.OtherDiscount.ToString("#,##0.00"));
            dt.Rows.Add("Total Discounts", ":", mclsDetails.TotalDiscount.ToString("#,##0.00"));

            clsSalesTransactions = new Data.SalesTransactions(clsReceipt.Connection, clsReceipt.Transaction);

            System.Data.DataTable dtDiscounts = clsSalesTransactions.Discounts(mclsDetails.BranchID, mclsDetails.TerminalNo, clsTerminalReportDetails.BeginningTransactionNo, clsTerminalReportDetails.EndingTransactionNo);
            if (dtDiscounts.Rows.Count > 0)
            {
                dt.Rows.Add("-", "-", "-");
                dt.Rows.Add("Subtotal Discounts Breakdown", "", "");
                dt.Rows.Add("-", "-", "-");
                foreach (System.Data.DataRow dr in dtDiscounts.Rows)
                {
                    dt.Rows.Add(dr["DiscountCode"].ToString(), ":", decimal.Parse(dr["Discount"].ToString()).ToString("#,##0.00"));
                }
            }

            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Drawer Information", "", "");
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Beginning Balance", ":", mclsDetails.BeginningBalance.ToString("#,##0.00"));
            dt.Rows.Add("Cash In Drawer", ":", mclsDetails.CashInDrawer.ToString("#,##0.00"));
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Paid Out", "", "");
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Paid Out", ":", mclsDetails.TotalPaidOut.ToString("#,##0.00"));
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("PICK UP / Disburstment", "", "");
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Cash", ":", mclsDetails.CashDisburse.ToString("#,##0.00"));
            dt.Rows.Add("Cheque", ":", mclsDetails.ChequeDisburse.ToString("#,##0.00"));
            dt.Rows.Add("Credit Card", ":", mclsDetails.CreditCardDisburse.ToString("#,##0.00"));
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Receive on Account", "", "");
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Cash", ":", mclsDetails.CashWithHold.ToString("#,##0.00"));
            dt.Rows.Add("Cheque", ":", mclsDetails.ChequeWithHold.ToString("#,##0.00"));
            dt.Rows.Add("Credit Card", ":", mclsDetails.CreditCardWithHold.ToString("#,##0.00"));
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Customer Deposits", "", "");
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Cash", ":", mclsDetails.CashDeposit.ToString("#,##0.00"));
            dt.Rows.Add("Cheque", ":", mclsDetails.ChequeDeposit.ToString("#,##0.00"));
            dt.Rows.Add("Credit Card", ":", mclsDetails.CreditCardDeposit.ToString("#,##0.00"));
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Transaction Count Breakdown", "", "");
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Cash Transactions", ":", mclsDetails.NoOfCashTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Cheque Transactions", ":", mclsDetails.NoOfChequeTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Credit Card Transactions", ":", mclsDetails.NoOfCreditCardTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Credit Transactions", ":", mclsDetails.NoOfCreditTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Debit Transactions", ":", mclsDetails.NoOfDebitPaymentTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Refund Transactions", ":", mclsDetails.NoOfRefundTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Void Transactions", ":", mclsDetails.NoOfVoidTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Combination Trans", ":", mclsDetails.NoOfCombinationPaymentTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Credit Payment Trans", ":", mclsDetails.NoOfCreditPaymentTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Reward Points Trans", ":", mclsDetails.NoOfRewardPointsPayment.ToString("#,##0.00"));

            dt.Rows.Add("", ":", "------------".PadLeft(mclsTerminalDetails.MaxReceiptWidth - 66, '-'));
            dt.Rows.Add("Total Transactions", ":", mclsDetails.NoOfTotalTransactions.ToString("#,##0.00"));

            dt.Rows.Add("Misc Amount Breakdown", "", "");
            dt.Rows.Add("    Consignment", ":", mclsDetails.ConsignmentSales.ToString("#,##0.00"));
            dt.Rows.Add("    Walk-In", ":", mclsDetails.WalkInSales.ToString("#,##0.00"));
            dt.Rows.Add("    Out Of Stock", ":", mclsDetails.OutOfStockSales.ToString("#,##0.00"));
            dt.Rows.Add("Refund - Misc Amount Breakdown", "", "");
            dt.Rows.Add("    Consignment", ":", mclsDetails.ConsignmentRefundSales.ToString("#,##0.00"));
            dt.Rows.Add("    Walk-In", ":", mclsDetails.WalkInRefundSales.ToString("#,##0.00"));
            dt.Rows.Add("    Out Of Stock", ":", mclsDetails.OutOfStockRefundSales.ToString("#,##0.00"));
            dt.Rows.Add("Misc Trans Breakdown", "", "");
            dt.Rows.Add("    Consignment Trans", ":", mclsDetails.NoOfConsignmentTransactions.ToString("#,##0.00"));
            dt.Rows.Add("    Walk-In Trans", ":", mclsDetails.NoOfWalkInTransactions.ToString("#,##0.00"));
            dt.Rows.Add("    Out Of Stock Trans", ":", mclsDetails.NoOfOutOfStockTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Refund - Misc Trans Breakdown", "", "");
            dt.Rows.Add("    Consignment Trans", ":", mclsDetails.NoOfConsignmentRefundTransactions.ToString("#,##0.00"));
            dt.Rows.Add("    Walk-In Trans", ":", mclsDetails.NoOfWalkInRefundTransactions.ToString("#,##0.00"));
            dt.Rows.Add("    Out Of Stock Trans", ":", mclsDetails.NoOfOutOfStockRefundTransactions.ToString("#,##0.00"));

            string strReportFooter1 = clsReceipt.Details("ReportFooter1").Value;
            string strReportFooter2 = clsReceipt.Details("ReportFooter2").Value;
            string strReportFooter3 = clsReceipt.Details("ReportFooter3").Value;
            if (!string.IsNullOrEmpty(strReportFooter1)) dt.Rows.Add(CenterString(GetReceiptFormatParameter(strReportFooter1), mclsTerminalDetails.MaxReceiptWidth));
            if (!string.IsNullOrEmpty(strReportFooter2)) dt.Rows.Add(CenterString(GetReceiptFormatParameter(strReportFooter2), mclsTerminalDetails.MaxReceiptWidth));
            if (!string.IsNullOrEmpty(strReportFooter3)) dt.Rows.Add(CenterString(GetReceiptFormatParameter(strReportFooter3), mclsTerminalDetails.MaxReceiptWidth));

            clsReceipt.CommitAndDispose();

            dgvItems.MultiSelect = true;
            dgvItems.AutoGenerateColumns = true;
            dgvItems.AutoSize = true;
            dgvItems.ScrollBars = ScrollBars.Vertical;
            dgvItems.DataSource = dt.TableName;
            dgvItems.DataSource = dt;

            //dgvItems.Columns["ReportValue"].Visible = true;
            //dgvItems.Columns["ReportValue"].HeaderText = "";
            //dgvItems.Columns["ReportValue"].Width = 388;

            dgvItems.Columns["Module"].Visible = true;
            dgvItems.Columns["Separator"].Visible = true;
            dgvItems.Columns["Value"].Visible = true;

            dgvItems.Columns["Module"].HeaderText = "";
            dgvItems.Columns["Separator"].HeaderText = "";
            dgvItems.Columns["Value"].HeaderText = "";

            dgvItems.Columns["Module"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            dgvItems.Columns["Separator"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvItems.Columns["Value"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

            dgvItems.Columns["Module"].Width = 230;
            dgvItems.Columns["Separator"].Width = 20;
            dgvItems.Columns["Value"].Width = dgvItems.Width-250-20;

        }
Exemple #16
0
        private void PopulateCashiersReport()
        {
            Receipt clsReceipt = new Receipt();

            clsReceipt.GetConnection();

            Data.TerminalReportDetails clsTerminalReportDetails = new Data.TerminalReport(clsReceipt.Connection, clsReceipt.Transaction).Details(mclsDetails.BranchID, mclsDetails.TerminalNo);

            mclsTerminalDetails.MaxReceiptWidth = 94;

            System.Data.DataTable dt = new System.Data.DataTable("tblTerminalReport");
            dt.Columns.Add("Module");
            dt.Columns.Add("Separator");
            dt.Columns.Add("Value");
            //dt.Rows.Add(CenterString(CompanyDetails.CompanyCode, mclsTerminalDetails.MaxReceiptWidth));
            //dt.Rows.Add("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-'));
            //dt.Rows.Add(CenterString("Terminal Report", mclsTerminalDetails.MaxReceiptWidth));
            //dt.Rows.Add("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-'));

            //string strReportHeader1 = clsReceipt.Details("ReportHeader1").Value;
            //string strReportHeader2 = clsReceipt.Details("ReportHeader2").Value;
            //string strReportHeader3 = clsReceipt.Details("ReportHeader3").Value;
            //string strReportHeader4 = clsReceipt.Details("ReportHeader4").Value;
            //if (!string.IsNullOrEmpty(strReportHeader1)) dt.Rows.Add(CenterString(GetReceiptFormatParameter(strReportHeader1), mclsTerminalDetails.MaxReceiptWidth));
            //if (!string.IsNullOrEmpty(strReportHeader2)) dt.Rows.Add(CenterString(GetReceiptFormatParameter(strReportHeader2), mclsTerminalDetails.MaxReceiptWidth));
            //if (!string.IsNullOrEmpty(strReportHeader3)) dt.Rows.Add(CenterString(GetReceiptFormatParameter(strReportHeader3), mclsTerminalDetails.MaxReceiptWidth));
            //if (!string.IsNullOrEmpty(strReportHeader4)) dt.Rows.Add(CenterString(GetReceiptFormatParameter(strReportHeader4), mclsTerminalDetails.MaxReceiptWidth));

            dt.Rows.Add("Gross Sales", ":", (mclsDetails.GrossSales + mclsDetails.TotalCharge).ToString("#,##0.#0"));
            dt.Rows.Add("(-) Service Charge", ":", mclsDetails.TotalCharge.ToString("#,##0.#0"));
            dt.Rows.Add("", ":", "------------".PadLeft(mclsTerminalDetails.MaxReceiptWidth - 66, '-'));
            dt.Rows.Add("Total Amount", ":", mclsDetails.GrossSales.ToString("#,##0.#0"));
            dt.Rows.Add("(-) " + mclsTerminalDetails.VAT.ToString("##") + "% VAT Exempt ", ":", (mclsDetails.VATExempt * (mclsTerminalDetails.VAT / 100)).ToString("#,##0.#0"));
            dt.Rows.Add("(-) Subtotal Discount", ":", mclsDetails.SubTotalDiscount.ToString("#,##0.#0"));
            dt.Rows.Add("", ":", "------------".PadLeft(mclsTerminalDetails.MaxReceiptWidth - 66, '-'));
            dt.Rows.Add("Net Sales", ":", mclsDetails.NetSales.ToString("#,##0.#0"));

            dt.Rows.Add("Taxables Breakdown", "", "");
            dt.Rows.Add("VAT Exempt", ":", mclsDetails.VATExempt.ToString("#,##0.00"));
            dt.Rows.Add("VAT Zero Rated", ":", mclsDetails.ZeroRatedSales.ToString("#,##0.00"));
            dt.Rows.Add("NonVATable Amount", ":", mclsDetails.NonVATableAmount.ToString("#,##0.00"));
            dt.Rows.Add("VATable Amount", ":", mclsDetails.VATableAmount.ToString("#,##0.00"));
            dt.Rows.Add(mclsTerminalDetails.VAT.ToString("##") + "% VAT", ":", mclsDetails.VAT.ToString("#,##0.00"));
            dt.Rows.Add("Local Tax", ":", mclsDetails.LocalTax.ToString("#,##0.00"));

            dt.Rows.Add("Total Amount Breakdown", "", "");
            dt.Rows.Add("Cash Sales", ":", mclsDetails.CashSales.ToString("#,##0.00"));
            dt.Rows.Add("Cheque Sales", ":", mclsDetails.ChequeSales.ToString("#,##0.00"));
            dt.Rows.Add("Credit Card Sales", ":", mclsDetails.CreditCardSales.ToString("#,##0.00"));
            dt.Rows.Add("Credit (Charge)", ":", mclsDetails.CreditSales.ToString("#,##0.00"));
            dt.Rows.Add("Credit Payment", ":", mclsDetails.CreditPayment.ToString("#,##0.00"));
            dt.Rows.Add("      Cash", ":", mclsDetails.CreditPaymentCash.ToString("#,##0.00"));
            dt.Rows.Add("      Cheque", ":", mclsDetails.CreditPaymentCheque.ToString("#,##0.00"));
            dt.Rows.Add("      Credit Card", ":", mclsDetails.CreditPaymentCreditCard.ToString("#,##0.00"));
            dt.Rows.Add("      Debit", ":", mclsDetails.CreditPaymentDebit.ToString("#,##0.00"));
            dt.Rows.Add("Debit Sales", ":", mclsDetails.DebitPayment.ToString("#,##0.00"));
            dt.Rows.Add("     Rewards Points Redeemed", ":", mclsDetails.RewardPointsPayment.ToString("#,##0.00"));
            dt.Rows.Add("Employee Acct.", ":", "0.00");
            dt.Rows.Add("Void Sales", ":", mclsDetails.VoidSales.ToString("#,##0.00"));
            dt.Rows.Add("Refund Sales", ":", mclsDetails.RefundSales.ToString("#,##0.00"));
            dt.Rows.Add("      Cash", ":", mclsDetails.RefundCash.ToString("#,##0.00"));
            dt.Rows.Add("      Cheque", ":", mclsDetails.RefundCheque.ToString("#,##0.00"));
            dt.Rows.Add("      Credit Card", ":", mclsDetails.RefundCreditCard.ToString("#,##0.00"));
            dt.Rows.Add("      Credit", ":", mclsDetails.RefundCredit.ToString("#,##0.00"));
            dt.Rows.Add("      Debit", ":", mclsDetails.RefundDebit.ToString("#,##0.00"));

            Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(clsReceipt.Connection, clsReceipt.Transaction);
            // CashierID = 0 ALL

            Data.TerminalReport   clsTerminalReport = new Data.TerminalReport(clsReceipt.Connection, clsReceipt.Transaction);
            System.Data.DataTable dtCreditCards     = clsSalesTransactions.SalesPerCreditCard(mclsDetails.BranchID, mclsDetails.TerminalNo, mclsDetails.CashierID, clsTerminalReportDetails.DateLastInitialized, clsTerminalReportDetails.NEXTDateLastInitialized);

            if (dtCreditCards.Rows.Count > 0)
            {
                dt.Rows.Add("-", "-", "-");
                dt.Rows.Add("Credit Card Breakdown", "", "");
                dt.Rows.Add("-", "-", "-");
                foreach (System.Data.DataRow dr in dtCreditCards.Rows)
                {
                    dt.Rows.Add(dr["CardTypeCode"].ToString(), ":", decimal.Parse(dr["Amount"].ToString()).ToString("#,##0.00"));
                }
            }

            dt.Rows.Add("Discounts", "", "");
            dt.Rows.Add("Items Discount", ":", mclsDetails.ItemsDiscount.ToString("#,##0.00"));
            dt.Rows.Add("Subtotal Discount", ":", mclsDetails.SubTotalDiscount.ToString("#,##0.00"));
            dt.Rows.Add("     Senior Citizen", ":", mclsDetails.SNRDiscount.ToString("#,##0.00"));
            dt.Rows.Add("     PWD", ":", mclsDetails.PWDDiscount.ToString("#,##0.00"));
            dt.Rows.Add("     Others", ":", mclsDetails.OtherDiscount.ToString("#,##0.00"));
            dt.Rows.Add("Total Discounts", ":", mclsDetails.TotalDiscount.ToString("#,##0.00"));

            clsSalesTransactions = new Data.SalesTransactions(clsReceipt.Connection, clsReceipt.Transaction);

            System.Data.DataTable dtDiscounts = clsSalesTransactions.Discounts(mclsDetails.BranchID, mclsDetails.TerminalNo, clsTerminalReportDetails.BeginningTransactionNo, clsTerminalReportDetails.EndingTransactionNo);
            if (dtDiscounts.Rows.Count > 0)
            {
                dt.Rows.Add("-", "-", "-");
                dt.Rows.Add("Subtotal Discounts Breakdown", "", "");
                dt.Rows.Add("-", "-", "-");
                foreach (System.Data.DataRow dr in dtDiscounts.Rows)
                {
                    dt.Rows.Add(dr["DiscountCode"].ToString(), ":", decimal.Parse(dr["Discount"].ToString()).ToString("#,##0.00"));
                }
            }

            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Drawer Information", "", "");
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Beginning Balance", ":", mclsDetails.BeginningBalance.ToString("#,##0.00"));
            dt.Rows.Add("Cash In Drawer", ":", mclsDetails.CashInDrawer.ToString("#,##0.00"));
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Paid Out", "", "");
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Paid Out", ":", mclsDetails.TotalPaidOut.ToString("#,##0.00"));
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("PICK UP / Disburstment", "", "");
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Cash", ":", mclsDetails.CashDisburse.ToString("#,##0.00"));
            dt.Rows.Add("Cheque", ":", mclsDetails.ChequeDisburse.ToString("#,##0.00"));
            dt.Rows.Add("Credit Card", ":", mclsDetails.CreditCardDisburse.ToString("#,##0.00"));
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Receive on Account", "", "");
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Cash", ":", mclsDetails.CashWithHold.ToString("#,##0.00"));
            dt.Rows.Add("Cheque", ":", mclsDetails.ChequeWithHold.ToString("#,##0.00"));
            dt.Rows.Add("Credit Card", ":", mclsDetails.CreditCardWithHold.ToString("#,##0.00"));
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Customer Deposits", "", "");
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Cash", ":", mclsDetails.CashDeposit.ToString("#,##0.00"));
            dt.Rows.Add("Cheque", ":", mclsDetails.ChequeDeposit.ToString("#,##0.00"));
            dt.Rows.Add("Credit Card", ":", mclsDetails.CreditCardDeposit.ToString("#,##0.00"));
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Transaction Count Breakdown", "", "");
            dt.Rows.Add("-", "-", "-");
            dt.Rows.Add("Cash Transactions", ":", mclsDetails.NoOfCashTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Cheque Transactions", ":", mclsDetails.NoOfChequeTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Credit Card Transactions", ":", mclsDetails.NoOfCreditCardTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Credit Transactions", ":", mclsDetails.NoOfCreditTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Debit Transactions", ":", mclsDetails.NoOfDebitPaymentTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Refund Transactions", ":", mclsDetails.NoOfRefundTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Void Transactions", ":", mclsDetails.NoOfVoidTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Combination Trans", ":", mclsDetails.NoOfCombinationPaymentTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Credit Payment Trans", ":", mclsDetails.NoOfCreditPaymentTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Reward Points Trans", ":", mclsDetails.NoOfRewardPointsPayment.ToString("#,##0.00"));

            dt.Rows.Add("", ":", "------------".PadLeft(mclsTerminalDetails.MaxReceiptWidth - 66, '-'));
            dt.Rows.Add("Total Transactions", ":", mclsDetails.NoOfTotalTransactions.ToString("#,##0.00"));

            dt.Rows.Add("Misc Amount Breakdown", "", "");
            dt.Rows.Add("    Consignment", ":", mclsDetails.ConsignmentSales.ToString("#,##0.00"));
            dt.Rows.Add("    Walk-In", ":", mclsDetails.WalkInSales.ToString("#,##0.00"));
            dt.Rows.Add("    Out Of Stock", ":", mclsDetails.OutOfStockSales.ToString("#,##0.00"));
            dt.Rows.Add("Refund - Misc Amount Breakdown", "", "");
            dt.Rows.Add("    Consignment", ":", mclsDetails.ConsignmentRefundSales.ToString("#,##0.00"));
            dt.Rows.Add("    Walk-In", ":", mclsDetails.WalkInRefundSales.ToString("#,##0.00"));
            dt.Rows.Add("    Out Of Stock", ":", mclsDetails.OutOfStockRefundSales.ToString("#,##0.00"));
            dt.Rows.Add("Misc Trans Breakdown", "", "");
            dt.Rows.Add("    Consignment Trans", ":", mclsDetails.NoOfConsignmentTransactions.ToString("#,##0.00"));
            dt.Rows.Add("    Walk-In Trans", ":", mclsDetails.NoOfWalkInTransactions.ToString("#,##0.00"));
            dt.Rows.Add("    Out Of Stock Trans", ":", mclsDetails.NoOfOutOfStockTransactions.ToString("#,##0.00"));
            dt.Rows.Add("Refund - Misc Trans Breakdown", "", "");
            dt.Rows.Add("    Consignment Trans", ":", mclsDetails.NoOfConsignmentRefundTransactions.ToString("#,##0.00"));
            dt.Rows.Add("    Walk-In Trans", ":", mclsDetails.NoOfWalkInRefundTransactions.ToString("#,##0.00"));
            dt.Rows.Add("    Out Of Stock Trans", ":", mclsDetails.NoOfOutOfStockRefundTransactions.ToString("#,##0.00"));

            string strReportFooter1 = clsReceipt.Details("ReportFooter1").Value;
            string strReportFooter2 = clsReceipt.Details("ReportFooter2").Value;
            string strReportFooter3 = clsReceipt.Details("ReportFooter3").Value;

            if (!string.IsNullOrEmpty(strReportFooter1))
            {
                dt.Rows.Add(CenterString(GetReceiptFormatParameter(strReportFooter1), mclsTerminalDetails.MaxReceiptWidth));
            }
            if (!string.IsNullOrEmpty(strReportFooter2))
            {
                dt.Rows.Add(CenterString(GetReceiptFormatParameter(strReportFooter2), mclsTerminalDetails.MaxReceiptWidth));
            }
            if (!string.IsNullOrEmpty(strReportFooter3))
            {
                dt.Rows.Add(CenterString(GetReceiptFormatParameter(strReportFooter3), mclsTerminalDetails.MaxReceiptWidth));
            }

            clsReceipt.CommitAndDispose();

            dgvItems.MultiSelect         = true;
            dgvItems.AutoGenerateColumns = true;
            dgvItems.AutoSize            = true;
            dgvItems.ScrollBars          = ScrollBars.Vertical;
            dgvItems.DataSource          = dt.TableName;
            dgvItems.DataSource          = dt;

            //dgvItems.Columns["ReportValue"].Visible = true;
            //dgvItems.Columns["ReportValue"].HeaderText = "";
            //dgvItems.Columns["ReportValue"].Width = 388;

            dgvItems.Columns["Module"].Visible    = true;
            dgvItems.Columns["Separator"].Visible = true;
            dgvItems.Columns["Value"].Visible     = true;

            dgvItems.Columns["Module"].HeaderText    = "";
            dgvItems.Columns["Separator"].HeaderText = "";
            dgvItems.Columns["Value"].HeaderText     = "";

            dgvItems.Columns["Module"].DefaultCellStyle.Alignment    = DataGridViewContentAlignment.MiddleLeft;
            dgvItems.Columns["Separator"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvItems.Columns["Value"].DefaultCellStyle.Alignment     = DataGridViewContentAlignment.MiddleRight;

            dgvItems.Columns["Module"].Width    = 230;
            dgvItems.Columns["Separator"].Width = 20;
            dgvItems.Columns["Value"].Width     = dgvItems.Width - 250 - 20;
        }
Exemple #17
0
        private bool CreateTransaction()
        {
            Boolean boRetValue = true;
            try
            {
                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

                DateTime dteTransactionDate = Convert.ToDateTime(lblTransDate.Text);

                boRetValue = CheckIfOKToSell(false);

                if (!boRetValue) return boRetValue;

                // Feb 16, 2015
                if (mclsTerminalDetails.WithRestaurantFeatures)
                {
                    if (mclsContactDetails.ContactID == Constants.ZERO ||
                        mclsContactDetails.ContactID == Constants.C_RETAILPLUS_CUSTOMERID)
                    {
                        MessageBox.Show("Sorry you must select a table / customer to order before punching an item.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return false;
                    }
                }

                clsEvent.AddEventLn("[" + lblCashier.Text + "] Creating new transaction.", true);

                mclsSalesTransactionDetails = new Data.SalesTransactionDetails();
                mclsSalesTransactionDetails.TransactionItemsList = new System.Collections.Generic.List<Data.SalesTransactionItemDetails>();
                try { mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag); }
                catch { }

                //mclsSalesTransactionDetails.CustomerID = Convert.ToInt64(lblCustomer.Tag);
                //mclsSalesTransactionDetails.CustomerName = lblCustomer.Text;

                if (mboRewardCardSwiped)
                {
                    mclsSalesTransactionDetails.RewardsCustomerID = mclsContactDetails.ContactID;
                    mclsSalesTransactionDetails.RewardsCustomerName = mclsContactDetails.ContactName;
                    mclsSalesTransactionDetails.RewardCardActive = mclsContactDetails.RewardDetails.RewardActive;
                    mclsSalesTransactionDetails.RewardCardNo = mclsContactDetails.RewardDetails.RewardCardNo;
                    mclsSalesTransactionDetails.RewardCardExpiry = mclsContactDetails.RewardDetails.ExpiryDate;
                    mclsSalesTransactionDetails.RewardPreviousPoints = mclsContactDetails.RewardDetails.RewardPoints;
                }
                else
                {
                    mclsSalesTransactionDetails.RewardsCustomerID = Constants.C_RETAILPLUS_CUSTOMERID;
                    mclsSalesTransactionDetails.RewardsCustomerName = Constants.C_RETAILPLUS_CUSTOMER;
                    mclsSalesTransactionDetails.RewardCardActive = mclsContactDetailsDEFCustomer.RewardDetails.RewardActive;
                    mclsSalesTransactionDetails.RewardCardNo = mclsContactDetailsDEFCustomer.RewardDetails.RewardCardNo;
                    mclsSalesTransactionDetails.RewardCardExpiry = mclsContactDetailsDEFCustomer.RewardDetails.ExpiryDate;
                    mclsSalesTransactionDetails.RewardPreviousPoints = mclsContactDetailsDEFCustomer.RewardDetails.RewardPoints;
                }
                mclsSalesTransactionDetails.CustomerDetails = mclsContactDetails;
                mclsSalesTransactionDetails.CustomerID = mclsContactDetails.ContactID;
                mclsSalesTransactionDetails.CustomerName = mclsContactDetails.ContactName;
                if (mclsSalesTransactionDetails.CustomerDetails.LastCheckInDate == Constants.C_DATE_MIN_VALUE) mclsSalesTransactionDetails.CustomerDetails.LastCheckInDate = dteTransactionDate;

                mclsSalesTransactionDetails.AgentID = Convert.ToInt64(lblAgent.Tag);
                mclsSalesTransactionDetails.AgentName = lblAgent.Text;
                mclsSalesTransactionDetails.AgentPositionName = lblAgentPositionDepartment.Text;
                mclsSalesTransactionDetails.AgentDepartmentName = lblAgentPositionDepartment.Tag.ToString();
                mclsSalesTransactionDetails.WaiterID = Convert.ToInt64(lblServedBy.Tag);
                mclsSalesTransactionDetails.WaiterName = lblServedBy.Text.Remove(0, 11);
                mclsSalesTransactionDetails.CreatedByID = Convert.ToInt64(lblCashier.Tag);
                mclsSalesTransactionDetails.CreatedByName = lblCashier.Text;
                mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag);
                mclsSalesTransactionDetails.CashierName = lblCashier.Text;
                mclsSalesTransactionDetails.TransactionDate = dteTransactionDate;
                mclsSalesTransactionDetails.DateSuspended = DateTime.MinValue;
                mclsSalesTransactionDetails.TerminalNo = mclsTerminalDetails.TerminalNo;
                mclsSalesTransactionDetails.BranchID = mclsTerminalDetails.BranchID;
                mclsSalesTransactionDetails.BranchCode = mclsTerminalDetails.BranchDetails.BranchCode;
                mclsSalesTransactionDetails.TransactionStatus = TransactionStatus.Open;
                mclsSalesTransactionDetails.TransactionType = mboIsRefund ? TransactionTypes.POSRefund : TransactionTypes.POSNormal;

                Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                mclsSalesTransactionDetails.TransactionNo = clsSalesTransactions.CreateTransactionNo(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
                // mclsTransactionStream.Create(mclsSalesTransactionDetails);

                lblTransNo.Text = mclsSalesTransactionDetails.TransactionNo;

                //insert to transaction table 
                mclsSalesTransactionDetails.TransactionID = clsSalesTransactions.Insert(mclsSalesTransactionDetails);

                lblTransNo.Tag = mclsSalesTransactionDetails.TransactionID.ToString();

                // Sep 24, 2014 : update back the LastCheckInDate to transaction date
                Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction);
                mConnection = clsContact.Connection; mTransaction = clsContact.Transaction;

                clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, dteTransactionDate);

                // Jan 31, 2015 : Lemu
                // put back to SuspendedOpen so that it won't be open somewhere else
                clsEvent.AddEventLn("Putting transaction SuspendedOpen: " + mclsSalesTransactionDetails.TransactionNo, true);
                clsSalesTransactions.UpdateTransactionToSuspendedOpen(mclsSalesTransactionDetails.TransactionID);

                mboIsInTransaction = true;
                clsTerminalReport.CommitAndDispose();

                InsertAuditLog(AccessTypes.CreateTransaction, "Create transaction #:" + lblTransNo.Text + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
                clsEvent.AddEventLn("Done! Trans #: " + lblTransNo.Text + " has been created.", true);

                // Added to put the default transaction charge during creation of transaction
                // this is set during the system setup
                ApplyTransDefaultCharge();
            }
            catch (Exception ex)
            { clsEvent.AddErrorEventLn(ex); boRetValue = false; }

            return boRetValue;
        }
        //public delegate void UpdateTerminalReportDelegate(TransactionStatus TransStatus, decimal SubTotal, decimal Discount, decimal Charge, decimal VAT, decimal VATableAmount, decimal ZeroRatedSales, decimal NonVATableAmount, decimal EVAT, decimal EVATableAmount, decimal NonEVATableAmount, decimal LocalTax, decimal CashPayment, decimal ChequePayment, decimal CreditCardPayment, decimal CreditPayment, decimal DebitPayment, PaymentTypes PaymentType);
        public void UpdateTerminalReport(TransactionStatus TransStatus, decimal ItemSold, decimal QuantitySold, decimal SubTotal, decimal Discount, decimal ItemsDiscount, decimal SNRItemsDiscount, decimal PWDItemsDiscount, decimal OtherItemsDiscount, decimal Charge, decimal VAT, decimal VATableAmount, decimal ZeroRatedSales, decimal NonVATableAmount, decimal VATExempt, decimal EVAT, decimal EVATableAmount, decimal NonEVATableAmount, decimal LocalTax, decimal CashPayment, decimal ChequePayment, decimal CreditCardPayment, decimal CreditPayment, decimal DebitPayment, decimal RewardPointsPayment, decimal RewardConvertedPayment, PaymentTypes PaymentType)
        {
            Int32 intNoOfCashTransactions = 0;
            Int32 intNoOfChequeTransactions = 0;
            Int32 intNoOfCreditCardTransactions = 0;
            Int32 intNoOfCreditTransactions = 0;
            Int32 intNoOfDebitTransactions = 0;
            Int32 intNoOfCombinationPaymentTransactions = 0;
            Int32 intNoOfDiscountedTransactions = 0;
            Int32 intNoOfRewardPointsPayment = 0;
            decimal decPromotionalItems = 0;

            foreach (System.Data.DataRow dr in ItemDataTable.Rows)
            {
                //decimal ItemQuantity = decimal.TryParse(dr["Quantity"].ToString().Replace("RETURN", "").Trim(), out ItemQuantity) ? ItemQuantity : 0;
                decPromotionalItems += Convert.ToDecimal(dr["PromoApplied"]);
                DiscountTypes ItemDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["ItemDiscountType"].ToString().ToString());
            }

            switch (PaymentType)
            {
                case PaymentTypes.Cash: { intNoOfCashTransactions = 1; break; }
                case PaymentTypes.Cheque: { intNoOfChequeTransactions = 1; break; }
                case PaymentTypes.CreditCard: { intNoOfCreditCardTransactions = 1; break; }
                case PaymentTypes.Credit: { intNoOfCreditTransactions = 1; break; }
                case PaymentTypes.Debit: { intNoOfDebitTransactions = 1; break; }
                case PaymentTypes.RewardPoints: { intNoOfRewardPointsPayment = 1; break; }
                case PaymentTypes.Combination: { intNoOfCombinationPaymentTransactions = 1; break; }
                default: { intNoOfCashTransactions = 1; break; }
            }
            

            Data.TerminalReportDetails clsTerminalReportDetails = new Data.TerminalReportDetails();

            if (TransStatus == TransactionStatus.Closed)
            {
                clsTerminalReportDetails.ItemSold = ItemSold;
                clsTerminalReportDetails.QuantitySold = QuantitySold;
                clsTerminalReportDetails.NoOfCashTransactions = intNoOfCashTransactions;
                clsTerminalReportDetails.NoOfChequeTransactions = intNoOfChequeTransactions;
                clsTerminalReportDetails.NoOfCreditCardTransactions = intNoOfCreditCardTransactions;
                clsTerminalReportDetails.NoOfCreditTransactions = intNoOfCreditTransactions;
                clsTerminalReportDetails.NoOfDebitPaymentTransactions = intNoOfDebitTransactions;
                clsTerminalReportDetails.NoOfCombinationPaymentTransactions = intNoOfCombinationPaymentTransactions;
                clsTerminalReportDetails.NoOfRewardPointsPayment = intNoOfRewardPointsPayment;
                clsTerminalReportDetails.NoOfClosedTransactions = 1;

                // march 19, 2009
                clsTerminalReportDetails.NoOfDiscountedTransactions = intNoOfDiscountedTransactions;
                clsTerminalReportDetails.CreditSalesTax = clsTerminalReportDetails.CreditPayment * (mclsTerminalDetails.VAT / 100);
                clsTerminalReportDetails.PromotionalItems = decPromotionalItems;
                clsTerminalReportDetails.NoOfTotalTransactions = 1;
            }
            else if (TransStatus == TransactionStatus.Void)
            {
                clsTerminalReportDetails.ItemSold = 0;
                clsTerminalReportDetails.QuantitySold = 0;
                clsTerminalReportDetails.NoOfVoidTransactions = 1;
                clsTerminalReportDetails.NoOfTotalTransactions = 1;
            }
            else if (TransStatus == TransactionStatus.Refund)
            {
                clsTerminalReportDetails.ItemSold = -ItemSold;
                clsTerminalReportDetails.QuantitySold = -QuantitySold;
                clsTerminalReportDetails.NoOfRefundTransactions = 1;
                clsTerminalReportDetails.NoOfTotalTransactions = 1;

                // march 19, 2009
                clsTerminalReportDetails.CreditSalesTax = -(clsTerminalReportDetails.CreditPayment * (mclsTerminalDetails.VAT / 100));
            }
            else if (TransStatus == TransactionStatus.CreditPayment)
            {
                clsTerminalReportDetails.NoOfCreditPaymentTransactions = 1;
                clsTerminalReportDetails.NoOfTotalTransactions = 1;

                // march 19, 2009
                // Apr 12, 2014 change to 0 coz its already taxed when goods are sold
                clsTerminalReportDetails.CreditSalesTax = 0; // clsTerminalReportDetails.CreditPayment * (mclsTerminalDetails.VAT / 100); 
                clsTerminalReportDetails.PromotionalItems = decPromotionalItems;
            }
            else if (TransStatus == TransactionStatus.ClosedWalkIn)
            {
                clsTerminalReportDetails.NoOfWalkInTransactions = 1;
            }
            else if (TransStatus == TransactionStatus.ClosedOutOfStock)
            {
                clsTerminalReportDetails.NoOfOutOfStockTransactions = 1;
            }
            else if (TransStatus == TransactionStatus.Consignment)
            {
                clsTerminalReportDetails.NoOfConsignmentTransactions = 1;
            }
            else if (TransStatus == TransactionStatus.ClosedWalkInRefund)
            {
                clsTerminalReportDetails.NoOfWalkInRefundTransactions = 1;
            }
            else if (TransStatus == TransactionStatus.ClosedOutOfStockRefund)
            {
                clsTerminalReportDetails.NoOfOutOfStockRefundTransactions = 1;
            }
            else if (TransStatus == TransactionStatus.ConsignmentRefund)
            {
                clsTerminalReportDetails.NoOfConsignmentRefundTransactions = 1;
            }

            clsTerminalReportDetails.TerminalNo = mclsTerminalDetails.TerminalNo;
            clsTerminalReportDetails.BranchID = mclsTerminalDetails.BranchID;

            Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
            mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

            clsTerminalReport.UpdateTransactionSales(clsTerminalReportDetails);
        }
Exemple #19
0
        private void InitializeZRead(bool boWithOutTF)
		{
            if (!SuspendTransactionAndContinue()) return;

			DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.InitializeZRead);

			if (loginresult == DialogResult.OK)
			{
				Data.SalesTransactions clsSales = new Data.SalesTransactions(mConnection, mTransaction);
                mConnection = clsSales.Connection; mTransaction = clsSales.Transaction;

				int count = clsSales.CountSuspended(mclsTerminalDetails.TerminalNo, 0, mclsTerminalDetails.BranchID);
				clsSales.CommitAndDispose();

				if (count != 0)
                {
                    if (MessageBox.Show("There are suspended transactions for this day. Please CLOSE the transactions first or press 'OK' to continue Z-Read... " + Environment.NewLine + Environment.NewLine + " Note: All Suspended transaction will be automatically VOID.", "RetailPlus", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return;
                    }
                }
				if (IsDateLastInitializationOK() == false)
				{
					return;
				}
				if (MessageBox.Show("Warning!!! Z-Read will be initialized...Press OK to continue.", "RetailPlus", MessageBoxButtons.OKCancel , MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
				{
					Cursor.Current = Cursors.WaitCursor;

					try
					{
						clsEvent.AddEvent("[" + lblCashier.Text + "] Initializing ZReading.",true);
						PrintZRead(true);

						Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                        mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

						// Dec 01, 2008      Lemuel E. Aceron
						// added the IsCashCountInitialized for
						// 1 time Cash count every printing of report.
						Data.Terminal clsTerminal = new Data.Terminal(mConnection, mTransaction);
                        mConnection = clsTerminal.Connection; mTransaction = clsTerminal.Transaction;

						clsTerminal.UpdateIsCashCountInitialized(mclsTerminalDetails.BranchID, mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.CashierID, false);

						//initialize Z-Read
                        clsTerminalReport.InitializeZRead(mclsTerminalDetails.BranchID, mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.CashierName, Constants.C_DATE_MIN_VALUE, boWithOutTF);

                        InsertAuditLog(AccessTypes.InitializeZRead, "Initialize Z-Read." + " [Branch]:" + mclsTerminalDetails.BranchDetails.BranchCode + " [TerminalNo]" + mclsTerminalDetails.TerminalNo);

						DateTime dteMAXDateLastInitialized = DateTime.MinValue;

						// May 21, 2009      Lemuel E. Aceron
						// added the for auto FTP of file for RLC
						// get the maxdatelastinitialized
						if (CONFIG.MallCode.ToUpper() == MallCodes.RLC)
						{
							Data.TerminalReportHistory clsTerminalReportHistory = new Data.TerminalReportHistory(mConnection, mTransaction);
                            mConnection = clsTerminalReportHistory.Connection; mTransaction = clsTerminalReportHistory.Transaction;

							dteMAXDateLastInitialized = clsTerminalReportHistory.MINDateLastInitialized(mclsTerminalDetails.BranchID, mclsTerminalDetails.TerminalNo, DateTime.Now);
						}

						clsTerminalReport.CommitAndDispose();

						clsEvent.AddEventLn("Done!", true);

                        MessageBox.Show("Z-Read has been initialized for [Branch]:" + mclsTerminalDetails.BranchDetails.BranchCode + " [TerminalNo]" + mclsTerminalDetails.TerminalNo + "...", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);

						// May 21, 2009      Lemuel E. Aceron
						// added the for auto FTP of file for RLC
						// send the data to RLC
						if (CONFIG.MallCode.ToUpper() == MallCodes.RLC)
							ProcessMallForwarder(dteMAXDateLastInitialized, true);
						
                        // 23Mar2015 : Initialize all reading with the same ORSeriesBranchID and ORSeriesTerminalNo
                        InitializeAllZreadWithSameORSeries(boWithOutTF);

						LoggedOutCashier(false);
					}
					catch (Exception ex)
					{
                        InsertErrorLogToFile(ex, "ERRROR!!! Initializing ZREAD for [Branch]:" + mclsTerminalDetails.BranchDetails.BranchCode + " [TerminalNo]" + mclsTerminalDetails.TerminalNo);
                    }

					Cursor.Current = Cursors.Default;
				}
			}
		}
        public void PrintZRead(bool pvtWillPreviewReport)
        {
            Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
            mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

            Data.TerminalReportDetails Details = clsTerminalReport.Details(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
            Details.InitializedBy = mclsSalesTransactionDetails.CashierName;
            clsTerminalReport.CommitAndDispose();

            //put the trustfund as zero during zread 
            //to show the correct zread
            Details.TrustFund = 0;

            DialogResult result = DialogResult.OK;

            if (pvtWillPreviewReport)
            {
                TerminalReportWnd clsTerminalReportWnd = new TerminalReportWnd();
                clsTerminalReportWnd.SysConfigDetails = mclsSysConfigDetails;
                clsTerminalReportWnd.TerminalDetails = mclsTerminalDetails;
                clsTerminalReportWnd.Details = Details;
                clsTerminalReportWnd.CashierName = mCashierName;
                clsTerminalReportWnd.TerminalReportType = TerminalReportType.ZRead;
                clsTerminalReportWnd.ShowDialog(this);
                result = clsTerminalReportWnd.Result;
                clsTerminalReportWnd.Close();
                clsTerminalReportWnd.Dispose();
            }

            if (result == DialogResult.OK)
            {
                PrintZRead(true, Details);
            }
        }
Exemple #21
0
        public void InitializeAllZreadWithSameORSeries(bool boWithOutTF)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                Data.Terminal clsTerminal = new Data.Terminal(mConnection, mTransaction);
                mConnection = clsTerminal.Connection; mTransaction = clsTerminal.Transaction;

                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

                AccessUser clsUser = new AccessUser(mConnection, mTransaction);
                mConnection = clsUser.Connection; mTransaction = clsUser.Transaction;

                System.Data.DataTable dt = clsTerminal.ListORSeries(mclsTerminalDetails.ORSeriesTerminalNo);

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    Int32 iBranchID = Int32.Parse(dr["BranchID"].ToString());
                    string stTerminalNo = dr["TerminalNo"].ToString();

                    clsEvent.AddEventLn("Getting Terminal Info BranchID: " + iBranchID.ToString() + " Terminalno:" + stTerminalNo, true);

                    mclsTerminalDetails = clsTerminal.Details(iBranchID, stTerminalNo);
                    mclsSalesTransactionDetails.CashierID = clsTerminal.getLastLoggedCashierID(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);

                    if (mclsSalesTransactionDetails.CashierID == 0)
                        mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag);

                    AccessUserDetails details = clsUser.Details(mclsSalesTransactionDetails.CashierID);

                    mclsSalesTransactionDetails.CashierName = details.Name;

                    if (IsDateLastInitializationOK(false))
                    {
                        try
                        {
                            clsEvent.AddEvent("[" + lblCashier.Text + "] Initializing ZReading.", true);
                            PrintZRead(false);

                            // Dec 01, 2008      Lemuel E. Aceron
                            // added the IsCashCountInitialized for
                            // 1 time Cash count every printing of report.
                            clsTerminal.UpdateIsCashCountInitialized(mclsTerminalDetails.BranchID, mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.CashierID, false);

                            //initialize Z-Read
                            clsTerminalReport.InitializeZRead(mclsTerminalDetails.BranchID, mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.CashierName, Constants.C_DATE_MIN_VALUE, boWithOutTF);

                            InsertAuditLog(AccessTypes.InitializeZRead, "Initialize Z-Read." + " [Branch]:" + mclsTerminalDetails.BranchDetails.BranchCode + " [TerminalNo]" + mclsTerminalDetails.TerminalNo);

                            DateTime dteMAXDateLastInitialized = DateTime.MinValue;

                            // May 21, 2009      Lemuel E. Aceron
                            // added the for auto FTP of file for RLC
                            // get the maxdatelastinitialized
                            if (CONFIG.MallCode.ToUpper() == MallCodes.RLC)
                            {
                                Data.TerminalReportHistory clsTerminalReportHistory = new Data.TerminalReportHistory(mConnection, mTransaction);
                                mConnection = clsTerminalReportHistory.Connection; mTransaction = clsTerminalReportHistory.Transaction;

                                dteMAXDateLastInitialized = clsTerminalReportHistory.MINDateLastInitialized(mclsTerminalDetails.BranchID, mclsTerminalDetails.TerminalNo, DateTime.Now);
                            }

                            clsEvent.AddEventLn("Done!", true);

                            MessageBox.Show("Z-Read has been initialized for [Branch]:" + mclsTerminalDetails.BranchDetails.BranchCode + " [TerminalNo]" + mclsTerminalDetails.TerminalNo + "...", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            // May 21, 2009      Lemuel E. Aceron
                            // added the for auto FTP of file for RLC
                            // send the data to RLC
                            if (CONFIG.MallCode.ToUpper() == MallCodes.RLC)
                                ProcessMallForwarder(dteMAXDateLastInitialized, true);
                        }
                        catch (Exception ex)
                        {
                            InsertErrorLogToFile(ex, "ERRROR!!! Initializing ZREAD for [Branch]:" + mclsTerminalDetails.BranchDetails.BranchCode + " [TerminalNo]" + mclsTerminalDetails.TerminalNo);
                        }
                    }
                }

                clsTerminal.CommitAndDispose();
                Cursor.Current = Cursors.Default;
            }
            catch (Exception ex)
            {
                InsertErrorLogToFile(ex, "ERRROR!!! Initializing ALL ZREAD [ORSeriesBranchID]:" + mclsTerminalDetails.ORSeriesBranchID.ToString() + " [ORSeriesTerminalNo]" + mclsTerminalDetails.ORSeriesTerminalNo);
            }

            // 23Mar2015 : Needed to do this
            mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag);
            mclsSalesTransactionDetails.CashierName = lblCashier.Text;
        }
        public void PrintXRead(Data.TerminalReportDetails Details)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

                PrintingPreference oldCONFIG_AutoPrint = mclsTerminalDetails.AutoPrint;
                mclsTerminalDetails.AutoPrint = PrintingPreference.Normal;

                DateTime dteEffectiveDate = Convert.ToDateTime(Details.DateLastInitializedToDisplay.ToString("MMM. dd, yyyy") + " " + Details.DateLastInitialized.ToString("hh:mm:ss tt"));
                PrintReportHeadersSection(false, dteEffectiveDate);

                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                msbToPrint.Append(CenterString("XRead Report : " + Details.XReadCount.ToString(), mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);

                PrintTerminalReportDetailseSales(Details);

                PrintPageAndReportFooterSection(false, DateTime.MinValue);

                mclsTerminalDetails.AutoPrint = oldCONFIG_AutoPrint;

                clsTerminalReport.UpdateXReadCount(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
                clsTerminalReport.UpdateTrustFund(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo, 0, mclsSalesTransactionDetails.CashierName, Constants.TRUSTFUND_UPDATE_REASON_XREAD);

                clsTerminalReport.CommitAndDispose();

                InsertAuditLog(AccessTypes.PrintXRead, "Print XREAD report: TerminalNo=" + mclsTerminalDetails.TerminalNo + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
            }
            catch (Exception ex)
            {
                InsertErrorLogToFile(ex, "ERROR!!! Printing XREAD report. Err Description: ");
            }
            Cursor.Current = Cursors.Default;
        }
Exemple #23
0
		private bool IsDateLastInitializationOK(bool ShowMessageBox = true)
		{
			try
			{
				clsEvent.AddEvent("Checking last initialization date");

				Data.Database clsDatabase = new Data.Database(mConnection, mTransaction);
                mConnection = clsDatabase.Connection; mTransaction = clsDatabase.Transaction;

				DateTime dtDateLastInitialized = clsDatabase.DateLastInitialized(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);

				bool boRetValue = false;

				if (DateTime.Now > dtDateLastInitialized)
				{
					clsEvent.AddEventLn("OK: Last initialization is smaller than system date. DateLastInitialized=" + dtDateLastInitialized.ToString("yyyy-MM-dd hh:mm") + " SystemDate=" + DateTime.Now.ToString("yyyy-MM-dd hh:mm"));
				}
				else
				{
					clsEvent.AddEventLn("Error: Last initialization is greater than system date. DateLastInitialized=" + dtDateLastInitialized.ToString("yyyy-MM-dd hh:mm") + " SystemDate=" + DateTime.Now.ToString("yyyy-MM-dd hh:mm"));
					clsDatabase.CommitAndDispose();
					MessageBox.Show("FATAL ERROR Level 2.!!! System date is behind ZREAD last initialization date. Please adjust SYSTEM DATE!!!", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);
					return boRetValue;
				}

				Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

				DateTime dteTransactionDate = Convert.ToDateTime(lblTransDate.Text);

				DateTime dteStartCutOffTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.StartCutOffTime);
				DateTime dteEndCutOffTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.EndCutOffTime);

				// if StartCutOffTime is greater than EndCutOffTime
				// this means that EndCutOffTime is in the morning.
				// Add 1 more day.
				if (dteStartCutOffTime >= dteEndCutOffTime)
					dteEndCutOffTime = dteEndCutOffTime.AddDays(1);

				DateTime dteAllowedStartDateTime; DateTime dteAllowedEndDateTime;
				if (dteTransactionDate < dteEndCutOffTime)
				{
					dteAllowedStartDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.EndCutOffTime).AddDays(-1).AddMilliseconds(1);
					dteAllowedEndDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.StartCutOffTime);
				}
				else
				{
					dteAllowedStartDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.EndCutOffTime).AddMilliseconds(1);
					dteAllowedEndDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.StartCutOffTime).AddDays(1);
				}
				if (dteTransactionDate < dteAllowedEndDateTime)
				{
					dteStartCutOffTime = dteStartCutOffTime.AddDays(1);
					dteEndCutOffTime = dteEndCutOffTime.AddDays(1);
				}

				DateTime dtePreviousStartCutOffTime = dteStartCutOffTime.AddDays(-1);
				DateTime dtePreviousEndCutOffTime = dteEndCutOffTime.AddDays(-1);
				DateTime dtePreviousAllowedStartDateTime = dteAllowedStartDateTime.AddDays(-1);
				DateTime dtePreviousAllowedEndDateTime = dteAllowedEndDateTime.AddDays(-1);

                DateTime dteMAXDateLastInitialized = clsTerminalReport.MAXDateLastInitialized(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo, Constants.C_DATE_MIN_VALUE);

				clsEvent.AddEventLn("Checking if MAXDateLastInitialized: " + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm") + " is already initialized.", true);
				if (dteMAXDateLastInitialized >= dteAllowedStartDateTime && dteMAXDateLastInitialized <= dteAllowedEndDateTime)
				{
					clsDatabase.CommitAndDispose();
					clsEvent.AddEventLn("Transaction is not allowed, ZRead is already initialized for this date.", true);
					MessageBox.Show("Sorry initialization is not permitted this time, ZRead is already initialized for this date.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
					txtBarCode.Text = "";
					return boRetValue;
				}
				clsEvent.AddEventLn("OK. MAXDateLastInitialized: " + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm") + " is for previous zreading.", true);

				if (dteMAXDateLastInitialized < dteAllowedStartDateTime)
				{
					if (dteMAXDateLastInitialized >= dtePreviousAllowedStartDateTime && dteMAXDateLastInitialized <= dtePreviousEndCutOffTime)
					{
						clsEvent.AddEventLn("OK: AllowedStartDateTime [" + dteAllowedStartDateTime.ToString("yyyy-MM-dd HH:mm:ss") + "] is now less than MAXDateLastInitialized [" + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm:ss") + "].", true);
					}
					else if(mclsTerminalDetails.CheckCutOffTime == true)
					{
						clsEvent.AddEventLn("Transaction is not allowed, transaction date is 2-Days delayed. Please restart FE.", true);
						MessageBox.Show("Transaction is not allowed, transaction date is 2Days delayed. Please restart FE." +
							Environment.NewLine + "Sorry selling is not permitted this time, Please consult for the Selling time.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
						txtBarCode.Text = "";
						return false;
					}
				}
				if (dteMAXDateLastInitialized > dteTransactionDate)
				{
					clsDatabase.CommitAndDispose();
					clsEvent.AddEventLn("Transaction is not allowed, transaction date is delayed. Please restart FE.", true);

                    // 22Jun2015 : ShowMessageBox = false if its from ZRead
                    if (ShowMessageBox) MessageBox.Show("Transaction is not allowed, transaction date is delayed. Please restart FE.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);

					txtBarCode.Text = "";
					return boRetValue;
				}
				clsEvent.AddEventLn("OK to initialize...", true);
                clsDatabase.CommitAndDispose();

				boRetValue = true;

				return boRetValue;
			}
			catch (Exception ex)
			{
				InsertErrorLogToFile(ex);
				return false;
			}
		}
        public void PrintHourlyReport()
        {
            Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
            mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

            Data.TerminalReportDetails clsTerminalReportDetails = clsTerminalReport.Details(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);

            System.Data.DataTable dtHourlyReport = clsTerminalReport.HourlyReport(clsTerminalReportDetails.BeginningTransactionNo, clsTerminalReportDetails.EndingTransactionNo, Constants.TerminalBranchID, mclsTerminalDetails.TerminalNo);
            clsTerminalReport.CommitAndDispose();

            DialogResult result = DialogResult.OK;

            if (mclsTerminalDetails.PreviewTerminalReport)
            {
                HourlyReportWnd clsHourlyReportWnd = new HourlyReportWnd();
                clsHourlyReportWnd.TerminalDetails = mclsTerminalDetails;
                clsHourlyReportWnd.CashierName = mCashierName;
                clsHourlyReportWnd.dtHourlyReport = dtHourlyReport;
                clsHourlyReportWnd.ShowDialog(this);
                result = clsHourlyReportWnd.Result;
                clsHourlyReportWnd.Close();
                clsHourlyReportWnd.Dispose();
            }

            if (result == DialogResult.OK)
            {
                //PrintHourlyReportDelegate hourlyreportDel = new PrintHourlyReportDelegate(PrintHourlyReport);
                PrintHourlyReport(dtHourlyReport);
            }
        }
Exemple #25
0
        private bool CheckIfOKToSell(bool WillCommitAndDispose)
        {
            Boolean boRetValue = true;
            try
            {
                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

                DateTime dteTransactionDate = Convert.ToDateTime(lblTransDate.Text);

                // Added checking of Cutofftime
                if (mclsTerminalDetails.CheckCutOffTime)
                {
                    DateTime dteStartCutOffTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.StartCutOffTime);
                    DateTime dteEndCutOffTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.EndCutOffTime);

                    // if StartCutOffTime is greater than EndCutOffTime
                    // this means that EndCutOffTime is in the morning.
                    // Add 1 more day.
                    if (dteStartCutOffTime >= dteEndCutOffTime)
                        dteEndCutOffTime = dteEndCutOffTime.AddDays(1);

                    DateTime dteAllowedStartDateTime; DateTime dteAllowedEndDateTime;
                    if (dteTransactionDate < dteEndCutOffTime)
                    {
                        dteAllowedStartDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.EndCutOffTime).AddDays(-1).AddMilliseconds(1);
                        dteAllowedEndDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.StartCutOffTime);
                    }
                    else
                    {
                        dteAllowedStartDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.EndCutOffTime).AddMilliseconds(1);
                        dteAllowedEndDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.StartCutOffTime).AddDays(1);
                    }
                    if (dteTransactionDate < dteAllowedEndDateTime)
                    {
                        dteStartCutOffTime = dteStartCutOffTime.AddDays(1);
                        dteEndCutOffTime = dteEndCutOffTime.AddDays(1);
                    }

                    DateTime dtePreviousStartCutOffTime = dteStartCutOffTime.AddDays(-1);
                    DateTime dtePreviousEndCutOffTime = dteEndCutOffTime.AddDays(-1);
                    DateTime dtePreviousAllowedStartDateTime = dteAllowedStartDateTime.AddDays(-1);
                    DateTime dtePreviousAllowedEndDateTime = dteAllowedEndDateTime.AddDays(-1);

                    clsEvent.AddEventLn("Checking Transactiondate: '" + dteTransactionDate.ToString("yyyy-MM-dd HH:mm") + "' before creating new transaction if not between cutoff: '" + dteStartCutOffTime.ToString("yyyy-MM-dd HH:mm") + "' & '" + dteEndCutOffTime.ToString("yyyy-MM-dd HH:mm") + "'", true);
                    if (dteTransactionDate >= dteStartCutOffTime && dteTransactionDate <= dteEndCutOffTime)
                    {
                        clsEvent.AddEventLn("Transaction is not allowed, transaction date is within the cutofftime.", true);
                        MessageBox.Show("Sorry selling is not permitted this time, Please consult for the Selling time.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtBarCode.Text = "";
                        return false;
                    }
                    clsEvent.AddEventLn("Transaction is ok, transaction date is within allowable transaction date.", true);

                    clsEvent.AddEventLn("Checking Transactiondate: '" + dteTransactionDate.ToString("yyyy-MM-dd HH:mm") + "' before creating new transaction if between selling time: '" + dteAllowedStartDateTime.ToString("yyyy-MM-dd HH:mm") + "' & '" + dteAllowedEndDateTime.ToString("yyyy-MM-dd HH:mm") + "'", true);
                    if (dteTransactionDate < dteAllowedStartDateTime && dteTransactionDate > dteAllowedEndDateTime)
                    {
                        clsEvent.AddEventLn("Transaction is not allowed, transaction date is not within the allowable transaction date.", true);
                        MessageBox.Show("Sorry selling is not permitted this time, Please consult for the Selling time.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtBarCode.Text = "";
                        return false;
                    }
                    clsEvent.AddEventLn("Transaction is ok, transaction date is within allowable transaction date.", true);

                    DateTime dteMAXDateLastInitialized = clsTerminalReport.MAXDateLastInitialized(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo, Constants.C_DATE_MIN_VALUE);

                    clsEvent.AddEventLn("PreviousStartCutOff       :    " + dtePreviousStartCutOffTime.ToString("yyyy-MM-dd HH:mm:ss"), true);
                    clsEvent.AddEventLn("PreviousEndCutOff         :    " + dtePreviousEndCutOffTime.ToString("yyyy-MM-dd HH:mm:ss"), true);
                    clsEvent.AddEventLn("PrevAllowedStartDateTime  :    " + dtePreviousAllowedStartDateTime.ToString("yyyy-MM-dd HH:mm:ss"), true);
                    clsEvent.AddEventLn("PrevAllowedEndDateTime    :    " + dtePreviousAllowedEndDateTime.ToString("yyyy-MM-dd HH:mm:ss"), true);

                    clsEvent.AddEventLn("StartCutOff               :    " + dteStartCutOffTime.ToString("yyyy-MM-dd HH:mm:ss"), true);
                    clsEvent.AddEventLn("EndCutOff                 :    " + dteEndCutOffTime.ToString("yyyy-MM-dd HH:mm:ss"), true);
                    clsEvent.AddEventLn("AllowedStartDateTime      :    " + dteAllowedStartDateTime.ToString("yyyy-MM-dd HH:mm:ss"), true);
                    clsEvent.AddEventLn("AllowedEndDateTime        :    " + dteAllowedEndDateTime.ToString("yyyy-MM-dd HH:mm:ss"), true);
                    clsEvent.AddEventLn("MAXDateLastInitialized    :    " + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm:ss"), true);

                    clsEvent.AddEventLn("Checking if MAXDateLastInitialized: " + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm") + " is already initialized.", true);
                    if (dteMAXDateLastInitialized >= dteAllowedStartDateTime && dteMAXDateLastInitialized <= dteAllowedEndDateTime)
                    {
                        clsTerminalReport.CommitAndDispose();
                        clsEvent.AddEventLn("Transaction is not allowed, ZRead is already initialized for this date.", true);
                        MessageBox.Show("Sorry selling is not permitted this time, ZRead is already initialized for this date.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtBarCode.Text = "";
                        return false;
                    }
                    clsEvent.AddEventLn("OK. MAXDateLastInitialized: " + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm") + " is for previous zreading.", true);
                    clsEvent.AddEventLn("Checking Transactiondate: '" + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm") + "' < '" + dteAllowedStartDateTime.ToString("yyyy-MM-dd HH:mm") + "'", true);
                    if (dteMAXDateLastInitialized < dteAllowedStartDateTime)
                    {
                        if (dteMAXDateLastInitialized >= dtePreviousAllowedStartDateTime && dteMAXDateLastInitialized <= dtePreviousEndCutOffTime)
                        {
                            clsEvent.AddEventLn("OK: AllowedStartDateTime [" + dteAllowedStartDateTime.ToString("yyyy-MM-dd HH:mm:ss") + "] is now less than MAXDateLastInitialized [" + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm:ss") + "].", true);
                        }
                        else
                        {
                            clsTerminalReport.CommitAndDispose();
                            clsEvent.AddEventLn("Transaction is not allowed, transaction date is 2-Days delayed. Please restart FE.", true);
                            MessageBox.Show("Transaction is not allowed, transaction date is 2Days delayed. Please restart FE." +
                                Environment.NewLine + "Sorry selling is not permitted this time, Please consult for the Selling time.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtBarCode.Text = "";
                            return false;
                        }
                    }
                    if (dteMAXDateLastInitialized > dteTransactionDate)
                    {
                        clsTerminalReport.CommitAndDispose();
                        clsEvent.AddEventLn("Transaction is not allowed, transaction date is delayed. Please restart FE.", true);
                        MessageBox.Show("Transaction is not allowed, transaction date is delayed. Please restart FE." +
                            Environment.NewLine + "Sorry selling/payment is not permitted this time, Please consult for the Selling/Payment time.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtBarCode.Text = "";
                        return false;
                    }
                    clsEvent.AddEventLn("OK to sell...", true);
                }
                else
                {
                    // this is to check if the last maxdate is too far from current date. that means they did not zread for at least 2 days which is not allowed.
                    // or the system date has been altered.
                    DateTime dteMAXDateLastInitialized = clsTerminalReport.MAXDateLastInitialized(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo, Constants.C_DATE_MIN_VALUE);

                    if (dteTransactionDate > dteMAXDateLastInitialized.AddDays(2))
                    {
                        clsTerminalReport.CommitAndDispose();
                        if (MessageBox.Show("Transaction date is too far from the last ZReadDate [" + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm") + "]. Do you want to continue?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.No)
                        {
                            clsEvent.AddEventLn("Transaction is not allowed, transaction date is too far from the last ZReadDate [" + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm") + "]. Please change the date.", true);
                            MessageBox.Show("Transaction is not allowed, transaction date is too far from the last ZReadDate [" + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm") + "]. Please change the date." +
                                Environment.NewLine + "Sorry selling is not permitted this time, Please consult for the Selling time.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtBarCode.Text = "";
                            return false;
                        }
                    }
                }
                if (WillCommitAndDispose) clsTerminalReport.CommitAndDispose();
                clsEvent.AddEventLn("Done! ok to sell.", true);
            }
            catch (Exception ex)
            {
                InsertErrorLogToFile(ex);
                boRetValue = false;
            }

            return boRetValue;
        }
        public void PrintEJournalReport()
        {
            Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
            mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

            Data.SalesTransactionDetails[] salesDetails = clsTerminalReport.EJournalReport(Constants.TerminalBranchID, mCashierName, mclsTerminalDetails.TerminalNo);
            clsTerminalReport.CommitAndDispose();

            DialogResult result = DialogResult.OK;

            if (mclsTerminalDetails.PreviewTerminalReport)
            {
                EJournalReportWnd clsEJournalReportWnd = new EJournalReportWnd();
                clsEJournalReportWnd.TerminalDetails = mclsTerminalDetails;
                clsEJournalReportWnd.CashierName = mCashierName;
                clsEJournalReportWnd.SalesDetails = salesDetails;
                clsEJournalReportWnd.ShowDialog(this);
                result = clsEJournalReportWnd.Result;
                clsEJournalReportWnd.Close();
                clsEJournalReportWnd.Dispose();
            }

            if (result == DialogResult.OK)
            {
                Cursor.Current = Cursors.WaitCursor;
                //PrintEJournalReportDelegate ejournalreportDel = new PrintEJournalReportDelegate(PrintEJournalReport);
                PrintEJournalReport(salesDetails);
                Cursor.Current = Cursors.Default;
            }
        }
Exemple #27
0
        private bool CreateTransaction()
        {
            Boolean boRetValue = true;
            try
            {
                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

                DateTime dteTransactionDate = Convert.ToDateTime(lblTransDate.Text);

                boRetValue = CheckIfOKToSell(false);

                if (!boRetValue) return boRetValue;

                clsEvent.AddEventLn("[" + lblCashier.Text + "] Creating new transaction.", true);

                mclsSalesTransactionDetails = new Data.SalesTransactionDetails();
                mclsSalesTransactionDetails.TransactionItemsList = new System.Collections.Generic.List<Data.SalesTransactionItemDetails>();
                try { mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag); }
                catch { }

                //mclsSalesTransactionDetails.CustomerID = Convert.ToInt64(lblCustomer.Tag);
                //mclsSalesTransactionDetails.CustomerName = lblCustomer.Text;

                if (mclsContactDetails.ContactID == 0)
                {
                    mclsContactDetails = mclsContactDetailsDEFCustomer;
                }

                if (mboRewardCardSwiped)
                {
                    mclsSalesTransactionDetails.RewardsCustomerID = mclsContactDetails.ContactID;
                    mclsSalesTransactionDetails.RewardsCustomerName = mclsContactDetails.ContactName;
                    mclsSalesTransactionDetails.RewardCardActive = mclsContactDetails.RewardDetails.RewardActive;
                    mclsSalesTransactionDetails.RewardCardNo = mclsContactDetails.RewardDetails.RewardCardNo;
                    mclsSalesTransactionDetails.RewardCardExpiry = mclsContactDetails.RewardDetails.ExpiryDate;
                    mclsSalesTransactionDetails.RewardPreviousPoints = mclsContactDetails.RewardDetails.RewardPoints;
                }
                else
                {
                    mclsSalesTransactionDetails.RewardsCustomerID = Constants.C_RETAILPLUS_CUSTOMERID;
                    mclsSalesTransactionDetails.RewardsCustomerName = Constants.C_RETAILPLUS_CUSTOMER;
                    mclsSalesTransactionDetails.RewardCardActive = mclsContactDetailsDEFCustomer.RewardDetails.RewardActive;
                    mclsSalesTransactionDetails.RewardCardNo = mclsContactDetailsDEFCustomer.RewardDetails.RewardCardNo;
                    mclsSalesTransactionDetails.RewardCardExpiry = mclsContactDetailsDEFCustomer.RewardDetails.ExpiryDate;
                    mclsSalesTransactionDetails.RewardPreviousPoints = mclsContactDetailsDEFCustomer.RewardDetails.RewardPoints;
                }
                mclsSalesTransactionDetails.CustomerDetails = mclsContactDetails;
                mclsSalesTransactionDetails.CustomerID = mclsContactDetails.ContactID;
                mclsSalesTransactionDetails.CustomerName = mclsContactDetails.ContactName;
                if (mclsSalesTransactionDetails.CustomerDetails.LastCheckInDate == Constants.C_DATE_MIN_VALUE) mclsSalesTransactionDetails.CustomerDetails.LastCheckInDate = dteTransactionDate;

                mclsSalesTransactionDetails.AgentID = Convert.ToInt64(lblAgent.Tag);
                mclsSalesTransactionDetails.AgentName = lblAgent.Text;
                mclsSalesTransactionDetails.AgentPositionName = lblAgentPositionDepartment.Text;
                mclsSalesTransactionDetails.AgentDepartmentName = lblAgentPositionDepartment.Tag.ToString();
                mclsSalesTransactionDetails.WaiterID = Convert.ToInt64(grpItems.Tag);
                mclsSalesTransactionDetails.WaiterName = grpItems.Text.Remove(0, 11);
                mclsSalesTransactionDetails.CreatedByID = Convert.ToInt64(lblCashier.Tag);
                mclsSalesTransactionDetails.CreatedByName = lblCashier.Text;
                mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag);
                mclsSalesTransactionDetails.CashierName = lblCashier.Text;
                mclsSalesTransactionDetails.TransactionDate = dteTransactionDate;
                mclsSalesTransactionDetails.DateSuspended = DateTime.MinValue;
                mclsSalesTransactionDetails.TerminalNo = mclsTerminalDetails.TerminalNo;
                mclsSalesTransactionDetails.BranchID = mclsTerminalDetails.BranchID;
                mclsSalesTransactionDetails.BranchCode = mclsTerminalDetails.BranchDetails.BranchCode;
                mclsSalesTransactionDetails.TransactionStatus = TransactionStatus.Open;
                mclsSalesTransactionDetails.TransactionType = mboIsRefund ? TransactionTypes.POSRefund : TransactionTypes.POSNormal;

                Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                mclsSalesTransactionDetails.TransactionNo = clsSalesTransactions.CreateTransactionNo(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);

                lblTransNo.Text = mclsSalesTransactionDetails.TransactionNo;

                //insert to transaction table 

                mclsSalesTransactionDetails.TransactionID = clsSalesTransactions.Insert(mclsSalesTransactionDetails);

                lblTransNo.Tag = mclsSalesTransactionDetails.TransactionID.ToString();

                // 24Sep2014 : update back the LastCheckInDate to transaction date
                Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction);
                mConnection = clsContact.Connection; mTransaction = clsContact.Transaction;

                clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, dteTransactionDate);

                // 31Jan2015 : Lemu
                // put back to SuspendedOpen so that it won't be open somewhere else
                clsEvent.AddEventLn("Putting transaction SuspendedOpen: " + mclsSalesTransactionDetails.TransactionNo, true);
                clsSalesTransactions.UpdateTransactionToSuspendedOpen(mclsSalesTransactionDetails.TransactionID);

                mboIsInTransaction = true;
                clsTerminalReport.CommitAndDispose();

                InsertAuditLog(AccessTypes.CreateTransaction, "Create transaction #".PadRight(15) + ":" + lblTransNo.Text + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
                clsEvent.AddEventLn("Done! Trans #: " + lblTransNo.Text + " has been created.", true);

            }
            catch (Exception ex)
            {
                InsertErrorLogToFile(ex);
                boRetValue = false;
            }

            return boRetValue;
        }
Exemple #28
0
        private bool isValuesAssigned()
        {
            bool boRetValue = false;

            try { Convert.ToDecimal(txtAmount.Text); }
            catch
            {
                MessageBox.Show("Sorry, the amount you entered is not valid. Please check the amount you entered.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return boRetValue;
            }

            if (Convert.ToDecimal(txtAmount.Text) > 0)
            {
                mclsPaidOutDetails.Amount = Convert.ToDecimal(txtAmount.Text);
                mclsPaidOutDetails.PaymentType = (PaymentTypes)Enum.Parse(typeof(PaymentTypes), cboType.Text, true);
                mclsPaidOutDetails.Remarks = txtRemarks.Text;
                mclsPaidOutDetails.DateCreated = DateTime.Now;
                mclsPaidOutDetails.TerminalNo = CompanyDetails.TerminalNo;
                mclsPaidOutDetails.BranchDetails = mclsTerminalDetails.BranchDetails;
                mclsPaidOutDetails.CashierID = mCashierID;

                // boRetValue = true;
                // 15Apr2015 No need to check for this coz Disburse is based on actual cash.

                Data.CashierReports clsCashierReport = new Data.CashierReports();
                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(clsCashierReport.Connection, clsCashierReport.Transaction);
                clsTerminalReport.SyncTransactionSales(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
                if (!clsCashierReport.IsPaidOutAmountValid(mclsPaidOutDetails))
                {
                    MessageBox.Show("Sorry, the amount you entered is greater than the " + cboType.Text + " sales." +
                        "Please check the amount you entered.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    boRetValue = true;
                }
                clsCashierReport.CommitAndDispose();
            }
            else
            {
                MessageBox.Show("Sorry, amount must be greater than zero." +
                    "Please enter amount that is greater than zero.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return boRetValue;
        }
Exemple #29
0
		private bool IsStartCutOffTimeOK()
		{
			bool bolRetValue = false;
            bool bolMessageBoxShown = false;
			try
			{
				// check if with Cutofftime
				if (mclsTerminalDetails.CheckCutOffTime)
				{
					clsEvent.AddEventLn("Checking StartCutOffTime vs MAXDateLastInitialized...", true);

					Data.TerminalReportDetails clsTerminalReportDetails;
					Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                    mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

					DateTime dteTransactionDate = Convert.ToDateTime(lblTransDate.Text);

                    DateTime dteMAXDateLastInitialized = clsTerminalReport.MAXDateLastInitialized(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo, Constants.C_DATE_MIN_VALUE);
					DateTime dteStartCutOffTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.StartCutOffTime);
					DateTime dteEndCutOffTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.EndCutOffTime);

					// if StartCutOffTime is greater than EndCutOffTime
					// this means that EndCutOffTime is in the morning.
					// Add 1 more day.
					if (dteStartCutOffTime >= dteEndCutOffTime)
						dteEndCutOffTime = dteEndCutOffTime.AddDays(1);

					DateTime dteAllowedStartDateTime; DateTime dteAllowedEndDateTime;
					if (dteTransactionDate < dteEndCutOffTime)
					{
						dteAllowedStartDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.EndCutOffTime).AddDays(-1).AddMilliseconds(1);
						dteAllowedEndDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.StartCutOffTime);
					}
					else
					{
						dteAllowedStartDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.EndCutOffTime).AddMilliseconds(1);
						dteAllowedEndDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.StartCutOffTime).AddDays(1);
					}
					if (dteTransactionDate < dteAllowedEndDateTime)
					{
						dteStartCutOffTime = dteStartCutOffTime.AddDays(1);
						dteEndCutOffTime = dteEndCutOffTime.AddDays(1);
					}

					DateTime dtePreviousStartCutOffTime = dteStartCutOffTime.AddDays(-1);
					DateTime dtePreviousEndCutOffTime = dteEndCutOffTime.AddDays(-1);
					DateTime dtePreviousAllowedStartDateTime = dteAllowedStartDateTime.AddDays(-1);
					DateTime dtePreviousAllowedEndDateTime = dteAllowedEndDateTime.AddDays(-1);

				Back:
					clsEvent.AddEventLn("PreviousStartCutOff       :    " + dtePreviousStartCutOffTime.ToString("yyyy-MM-dd HH:mm:ss"), true);
					clsEvent.AddEventLn("PreviousEndCutOff         :    " + dtePreviousEndCutOffTime.ToString("yyyy-MM-dd HH:mm:ss"), true);
					clsEvent.AddEventLn("PrevAllowedStartDateTime  :    " + dtePreviousAllowedStartDateTime.ToString("yyyy-MM-dd HH:mm:ss"), true);
					clsEvent.AddEventLn("PrevAllowedEndDateTime    :    " + dtePreviousAllowedEndDateTime.ToString("yyyy-MM-dd HH:mm:ss"), true);

					clsEvent.AddEventLn("StartCutOff               :    " + dteStartCutOffTime.ToString("yyyy-MM-dd HH:mm:ss"), true);
					clsEvent.AddEventLn("EndCutOff                 :    " + dteEndCutOffTime.ToString("yyyy-MM-dd HH:mm:ss"), true);
					clsEvent.AddEventLn("AllowedStartDateTime      :    " + dteAllowedStartDateTime.ToString("yyyy-MM-dd HH:mm:ss"), true);
					clsEvent.AddEventLn("AllowedEndDateTime        :    " + dteAllowedEndDateTime.ToString("yyyy-MM-dd HH:mm:ss"), true);
					clsEvent.AddEventLn("MAXDateLastInitialized    :    " + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm:ss"), true);
				
					if (dteMAXDateLastInitialized < dteAllowedStartDateTime)
					{
						if (dteMAXDateLastInitialized >= dtePreviousAllowedStartDateTime && dteMAXDateLastInitialized <= dtePreviousEndCutOffTime)
						{
							if (dteTransactionDate >= dteStartCutOffTime && dteTransactionDate <= dteEndCutOffTime)
							{
                                if (!bolMessageBoxShown)
                                {
                                    MessageBox.Show("Today's EOD was not performed. Performing Auto Z-Read this may take some time. Please wait...", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    bolMessageBoxShown = true;
                                }

								clsEvent.AddEventLn("Today's EOD was not performed: System found AllowedStartDateTime [" + dteAllowedStartDateTime.ToString("yyyy-MM-dd HH:mm:ss") + "] > MAXDateLastInitialized [" + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm:ss") + "].", true);
								clsEvent.AddEventLn("System is Auto-Initializing ZREAD", true);

                                clsTerminalReportDetails = clsTerminalReport.Details(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
                                mstrBeginningTransactionNo = clsTerminalReportDetails.BeginningTransactionNo;

								PrintZRead(false, clsTerminalReportDetails);

								dteMAXDateLastInitialized = Convert.ToDateTime(dteMAXDateLastInitialized.AddDays(1));
								clsTerminalReport.InitializeZRead(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo, "System Auto Z-Read", dteMAXDateLastInitialized, false);
								clsEvent.AddEventLn("Done.", true);
								goto Back;
							}
							else
							{
								bolRetValue = true;
								clsEvent.AddEventLn("OK: AllowedStartDateTime [" + dteAllowedStartDateTime.ToString("yyyy-MM-dd HH:mm:ss") + "] is now less than MAXDateLastInitialized [" + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm:ss") + "].", true);
							}
						}
						else
						{
                            if (!bolMessageBoxShown)
                            {
                                MessageBox.Show("Previous' day's EOD was not performed. Performing Auto Z-Read this may take some time. Please wait...", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                bolMessageBoxShown = true;
                            }

							clsEvent.AddEventLn("Previous' day's EOD was not performed: System found AllowedStartDateTime [" + dteAllowedStartDateTime.ToString("yyyy-MM-dd HH:mm:ss") + "] > MAXDateLastInitialized [" + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm:ss") + "].", true);
							clsEvent.AddEventLn("System is Auto-Initializing ZREAD", true);

                            clsTerminalReportDetails = clsTerminalReport.Details(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
                            mstrBeginningTransactionNo = clsTerminalReportDetails.BeginningTransactionNo;

							PrintZRead(false, clsTerminalReportDetails);

							dteMAXDateLastInitialized = Convert.ToDateTime(dteMAXDateLastInitialized.AddDays(1));
                            clsTerminalReport.InitializeZRead(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo, "System Auto Z-Read", dteMAXDateLastInitialized, false);
							clsEvent.AddEventLn("Done.",true);
							goto Back;
						}
					}
					else
					{
						bolRetValue = true;
						clsEvent.AddEventLn("OK: AllowedStartDateTime [" + dteAllowedStartDateTime.ToString("yyyy-MM-dd HH:mm:ss") + "] is now less than MAXDateLastInitialized [" + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm:ss") + "].", true);
					}

					clsTerminalReport.CommitAndDispose();

				}
				else { clsEvent.AddEventLn("OK: StartCutOffTime not configured if greater than MAXDateLastInitialized", true); }

				return bolRetValue;
			}
			catch (Exception ex)
			{
				InsertErrorLogToFile(ex);
				return false;
			}
		}
Exemple #30
0
		public Int64 UpdateBeginningBalance(CashierLogsDetails Details, decimal BeginningBalanceAmount)
		{
			Int64 iRetValue = Insert(Details);

			Data.CashierReports clsCashierReport = new Data.CashierReports(base.Connection, base.Transaction);
            clsCashierReport.UpdateBeginningBalance(Details.BranchID, Details.TerminalNo, Details.CashierID, BeginningBalanceAmount);

			Data.TerminalReport clsTerminalReport = new Data.TerminalReport(base.Connection, base.Transaction);
            clsTerminalReport.UpdateBeginningBalance(Details.BranchID, Details.TerminalNo, BeginningBalanceAmount);

			return iRetValue;
		}
		private void SetDataSource(ReportDocument Report)
		{
			ReportDataset rptds = new ReportDataset();

			Data.TerminalReport clsTerminalReport = new Data.TerminalReport();
            Data.Terminal clsTerminal = new Data.Terminal(clsTerminalReport.Connection, clsTerminalReport.Transaction);
            Data.TerminalDetails clsTerminalDetails = clsTerminal.Details(txtTerminalNo.Text);
            clsTerminalReport.SyncTransactionSales(clsTerminalDetails.BranchDetails.BranchID, txtTerminalNo.Text);
			System.Data.DataTable dt = clsTerminalReport.List(txtTerminalNo.Text);
			clsTerminalReport.CommitAndDispose();

			foreach(System.Data.DataRow dr in dt.Rows)
			{
				DataRow drNew = rptds.TerminalReport.NewRow();
				
				foreach (DataColumn dc in rptds.TerminalReport.Columns)
					drNew[dc] = dr[dc.ColumnName]; 
				
				rptds.TerminalReport.Rows.Add(drNew);
			}

			Report.SetDataSource(rptds); 
			SetParameters(Report);
		}