Beispiel #1
0
        private void LoadData()
        {
            try
            {
                Data.SalesTransactions clsTransactions = new Data.SalesTransactions();

                System.Data.DataTable dt;
                if (TerminalDetails.ShowOneTerminalSuspendedTransactions == false)
                {
                    dt = clsTransactions.ListSuspendedDataTable(TerminalDetails.BranchID, TerminalDetails.TerminalNo, 0, TerminalDetails.ShowOnlyPackedTransactions);
                }
                else
                {
                    dt = clsTransactions.ListSuspendedDataTable(TerminalDetails.BranchID, TerminalDetails.TerminalNo, mCashierID, TerminalDetails.ShowOnlyPackedTransactions);
                }
                clsTransactions.CommitAndDispose();

                this.dgStyle.MappingName = dt.TableName;
                dgItems.DataSource       = dt;
                dgItems.Select(0);
                dgItems.CurrentRowIndex = 0;
            }
            catch (IndexOutOfRangeException) { }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private bool CreateDetails(int iRow)
        {
            try
            {
                bool boRetValue = false;

                mDetails = new Data.SalesTransactionDetails();

                mDetails.TransactionID = Convert.ToInt64(dgItems[iRow, 0]);
                mDetails.TransactionNo = dgItems[iRow, 1].ToString();

                Data.SalesTransactions clsTransactions = new Data.SalesTransactions();
                mDetails = clsTransactions.Details(mDetails.TransactionNo, TerminalDetails.TerminalNo, TerminalDetails.BranchID);

                // 14Jun2015 : Update to Status Resume only if the Status is not Closed.
                if (TransactionStatusToList != RetailPlus.TransactionStatus.Closed)
                {
                    clsTransactions.Resume(mDetails.TransactionID);
                }

                Data.SalesTransactionItems clsItems = new Data.SalesTransactionItems(clsTransactions.Connection, clsTransactions.Transaction);
                mDetails.TransactionItems = clsItems.Details(mDetails.TransactionID, mDetails.TransactionDate);

                clsTransactions.CommitAndDispose();

                boRetValue = true;

                return(boRetValue);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
		public Int64 Insert(SalesTransactionDetails Details)
		{
			Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions();
			Int64 iRetValue = clsSalesTransactions.Insert(Details);
            clsSalesTransactions.CommitAndDispose();
			return iRetValue;
		}
Beispiel #4
0
        public Int64 Insert(SalesTransactionDetails Details)
        {
            Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions();
            Int64 iRetValue = clsSalesTransactions.Insert(Details);

            clsSalesTransactions.CommitAndDispose();
            return(iRetValue);
        }
Beispiel #5
0
 private void LoadPurchases(Int64 CreditorID)
 {
     Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions();
     System.Data.DataTable  dt = clsSalesTransactions.ListForPaymentDataTable(CreditorID);
     clsSalesTransactions.CommitAndDispose();
     lstPurchases.DataSource = dt.DefaultView;
     lstPurchases.DataBind();
 }
Beispiel #6
0
        /// <summary>
        ///     Load the transaction using the transaction no. scanned in the txtScan.
        /// </summary>
        private void LoadTransaction()
        {
            try
            {
                LoadOptions();
                string strTransactionNo = txtScan.Text.Trim().PadLeft(14, '0');
                Data.SalesTransactions clsTransactions = new Data.SalesTransactions();
                mclsSalesTransactionDetails = clsTransactions.Details(strTransactionNo, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID);

                if (!string.IsNullOrEmpty(mclsSalesTransactionDetails.TransactionNo))
                {
                    if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.Closed)
                    {
                        Data.SalesTransactionItems clsItems = new Data.SalesTransactionItems(clsTransactions.Connection, clsTransactions.Transaction);
                        mclsSalesTransactionDetails.TransactionItems = clsItems.Details(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TransactionDate);
                        clsTransactions.CommitAndDispose();

                        lblTransactionNo.Text = "Transaction #: " + mclsSalesTransactionDetails.TransactionNo;
                        lblTransactionNo.Tag  = mclsSalesTransactionDetails.TransactionID.ToString();
                        lblCommand.Tag        = mclsSalesTransactionDetails.TransactionDate.ToString("MM/dd/yyyy hh:mm");
                        LoadResumedItems(mclsSalesTransactionDetails.TransactionItems);
                        getTotal();

                        lblCommand.Text = "Scan item:";
                        txtScan.Text    = string.Empty;
                        txtScan.Focus();
                    }
                    else
                    {
                        clsTransactions.CommitAndDispose();
                        txtScan.Text = string.Empty;
                        txtScan.Focus();

                        MessageBox.Show("Sorry, you cannot release transaction with status: " + mclsSalesTransactionDetails.TransactionStatus.ToString("G") + ".", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    clsTransactions.CommitAndDispose();
                }
            }
            catch {  }
        }
Beispiel #7
0
        private void ReleaseTransaction()
        {
            decimal decScannedAmt = decimal.Parse(lblTotalScannedAmt.Text);

            if (mclsSalesTransactionDetails.SubTotal != decScannedAmt)
            {
                MessageBox.Show("Transaction subtotal versus scanned amount is not yet equal, you cannot release this transaction.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions();
                clsSalesTransactions.Release(long.Parse(lblTransactionNo.Tag.ToString()), mlngReleaserID, mstrReleaserName);
                clsSalesTransactions.CommitAndDispose();
                LoadOptions();
                MessageBox.Show("Transaction has been released.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Beispiel #8
0
        private void LoadData()
        {
            try
            {
                Data.SalesTransactions clsTransactions = new Data.SalesTransactions();
                System.Data.DataTable  dt = clsTransactions.ListForPaymentDataTable(mclsCustomerDetails.ContactID);

                clsTransactions.CommitAndDispose();

                this.dgStyle.MappingName = dt.TableName;
                dgItems.DataSource       = dt;

                if (dt.Rows.Count > 0)
                {
                    dgItems.Select(0);
                    dgItems.CurrentRowIndex = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #9
0
        private void LoadData()
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                Data.SalesTransactions clsTransactions = new Data.SalesTransactions();

                DateTime dteTransactionDateFrom = DateTime.TryParse(txtTrxStartDate.Text, out dteTransactionDateFrom) ? dteTransactionDateFrom : DateTime.Now.AddDays(-2);
                DateTime dteTransactionDateTo   = DateTime.TryParse(txtTrxEndDate.Text + " 23:59:59", out dteTransactionDateTo) ? dteTransactionDateTo : DateTime.Now;

                Int64 iCashierID         = TerminalDetails.ShowOneTerminalSuspendedTransactions ? mCashierID : 0;
                System.Data.DataTable dt = new System.Data.DataTable();
                if (TransactionStatusToList == RetailPlus.TransactionStatus.Closed)
                {
                    dt = clsTransactions.ListClosedDataTable(TerminalDetails.BranchID, dteTransactionDateFrom, dteTransactionDateTo);
                }
                else
                {
                    dt = clsTransactions.ListSuspendedDataTable(TerminalDetails.BranchID, TerminalDetails.TerminalNo, iCashierID, TerminalDetails.ShowOnlyPackedTransactions);
                }
                clsTransactions.CommitAndDispose();

                this.dgStyle.MappingName = dt.TableName;
                dgItems.DataSource       = dt;
                dgItems.Select(0);
                dgItems.CurrentRowIndex = 0;

                Cursor.Current = Cursors.Default;
            }
            catch (IndexOutOfRangeException) { Cursor.Current = Cursors.Default; }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(ex.Message, "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #10
0
        private void TransactionNoWnd_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            switch (e.KeyData)
            {
            case Keys.Escape:
                dialog = DialogResult.Cancel;
                this.Hide();
                break;

            case Keys.Enter:
                Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions();
                TransactionStatus      status = clsSalesTransactions.Status(txtTransactionNo.Text);
                clsSalesTransactions.CommitAndDispose();

                if (status == TransactionStatus.NotYetApplied)
                {
                    MessageBox.Show("Sorry you have entered an invalid Transaction No." +
                                    "Please type a valid Transaction No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                else if (status == TransactionStatus.Closed || status == TransactionStatus.Released || status == TransactionStatus.Refund)
                {
                    mstrTransactionNo = txtTransactionNo.Text.PadLeft(miTransactionNoLength - 1, '0');
                    mstrTerminalNo    = txtTerminalNo.Text;
                    dialog            = DialogResult.OK;
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Sorry the Transaction No. you entered is " + status.ToString("G") + ". " +
                                    "Please enter a valid Transaction No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                break;
            }
        }
Beispiel #11
0
		private void ShowCreditPaymentWindow()
		{
			if (mboIsCreditAllowed)
			{
				CreditPaymentWnd credit = new CreditPaymentWnd();
                credit.TerminalDetails = mclsTerminalDetails;
				credit.SalesTransactionDetails = mclsSalesTransactionDetails;
                credit.CustomerDetails = mclsCustomerDetails;
                credit.AllowedCredit = mdecAllowedCredit;

                decimal decBalance = Convert.ToDecimal(lblBalance.Text);
                decimal decAdditionalCreditCharge = 0;
                if (mclsCustomerDetails.CreditDetails.CreditType == CreditType.Group && mclsTerminalDetails.GroupChargeType.ChargeTypeID != 0)
                {
                    if (mclsTerminalDetails.GroupChargeType.InPercent)
                        decAdditionalCreditCharge = decBalance * (mclsTerminalDetails.GroupChargeType.ChargeAmount / 100);
                    else
                        decAdditionalCreditCharge = decBalance + mclsTerminalDetails.GroupChargeType.ChargeAmount;

                    if ((decBalance + decAdditionalCreditCharge) > mdecAllowedCredit)
                    {
                        if (mclsTerminalDetails.GroupChargeType.InPercent)
                            decAdditionalCreditCharge = mdecAllowedCredit * (mclsTerminalDetails.GroupChargeType.ChargeAmount / 100);
                        else
                            decAdditionalCreditCharge = mdecAllowedCredit + mclsTerminalDetails.GroupChargeType.ChargeAmount;
                    }
                }
                else if (mclsCustomerDetails.CreditDetails.CreditType == CreditType.Individual && mclsTerminalDetails.PersonalChargeType.ChargeTypeID != 0)
                {
                    if (mclsTerminalDetails.PersonalChargeType.InPercent)
                        decAdditionalCreditCharge = decBalance * (mclsTerminalDetails.PersonalChargeType.ChargeAmount / 100);
                    else
                        decAdditionalCreditCharge = decBalance + mclsTerminalDetails.PersonalChargeType.ChargeAmount;

                    if ((decBalance + decAdditionalCreditCharge) > mdecAllowedCredit)
                    {
                        if (mclsTerminalDetails.PersonalChargeType.InPercent)
                            decAdditionalCreditCharge = mdecAllowedCredit * (mclsTerminalDetails.PersonalChargeType.ChargeAmount / 100);
                        else
                            decAdditionalCreditCharge = mdecAllowedCredit + mclsTerminalDetails.PersonalChargeType.ChargeAmount;
                    }
                }

                credit.BalanceAmount = decBalance + Convert.ToDecimal(decAdditionalCreditCharge.ToString("#,##0.#0"));
                credit.IsRefund = mboIsRefund;
				credit.ShowDialog(this);
				DialogResult result = credit.Result;
				Data.CreditPaymentDetails creditDetails = credit.Details;
				credit.Close();
				credit.Dispose();

				if (result == DialogResult.OK)
				{
                    if (mclsCustomerDetails.CreditDetails.CreditType == CreditType.Group && mclsTerminalDetails.GroupChargeType.ChargeTypeID != 0)
                    {
                        // update transaction with additional charge
                        if (mclsTerminalDetails.GroupChargeType.InPercent)
                            decAdditionalCreditCharge = creditDetails.Amount * (mclsTerminalDetails.GroupChargeType.ChargeAmount / 100);
                        else
                            decAdditionalCreditCharge = creditDetails.Amount + mclsTerminalDetails.GroupChargeType.ChargeAmount;

                        lblCharge.Text = Convert.ToDecimal(Convert.ToDecimal(lblCharge.Text) + decAdditionalCreditCharge).ToString("#,##0.#0");
                        mclsSalesTransactionDetails.CreditChargeAmount = decAdditionalCreditCharge;
                        
                        //Aug 30, 2014 delete need to move this from here to mainwnd
                        Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions();
                        clsSalesTransactions.UpdateCreditChargeAmount(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.CreditChargeAmount);
                        clsSalesTransactions.CommitAndDispose();
                    }

                    mdecAllowedCredit -= creditDetails.Amount;
					lblAmountPaid.Text = Convert.ToDecimal(Convert.ToDecimal(lblAmountPaid.Text) + creditDetails.Amount).ToString("#,##0.#0");
					marrCreditPaymentDetails.Add(creditDetails);

                    // Add 
					ComputePayments();
					lblCredit.Tag = Convert.ToDecimal(Convert.ToDecimal(lblCredit.Tag) + creditDetails.Amount - Convert.ToDecimal(lblChange.Text)).ToString("#,##0.#0");

					if (mPaymentType == PaymentTypes.NotYetAssigned)
						mPaymentType = PaymentTypes.Credit;
					else
						mPaymentType = PaymentTypes.Combination;
				}
			}
		}
Beispiel #12
0
        public void PrintTerminalReportDetailsXRead(Data.TerminalReportDetails Details)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                Data.SysConfig clsSysConfig = new Data.SysConfig(mConnection, mTransaction);
                mConnection = clsSysConfig.Connection; mTransaction = clsSysConfig.Transaction;

                if (Int64.Parse(Details.BeginningORNo) == 0)
                    msbToPrint.Append("Beginning OR No.".PadRight(21) + ":" + (Details.BeginningORNo.Remove(Details.BeginningORNo.Length - 1) + "1").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                else
                    msbToPrint.Append("Beginning OR No.".PadRight(21) + ":" + Details.BeginningORNo.PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                msbToPrint.Append("Ending    OR No.".PadRight(21) + ":" + Details.EndingORNo.PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine + Environment.NewLine);
                msbToPrint.Append("Gross Sales".PadRight(21) + ":" + ((Details.GrossSales + Details.TotalCharge) * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("(-) Service Charge".PadRight(21) + ":" + (Details.TotalCharge * ((100 - Details.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 - Details.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 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("(-) Discount".PadRight(21) + ":" + ((Details.SubTotalDiscount + Details.ItemsDiscount) * ((100 - Details.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 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                if (mclsTerminalDetails.WillPrintGrandTotal == true)
                {
                    msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                    msbToPrint.Append("OLD GRAND TOTAL".PadRight(21) + ":" + (Details.eSalesOldGrandTotal).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                    msbToPrint.Append("This Total Amount".PadRight(21) + ":" + (Details.GrossSales * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                    msbToPrint.Append("".PadRight(21) + ":" + "------------".PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22, ' ') + Environment.NewLine);
                    msbToPrint.Append("NEW GRAND TOTAL".PadRight(21) + ":" + (Details.eSalesNewGrandTotal).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                    mclsSysConfigDetails.WillDeductTFInTerminalReport = clsSysConfig.get_WillDeductTFInTerminalReport();
                }

                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 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("VAT Zero Rated".PadRight(21) + ":" + (Details.ZeroRatedSales * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("NonVATable Amount".PadRight(21) + ":" + (Details.NonVATableAmount * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("VATable Amount".PadRight(21) + ":" + (Details.VATableAmount * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("VAT".PadRight(21) + ":" + (Details.VAT * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Local Tax".PadRight(21) + ":" + (Details.LocalTax * ((100 - Details.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 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Cheque Sales".PadRight(21) + ":" + (Details.ChequeSales * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit Card Sales".PadRight(21) + ":" + (Details.CreditCardSales * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit (Charge)".PadRight(21) + ":" + (Details.CreditSales * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit Payment".PadRight(21) + ":" + (Details.CreditPayment * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

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

                msbToPrint.Append("Debit  Sales".PadRight(21) + ":" + (Details.DebitPayment * ((100 - Details.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 - Details.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 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Refund Sales".PadRight(21) + ":" + (Details.RefundSales * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Cash".PadRight(21) + ":" + (Details.RefundCash * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Cheque".PadRight(21) + ":" + (Details.RefundCheque * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Credit Card".PadRight(21) + ":" + (Details.RefundCreditCard * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Credit".PadRight(21) + ":" + (Details.RefundCredit * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("      Debit".PadRight(21) + ":" + (Details.RefundDebit * ((100 - Details.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; // CashierID = 0 ALL
                System.Data.DataTable dt = clsSalesTransactions.SalesPerCreditCard(Details.BranchID, Details.TerminalNo, 0, Details.DateLastInitialized, Details.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 - Details.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 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("     Senior Citizen".PadRight(21) + ":" + (Details.SNRItemsDiscount * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("     PWD".PadRight(21) + ":" + (Details.PWDItemsDiscount * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("     Other".PadRight(21) + ":" + (Details.OtherItemsDiscount * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Subtotal Discount".PadRight(21) + ":" + (Details.SubTotalDiscount * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("     Senior Citizen".PadRight(21) + ":" + (Details.SNRDiscount * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("     PWD".PadRight(21) + ":" + (Details.PWDDiscount * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("     Others".PadRight(21) + ":" + (Details.OtherDiscount * ((100 - Details.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 - Details.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, Details.BeginningTransactionNo, Details.EndingTransactionNo);
                clsSalesTransactions.CommitAndDispose();
                clsSysConfig.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 - Details.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 - Details.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 - Details.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 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Cheque".PadRight(21) + ":" + (Details.ChequeDisburse * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit Card".PadRight(21) + ":" + (Details.CreditCardDisburse * ((100 - Details.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 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Cheque".PadRight(21) + ":" + (Details.ChequeWithHold * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit Card".PadRight(21) + ":" + (Details.CreditCardWithHold * ((100 - Details.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 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Cheque".PadRight(21) + ":" + (Details.ChequeDeposit * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                msbToPrint.Append("Credit Card".PadRight(21) + ":" + (Details.CreditCardDeposit * ((100 - Details.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("Misc Amount Breakdown", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                //msbToPrint.Append("-".PadRight(mclsTerminalDetails.MaxReceiptWidth, '-') + Environment.NewLine);
                //msbToPrint.Append("Consignment".PadRight(21) + ":" + (Details.ConsignmentSales * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                //msbToPrint.Append("Walk-In".PadRight(21) + ":" + (Details.WalkInSales * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                //msbToPrint.Append("Out Of Stock".PadRight(21) + ":" + (Details.OutOfStockSales * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                //msbToPrint.Append("      Refund:" + Environment.NewLine);
                //msbToPrint.Append("Consignment".PadRight(21) + ":" + (Details.ConsignmentRefundSales * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                //msbToPrint.Append("Walk-In".PadRight(21) + ":" + (Details.WalkInRefundSales * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);
                //msbToPrint.Append("Out Of Stock".PadRight(21) + ":" + (Details.OutOfStockRefundSales * ((100 - Details.TrustFund) / 100)).ToString("#,##0.#0").PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22) + Environment.NewLine);

                //msbToPrint.Append("".PadRight(21) + ":" + "------------".PadLeft(mclsTerminalDetails.MaxReceiptWidth - 22, ' ') + 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 StockTrans".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);
            }
            catch (Exception ex)
            {
                InsertErrorLogToFile(ex, "ERROR!!! Printing terminal report details. Err Description: ");
            }
            Cursor.Current = Cursors.Default;
        }
Beispiel #13
0
        public void PrintOfficialReceipt()
        {
            try
            {
                CRSReports.OR rpt = new CRSReports.OR();

                AceSoft.RetailPlus.Client.ReportDataset rptds = new AceSoft.RetailPlus.Client.ReportDataset();
                System.Data.DataRow drNew;

                /****************************report logo *****************************/
                try
                {
                    System.IO.FileStream fs = new System.IO.FileStream(Application.StartupPath + "/images/ReportLogo.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read);
                    System.IO.FileInfo fi = new System.IO.FileInfo(Application.StartupPath + "/images/ReportLogo.jpg");

                    byte[] propimg = new byte[fi.Length];
                    fs.Read(propimg, 0, Convert.ToInt32(fs.Length));
                    fs.Close();

                    drNew = rptds.CompanyLogo.NewRow(); drNew["Picture"] = propimg;
                    rptds.CompanyLogo.Rows.Add(drNew);
                }
                catch { }

                /****************************sales transaction *****************************/
                Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                Data.SalesTransactionDetails clsSalesTransactionDetails = clsSalesTransactions.Details(mclsSalesTransactionDetails.TransactionNo, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID);

                Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction);
                mConnection = clsContact.Connection; mTransaction = clsContact.Transaction;

                Data.ContactDetails clsContactDetails = clsContact.Details(clsSalesTransactionDetails.CustomerID);

                if (clsSalesTransactionDetails.isExist)
                {
                    /****************************sales transaction details*****************************/
                    drNew = rptds.Transactions.NewRow();

                    drNew["TransactionID"] = clsSalesTransactionDetails.TransactionID;
                    drNew["TransactionNo"] = clsSalesTransactionDetails.TransactionNo;
                    drNew["ORNo"] = clsSalesTransactionDetails.ORNo;
                    drNew["CustomerName"] = clsSalesTransactionDetails.CustomerName;
                    drNew["CustomerAddress"] = clsContactDetails.Address;
                    drNew["CustomerTerms"] = clsSalesTransactionDetails.Terms;
                    drNew["CustomerModeOfterms"] = clsSalesTransactionDetails.ModeOfTerms;
                    drNew["CustomerBusinessName"] = clsContactDetails.BusinessName;
                    drNew["CustomerTelNo"] = clsContactDetails.TelephoneNo;
                    drNew["CashierName"] = clsSalesTransactionDetails.CashierName;
                    drNew["CreatedByName"] = clsSalesTransactionDetails.CreatedByName;
                    drNew["AgentName"] = clsSalesTransactionDetails.AgentName;
                    drNew["TerminalNo"] = clsSalesTransactionDetails.TerminalNo;
                    drNew["TransactionDate"] = clsSalesTransactionDetails.TransactionDate;
                    drNew["DateSuspended"] = clsSalesTransactionDetails.DateSuspended.ToString();
                    drNew["DateResumed"] = clsSalesTransactionDetails.DateResumed;
                    drNew["TransactionStatus"] = clsSalesTransactionDetails.TransactionStatus;
                    drNew["SubTotal"] = clsSalesTransactionDetails.SubTotal;
                    drNew["ItemsDiscount"] = clsSalesTransactionDetails.ItemsDiscount;
                    //drNew["SNRItemsDiscount"] = clsSalesTransactionDetails.SNRItemsDiscount;
                    //drNew["PWDItemsDiscount"] = clsSalesTransactionDetails.PWDItemsDiscount;
                    //drNew["OtherItemsDiscount"] = clsSalesTransactionDetails.OtherItemsDiscount;
                    drNew["Discount"] = clsSalesTransactionDetails.Discount;
                    drNew["VAT"] = clsSalesTransactionDetails.VAT;
                    drNew["VATableAmount"] = clsSalesTransactionDetails.VATableAmount;
                    //drNew["ZeroRatedSales"] = clsSalesTransactionDetails.ZeroRatedSales;
                    drNew["LocalTax"] = clsSalesTransactionDetails.LocalTax;
                    drNew["AmountPaid"] = clsSalesTransactionDetails.AmountPaid;
                    drNew["CashPayment"] = clsSalesTransactionDetails.CashPayment;
                    drNew["ChequePayment"] = clsSalesTransactionDetails.ChequePayment;
                    drNew["CreditCardPayment"] = clsSalesTransactionDetails.CreditCardPayment;
                    drNew["CreditPayment"] = clsSalesTransactionDetails.CreditPayment;
                    drNew["DebitPayment"] = clsSalesTransactionDetails.DebitPayment;
                    drNew["BalanceAmount"] = clsSalesTransactionDetails.BalanceAmount;
                    drNew["ChangeAmount"] = clsSalesTransactionDetails.ChangeAmount;
                    drNew["DateClosed"] = clsSalesTransactionDetails.DateClosed;
                    drNew["PaymentType"] = clsSalesTransactionDetails.PaymentType.ToString("d");
                    drNew["Charge"] = clsSalesTransactionDetails.Charge;
                    drNew["isConsignment"] = clsSalesTransactionDetails.isConsignment;
                    drNew["CRNo"] = clsSalesTransactionDetails.CRNo;

                    rptds.Transactions.Rows.Add(drNew);

                    /****************************sales transaction items*****************************/
                    Data.SalesTransactionItems clsSalesTransactionItems = new Data.SalesTransactionItems(mConnection, mTransaction);
                    mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                    System.Data.DataTable dt = clsSalesTransactionItems.List(clsSalesTransactionDetails.TransactionID, clsSalesTransactionDetails.TransactionDate, "TransactionItemsID", SortOption.Ascending);

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

                        foreach (System.Data.DataColumn dc in rptds.SalesTransactionItems.Columns)
                            drNew[dc] = dr[dc.ColumnName];

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

                clsSalesTransactions.CommitAndDispose();

                rpt.SetDataSource(rptds);

                CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition paramField;
                CrystalDecisions.Shared.ParameterValues currentValues;
                CrystalDecisions.Shared.ParameterDiscreteValue discreteParam;

                paramField = rpt.DataDefinition.ParameterFields["CompanyName"];
                discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue();
                discreteParam.Value = CompanyDetails.CompanyName;
                currentValues = new CrystalDecisions.Shared.ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                paramField = rpt.DataDefinition.ParameterFields["PrintedBy"];
                discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue();
                discreteParam.Value = mclsSalesTransactionDetails.CashierName;
                currentValues = new CrystalDecisions.Shared.ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                paramField = rpt.DataDefinition.ParameterFields["PackedBy"];
                discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue();
                discreteParam.Value = mclsSalesTransactionDetails.WaiterName; // grpItems.Text.Remove(0, 11);
                currentValues = new CrystalDecisions.Shared.ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                paramField = rpt.DataDefinition.ParameterFields["CompanyAddress"];
                discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue();
                discreteParam.Value = CompanyDetails.Address1 +
                        ((!string.IsNullOrEmpty(CompanyDetails.Address2) ? Environment.NewLine + CompanyDetails.Address2 + ", " : " ")) +
                        CompanyDetails.City + " " + CompanyDetails.Country +
                        ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "Tel #: " + CompanyDetails.OfficePhone + " " : " ")) +
                        ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "FaxPhone #: " + CompanyDetails.FaxPhone + " " : " "));
                currentValues = new CrystalDecisions.Shared.ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                paramField = rpt.DataDefinition.ParameterFields["BIRInfo"];
                discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue();
                discreteParam.Value = "TIN : " + CompanyDetails.TIN + "      VAT Reg." +
                                        Environment.NewLine + "BIR Acc #: " + CONFIG.AccreditationNo + " SN#: " + CONFIG.MachineSerialNo +
                                        Environment.NewLine + "Permit No: FP102014-064-0015149-00000";
                currentValues = new CrystalDecisions.Shared.ParameterValues();
                currentValues.Add(discreteParam);
                paramField.ApplyCurrentValues(currentValues);

                //foreach (CrystalDecisions.CrystalReports.Engine.ReportObject objPic in rpt.Section1.ReportObjects)
                //{
                //    if (objPic.Name.ToUpper() == "PICLOGO1")
                //    {
                //        objPic = new Bitmap(Application.StartupPath + "/images/ReportLogo.jpg");
                //    }
                //}

                //CRViewer.Visible = true;
                //CRViewer.ReportSource = rpt;
                //CRViewer.Show();

                try
                {
                    DateTime logdate = DateTime.Now;
                    string logsdir = System.Configuration.ConfigurationManager.AppSettings["logsdir"].ToString();

                    if (!Directory.Exists(logsdir + logdate.ToString("MMM")))
                    {
                        Directory.CreateDirectory(logsdir + logdate.ToString("MMM"));
                    }
                    string logFile = logsdir + logdate.ToString("MMM") + "/OR_" + clsSalesTransactionDetails.TransactionNo + logdate.ToString("yyyyMMddhhmmss") + ".doc";

                    rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, logFile);
                }
                catch { }

                if (isPrinterOnline(mclsTerminalDetails.SalesInvoicePrinterName))
                {
                    rpt.PrintOptions.PrinterName = mclsTerminalDetails.SalesInvoicePrinterName;
                    rpt.PrintToPrinter(1, false, 0, 0);
                }
                else
                {
                    clsEvent.AddEventLn("will not print sales invoice. printer is offline.", true, mclsSysConfigDetails.WillWriteSystemLog);
                }

                rpt.Close();
                rpt.Dispose();
            }
            catch (Exception ex)
            {
                InsertErrorLogToFile(ex);
                MessageBox.Show("Sorry an error was encountered during printing, please reprint again." + Environment.NewLine + "Details: " + ex.Message, "RetailPlus");
            }
        }
Beispiel #14
0
        public Int64 AddItemToDB(Data.SalesTransactionItemDetails Details)
        {
            try
            {
                Details.TransactionID = mclsSalesTransactionDetails.TransactionID;
                Details.TransactionDate = mclsSalesTransactionDetails.TransactionDate;

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

                Int64 TransactionItemsID = clsSalesTransactions.AddItem(mclsSalesTransactionDetails, Details);
                clsSalesTransactions.CommitAndDispose();

                Details.TransactionItemsID = TransactionItemsID;
                clsEvent.AddEventLn("Adding item no: " + Details.ItemNo + " Barcode".PadRight(15) + ":" + Details.BarCode + " ProductCode".PadRight(15) + ":" + Details.ProductCode + " Price".PadRight(15) + ":" + Details.Price, true);

                return TransactionItemsID;
            }
            catch (Exception ex)
            {
                InsertErrorLogToFile(ex, "ERROR!!! Adding sales item to database. TRACE: ");
                throw ex;
            }
        }
Beispiel #15
0
        private void TransactionNoWnd_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            switch (e.KeyData)
            {
                case Keys.Escape:
                    dialog = DialogResult.Cancel;
                    this.Hide();
                    break;

                case Keys.Enter:
                    if (string.IsNullOrEmpty(txtTerminalNo.Text))
                    {
                        MessageBox.Show("Sorry please enter a valid TerminalNo.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    if (string.IsNullOrEmpty(txtTransactionNo.Text))
                    {
                        MessageBox.Show("Sorry please enter a valid TransactionNo.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions();
                    TransactionStatus status = clsSalesTransactions.Status(txtTransactionNo.Text, txtTerminalNo.Text);
                    clsSalesTransactions.CommitAndDispose();

                    switch (status)
	                {
                        case TransactionStatus.Closed:
                        case TransactionStatus.Reprinted:
                        case TransactionStatus.Refund:
                        case TransactionStatus.CreditPayment:
                        case TransactionStatus.DebitPayment:
                        case TransactionStatus.Released:
                        case TransactionStatus.ParkingTicket:

                        case TransactionStatus.ClosedWalkIn:
                        case TransactionStatus.ClosedOutOfStock:
                        case TransactionStatus.Consignment:
                        case TransactionStatus.ClosedWalkInRefund:
                        case TransactionStatus.ClosedOutOfStockRefund:
                        case TransactionStatus.ConsignmentRefund:
                            mstrTransactionNo = txtTransactionNo.Text.PadLeft(miTransactionNoLength - 1, '0');
                            mstrTerminalNo = txtTerminalNo.Text;
                            dialog = DialogResult.OK;
                            this.Hide();
                            break;
                        case TransactionStatus.Open:
                        case TransactionStatus.NotYetApplied:
                        
                            MessageBox.Show("Sorry you have entered an invalid Transaction No. Please type a valid Transaction No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            break;
                        case TransactionStatus.Void:
                        case TransactionStatus.CancelledCreditPayment:
                        case TransactionStatus.Suspended:
                        case TransactionStatus.SuspendedOpen:
                        case TransactionStatus.OrderSlip:
                        default:
                            MessageBox.Show("Sorry the Transaction No. you entered is " + status.ToString("G") + ". " +
                            "Please enter a valid Transaction No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            break;
	                }
                    //if (status == TransactionStatus.NotYetApplied)
                    //{
                    //    MessageBox.Show("Sorry you have entered an invalid Transaction No. Please type a valid Transaction No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    //    return;
                    //}
                    //else if (status == TransactionStatus.Closed || 
                    //        status == TransactionStatus.Released || status == TransactionStatus.Refund || status == TransactionStatus.CreditPayment)
                    //{
                    //    mstrTransactionNo = txtTransactionNo.Text.PadLeft(miTransactionNoLength - 1, '0');
                    //    mstrTerminalNo = txtTerminalNo.Text;
                    //    dialog = DialogResult.OK;
                    //    this.Hide();
                    //}
                    //else
                    //{
                    //    MessageBox.Show("Sorry the Transaction No. you entered is " + status.ToString("G") + ". " +
                    //        "Please enter a valid Transaction No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    //    return;
                    //}
                    break;
            }
        }
Beispiel #16
0
        private void LoadTransaction(string stTransactionNo, string pstrTerminalNo)
		{
			Cursor.Current = Cursors.WaitCursor;
			try
			{
				clsEvent.AddEvent("Loading transaction : " + stTransactionNo);

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

				mclsSalesTransactionDetails = clsSalesTransactions.Details(stTransactionNo, pstrTerminalNo, mclsTerminalDetails.BranchID);

                if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.Open ||
                    mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.Suspended)
                {
                    // Aug 6, 2011 : Lemu
                    // overwrite to change cashierid and name
                    try { mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag); }
                    catch { }
                    mclsSalesTransactionDetails.CashierName = lblCashier.Text;

                    // Jan 31, 2015 : Lemu
                    // put to SuspendedOpen so that it won't be open somewhere else
                    if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.Suspended)
                    {
                        clsEvent.AddEvent("Putting transaction SuspendedOpen: " + stTransactionNo, true);
                        clsSalesTransactions.UpdateTransactionToSuspendedOpen(mclsSalesTransactionDetails.TransactionID);
                    }
                }

				Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction);
				Data.ContactDetails clsContactDetails = clsContact.Details(mclsSalesTransactionDetails.CustomerID);
				LoadContact(AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER, clsContactDetails);

				//mclsSalesTransactionDetails.RewardCardNo = clsContactDetails.RewardDetails.RewardCardNo;
				//mclsSalesTransactionDetails.RewardCardExpiry = clsContactDetails.RewardDetails.ExpiryDate;
				//mclsSalesTransactionDetails.RewardPreviousPoints = clsContactDetails.RewardDetails.RewardPoints;

                if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.Refund || mclsSalesTransactionDetails.TransactionType == TransactionTypes.POSRefund)
				{
					mboIsRefund = true;
					lblSubtotalName.Text = "SUBTOTAL: REFUND";
					lblOrderType.Visible = false;
				}
				lblTransNo.Text = mclsSalesTransactionDetails.TransactionNo;
				lblTransNo.Tag = mclsSalesTransactionDetails.TransactionID.ToString();
				lblCustomer.Text = mclsSalesTransactionDetails.CustomerName;
				lblCustomer.Tag = mclsSalesTransactionDetails.CustomerID.ToString();
				lblAgent.Text = mclsSalesTransactionDetails.AgentName;
				lblAgent.Tag = mclsSalesTransactionDetails.AgentID.ToString();
				lblAgentPositionDepartment.Text = mclsSalesTransactionDetails.AgentPositionName;
				lblAgentPositionDepartment.Tag = mclsSalesTransactionDetails.AgentDepartmentName;
				grpItems.Text = "Served by: " + mclsSalesTransactionDetails.WaiterName;
				grpItems.Tag = mclsSalesTransactionDetails.WaiterID;

				lblTransDate.Text = mclsSalesTransactionDetails.TransactionDate.ToString("MMM. dd, yyyy hh:mm:ss tt");
                mdteOverRidingPrintDate = mclsSalesTransactionDetails.TransactionDate;

				lblTransDiscount.Tag = mclsSalesTransactionDetails.TransDiscountType.ToString("d");
                lblConsignment.Visible = mclsSalesTransactionDetails.isConsignment;

                //mclsSalesTransactionDetails.ChargeAmount = mclsSalesTransactionDetails.ChargeAmount;
                if (mclsSalesTransactionDetails.ChargeAmount == 0)
                    lblTransCharge.Tag = ChargeTypes.NotApplicable.ToString("d"); //details.TransDiscountType.ToString("d");
                else
                {
                    //lblTransCharge.Tag = ChargeTypes.Percentage.ToString("d"); //details.TransDiscountType.ToString("d");
                    Data.ChargeType clsChargeType = new Data.ChargeType(mConnection, mTransaction);
                    bool bolInPercent = clsChargeType.Details(mclsSalesTransactionDetails.ChargeCode).InPercent;
                    clsChargeType.CommitAndDispose();

                    if (bolInPercent)
                        lblTransCharge.Tag = ChargeTypes.Percentage.ToString("d");
                    else
                        lblTransCharge.Tag = ChargeTypes.FixedValue.ToString("d");
                }

				Data.SalesTransactionItems clsItems = new Data.SalesTransactionItems(mConnection, mTransaction);
                mConnection = clsItems.Connection; mTransaction = clsItems.Transaction;

				Data.SalesTransactionItemDetails[] TransactionItems = clsItems.Details(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TransactionDate);

				clsEvent.AddEventLn("Done loading transaction : " + stTransactionNo, true);

                if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto)
					LoadResumedItems(TransactionItems, true);
				else
					LoadResumedItems(TransactionItems, false);

				mboIsInTransaction = true;

                clsSalesTransactions.CommitAndDispose();
			}
			catch (Exception ex)
			{
				InsertErrorLogToFile(ex, "ERROR!!! Loading transaction. TRACE: ");
			}
			Cursor.Current = Cursors.Default;
		}
Beispiel #17
0
		private void ApplyTransDiscount()
		{
			if (ItemDataTable.Rows.Count <= 0) return;

			if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto && mboIsInTransaction)
			{
				MessageBox.Show("Sorry you cannot apply a transaction discount if Auto-print is ON an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				return;
			}
			DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.ApplyTransDiscount);

			if (loginresult == DialogResult.OK)
			{
				//mboIsDiscountAuthorized = true;
				try
				{
					clsEvent.AddEvent("[" + lblCashier.Text + "] Applying transaction discount for trans. no. " + lblTransNo.Text);

				Back:
					DiscountTypes TransDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), lblTransDiscount.Tag.ToString());
					DiscountWnd discount = new DiscountWnd();
					discount.Header = "Apply Transaction Discount"; 
					discount.BalanceAmount = mclsSalesTransactionDetails.SubTotal;
					discount.DiscountType = TransDiscountType;
					discount.DiscountAmount = mclsSalesTransactionDetails.TransDiscount;
					discount.DiscountCode = mclsSalesTransactionDetails.DiscountCode;
					discount.Remarks = mclsSalesTransactionDetails.DiscountRemarks;
					discount.IsDiscountEditable = mclsTerminalDetails.IsDiscountEditable;
                    discount.TerminalDetails = mclsTerminalDetails;
                    //discount.DisableVATExempt = false;
					discount.ShowDialog(this);
					DialogResult result = discount.Result;
					decimal DiscountAmount = discount.DiscountAmount;
					string TransDiscountCode = discount.DiscountCode;
					string TransDiscountRemarks = discount.Remarks;
					TransDiscountType = discount.DiscountType;
					discount.Close();
					discount.Dispose();

					if (result == DialogResult.OK)
					{
                        if (mclsSalesTransactionDetails.ItemsDiscount > 0)
                        {
                            MessageBox.Show("Sorry you cannot use the Senior Citizen, another discount is already applied to an item. Please separate the transaction for items with senior citizen discount.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                            return;
                        }

						int iCurrentSelectedRow = dgItems.CurrentRowIndex;

						Cursor.Current = Cursors.WaitCursor;
						if (!mboIsInTransaction) //false ito
						{
							this.LoadOptions();
							if (!this.CreateTransaction()) return;
						}

						decimal OldDiscount = mclsSalesTransactionDetails.TransDiscount;
						string OldTransDiscountType = lblTransDiscount.Tag.ToString();

						if (TransDiscountType == DiscountTypes.NotApplicable)
						{
							lblTransDiscount.Text = "Less 0% / 0.00";
						}
						lblTransDiscount.Tag = TransDiscountType.ToString("d");
						mclsSalesTransactionDetails.TransDiscountType = TransDiscountType;
						mclsSalesTransactionDetails.TransDiscount = DiscountAmount;
						mclsSalesTransactionDetails.DiscountCode = TransDiscountCode;
						mclsSalesTransactionDetails.DiscountRemarks = TransDiscountRemarks;

						ComputeSubTotal(); setTotalDetails();

						if (mclsSalesTransactionDetails.Discount <= mclsSalesTransactionDetails.DiscountableAmount)
						{
							Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                            mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                            clsSalesTransactions.UpdateSubTotal(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.GrossSales, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.NetSales, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.SNRDiscount, mclsSalesTransactionDetails.PWDDiscount, mclsSalesTransactionDetails.OtherDiscount, mclsSalesTransactionDetails.TransDiscount, mclsSalesTransactionDetails.TransDiscountType, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, mclsSalesTransactionDetails.DiscountCode, mclsSalesTransactionDetails.DiscountRemarks, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.ChargeAmount, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.ChargeType);
                            clsSalesTransactions.CommitAndDispose();

                            InsertAuditLog(AccessTypes.Discounts, "Apply transaction discount for " + mclsSalesTransactionDetails.Discount.ToString("#,###.#0") + ". Tran. #".PadRight(15) + ":" + lblTransNo.Text + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
						}
						else
						{
							MessageBox.Show("Sorry the input discount will yield a less than ZERO amount. Please type another discount.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
							mclsSalesTransactionDetails.TransDiscount = OldDiscount;
							lblTransDiscount.Tag = OldTransDiscountType;

							ComputeSubTotal(); setTotalDetails();
							goto Back;
						}
						dgItems.Select(iCurrentSelectedRow);
						clsEvent.AddEventLn("Done! " + mclsSalesTransactionDetails.DiscountCode + " amount=" + mclsSalesTransactionDetails.Discount.ToString("#,###.#0"), true);
					}
					else { clsEvent.AddEventLn("Cancelled!"); }
				}
				catch (Exception ex)
				{ 
                    InsertErrorLogToFile(ex, "ERROR!!! Applying transaction discount."); 
                }
				Cursor.Current = Cursors.Default;
			}
		}
Beispiel #18
0
		private void CloseTransactionAsOrderSlip()
		{
			if (!mboIsInTransaction)
			{
				MessageBox.Show("No active transaction found.", "RetailPlus", MessageBoxButtons.OK);
				return;
			}

			// Feb 13, 2009
			// overwrite cashierid and cashiername that will close the transaction
			// Aug 6, 2011 : Lemu
			// Remove this and put in ResumeTransaction 
			//try { mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag); }
			//catch { }
			//mclsSalesTransactionDetails.CashierName = lblCashier.Text;
			DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.CloseTransaction);

			if (loginresult == DialogResult.OK)
			{
				try
				{
					clsEvent.AddEventLn("[" + lblCashier.Text + "] Closing as order slip transaction no. " + lblTransNo.Text, true);


					// start a connection for the database.
					//update the transaction table 
					Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                    mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

					clsSalesTransactions.CloseAsOrderSlip(mclsSalesTransactionDetails.TransactionID);

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

                    clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE);

                    clsSalesTransactions.CommitAndDispose();

					InsertAuditLog(AccessTypes.CloseTransaction, "Close transaction #: " + lblTransNo.Text + "... Subtotal: " + mclsSalesTransactionDetails.SubTotal.ToString("#,###.#0") + " Discount: " + mclsSalesTransactionDetails.Discount.ToString("#,###.#0") + " AmountPaid: " + mclsSalesTransactionDetails.AmountPaid.ToString("#,###.#0") + " CashPayment: " + 0.ToString("#,###.#0") + " ChequePayment: " + 0.ToString("#,###.#0") + " CreditCardPayment: " + 0 + " CreditPayment: " + 0.ToString("#,###.#0") + " DebitPayment: " + 0.ToString("#,###.#0") + " ChangeAmount: " + 0.ToString("#,###.#0") + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
					
                    clsEvent.AddEventLn("Done! Transaction no. " + lblTransNo.Text + " has been closed as order slip. Subtotal: " + mclsSalesTransactionDetails.SubTotal.ToString("#,###.#0") + " Discount: " + mclsSalesTransactionDetails.Discount.ToString("#,###.#0") + " AmountPaid: " + mclsSalesTransactionDetails.AmountPaid.ToString("#,###.#0") + " CashPayment: " + 0.ToString("#,###.#0") + " ChequePayment: " + 0.ToString("#,###.#0") + " CreditCardPayment: " + 0 + " CreditPayment: " + 0.ToString("#,###.#0") + " DebitPayment: " + 0.ToString("#,###.#0") + " ChangeAmount: " + 0.ToString("#,###.#0"), true);
                    this.LoadOptions();

					MessageBox.Show("Transaction has been closed as ORDER SLIP.", "RetailPlus", MessageBoxButtons.OK);
				}
				catch (Exception ex)
				{
					InsertErrorLogToFile(ex, "ERROR!!! Closing transaction as ORDER SLIP.");
				}
			}
			Cursor.Current = Cursors.Default;
		}
Beispiel #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;
				}
			}
		}
Beispiel #20
0
		private void VoidItem()
		{
			Data.SalesTransactionItemDetails Details;

			int iRow = dgItems.CurrentRowIndex;

			if (iRow >= 0)
			{
				if (dgItems[iRow, 8].ToString() != "VOID")
				{
					DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.VoidItem);

					if (loginresult == DialogResult.OK)
					{
						if (mclsTerminalDetails.ItemVoidConfirmation)
						{
							if (MessageBox.Show("Are you sure you want to void this item?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
							{
								return;
							}
						}

                        Details = getCurrentRowItemDetails();
                        clsEvent.AddEvent("[" + lblCashier.Text + "] Voiding item no. " + Details.ItemNo + "".PadRight(15) + ":" + Details.Description + ".");
						try
						{
							// override the transaction item status
							TransactionItemStatus _previousTransactionItemStatus = Details.TransactionItemStatus;

							Details.TransactionItemStatus = TransactionItemStatus.Void;

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

							clsSalesTransactions.VoidItem(Details.TransactionItemsID, mclsSalesTransactionDetails.TransactionDate);
                            clsEvent.AddEventLn("Voiding item #: " + Details.ItemNo + "".PadRight(15) + ":" + Details.Description + ".", true);

							// Added May 7, 2011 to Cater Reserved and Commit functionality    
							ReservedAndCommitItem(Details, _previousTransactionItemStatus);
                            clsSalesTransactions.CommitAndDispose();

                            InsertAuditLog(AccessTypes.VoidItem, "Voiding item #: " + Details.ItemNo + "".PadRight(15) + ":" + Details.Description + "." + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);

							dgItems[iRow, 8] = "VOID";
							dgItems[iRow, 9] = "0.00";
							dgItems[iRow, 10] = "0.00";
							dgItems[iRow, 11] = "0.00";
							dgItems[iRow, 13] = "0.00";
                            dgItems[iRow, 21] = TransactionItemStatus.Void.ToString("d");

							SetItemDetails();
							
							clsEvent.AddEventLn("Done!", true);
							
							ComputeSubTotal(); setTotalDetails();

							try
							{
								DisplayItemToTurretDelegate DisplayItemToTurretDel = new DisplayItemToTurretDelegate(DisplayItemToTurret);
								DisplayItemToTurretDel.BeginInvoke("VOID-" + Details.ProductCode, Details.ProductUnitCode, Details.Quantity, Details.Price, Details.Discount, Details.PromoApplied, Details.Amount, Details.VAT, Details.EVAT, null, null);
							}
							catch { }
							if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto)
							{
								PrintItemDelegate PrintItemDel = new PrintItemDelegate(PrintItem);
                                PrintItemDel.BeginInvoke(Details.ItemNo, Details.ProductCode + " - VOID ", Details.ProductUnitCode, Details.Quantity, Details.Price, Details.Discount, Details.PromoApplied, Details.Amount, Details.VAT, Details.EVAT, Details.DiscountCode, Details.ItemDiscountType, null, null);
								//PrintItemDel.BeginInvoke(Details.ProductCode + " - VOID ", Details.ProductUnitCode, Details.Quantity, Details.Price, Details.Discount, Details.PromoApplied, Details.Amount, Details.VAT, Details.EVAT, null, null);
							}

						}
						catch (Exception ex)
						{
                            InsertErrorLogToFile(ex, "ERROR!!! Voiding item." + Details.ItemNo + "".PadRight(15) + ":" + Details.Description); 
                        }
					}
				}
			}
		}
Beispiel #21
0
		private void VoidTransaction()
		{
			if (!mboIsInTransaction)
			{
				MessageBox.Show("Sorry you cannot void an empty transaction.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				return;
			}

			if (MessageBox.Show("Are you sure you want to void this transaction?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
			{
				return;
			}

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

			if (loginresult == DialogResult.OK)
			{
				try
				{
					clsEvent.AddEventLn("[" + lblCashier.Text + "] Voiding transaction no. " + lblTransNo.Text, true);

                    mclsSalesTransactionDetails.TransactionStatus = TransactionStatus.Void;

					if (mclsTerminalDetails.AutoPrint == PrintingPreference.AskFirst)
						if (MessageBox.Show("Would you like to print this transaction?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, (mclsSysConfigDetails.isDefaultButtonYesInPrintTransaction ? MessageBoxDefaultButton.Button1 : MessageBoxDefaultButton.Button2)) == DialogResult.Yes)
							mclsTerminalDetails.AutoPrint = PrintingPreference.Normal;

                    // Sep 14, 2014 Control printing in mclsFilePrinter.Write
                    //if (mclsTerminalDetails.AutoPrint == PrintingPreference.Normal) 
                    //{
						//if (mclsTerminalDetails.IsPrinterAutoCutter)
						//    PrintReportPageHeaderSectionChecked(true);
						//else
							PrintReportHeadersSection(true);

						mboIsItemHeaderPrinted = true;

						foreach (System.Data.DataRow dr in ItemDataTable.Rows)
						{
                            string stItemNo = "" + dr["ItemNo"].ToString();
							string stProductUnitCode = "" + dr["ProductUnitCode"].ToString();
							decimal decPrice = Convert.ToDecimal(dr["Price"]);
							decimal decDiscount = Convert.ToDecimal(dr["Discount"]);
							decimal decAmount = Convert.ToDecimal(dr["Amount"]);
							decimal decVAT = Convert.ToDecimal(dr["VAT"]);
							decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
							decimal decPromoApplied = Convert.ToDecimal(dr["PromoApplied"]);
							string stProductCode = "";
							decimal decQuantity = 0;
                            string stDiscountCode = "" + dr["DiscountCode"].ToString();
                            DiscountTypes ItemDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["ItemDiscountType"].ToString());

							if (dr["Quantity"].ToString().IndexOf("RETURN") != -1)
							{
								stProductCode = "" + dr["ProductCode"].ToString() + "-RET";
								decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - RETURN", "").Trim());
								decAmount = -decAmount;
							}
                            else if (dr["Quantity"].ToString().IndexOf("DEMO") != -1)
                            {
                                stProductCode = "" + dr["ProductCode"].ToString() + "-DEMO";
                                decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - DEMO", "").Trim());
                                decAmount = 0;
                            }
							else if (dr["Quantity"].ToString() != "VOID")
							{
								stProductCode = "" + dr["ProductCode"].ToString();
								decQuantity = Convert.ToDecimal(dr["Quantity"]);
							}
                            if (dr["Quantity"].ToString().IndexOf("VOID") != -1)
                            {
                                if (mclsTerminalDetails.WillPrintVoidItem)
                                    if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default)
                                        PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType);
                            }
                            else
                            {
                                if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default)
                                    PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType);
                            }
								
                        //}
                        // Sep 14, 2014 Control printing in mclsFilePrinter.Write
					}

					Cursor.Current = Cursors.WaitCursor;

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

					// Added May 7, 2011 to Cater Reserved and Commit functionality    
					#region Reserved And Commit
                    //if (mclsTerminalDetails.ReservedAndCommit == true)
                    //{
						System.Data.DataTable dt = (System.Data.DataTable)dgItems.DataSource;
						for (int x = 0; x < dt.Rows.Count; x++)
						{
							dgItems.CurrentRowIndex = x;
							Data.SalesTransactionItemDetails Details = getCurrentRowItemDetails();

                            if (Details.TransactionItemStatus != TransactionItemStatus.Void)
                            {
                                Details.TransactionItemStatus = TransactionItemStatus.Void;
                                ReservedAndCommitItem(Details, Details.TransactionItemStatus);
                            }
						}
                    //}
					#endregion

					//UpdateTerminalReportDelegate updateterminalDel = new UpdateTerminalReportDelegate(UpdateTerminalReport);
                        UpdateTerminalReport(TransactionStatus.Void, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, 0, 0, 0, 0, 0, 0, 0, PaymentTypes.NotYetAssigned);

					//UpdateCashierReportDelegate updatecashierDel = new UpdateCashierReportDelegate(UpdateCashierReport);
                        UpdateCashierReport(TransactionStatus.Void, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, 0, 0, 0, 0, 0, 0, 0, PaymentTypes.NotYetAssigned);

                        clsSalesTransactions.Void(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.GrossSales, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.NetSales, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.SNRDiscount, mclsSalesTransactionDetails.PWDDiscount, mclsSalesTransactionDetails.OtherDiscount, mclsSalesTransactionDetails.TransDiscount, mclsSalesTransactionDetails.TransDiscountType, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.CashierID, mclsSalesTransactionDetails.CashierName);
					
                    clsSalesTransactions.UpdateTerminalNo(mclsSalesTransactionDetails.TransactionID, lblTerminalNo.Text);

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

                    clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE);

                    // 22Nov2014 : remove the merge tables when closed or void
                    RemoveFromMergeTable(mclsSalesTransactionDetails.CustomerDetails.ContactCode);

                    try
                    {
                        clsSalesTransactions.CommitAndDispose();
                    }
                    catch
                    {
                        mclsSalesTransactionDetails.TransactionStatus = TransactionStatus.Open;
                    }

                    InsertAuditLog(AccessTypes.VoidTransaction, "VOID transaction #".PadRight(15) + ":" + lblTransNo.Text + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);

					clsEvent.AddEventLn("Done transaction no. " + lblTransNo.Text + " has been void.", true);

					if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default)
					{
						PrintReportFooterSection(true, TransactionStatus.Void, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.Charge, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, null, null, null);
					}
					else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice)
					{
						PrintSalesInvoice();
					}
					else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt)
					{
						PrintDeliveryReceipt();
					}
					else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR)
					{
						PrintSalesInvoice();
						PrintDeliveryReceipt();
					}
                    //Added April 12, 2014
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.OfficialReceiptAndDR)
                    {
                        PrintOfficialReceipt();
                        PrintDeliveryReceipt();
                    }
					//Added February 10, 2010
					else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300Printer)
					{
						PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300Printer);
					}
					//Added May 11, 2010
					else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceOrDR)
					{
						PrintDeliveryReceipt();
					}
					//Added January 17, 2011
					else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300PlusPrinter)
					{
						PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300PlusPrinter);
					}
					//Added February 22, 2011
					else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300PlusAmazon)
					{
						PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300PlusAmazon); //8.5inc x 7inch
					}

                    this.LoadOptions();

					MessageBox.Show("Transaction has been VOID. Press OK button to continue...", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
					Cursor.Current = Cursors.Default;
				}
				catch (Exception ex)
				{ 
                    InsertErrorLogToFile(ex, "ERROR!!! Voiding transaction."); 
                }
			}
		}
Beispiel #22
0
		private void ResumeTransaction()
		{
            if (!SuspendTransactionAndContinue()) return;

            // ShowOneTerminalSuspendedTransactions 
            // Only same cashier in same terminal can be resume.
            // if terminalno and cashier is not the same to not allow   
			if (mclsTerminalDetails.ShowOneTerminalSuspendedTransactions)
			{
                Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                int count = clsSalesTransactions.CountSuspended(mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.CashierID, mclsTerminalDetails.BranchID);
                clsSalesTransactions.CommitAndDispose();

				if (count == 0)
				{
					MessageBox.Show("No suspended transaction found for this day.", "RetailPlus", MessageBoxButtons.OK);
					return;
				}
			}

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

			if (loginresult == DialogResult.OK)
			{
				try
				{
					ResumeTransactionWnd ResumeWnd = new ResumeTransactionWnd();
                    ResumeWnd.TerminalDetails = mclsTerminalDetails;
					ResumeWnd.CashierID = mclsSalesTransactionDetails.CashierID;
                    ResumeWnd.TransactionStatusToList = AceSoft.RetailPlus.TransactionStatus.Suspended;
					ResumeWnd.ShowDialog(this);
					DialogResult result = ResumeWnd.Result;
					Data.SalesTransactionDetails details = ResumeWnd.Details;
					ResumeWnd.Close();
					ResumeWnd.Dispose();

					if (result == DialogResult.OK)
					{
                        if (details.TransactionStatus == TransactionStatus.SuspendedOpen)
                        {
                            if (MessageBox.Show("This transaction is already open in another terminal. Please suspend in the other terminal first before opening." + Environment.NewLine + "Would you like to force open this transaction?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                            {
                                return;
                            }
                            else
                            {
                                DialogResult resResumeSuspendedOpenTransaction = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.ResumeSuspendedOpenTransaction);

                                if (resResumeSuspendedOpenTransaction != System.Windows.Forms.DialogResult.OK)
                                {
                                    clsEvent.AddEvent("[" + lblCashier.Text + "] Resuming transaction no. " + details.TransactionNo + " cancelled. SuspendedOpen");
                                    return;
                                }
                            }
                        }

						clsEvent.AddEvent("[" + lblCashier.Text + "] Resuming transaction no. " + details.TransactionNo);

						mclsSalesTransactionDetails = details;

						if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.Refund || mclsSalesTransactionDetails.TransactionType == TransactionTypes.POSRefund)
						{
							mboIsRefund = true;
							lblSubtotalName.Text = "SUBTOTAL: REFUND";
							lblOrderType.Visible = false;
						}
						lblOrderType.Text = mclsSalesTransactionDetails.OrderType.ToString("G").ToUpper();
						lblTransNo.Text = mclsSalesTransactionDetails.TransactionNo;
						lblTransNo.Tag = mclsSalesTransactionDetails.TransactionID.ToString();
						lblCustomer.Text = mclsSalesTransactionDetails.CustomerName;
						lblCustomer.Tag = mclsSalesTransactionDetails.CustomerID.ToString();
						lblAgent.Text = mclsSalesTransactionDetails.AgentName;
						lblAgent.Tag = mclsSalesTransactionDetails.AgentID.ToString();
						lblAgentPositionDepartment.Text = mclsSalesTransactionDetails.AgentPositionName;
						lblAgentPositionDepartment.Tag = mclsSalesTransactionDetails.AgentDepartmentName;
						grpItems.Text = "Served by: " + details.WaiterName;
						grpItems.Tag = mclsSalesTransactionDetails.WaiterID.ToString();

						lblTransDate.Text = mclsSalesTransactionDetails.TransactionDate.ToString("MMM. dd, yyyy hh:mm:ss tt");
                        mdteOverRidingPrintDate = mclsSalesTransactionDetails.TransactionDate;

						lblTransDiscount.Tag = mclsSalesTransactionDetails.TransDiscountType.ToString("d");
                        lblConsignment.Visible = mclsSalesTransactionDetails.isConsignment;

                        if (mclsSalesTransactionDetails.ChargeAmount == 0)
                            lblTransCharge.Tag = ChargeTypes.NotApplicable.ToString("d");
                        else
                        {
                            Data.ChargeType clsChargeType = new Data.ChargeType(mConnection, mTransaction);
                            bool bolInPercent = clsChargeType.Details(mclsSalesTransactionDetails.ChargeCode).InPercent;
                            clsChargeType.CommitAndDispose();

                            if (bolInPercent)
                                lblTransCharge.Tag = ChargeTypes.Percentage.ToString("d");
                            else
                                lblTransCharge.Tag = ChargeTypes.FixedValue.ToString("d");
                        }

						// Aug 6, 2011 : Lemu
						// Put here from CloseTransaction
						try { mclsSalesTransactionDetails.CashierID = Convert.ToInt64(lblCashier.Tag); }
						catch { }
						mclsSalesTransactionDetails.CashierName = lblCashier.Text;

						LoadResumedItems(details.TransactionItems, false);

                        // Jan 31, 2015 : Lemu
                        // put back to SuspendedOpen so that it won't be open somewhere else
                        if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.Suspended)
                        {
                            Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                            mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;
                            clsEvent.AddEvent("Putting transaction SuspendedOpen: " + mclsSalesTransactionDetails.TransactionNo, true);
                            clsSalesTransactions.UpdateTransactionToSuspendedOpen(mclsSalesTransactionDetails.TransactionID);
                            clsSalesTransactions.CommitAndDispose();
                        }

                        // 06Mar2015 : reload this, to use for price level
                        Data.Contacts clsContacts = new Data.Contacts(mConnection, mTransaction);
                        mConnection = clsContacts.Connection; mTransaction = clsContacts.Transaction;
                        mclsContactDetails = clsContacts.Details(mclsSalesTransactionDetails.CustomerID);
                        clsContacts.CommitAndDispose();

						mboIsInTransaction = true;

						InsertAuditLog(AccessTypes.ResumeTransaction, "Resume transaction #: " + lblTransNo.Text + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
						clsEvent.AddEventLn("[" + lblCashier.Text + "] Resuming transaction no. " + details.TransactionNo + " Done.", true);
					}
					else { clsEvent.AddEventLn("Cancelled!"); }


				}
				catch (Exception ex)
				{ 
                    InsertErrorLogToFile(ex, "ERROR!!! Resuming transaction."); 
                }
			}
		}
Beispiel #23
0
		private bool SelectWaiter()
		{
			bool retValue = false;

			if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto && mboIsInTransaction)
			{
				MessageBox.Show("Sorry you cannot select a waiter when an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				return retValue;
			}

			try
			{
				clsEvent.AddEvent("[" + lblCashier.Text + "] Selecting waiter.");

				WaiterSelectWnd clsWaiterSelectWnd = new WaiterSelectWnd();
                clsWaiterSelectWnd.TerminalDetails = mclsTerminalDetails;
                clsWaiterSelectWnd.ShowDialog(this);
                long iWaiterID = clsWaiterSelectWnd.getWaiterID;
                string stWaiterName = clsWaiterSelectWnd.getWaiterName;
                DialogResult result = clsWaiterSelectWnd.Result;
                clsWaiterSelectWnd.Close();
                clsWaiterSelectWnd.Dispose();

				if (result == DialogResult.OK)
				{
					grpItems.Text = "Served by: " + stWaiterName;
					grpItems.Tag = iWaiterID.ToString();
					clsEvent.AddEventLn("Done! Selected Waiter: " + stWaiterName);

					if (mboIsInTransaction)
					{
						mclsSalesTransactionDetails.WaiterID = iWaiterID;
						mclsSalesTransactionDetails.WaiterName = stWaiterName;
                        Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                        mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

						clsSalesTransactions.UpdateWaiter(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TransactionDate, iWaiterID, stWaiterName);
						clsSalesTransactions.CommitAndDispose();

						retValue = true;
					}
				}
				else { clsEvent.AddEventLn("Cancelled!"); }
			}
			catch (Exception ex)
			{ 
                InsertErrorLogToFile(ex, "ERROR!!! Selecting waiter."); 
            }

			return retValue;
		}
Beispiel #24
0
        private void ReprintTransaction(string TransactionNo = "", string TerminalNo = "")
		{
            if (!SuspendTransactionAndContinue()) return;

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

            if (loginresult == DialogResult.OK)
			{
                DialogResult result = System.Windows.Forms.DialogResult.OK;
                string strTransactionNo = TransactionNo;
                string strTerminalNo = TerminalNo;

                if (string.IsNullOrEmpty(TransactionNo))
                {
                    TransactionNoWnd clsTransactionNoWnd = new TransactionNoWnd();
                    clsTransactionNoWnd.TransactionNoLength = mclsTerminalDetails.TransactionNoLength;
                    clsTransactionNoWnd.TerminalNo = mclsTerminalDetails.TerminalNo;
                    clsTransactionNoWnd.TerminalDetails = mclsTerminalDetails;
                    clsTransactionNoWnd.ShowDialog(this);
                    result = clsTransactionNoWnd.Result;
                    strTransactionNo = clsTransactionNoWnd.TransactionNo;
                    strTerminalNo = clsTransactionNoWnd.TerminalNo;
                    clsTransactionNoWnd.Close();
                    clsTransactionNoWnd.Dispose();
                }

				if (result == DialogResult.OK)
                {
                    LoadOptions();

                    clsEvent.AddEventLn("Reprinting transaction #: " + strTransactionNo, true);

                    mclsTerminalDetails.AutoPrint = PrintingPreference.Normal;
                    string OldTerminalNo = mclsTerminalDetails.TerminalNo; //put to print the correct terminal no
                    mclsTerminalDetails.TerminalNo = strTerminalNo;

                    //open salestransaction data
                    Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                    mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                    LoadTransaction(strTransactionNo, strTerminalNo);

                    AddToReprintedTransaction(strTransactionNo, strTerminalNo);

                    clsSalesTransactions.CommitAndDispose();

                    ArrayList arrChequePaymentDetails = null;
                    if (mclsSalesTransactionDetails.PaymentDetails.arrChequePaymentDetails != null)
                    {
                        arrChequePaymentDetails = new ArrayList();
                        foreach (Data.ChequePaymentDetails det in mclsSalesTransactionDetails.PaymentDetails.arrChequePaymentDetails)
                        { arrChequePaymentDetails.Add(det); }
                    }

                    ArrayList arrCreditCardPaymentDetails = null;
                    {
                        arrCreditCardPaymentDetails = new ArrayList();
                        if (mclsSalesTransactionDetails.PaymentDetails.arrCreditCardPaymentDetails != null)
                            foreach (Data.CreditCardPaymentDetails det in mclsSalesTransactionDetails.PaymentDetails.arrCreditCardPaymentDetails)
                            { arrCreditCardPaymentDetails.Add(det); }
                    }

                    ArrayList arrCreditPaymentDetails = null;
                    if (mclsSalesTransactionDetails.PaymentDetails.arrCreditPaymentDetails != null)
                    {
                        arrCreditPaymentDetails = new ArrayList();
                        foreach (Data.CreditPaymentDetails det in mclsSalesTransactionDetails.PaymentDetails.arrCreditPaymentDetails)
                        { arrCreditPaymentDetails.Add(det); }
                    }

                    ArrayList arrDebitPaymentDetails = null;
                    if (mclsSalesTransactionDetails.PaymentDetails.arrDebitPaymentDetails != null)
                    {
                        arrDebitPaymentDetails = new ArrayList();
                        foreach (Data.DebitPaymentDetails det in mclsSalesTransactionDetails.PaymentDetails.arrDebitPaymentDetails)
                        { arrDebitPaymentDetails.Add(det); }
                    }

                    //print transactionfooter
                    //items are already printed during the loading of items.
                    //if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default)
                    //    PrintReportFooterSection(true, TransactionStatus.Reprinted, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.AmountPaid, mclsSalesTransactionDetails.CashPayment, mclsSalesTransactionDetails.ChequePayment, mclsSalesTransactionDetails.CreditCardPayment, mclsSalesTransactionDetails.CreditPayment, mclsSalesTransactionDetails.DebitPayment, mclsSalesTransactionDetails.RewardPointsPayment, mclsSalesTransactionDetails.RewardConvertedPayment, mclsSalesTransactionDetails.ChangeAmount, arrChequePaymentDetails, arrCreditCardPaymentDetails, arrCreditPaymentDetails, arrDebitPaymentDetails);
                    if (mclsSalesTransactionDetails.isConsignment)
                    {
                        // 18Feb2015 : Print DR only if the transaction is consignment
                        clsEvent.AddEventLn("      re-printing delivery receipt as consginment...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintDeliveryReceipt();
                    }
                    else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode &&
                        (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice ||
                         mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt ||
                        mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR))
                    {
                        clsEvent.AddEventLn("      re-printing walk-in customer quote form...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintWalkInReceipt();
                    }
                    else if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.CreditPayment && 
                        mclsSysConfigDetails.CreditPaymentType == CreditPaymentType.Houseware)
                    {
                        // do another report for credit payment if HP
                        PrintCreditPayment();

                        // do this twice as per request of CN trader's and CS
                        PrintCreditPayment();
                    }
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice)
                    {
                        clsEvent.AddEventLn("      re-printing sales invoice...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintSalesInvoice();
                    }
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt)
                    {
                        clsEvent.AddEventLn("      re-printing delivery receipt...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintDeliveryReceipt();
                    }
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR)
                    {
                        clsEvent.AddEventLn("      re-printing sales invoice & delivery receipt...", true, mclsSysConfigDetails.WillWriteSystemLog);

                        PrintSalesInvoice();

                        PrintDeliveryReceipt();
                    }
                    //Added February 10, 2010
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300Printer)
                    {
                        clsEvent.AddEventLn("      re-printing sales invoice for LX300...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300Printer);
                    }
                    //Added May 11, 2010
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceOrDR)
                    {
                        clsEvent.AddEventLn("      re-printing sales invoice or OR...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        if (mclsSalesTransactionDetails.CashPayment != 0 || mclsSalesTransactionDetails.CreditCardPayment != 0)
                            PrintSalesInvoice();
                        if (mclsSalesTransactionDetails.ChequePayment != 0 || mclsSalesTransactionDetails.CreditPayment != 0)
                            PrintDeliveryReceipt();
                    }
                    //Added January 17, 2011
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300PlusPrinter)
                    {
                        clsEvent.AddEventLn("      re-printing sales invoice for LX300 Plus...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300PlusPrinter);
                    }
                    //Added February 22, 2011
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300PlusAmazon)
                    {
                        clsEvent.AddEventLn("      re-printing sales invoice for LX300 Plus Amazon...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300PlusAmazon);
                    }
                    else if (!mboIsRefund) // do not print if refund coz its already printed above
                    {
                        // Sep 14, 2014 Control printing in mclsFilePrinter.Write
                        //if (mclsTerminalDetails.AutoPrint == PrintingPreference.Normal)	//print items if not yet printed
                        //{
                        clsEvent.AddEventLn("      printing items to POS printer...", true, mclsSysConfigDetails.WillWriteSystemLog);

                        // do this here in case void items are to be printed
                        if (!mboIsItemHeaderPrinted)
                        {
                            PrintReportHeadersSection(true);
                            mboIsItemHeaderPrinted = true;
                        }
                        foreach (System.Data.DataRow dr in ItemDataTable.Rows)
                        {
                            string stItemNo = "" + dr["ItemNo"].ToString();
                            string stProductUnitCode = "" + dr["ProductUnitCode"].ToString();
                            decimal decPrice = Convert.ToDecimal(dr["Price"]);
                            decimal decDiscount = Convert.ToDecimal(dr["Discount"]);
                            decimal decAmount = Convert.ToDecimal(dr["Amount"]);
                            decimal decVAT = Convert.ToDecimal(dr["VAT"]);
                            decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                            decimal decPromoApplied = Convert.ToDecimal(dr["PromoApplied"]);
                            string stProductCode = "" + dr["ProductCode"].ToString();
                            if (dr["MatrixDescription"].ToString() != string.Empty && dr["MatrixDescription"].ToString() != null) stProductCode += "-" + dr["MatrixDescription"].ToString();
                            decimal decQuantity = 0;
                            string stDiscountCode = "" + dr["DiscountCode"].ToString();
                            DiscountTypes ItemDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["ItemDiscountType"].ToString());

                            if (dr["Quantity"].ToString().IndexOf("RETURN") != -1)
                            {
                                stProductCode = "" + dr["ProductCode"].ToString() + "-RET";
                                decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - RETURN", "").Trim());
                                decAmount = -decAmount;
                            }
                            else if (dr["Quantity"].ToString().IndexOf("DEMO") != -1)
                            {
                                stProductCode = "" + dr["ProductCode"].ToString() + "-DEMO";
                                decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - DEMO", "").Trim());
                                decAmount = 0;
                            }
                            else if (dr["Quantity"].ToString() != "VOID")
                            {
                                decQuantity = Convert.ToDecimal(dr["Quantity"]);
                            }

                            if (dr["Quantity"].ToString().IndexOf("VOID") != -1)
                            {
                                if (mclsTerminalDetails.WillPrintVoidItem)
                                    if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default)
                                        PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType);
                            }
                            else
                            {
                                if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default)
                                    PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType);
                            }

                        }
                        if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default)
                        {
                            PrintReportFooterSection(true, TransactionStatus.Reprinted, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.AmountPaid, mclsSalesTransactionDetails.CashPayment, mclsSalesTransactionDetails.ChequePayment, mclsSalesTransactionDetails.CreditCardPayment, mclsSalesTransactionDetails.CreditPayment, mclsSalesTransactionDetails.DebitPayment, mclsSalesTransactionDetails.RewardPointsPayment, mclsSalesTransactionDetails.RewardConvertedPayment, mclsSalesTransactionDetails.ChangeAmount, arrChequePaymentDetails, arrCreditCardPaymentDetails, arrCreditPaymentDetails, arrDebitPaymentDetails);

                            // print the charge slip if not refund and will print
                            if (mclsTerminalDetails.WillPrintChargeSlip && !mboIsRefund)
                            {
                                clsEvent.AddEventLn("      printing charge slip...", true, mclsSysConfigDetails.WillWriteSystemLog);

                                // Nov 05, 2011 : Print Charge Slip
                                PrintChargeSlip(ChargeSlipType.Customer);
                                PrintChargeSlip(ChargeSlipType.Original);
                                if (mclsTerminalDetails.IncludeCreditChargeAgreement && mclsSalesTransactionDetails.CustomerDetails.CreditDetails.CardTypeDetails.WithGuarantor) //do not print the guarantor if there is no agreement printed
                                {
                                    PrintChargeSlip(ChargeSlipType.Guarantor);
                                }
                            }
                        }
                        //}
                        // Sep 14, 2014 Control printing in mclsFilePrinter.Write
                    }
                    clsEvent.AddEventLn("Done reprinting transaction #".PadRight(15) + ":" + strTransactionNo, true);

                    if (mclsSalesTransactionDetails.RewardPointsPayment != 0)
                    {
                        clsEvent.AddEventLn("      printing rewards slip...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintRewardsRedemptionSlip();
                    }

                    mclsTerminalDetails.TerminalNo = OldTerminalNo; //put back after printing the correct terminal no
                    this.LoadOptions();
                }
			}
		}
Beispiel #25
0
        private void ApplyTransCharge()
        {
            int iRow = dgItems.CurrentRowIndex;
            if (iRow < 0) return;

            if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto && mboIsInTransaction)
            {
                MessageBox.Show("Sorry you cannot apply a transaction Charge if Auto-print is ON an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.ChargeType);

            if (loginresult == DialogResult.OK)
            {
                try
                {
                    clsEvent.AddEvent("[" + lblCashier.Text + "] Applying transaction Charge for trans. no. " + lblTransNo.Text);

                BackToCharge:
                    ChargeTypes TransChargeType = mclsSalesTransactionDetails.ChargeType;
                    ChargeWnd charge = new ChargeWnd();
                    charge.TerminalDetails = mclsTerminalDetails;
                    charge.BalanceAmount = mclsSalesTransactionDetails.SubTotal;
                    charge.ChargeType = TransChargeType;
                    charge.ChargeAmount = mclsSalesTransactionDetails.ChargeAmount;
                    charge.ChargeCode = mclsSalesTransactionDetails.ChargeCode;
                    charge.Remarks = mclsSalesTransactionDetails.ChargeRemarks;
                    charge.IsChargeEditable = mclsTerminalDetails.IsChargeEditable;
                    charge.ShowDialog(this);
                    DialogResult result = charge.Result;
                    decimal ChargeAmount = charge.ChargeAmount;
                    string TransChargeCode = charge.ChargeCode;
                    string TransChargeRemarks = charge.Remarks;
                    TransChargeType = charge.ChargeType;
                    charge.Close();
                    charge.Dispose();

                    if (result == DialogResult.OK)
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        if (!mboIsInTransaction) //false ito
                        {
                            this.LoadOptions();
                            if (!this.CreateTransaction()) return;
                        }

                        decimal OldCharge = mclsSalesTransactionDetails.ChargeAmount;
                        ChargeTypes OldTransChargeType = mclsSalesTransactionDetails.ChargeType;

                        mclsSalesTransactionDetails.ChargeAmount = ChargeAmount;
                        mclsSalesTransactionDetails.ChargeCode = TransChargeCode;
                        mclsSalesTransactionDetails.ChargeRemarks = TransChargeRemarks;
                        mclsSalesTransactionDetails.ChargeType = TransChargeType;

                        ComputeSubTotal(); setTotalDetails();

                        if (mclsSalesTransactionDetails.Discount <= mclsSalesTransactionDetails.DiscountableAmount)
                        {
                            Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                            mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                            clsSalesTransactions.UpdateSubTotal(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.GrossSales, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.NetSales, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.SNRDiscount, mclsSalesTransactionDetails.PWDDiscount, mclsSalesTransactionDetails.OtherDiscount, mclsSalesTransactionDetails.TransDiscount, mclsSalesTransactionDetails.TransDiscountType, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.ChargeAmount, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.ChargeType);
                            clsSalesTransactions.CommitAndDispose();

                            InsertAuditLog(AccessTypes.ChargeType, "Apply transaction Charge for " + mclsSalesTransactionDetails.Charge.ToString("#,###.#0") + ". Tran. #".PadRight(15) + ":" + lblTransNo.Text + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
                        }
                        else
                        {
                            MessageBox.Show("Sorry the input Charge will yield a less than ZERO amount. Please type another Charge.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                            mclsSalesTransactionDetails.ChargeAmount = OldCharge;
                            mclsSalesTransactionDetails.ChargeType = OldTransChargeType;

                            ComputeSubTotal(); setTotalDetails();
                            goto BackToCharge;
                        }

                        clsEvent.AddEventLn("Done! amount=" + mclsSalesTransactionDetails.Charge.ToString("#,###.#0"));
                    }
                    else { clsEvent.AddEventLn("Cancelled!"); }
                }
                catch (Exception ex)
                {
                    InsertErrorLogToFile(ex, "ERROR!!! Applying transaction charge.");
                }
                Cursor.Current = Cursors.Default;
            }
        }
Beispiel #26
0
 private void LoadPurchases(Int64 CreditorID)
 {
     Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions();
     System.Data.DataTable dt = clsSalesTransactions.ListForPaymentDataTable(CreditorID);
     clsSalesTransactions.CommitAndDispose();
     lstPurchases.DataSource = dt.DefaultView;
     lstPurchases.DataBind();
 }
Beispiel #27
0
        private void setTransCharge(Data.ChargeTypeDetails ChargeTypeDetails, string Remarks)
        {
            try
            {
                mclsSalesTransactionDetails.ChargeAmount = ChargeTypeDetails.ChargeAmount;
                mclsSalesTransactionDetails.ChargeCode = ChargeTypeDetails.ChargeTypeCode;
                mclsSalesTransactionDetails.ChargeRemarks = Remarks;

                if (ChargeTypeDetails.ChargeAmount == 0)
                    mclsSalesTransactionDetails.ChargeType = ChargeTypes.NotApplicable;
                else if (ChargeTypeDetails.InPercent)
                    mclsSalesTransactionDetails.ChargeType = ChargeTypes.Percentage;
                else
                    mclsSalesTransactionDetails.ChargeType = ChargeTypes.FixedValue;

                ComputeSubTotal(); setTotalDetails();

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

                clsSalesTransactions.UpdateSubTotal(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.GrossSales, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.NetSales, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.SNRDiscount, mclsSalesTransactionDetails.PWDDiscount, mclsSalesTransactionDetails.OtherDiscount, mclsSalesTransactionDetails.TransDiscount, mclsSalesTransactionDetails.TransDiscountType, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.ChargeAmount, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.ChargeType);
                clsSalesTransactions.CommitAndDispose();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #28
0
        private void LoadItemData()
        {
            try
            {
                System.Data.DataTable dt = new System.Data.DataTable("tblproducts");

                dt.Columns.Add("ProductID");
                dt.Columns.Add("ProductCode");
                dt.Columns.Add("BarCode");
                dt.Columns.Add("ProductDesc");
                dt.Columns.Add("ProductGroup");
                dt.Columns.Add("ProductSubGroup");
                dt.Columns.Add("ProductUnitID");
                dt.Columns.Add("ProductUnitCode");
                dt.Columns.Add("Quantity");
                dt.Columns.Add("Price");
                dt.Columns.Add("SpecialDiscount");
                dt.Columns.Add("VAT");
                dt.Columns.Add("EVAT");
                dt.Columns.Add("LocalTax");

                Data.SalesTransactions       clsSalesTransactions = new Data.SalesTransactions();
                Data.SalesTransactionDetails det = clsSalesTransactions.Details(mstTransactionNo, mstTerminalNo, Constants.TerminalBranchID);
                clsSalesTransactions.CommitAndDispose();

                Data.SalesTransactionItems         clsItems         = new Data.SalesTransactionItems();
                Data.SalesTransactionItemDetails[] TransactionItems = clsItems.Details(det.TransactionID, det.TransactionDate);
                clsItems.CommitAndDispose();

                foreach (Data.SalesTransactionItemDetails item in TransactionItems)
                {
                    System.Data.DataRow dr = dt.NewRow();

                    dr["ProductID"]       = item.ProductID;
                    dr["ProductCode"]     = item.ProductCode;
                    dr["BarCode"]         = item.BarCode;
                    dr["ProductDesc"]     = item.Description;
                    dr["ProductGroup"]    = item.ProductGroup;
                    dr["ProductSubGroup"] = item.ProductSubGroup;
                    dr["ProductUnitID"]   = item.ProductUnitID;
                    dr["ProductUnitCode"] = item.ProductUnitCode;
                    dr["Quantity"]        = item.Quantity;
                    dr["Price"]           = item.Price;
                    dr["SpecialDiscount"] = item.Discount;
                    dr["VAT"]             = item.VAT;
                    dr["EVAT"]            = item.EVAT;
                    dr["LocalTax"]        = item.LocalTax;

                    dt.Rows.Add(dr);
                }
                this.dgStyle.MappingName = dt.TableName;
                dgItems.DataSource       = dt;

                if (dgItems.VisibleRowCount > 0)
                {
                    dgItems.Select(0);
                }
                dgItems.CurrentRowIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #29
0
        private void ChangeZeroRated(bool isZeroRated)
        {
            if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto && mboIsInTransaction)
            {
                MessageBox.Show("Sorry you cannot change Order Type if Auto-print is ON an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.CloseTransaction);

            if (loginresult == DialogResult.OK)
            {
                try
                {
                    clsEvent.AddEvent("[" + lblCashier.Text + "] Changing ZeroRated. " + lblTransNo.Text + " as " + isZeroRated.ToString());

                    mclsSalesTransactionDetails.isZeroRated = isZeroRated;

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

                    clsSalesTransactions.UpdateisZeroRated(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.isZeroRated);

                    ComputeSubTotal();
                    clsSalesTransactions.UpdateSubTotal(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.GrossSales, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.NetSales, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.SNRDiscount, mclsSalesTransactionDetails.PWDDiscount, mclsSalesTransactionDetails.OtherDiscount, mclsSalesTransactionDetails.TransDiscount, mclsSalesTransactionDetails.TransDiscountType, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, mclsSalesTransactionDetails.DiscountCode, mclsSalesTransactionDetails.DiscountRemarks, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.ChargeAmount, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.ChargeType);

                    InsertAuditLog(AccessTypes.ChargeType, "Change zerorated type to " + mclsSalesTransactionDetails.isZeroRated.ToString() + ". Tran. #".PadRight(15) + ":" + lblTransNo.Text + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
                    clsEvent.AddEventLn("Done!", true);
                    clsSalesTransactions.CommitAndDispose();
                }
                catch (Exception ex)
                {
                    InsertErrorLogToFile(ex, "ERROR!!! Changing zero rated type.");
                }
                Cursor.Current = Cursors.Default;
            }
        }
Beispiel #30
0
        public void CloseTransaction(Data.SalesTransactionItemDetails mTopItemDetails,
                decimal AmountPaid, decimal ChangeAmount, decimal BalanceAmount, decimal CashPayment, decimal ChequePayment,
                decimal CreditCardPayment, decimal CreditPayment, decimal CreditChargeAmount, decimal DebitPayment,
                decimal RewardConvertedPayment, decimal RewardPointsPayment, PaymentTypes PaymentType,
                ArrayList arrCashPaymentDetails, ArrayList arrChequePaymentDetails, ArrayList arrCreditCardPaymentDetails,
                ArrayList arrCreditPaymentDetails, ArrayList arrDebitPaymentDetails)
        {
            mclsSalesTransactionDetails.AmountPaid = AmountPaid;
            mclsSalesTransactionDetails.ChangeAmount = ChangeAmount;
            mclsSalesTransactionDetails.CashPayment = CashPayment;
            mclsSalesTransactionDetails.ChequePayment = ChequePayment;
            mclsSalesTransactionDetails.CreditCardPayment = CreditCardPayment;
            mclsSalesTransactionDetails.CreditPayment = CreditPayment;

            // include credit charge amount
            mclsSalesTransactionDetails.CreditChargeAmount = CreditChargeAmount;
            mclsSalesTransactionDetails.AmountDue += mclsSalesTransactionDetails.CreditChargeAmount;

            mclsSalesTransactionDetails.DebitPayment = DebitPayment;
            mclsSalesTransactionDetails.RewardPointsPayment = RewardConvertedPayment;

            /***
             * Nov 04, 2011 : for payments using reward points
             ***/
            mclsSalesTransactionDetails.RewardPointsPayment = RewardPointsPayment;
            mclsSalesTransactionDetails.RewardConvertedPayment = RewardConvertedPayment;

            /***
             * Oct 17, 2011 : Move this code here.
             * check if will print transaction or not before opening any connection to database.
             ***/
            mboDoNotPrintTransactionDate = false;
            if (mclsTerminalDetails.AutoPrint == PrintingPreference.AskFirst)
            {
                if (MessageBox.Show("Would you like to print this transaction?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, (mclsSysConfigDetails.isDefaultButtonYesInPrintTransaction ? MessageBoxDefaultButton.Button1 : MessageBoxDefaultButton.Button2)) == DialogResult.Yes)
                {
                    mclsTerminalDetails.AutoPrint = PrintingPreference.Normal;

                    if (mclsSysConfigDetails.WillAskDoNotPrintTransactionDate)
                        if (MessageBox.Show("Would you like the system NOT to print the transaction date?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                            mboDoNotPrintTransactionDate = true;
                }
            }

            // Mar 17, 2009
            // open drawer first before printing.
            //OpenDrawerDelegate opendrawerDel = new OpenDrawerDelegate(OpenDrawer);
            //Invoke(opendrawerDel);
            OpenDrawer();

            Cursor.Current = Cursors.WaitCursor;
            clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "]      saving payments...", true);

            // for assignment of payments
            mclsSalesTransactionDetails.PaymentDetails = AssignArrayListPayments(arrCashPaymentDetails, arrChequePaymentDetails, arrCreditCardPaymentDetails, arrCreditPaymentDetails, arrDebitPaymentDetails);

            // start a connection for the database.
            //update the transaction table 
            Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
            mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;
            
            SavePayments(arrCashPaymentDetails, arrChequePaymentDetails, arrCreditCardPaymentDetails, arrCreditPaymentDetails, arrDebitPaymentDetails);

            if (mclsSalesTransactionDetails.CreditChargeAmount != 0)
            {
                //Aug 30, 2014 delete need to move this from here to mainwnd
                clsSalesTransactions.UpdateCreditChargeAmount(mclsSalesTransactionDetails.BranchID, mclsSalesTransactionDetails.TerminalNo, mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.CreditChargeAmount);
            }

            Data.Products clsProduct = new Data.Products(mConnection, mTransaction);
            mConnection = clsProduct.Connection; mTransaction = clsProduct.Transaction;

            TransactionStatus clsTransactionStatus = TransactionStatus.Closed;
            if (mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE)
            {
                clsTransactionStatus = TransactionStatus.CreditPayment;
            }
            else if (mboIsRefund)
            {
                clsTransactionStatus = TransactionStatus.Refund;

                if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode)
                {
                    clsTransactionStatus = TransactionStatus.ClosedOutOfStockRefund;
                }
                else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode)
                {
                    clsTransactionStatus = TransactionStatus.ClosedWalkInRefund;
                }
                else if (mclsSalesTransactionDetails.isConsignment)
                {
                    clsTransactionStatus = TransactionStatus.ConsignmentRefund;
                }
            }
            else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode)
            {
                clsTransactionStatus = TransactionStatus.ClosedOutOfStock;
            }
            else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode)
            {
                clsTransactionStatus = TransactionStatus.ClosedWalkIn;
            }
            else if (mclsSalesTransactionDetails.isConsignment)
            {
                clsTransactionStatus = TransactionStatus.Consignment;
            }

            if (mboIsRefund && !mclsTerminalDetails.IsParkingTerminal)
            {
                #region mboIsRefund

                clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "]      updating refund terminal no...", true, mclsSysConfigDetails.WillWriteSystemLog);
                clsSalesTransactions.UpdateTerminalNo(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TerminalNo);

                if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode ||
                    mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode)
                {
                    // 20Feb2015 : Added as an exemption
                    clsEvent.AddEventLn("      no need to apply an ORNo. Customer is " + mclsSalesTransactionDetails.CustomerDetails.ContactCode, true, mclsSysConfigDetails.WillWriteSystemLog);
                }
                
                else if (!mclsSalesTransactionDetails.isConsignment)
                {
                    // 04Sep2014 : Added to put as OR No - Void NO-OR
                    mclsSalesTransactionDetails.ORNo = clsSalesTransactions.CreateORNo(mclsTerminalDetails.ORSeriesBranchID, mclsTerminalDetails.ORSeriesTerminalNo);
                    clsEvent.AddEventLn("      applying ORNo".PadRight(15) + ":" + mclsSalesTransactionDetails.ORNo, true, mclsSysConfigDetails.WillWriteSystemLog);
                }

                clsSalesTransactions.Refund(clsTransactionStatus, mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.ORNo, -mclsSalesTransactionDetails.ItemSold, -mclsSalesTransactionDetails.QuantitySold, -mclsSalesTransactionDetails.GrossSales, -mclsSalesTransactionDetails.SubTotal, -mclsSalesTransactionDetails.NetSales, -mclsSalesTransactionDetails.ItemsDiscount, -mclsSalesTransactionDetails.SNRItemsDiscount, -mclsSalesTransactionDetails.PWDItemsDiscount, -mclsSalesTransactionDetails.OtherItemsDiscount, -mclsSalesTransactionDetails.Discount, -mclsSalesTransactionDetails.SNRDiscount, -mclsSalesTransactionDetails.PWDDiscount, -mclsSalesTransactionDetails.OtherDiscount, mclsSalesTransactionDetails.TransDiscount, mclsSalesTransactionDetails.TransDiscountType, -mclsSalesTransactionDetails.VAT, -mclsSalesTransactionDetails.VATableAmount, -mclsSalesTransactionDetails.ZeroRatedSales, - mclsSalesTransactionDetails.NonVATableAmount, -mclsSalesTransactionDetails.VATExempt, -mclsSalesTransactionDetails.EVAT, -mclsSalesTransactionDetails.EVATableAmount, -mclsSalesTransactionDetails.NonEVATableAmount, -mclsSalesTransactionDetails.LocalTax, -mclsSalesTransactionDetails.AmountPaid, -CashPayment, -ChequePayment, -CreditCardPayment, -CreditPayment, -DebitPayment, -RewardPointsPayment, -RewardConvertedPayment, -BalanceAmount, -ChangeAmount, PaymentType, mclsSalesTransactionDetails.DiscountCode, mclsSalesTransactionDetails.DiscountRemarks, -mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.ChargeAmount, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.CashierID, mclsSalesTransactionDetails.CashierName);

                //UpdateTerminalReportDelegate updateterminalDel = new UpdateTerminalReportDelegate(UpdateTerminalReport);
                clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "]      updating refund terminal report...", true, mclsSysConfigDetails.WillWriteSystemLog);
                UpdateTerminalReport(clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, PaymentType);

                //UpdateCashierReportDelegate updatecashierDel = new UpdateCashierReportDelegate(UpdateCashierReport);
                clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "]      updating redunf cashier report...", true, mclsSysConfigDetails.WillWriteSystemLog);
                UpdateCashierReport(clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, PaymentType);

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

                clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE);

                // Sep 14, 2014 Control printing in mclsFilePrinter.Write
                //if (mclsTerminalDetails.AutoPrint == PrintingPreference.Normal)	//print items if not yet printed
                //{
                clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName  + "]      printing refund items...", true, mclsSysConfigDetails.WillWriteSystemLog);
                foreach (System.Data.DataRow dr in ItemDataTable.Rows)
                {
                    if (dr["Quantity"].ToString() != "VOID")
                    {
                        string stItemNo = "" + dr["ItemNo"].ToString();
                        string stProductCode = "" + dr["ProductCode"].ToString();
                        if (dr["MatrixDescription"].ToString() != string.Empty && dr["MatrixDescription"].ToString() != null) stProductCode += "-" + dr["MatrixDescription"].ToString();
                        string stProductUnitCode = "" + dr["ProductUnitCode"].ToString();
                        decimal decQuantity = Convert.ToDecimal(dr["Quantity"]);
                        decimal decPrice = Convert.ToDecimal(dr["Price"]);
                        decimal decDiscount = Convert.ToDecimal(dr["Discount"]);
                        decimal decAmount = Convert.ToDecimal(dr["Amount"]);
                        decimal decVAT = Convert.ToDecimal(dr["VAT"]);
                        decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                        decimal decPromoApplied = Convert.ToDecimal(dr["PromoApplied"]);
                        string stDiscountCode = "" + dr["DiscountCode"].ToString();
                        DiscountTypes ItemDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["ItemDiscountType"].ToString());

                        if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default)
                            PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType);
                    }
                }

                if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default)
                    PrintReportFooterSection(true, TransactionStatus.Refund, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.AmountPaid, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, ChangeAmount, arrChequePaymentDetails, arrCreditCardPaymentDetails, arrCreditPaymentDetails, arrDebitPaymentDetails);
                //}
                // Sep 14, 2014 Control printing in mclsFilePrinter.Write

                // Sep 24, 2011      Lemuel E. Aceron
                // Added order slip wherein all punch items will not change sales and inventory
                // a customer named ORDER SLIP should be defined in contacts
                // lblCustomer.Text.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER

                // Added May 7, 2011 to Cater Reserved and Commit functionality
                // !mclsTerminalDetails.ReservedAndCommit

                // Sep 14, 2013: Remove the reserved and commit.
                //if (lblCustomer.Text.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER && !mclsTerminalDetails.ReservedAndCommit && !mclsTerminalDetails.IsParkingTerminal)
                if (mclsSalesTransactionDetails.CustomerName.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER && 
                    !mclsTerminalDetails.IsParkingTerminal &&
                    mclsSalesTransactionDetails.CustomerDetails.ContactCode.Trim() != mclsSysConfigDetails.OutOfStockCustomerCode) // do not change the inventory if OUT_OF_STOCK_CUSTOMER_CODE
                {
                    clsEvent.AddEventLn("[" + mclsSalesTransactionDetails.CashierName + "]      adding the refund items quantity to inv...", true, mclsSysConfigDetails.WillWriteSystemLog);
                    Data.ProductUnit clsProductUnit = new Data.ProductUnit(mConnection, mTransaction);
                    mConnection = clsProductUnit.Connection; mTransaction = clsProductUnit.Transaction;

                    foreach (System.Data.DataRow dr in ItemDataTable.Rows)
                    {
                        Int64 lProductID = Convert.ToInt64(dr["ProductID"]);
                        Int64 lVariationsMatrixID = Convert.ToInt64(dr["VariationsMatrixID"]);
                        Int32 iProductUnitID = Convert.ToInt32(dr["ProductUnitID"]);
                        decimal decQuantity = 0;
                        decimal decPackageQuantity = 0;
                        decimal decNewQuantity = 0;

                        if (dr["Quantity"].ToString().IndexOf("RETURN") != -1)
                        {
                            decimal decPrice = Convert.ToDecimal(dr["Price"]);
                            decimal decPurchasePrice = Convert.ToDecimal(dr["PurchasePrice"]);

                            decimal decDiscount = Convert.ToDecimal(dr["Discount"]);
                            decimal decAmount = -Convert.ToDecimal(dr["Amount"]);

                            decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - RETURN", "").Trim());
                            decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]);
                            decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity);
                            decNewQuantity = -decNewQuantity;

                            clsEvent.AddEventLn("      subtracting refund-return item: prdid-" + lProductID.ToString() + " to inv: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog);
                            clsProduct.SubtractQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_REFUND_RETURN) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName);
                        }
                        else if (dr["Quantity"].ToString().IndexOf("DEMO") != -1)
                        {
                            decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - DEMO", "").Trim());
                            decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]);
                            decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity);

                            clsEvent.AddEventLn("      adding refund-demo item: prdid-" + lProductID.ToString() + " from inv/rsrvd: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog);
                            clsProduct.AddQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.ADD_REFUND_DEMO_ITEM) + " Ter#: " + mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName);
                        }
                        else if (dr["Quantity"].ToString() != "VOID")
                        {
                            decQuantity = Convert.ToDecimal(dr["Quantity"]);
                            decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]);
                            decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity);

                            clsEvent.AddEventLn("      adding refund item: prdid-" + lProductID.ToString() + " from inv/rsrvd: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog);
                            clsProduct.AddQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.ADD_REFUND_ITEM) + " Ter#: " + mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName);
                        }
                    }
                }
                #endregion
            }
            else if (!mboIsRefund)
            {
                #region Normal and ParkingTerminal

                clsEvent.AddEventLn("      closing transaction...", true, mclsSysConfigDetails.WillWriteSystemLog);

                
                if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode ||
                    mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode)
                {
                    // 20Feb2015 : Added as an exemption
                    clsEvent.AddEventLn("      no need to apply an ORNo. Customer is " + mclsSalesTransactionDetails.CustomerDetails.ContactCode, true, mclsSysConfigDetails.WillWriteSystemLog);
                }
                else if (!mclsSalesTransactionDetails.isConsignment)
                {
                    // 04Sep2014 : Added to put as OR No - Void NO-OR
                    if (mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE ||
                            mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_MEMBERSHIP_FEE_BARCODE ||
                            mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_RENEWAL_FEE_BARCODE ||
                            mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_REPLACEMENT_FEE_BARCODE ||
                            mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_CARD_MEMBERSHIP_FEE_BARCODE ||
                            mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_CARD_RENEWAL_FEE_BARCODE ||
                            mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_MEMBERSHIP_FEE_BARCODE ||
                            mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_RENEWAL_FEE_BARCODE ||
                            mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_REPLACEMENT_FEE_BARCODE)
                    {
                        clsEvent.AddEventLn("      no need to apply an ORNo. Product is " + mTopItemDetails.BarCode, true, mclsSysConfigDetails.WillWriteSystemLog);
                    }
                    else
                    {
                        mclsSalesTransactionDetails.ORNo = clsSalesTransactions.CreateORNo(mclsTerminalDetails.ORSeriesBranchID, mclsTerminalDetails.ORSeriesTerminalNo);
                        clsEvent.AddEventLn("      applying ORNo".PadRight(15) + ":" + mclsSalesTransactionDetails.ORNo, true, mclsSysConfigDetails.WillWriteSystemLog);
                    }
                }

                // clsSalesTransactions.UpdateTerminalNo(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TerminalNo);
                // remove the above. Include the TerminalNo in clsSalesTransactions.Close below
                clsSalesTransactions.Close(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TerminalNo, mclsSalesTransactionDetails.ORNo, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.GrossSales, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.NetSales, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.SNRDiscount, mclsSalesTransactionDetails.PWDDiscount, mclsSalesTransactionDetails.OtherDiscount, mclsSalesTransactionDetails.TransDiscount, mclsSalesTransactionDetails.TransDiscountType, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, mclsSalesTransactionDetails.AmountPaid, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, BalanceAmount, ChangeAmount, PaymentType, mclsSalesTransactionDetails.DiscountCode, mclsSalesTransactionDetails.DiscountRemarks, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.ChargeAmount, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.CashierID, mclsSalesTransactionDetails.CashierName, clsTransactionStatus);

                //UpdateTerminalReportDelegate updateterminalDel = new UpdateTerminalReportDelegate(UpdateTerminalReport);
                clsEvent.AddEventLn("      updating terminal report...", true, mclsSysConfigDetails.WillWriteSystemLog);
                UpdateTerminalReport(clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, PaymentType);

                //UpdateCashierReportDelegate updatecashierDel = new UpdateCashierReportDelegate(UpdateCashierReport);
                clsEvent.AddEventLn("      updating cashier's report...", true, mclsSysConfigDetails.WillWriteSystemLog);
                UpdateCashierReport(clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, PaymentType);

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

                clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE);

                // Sep 24, 2011      Lemuel E. Aceron
                // Added order slip wherein all punch items will not change sales and inventory
                // a customer named ORDER SLIP should be defined in contacts
                //if (lblCustomer.Text.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER)

                // Added May 7, 2011 to Cater Reserved and Commit functionality    
                // !mclsTerminalDetails.ReservedAndCommit
                if (mclsTerminalDetails.IsParkingTerminal)
                {
                    clsEvent.AddEventLn("      adding back the parking slot to inv...", true, mclsSysConfigDetails.WillWriteSystemLog);
                    Data.ProductUnit clsProductUnit = new Data.ProductUnit(mConnection, mTransaction);
                    mConnection = clsProductUnit.Connection; mTransaction = clsProductUnit.Transaction;

                    Data.ProductVariationsMatrix clsProductVariationsMatrix = new Data.ProductVariationsMatrix(mConnection, mTransaction);

                    foreach (System.Data.DataRow dr in ItemDataTable.Rows)
                    {
                        long lProductID = Convert.ToInt64(dr["ProductID"]);
                        long lVariationsMatrixID = Convert.ToInt64(dr["VariationsMatrixID"]);
                        int iProductUnitID = Convert.ToInt32(dr["ProductUnitID"]);
                        decimal decQuantity = 0;
                        decimal decPackageQuantity = 0;
                        decimal decNewQuantity = 0;
                        decimal decPrice = Convert.ToDecimal(dr["Price"]);
                        decimal decPurchasePrice = Convert.ToDecimal(dr["PurchasePrice"]);

                        if ((dr["Quantity"].ToString().IndexOf("RETURN") == -1) && (dr["Quantity"].ToString() != "VOID"))
                        {
                            decQuantity = Convert.ToDecimal(dr["Quantity"]);
                            decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]);
                            decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity);

                            clsProduct.AddQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.PARKING_OUT), mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName);
                        }
                    }
                }
                else if (mclsSalesTransactionDetails.CustomerName.Trim().ToUpper() != Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER &&
                    !mclsTerminalDetails.IsParkingTerminal &&
                    mclsSalesTransactionDetails.CustomerDetails.ContactCode.Trim() != mclsSysConfigDetails.OutOfStockCustomerCode) // do not change the inventory if OUT_OF_STOCK_CUSTOMER_CODE
                {
                    Data.ProductUnit clsProductUnit = new Data.ProductUnit(mConnection, mTransaction);
                    mConnection = clsProductUnit.Connection; mTransaction = clsProductUnit.Transaction;

                    Data.ProductVariationsMatrix clsProductVariationsMatrix = new Data.ProductVariationsMatrix(mConnection, mTransaction);
                    
                    Data.SalesTransactionItems clsSalesTransactionItems = new Data.SalesTransactionItems(mConnection, mTransaction);

                    foreach (System.Data.DataRow dr in ItemDataTable.Rows)
                    {
                        long lProductID = Convert.ToInt64(dr["ProductID"]);
                        long lVariationsMatrixID = Convert.ToInt64(dr["VariationsMatrixID"]);
                        int iProductUnitID = Convert.ToInt32(dr["ProductUnitID"]);
                        decimal decQuantity = 0;
                        decimal decPackageQuantity = 0;
                        decimal decNewQuantity = 0;
                        decimal decPrice = Convert.ToDecimal(dr["Price"]);
                        decimal decPurchasePrice = Convert.ToDecimal(dr["PurchasePrice"]);

                        decimal decDiscount = Convert.ToDecimal(dr["Discount"]);
                        decimal decAmount = Convert.ToDecimal(dr["Amount"]);

                        if (dr["Quantity"].ToString().IndexOf("RETURN") != -1)
                        {
                            decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - RETURN", "").Trim());
                            decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]);
                            decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity);

                            clsEvent.AddEventLn("      adding return item: prdid-" + lProductID.ToString() + " to inv: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog);
                            clsProduct.AddQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.ADD_RETURN_ITEM) + " Ter#: " + mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName);

                            // 28JUn2015 : Add the RefReturnTransactionItemsID to the 
                            Int64 intReturnTransactionItemsID = Convert.ToInt64(dr["ReturnTransactionItemsID"]);
                            Int64 intTransactionItemsID = Convert.ToInt64(dr["TransactionItemsID"]);
                            clsSalesTransactionItems.UpdateRefReturnTransactionItemsID(intReturnTransactionItemsID, intTransactionItemsID);
                        }
                        else if (dr["Quantity"].ToString().IndexOf("DEMO") != -1)
                        {
                            decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - DEMO", "").Trim());
                            decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]);
                            decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity);

                            clsEvent.AddEventLn("      subtracting demo item: prdid-" + lProductID.ToString() + " from inv/rsrvd: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog);
                            clsProduct.SubtractQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_DEMO_RETAIL) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName);
                            clsProduct.SubtractReservedQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_DEMO_RETAIL) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName);
                        }
                        else if (dr["Quantity"].ToString() != "VOID")
                        {
                            decQuantity = Convert.ToDecimal(dr["Quantity"]);
                            decPackageQuantity = Convert.ToDecimal(dr["PackageQuantity"]);
                            decNewQuantity = clsProductUnit.GetBaseUnitValue(lProductID, iProductUnitID, decQuantity * decPackageQuantity);

                            clsEvent.AddEventLn("      subtracting sold item: prdid-" + lProductID.ToString() + " from inv/rsrvd: qty-" + decNewQuantity.ToString() + "...", true, mclsSysConfigDetails.WillWriteSystemLog);
                            clsProduct.SubtractQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_SOLD_RETAIL) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName);
                            clsProduct.SubtractReservedQuantity(mclsTerminalDetails.BranchID, lProductID, lVariationsMatrixID, decNewQuantity, Data.Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(Data.PRODUCT_INVENTORY_MOVEMENT.DEDUCT_SOLD_RETAIL) + " @ " + (decAmount / decNewQuantity).ToString("#,##0.#0") + " Buying: " + decPurchasePrice.ToString("#,##0.#0") + " Orig Selling: " + decPrice.ToString("#,##0.#0") + " Discount: " + (decPrice - (decAmount / decNewQuantity)).ToString("#,##0.#0") + " to " + mclsSalesTransactionDetails.CustomerName + " Ter#: " + mclsTerminalDetails.TerminalNo, DateTime.Now, mclsSalesTransactionDetails.TransactionNo, mclsSalesTransactionDetails.CashierName);
                        }
                    }
                }

                // Nov 1, 2011 : Lemu - disabled reward points if product is exempted 
                clsEvent.AddEventLn("      checking if rewards is enabled...", true, mclsSysConfigDetails.WillWriteSystemLog);
                if (mclsSalesTransactionDetails.RewardCardActive && mclsTerminalDetails.RewardPointsDetails.EnableRewardPoints)
                {
                    // Note: mTopItemDetails is already set in the MainWnd.CloseTransaction()
                    if (mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE ||
                        mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_MEMBERSHIP_FEE_BARCODE ||
                        mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_RENEWAL_FEE_BARCODE ||
                        mTopItemDetails.BarCode == Data.Products.DEFAULT_ADVANTAGE_CARD_REPLACEMENT_FEE_BARCODE ||
                        mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_CARD_MEMBERSHIP_FEE_BARCODE ||
                        mTopItemDetails.BarCode == Data.Products.DEFAULT_CREDIT_CARD_RENEWAL_FEE_BARCODE ||
                        mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_MEMBERSHIP_FEE_BARCODE ||
                        mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_RENEWAL_FEE_BARCODE ||
                        mTopItemDetails.BarCode == Data.Products.DEFAULT_SUPER_CARD_REPLACEMENT_FEE_BARCODE)
                        {
                            mclsTerminalDetails.RewardPointsDetails.EnableRewardPoints = false;
                        }
                }

                #endregion
            }

            // Oct 23, 2011 : Lemu - Added Reward Points
            #region Reward Payment

            if (mclsSalesTransactionDetails.RewardPointsPayment != 0)
            {
                clsEvent.AddEventLn("      deducting rewards payment...", true, mclsSysConfigDetails.WillWriteSystemLog);
                // this should comes before earning of points otherwise this will be wrong.
                Data.ContactReward clsContactReward = new Data.ContactReward(mConnection, mTransaction);
                mConnection = clsContactReward.Connection; mTransaction = clsContactReward.Transaction;

                clsContactReward.DeductPoints(mclsSalesTransactionDetails.CustomerID, mclsSalesTransactionDetails.RewardPointsPayment);
                string strReason = "Redeemed " + mclsSalesTransactionDetails.RewardPointsPayment + " using Reward Card #: " + mclsSalesTransactionDetails.RewardCardNo;
                clsContactReward.AddMovement(mclsSalesTransactionDetails.CustomerID, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.RewardCurrentPoints, -mclsSalesTransactionDetails.RewardPointsPayment, mclsSalesTransactionDetails.RewardCurrentPoints - mclsSalesTransactionDetails.RewardPointsPayment, mclsSalesTransactionDetails.RewardCardExpiry, strReason, mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.CashierName, mclsSalesTransactionDetails.TransactionNo);

                mclsSalesTransactionDetails.RewardPreviousPoints = mclsSalesTransactionDetails.RewardCurrentPoints;
                mclsSalesTransactionDetails.RewardCurrentPoints -= mclsSalesTransactionDetails.RewardPointsPayment;
                mclsSalesTransactionDetails.RewardEarnedPoints = 0;

                clsEvent.AddEventLn("      printing rewards slip...", true, mclsSysConfigDetails.WillWriteSystemLog);
                PrintRewardsRedemptionSlip();

                // do this after printing so that it will be equal
                mclsSalesTransactionDetails.RewardPreviousPoints = mclsSalesTransactionDetails.RewardCurrentPoints;
            }
            #endregion

            #region Add reward points to customer

            if (mclsTerminalDetails.RewardPointsDetails.EnableRewardPoints && 
                mclsSalesTransactionDetails.RewardCardActive && 
                mclsSalesTransactionDetails.RewardsCustomerID != Constants.C_RETAILPLUS_CUSTOMERID &&
                mclsTerminalDetails.RewardPointsDetails.RewardPointsMinimum <= mclsSalesTransactionDetails.AmountDue)
            {
                decimal decRewardPoints = 0;
                try
                {
                    decRewardPoints = (mclsSalesTransactionDetails.AmountDue - mclsSalesTransactionDetails.RewardConvertedPayment) / mclsTerminalDetails.RewardPointsDetails.RewardPointsEvery * mclsTerminalDetails.RewardPointsDetails.RewardPoints;

                    // round down points if RoundDown is enabled
                    if (mclsTerminalDetails.RewardPointsDetails.RoundDownRewardPoints) decRewardPoints = decimal.Floor(decRewardPoints);

                    //Data.Product clsProduct
                    //long lngProductID = 0;
                    foreach (System.Data.DataRow dr in ItemDataTable.Rows)
                    {
                        //lngProductID = decimal.Parse(dr["RewardPoints"].ToString());
                        //decRewardPoints += clsProduct.Details1(mclsTerminalDetails.BranchID, lngProductID).RewardPoints;
                        decRewardPoints += decimal.Parse(dr["RewardPoints"].ToString());
                    }
                }
                catch { }

                mclsSalesTransactionDetails.RewardEarnedPoints = decRewardPoints;
                mclsSalesTransactionDetails.RewardCurrentPoints = mclsSalesTransactionDetails.RewardPreviousPoints + mclsSalesTransactionDetails.RewardEarnedPoints;

                Data.ContactReward clsContactReward = new Data.ContactReward(mConnection, mTransaction);
                mConnection = clsContactReward.Connection; mTransaction = clsContactReward.Transaction;
                
                clsContactReward.AddPoints(mclsSalesTransactionDetails.RewardsCustomerID, mclsSalesTransactionDetails.RewardEarnedPoints);
                clsContactReward.AddPurchase(mclsSalesTransactionDetails.RewardsCustomerID, mclsSalesTransactionDetails.AmountDue);
                string strReason = "Purchase " + mclsSalesTransactionDetails.AmountDue.ToString("#,##0.#0") + " using Reward Card #: " + mclsSalesTransactionDetails.RewardCardNo;
                clsContactReward.AddMovement(mclsSalesTransactionDetails.RewardsCustomerID, mclsSalesTransactionDetails.TransactionDate, mclsSalesTransactionDetails.RewardPreviousPoints, mclsSalesTransactionDetails.RewardEarnedPoints, mclsSalesTransactionDetails.RewardCurrentPoints, mclsSalesTransactionDetails.RewardCardExpiry, strReason, mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.CashierName, mclsSalesTransactionDetails.TransactionNo);
            }
            #endregion

            #region  3Nov2014 : autoamtically deposit the change if credit payment
            //#region Auto deposit for creditpayment
            //if (clsTransactionStatus == TransactionStatus.CreditPayment && mclsSysConfigDetails.WillDepositChangeOfCreditPayment)
            //{
            //    InsertAuditLog(AccessTypes.Deposit, "Auto depositing change of trx #: " + mclsSalesTransactionDetails.TransactionNo + ".");
            //    clsEvent.AddEventLn("Auto depositing change of trx #: " + mclsSalesTransactionDetails.TransactionNo + ".", true);

            //    Data.Deposits clsDeposit = new Data.Deposits(mConnection, mTransaction);
            //    mConnection = clsDeposit.Connection; mTransaction = clsDeposit.Transaction;

            //    Data.DepositDetails clsDepositDetails = new Data.DepositDetails()
            //    {
            //        BranchDetails = mclsTerminalDetails.BranchDetails,
            //        TerminalNo = mclsTerminalDetails.TerminalNo,
            //        Amount = mclsSalesTransactionDetails.ChangeAmount,
            //        PaymentType = mclsSalesTransactionDetails.PaymentType,
            //        DateCreated = DateTime.Now,
            //        CashierID = mclsSalesTransactionDetails.CashierID,
            //        CashierName = mclsSalesTransactionDetails.CashierName,
            //        ContactID = mclsSalesTransactionDetails.CustomerDetails.ContactID,
            //        ContactName = mclsSalesTransactionDetails.CustomerDetails.ContactName,
            //        Remarks = "Auto deposit from trx #: " + mclsSalesTransactionDetails.TransactionNo + ".",
            //        CreatedOn = DateTime.Now,
            //        LastModified = DateTime.Now
            //    };
            //    clsDeposit.Insert(clsDepositDetails);

            //    clsContact = new Data.Contacts(mConnection, mTransaction);
            //    mConnection = clsContact.Connection; mTransaction = clsContact.Transaction;

            //    clsContact.AddDebit(clsDepositDetails.ContactID, clsDepositDetails.Amount);
            //    clsDeposit.CommitAndDispose();

            //    InsertAuditLog(AccessTypes.Deposit, "Deposit: type='" + clsDepositDetails.PaymentType.ToString("G") + "' amount='" + clsDepositDetails.Amount.ToString(",##0.#0") + "'" + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
            //    clsEvent.AddEventLn("Done! type=" + clsDepositDetails.PaymentType.ToString("G") + " amount=" + clsDepositDetails.Amount.ToString("#,###.#0"), true);
            //}
            //#endregion
            #endregion

            // 22Nov2014 : remove the merge tables when closed or void
            if (mclsTerminalDetails.WithRestaurantFeatures)
                RemoveFromMergeTable(mclsSalesTransactionDetails.CustomerDetails.ContactCode);

            // commit the transactions here.
            // in case error s encoutered n printing. transaction is already committed.
            clsEvent.AddEventLn("      commiting transaction to database...", true, mclsSysConfigDetails.WillWriteSystemLog);
            clsSalesTransactions.CommitAndDispose();


            /***
             * print the transaction
             ***/
            #region printing
            if (mclsTerminalDetails.AutoPrint != PrintingPreference.AskFirst)
            {
                try
                {
                    if (mclsSalesTransactionDetails.isConsignment)
                    {
                        // 18Feb2015 : Print DR only if the transaction is consignment
                        clsEvent.AddEventLn("      printing delivery receipt as consginment...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintDeliveryReceipt();
                    }
                    else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode &&
                        (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice ||
                         mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt ||
                        mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR))
                    {
                        clsEvent.AddEventLn("      printing out of stock orders...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintOSReceipt();
                    }
                    else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode &&
                    (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice ||
                     mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt ||
                    mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR))
                    {
                        clsEvent.AddEventLn("      printing walk-in customer quote form...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintWalkInReceipt();
                    }
                    else if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.CreditPayment &&
                        mclsSysConfigDetails.CreditPaymentType == CreditPaymentType.Houseware)
                    {
                        // do another report for credit payment if HP
                        PrintCreditPayment();

                        // do this twice as per request of CN trader's and CS
                        PrintCreditPayment();
                    }
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice)
                    {
                        clsEvent.AddEventLn("      printing sales invoice...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintSalesInvoice();
                    }
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt)
                    {
                        clsEvent.AddEventLn("      printing delivery receipt...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintDeliveryReceipt();
                    }
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR)
                    {
                        clsEvent.AddEventLn("      printing sales invoice & delivery receipt...", true, mclsSysConfigDetails.WillWriteSystemLog);

                        if (mclsSalesTransactionDetails.TransactionStatus != TransactionStatus.Void)
                        {
                            clsEvent.AddEventLn("      will not print sales invoice. trx is void...", true, mclsSysConfigDetails.WillWriteSystemLog);
                            PrintSalesInvoice();
                        }
                        PrintDeliveryReceipt();
                    }
                    // 10Feb2010 : print sales invoice to LX as required by Wireless Link
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300Printer)
                    {
                        clsEvent.AddEventLn("      printing sales invoice for LX300...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300Printer);
                    }
                    //Added May 11, 2010
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceOrDR)
                    {
                        clsEvent.AddEventLn("      printing sales invoice or OR...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        if (mclsSalesTransactionDetails.CashPayment != 0 || mclsSalesTransactionDetails.CreditCardPayment != 0)
                            PrintSalesInvoice();
                        if (mclsSalesTransactionDetails.ChequePayment != 0 || mclsSalesTransactionDetails.CreditPayment != 0)
                            PrintDeliveryReceipt();
                    }
                    //Added January 17, 2011
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300PlusPrinter)
                    {
                        clsEvent.AddEventLn("      printing sales invoice for LX300 Plus...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300PlusPrinter);
                    }
                    //Added February 22, 2011
                    else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceForLX300PlusAmazon)
                    {
                        clsEvent.AddEventLn("      printing sales invoice for LX300 Plus Amazon...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        PrintSalesInvoiceToLX(TerminalReceiptType.SalesInvoiceForLX300PlusAmazon);
                    }
                    else if (!mboIsRefund) // do not print if refund coz its already printed above
                    {
                        // Sep 14, 2014 Control printing in mclsFilePrinter.Write
                        //if (mclsTerminalDetails.AutoPrint == PrintingPreference.Normal)	//print items if not yet printed
                        //{
                        clsEvent.AddEventLn("      printing items to POS printer...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        foreach (System.Data.DataRow dr in ItemDataTable.Rows)
                        {
                            string stItemNo = "" + dr["ItemNo"].ToString();
                            string stProductUnitCode = "" + dr["ProductUnitCode"].ToString();
                            decimal decPrice = Convert.ToDecimal(dr["Price"]);
                            decimal decDiscount = Convert.ToDecimal(dr["Discount"]);
                            decimal decAmount = Convert.ToDecimal(dr["Amount"]);
                            decimal decVAT = Convert.ToDecimal(dr["VAT"]);
                            decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                            decimal decPromoApplied = Convert.ToDecimal(dr["PromoApplied"]);
                            string stProductCode = "" + dr["ProductCode"].ToString();
                            if (dr["MatrixDescription"].ToString() != string.Empty && dr["MatrixDescription"].ToString() != null) stProductCode += "-" + dr["MatrixDescription"].ToString();
                            decimal decQuantity = 0;
                            string stDiscountCode = "" + dr["DiscountCode"].ToString();
                            DiscountTypes ItemDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["ItemDiscountType"].ToString());

                            if (dr["Quantity"].ToString().IndexOf("RETURN") != -1)
                            {
                                stProductCode = "" + dr["ProductCode"].ToString() + "-RET";
                                decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - RETURN", "").Trim());
                                decAmount = -decAmount;
                            }
                            else if (dr["Quantity"].ToString().IndexOf("DEMO") != -1)
                            {
                                stProductCode = "" + dr["ProductCode"].ToString() + "-DEMO";
                                decQuantity = Convert.ToDecimal(dr["Quantity"].ToString().Replace(" - DEMO", "").Trim());
                                decAmount = 0;
                            }
                            else if (dr["Quantity"].ToString() != "VOID")
                            {
                                decQuantity = Convert.ToDecimal(dr["Quantity"]);
                            }

                            if (dr["Quantity"].ToString().IndexOf("VOID") != -1)
                            {
                                if (mclsTerminalDetails.WillPrintVoidItem)
                                    if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default)
                                        PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType);
                            }
                            else
                            {
                                if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default)
                                    PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType);
                            }

                        }
                        if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.Default)
                        {
                            PrintReportFooterSection(true, clsTransactionStatus, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.AmountPaid, CashPayment, ChequePayment, CreditCardPayment, CreditPayment, DebitPayment, RewardPointsPayment, RewardConvertedPayment, ChangeAmount, arrChequePaymentDetails, arrCreditCardPaymentDetails, arrCreditPaymentDetails, arrDebitPaymentDetails);

                            // print the charge slip if not refund and will print
                            if (mclsTerminalDetails.WillPrintChargeSlip && !mboIsRefund)
                            {
                                clsEvent.AddEventLn("      printing charge slip...", true, mclsSysConfigDetails.WillWriteSystemLog);

                                // Nov 05, 2011 : Print Charge Slip
                                PrintChargeSlip(ChargeSlipType.Customer);
                                PrintChargeSlip(ChargeSlipType.Original);

                                if (mclsTerminalDetails.IncludeCreditChargeAgreement && mclsSalesTransactionDetails.CustomerDetails.CreditDetails.CardTypeDetails.WithGuarantor)
                                //if (!mclsTerminalDetails.IncludeCreditChargeAgreement) //do not print the guarantor if there is no agreement printed
                                {
                                    PrintChargeSlip(ChargeSlipType.Guarantor);
                                }
                            }
                        }
                        //}
                        // Sep 14, 2014 Control printing in mclsFilePrinter.Write
                    }
                }
                catch (Exception ex)
                {
                    clsEvent.AddErrorEventLn(ex);
                    clsEvent.AddEventLn("Error printing transaction no: " + mclsSalesTransactionDetails.TransactionNo + ". Already commited in the database.", true);
                }
            }
            #endregion

            // print all the coupon's
            #region Printing of coupons

            // print coupon's only for customer's with reward cards as per request of Sir Guy,
            // sa susunod ilalagay na sya sa selection
            if (mclsContactDetails.ContactID != Constants.C_RETAILPLUS_CUSTOMERID &&
                mclsContactDetails.RewardDetails.ContactID != 0)
            {
                Data.PromoBySupplier clsPromoBySupplier = new Data.PromoBySupplier(mConnection, mTransaction);
                mConnection = clsPromoBySupplier.Connection; mTransaction = clsPromoBySupplier.Transaction;

                try
                {
                    clsEvent.AddEventLn("Printing coupon if necessary...", true);

                    Data.PromoBySupplierDetails clsPromoBySupplierDetails = clsPromoBySupplier.getPromoBySupplierID();
                    if (clsPromoBySupplierDetails.PromoBySupplierID != 0)
                    {
                        Data.PromoBySupplierItems clsPromoBySupplierItems = new Data.PromoBySupplierItems(mConnection, mTransaction);
                        mConnection = clsPromoBySupplierItems.Connection; mTransaction = clsPromoBySupplierItems.Transaction;

                        Data.ProductGroup clsProductGroup = new Data.ProductGroup(mConnection, mTransaction);
                        mConnection = clsProductGroup.Connection; mTransaction = clsProductGroup.Transaction;

                        Data.ProductSubGroup clsProductSubGroup = new Data.ProductSubGroup(mConnection, mTransaction);
                        mConnection = clsProductSubGroup.Connection; mTransaction = clsProductSubGroup.Transaction;

                        decimal decPromoBySupplierValue = -1;
                        decimal decItemAmount = 0;
                        string strCouponRemarks = "";
                        var lstItems = mclsSalesTransactionDetails.TransactionItemsList;

                        Int64 ProductGroupID = 0, ProductSubGroupID = 0;
                        switch (clsPromoBySupplierDetails.PromoLevel)
                        {
                            case PromoLevel.All:
                                lstItems = mclsSalesTransactionDetails.TransactionItemsList;
                                decPromoBySupplierValue = -1;
                                decItemAmount = mclsSalesTransactionDetails.TransactionItemsList.Sum(x => x.Amount);
                                if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, 0, 0, 0, 0, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID))
                                {
                                    if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount)
                                    {
                                        //print it
                                        PrintCoupon(lstItems[0], strCouponRemarks);
                                    }
                                }

                                break;
                            case PromoLevel.Contact:
                                lstItems = mclsSalesTransactionDetails.TransactionItemsList
                                    .GroupBy(x => new { x.SupplierID, x.SupplierName })
                                    .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = "All", ProductSubGroup = "All", Amount = data.Sum(x => x.Amount) }).ToList();

                                foreach (Data.SalesTransactionItemDetails item in lstItems)
                                {
                                    decPromoBySupplierValue = -1;
                                    decItemAmount = item.Amount;
                                    if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, 0, 0, 0, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID))
                                    {
                                        if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount)
                                        {
                                            //print it
                                            PrintCoupon(item, strCouponRemarks);
                                        }
                                    }
                                }
                                break;
                            case PromoLevel.ProductGroup:
                                lstItems = mclsSalesTransactionDetails.TransactionItemsList
                                    .GroupBy(x => new { x.SupplierID, x.SupplierName, x.ProductGroup })
                                    .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = data.Key.ProductGroup, ProductSubGroup = "All", Amount = data.Sum(x => x.Amount) }).ToList();

                                foreach (Data.SalesTransactionItemDetails item in lstItems)
                                {
                                    decPromoBySupplierValue = -1;
                                    decItemAmount = item.Amount;
                                    ProductGroupID = clsProductGroup.DetailsByName(item.ProductGroup).ProductGroupID;

                                    if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, ProductGroupID, 0, 0, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID))
                                    {
                                        if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount)
                                        {
                                            //print it
                                            PrintCoupon(item, strCouponRemarks);
                                        }
                                    }
                                }
                                break;
                            case PromoLevel.ProductSubGroup:
                                lstItems = mclsSalesTransactionDetails.TransactionItemsList
                                    .GroupBy(x => new { x.SupplierID, x.SupplierName, x.ProductGroup, x.ProductSubGroup })
                                    .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = data.Key.ProductGroup, ProductSubGroup = data.Key.ProductSubGroup, Amount = data.Sum(x => x.Amount) }).ToList();

                                foreach (Data.SalesTransactionItemDetails item in lstItems)
                                {
                                    decPromoBySupplierValue = -1;
                                    decItemAmount = item.Amount;

                                    ProductGroupID = clsProductGroup.DetailsByName(item.ProductGroup).ProductGroupID;
                                    ProductSubGroupID = clsProductSubGroup.DetailsByName(item.ProductSubGroup).ProductSubGroupID;
                                    if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, ProductGroupID, ProductSubGroupID, 0, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID))
                                    {
                                        if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount)
                                        {
                                            //print it
                                            PrintCoupon(item, strCouponRemarks);
                                        }
                                    }
                                }
                                break;
                            case PromoLevel.Product:
                                lstItems = mclsSalesTransactionDetails.TransactionItemsList
                                    .GroupBy(x => new { x.SupplierID, x.SupplierName, x.ProductGroup, x.ProductSubGroup, x.ProductID })
                                    .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = data.Key.ProductGroup, ProductSubGroup = data.Key.ProductSubGroup, ProductID = data.Key.ProductID, Amount = data.Sum(x => x.Amount) }).ToList();

                                foreach (Data.SalesTransactionItemDetails item in lstItems)
                                {
                                    decPromoBySupplierValue = -1;
                                    decItemAmount = item.Amount;

                                    ProductGroupID = clsProductGroup.DetailsByName(item.ProductGroup).ProductGroupID;
                                    ProductSubGroupID = clsProductSubGroup.DetailsByName(item.ProductSubGroup).ProductSubGroupID;
                                    if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, ProductGroupID, ProductSubGroupID, item.ProductID, 0, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID))
                                    {
                                        if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount)
                                        {
                                            //print it
                                            PrintCoupon(item, strCouponRemarks);
                                        }
                                    }
                                }
                                break;
                            case PromoLevel.Variation:
                                lstItems = mclsSalesTransactionDetails.TransactionItemsList
                                    .GroupBy(x => new { x.SupplierID, x.SupplierName, x.ProductGroup, x.ProductSubGroup, x.ProductID, x.VariationsMatrixID })
                                    .Select(data => new Data.SalesTransactionItemDetails() { SupplierID = data.Key.SupplierID, SupplierName = data.Key.SupplierName, ProductGroup = data.Key.ProductGroup, ProductSubGroup = data.Key.ProductSubGroup, ProductID = data.Key.ProductID, VariationsMatrixID = data.Key.VariationsMatrixID, Amount = data.Sum(x => x.Amount) }).ToList();

                                foreach (Data.SalesTransactionItemDetails item in lstItems)
                                {
                                    decPromoBySupplierValue = -1;
                                    decItemAmount = item.Amount;

                                    ProductGroupID = clsProductGroup.DetailsByName(item.ProductGroup).ProductGroupID;
                                    ProductSubGroupID = clsProductSubGroup.DetailsByName(item.ProductSubGroup).ProductSubGroupID;
                                    if (clsPromoBySupplierItems.ApplyPromoBySupplierValue(clsPromoBySupplierDetails, item.SupplierID, ProductGroupID, ProductSubGroupID, item.ProductID, item.VariationsMatrixID, out decPromoBySupplierValue, out strCouponRemarks, mclsSalesTransactionDetails.BranchID))
                                    {
                                        if (decPromoBySupplierValue == 0 || decPromoBySupplierValue <= decItemAmount)
                                        {
                                            //print it
                                            PrintCoupon(item, strCouponRemarks);
                                        }
                                    }
                                }
                                break;
                        }

                    }
                    clsEvent.AddEventLn("done...", true);
                }
                catch (Exception ex)
                {
                    clsEvent.AddEventLn("Error printing coupon", true);
                    clsEvent.AddErrorEventLn(ex);
                }
                finally
                {
                    clsPromoBySupplier.CommitAndDispose();
                }

            }

            #endregion

            InsertAuditLog(AccessTypes.CloseTransaction, "Close transaction #: " + mclsSalesTransactionDetails.TransactionNo + "... Subtotal: " + mclsSalesTransactionDetails.SubTotal.ToString("#,###.#0") + " Discount: " + mclsSalesTransactionDetails.Discount.ToString("#,###.#0") + " AmountPaid: " + mclsSalesTransactionDetails.AmountPaid.ToString("#,###.#0") + " CashPayment: " + CashPayment.ToString("#,###.#0") + " ChequePayment: " + ChequePayment.ToString("#,###.#0") + " CreditCardPayment: " + CreditCardPayment + " CreditPayment: " + CreditPayment.ToString("#,###.#0") + " DebitPayment: " + DebitPayment.ToString("#,###.#0") + " ChangeAmount: " + ChangeAmount.ToString("#,###.#0") + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);

            clsEvent.AddEventLn("Done! Transaction no. " + mclsSalesTransactionDetails.TransactionNo + " has been closed. Subtotal: " + mclsSalesTransactionDetails.SubTotal.ToString("#,###.#0") + " Discount: " + mclsSalesTransactionDetails.Discount.ToString("#,###.#0") + " AmountPaid: " + mclsSalesTransactionDetails.AmountPaid.ToString("#,###.#0") + " CashPayment: " + CashPayment.ToString("#,###.#0") + " ChequePayment: " + ChequePayment.ToString("#,###.#0") + " CreditCardPayment: " + CreditCardPayment + " CreditPayment: " + CreditPayment.ToString("#,###.#0") + " DebitPayment: " + DebitPayment.ToString("#,###.#0") + " ChangeAmount: " + ChangeAmount.ToString("#,###.#0"), true);

        }
Beispiel #31
0
		private void LoadContact(AceSoft.RetailPlus.Data.ContactGroupCategory enumContactGroupCategory, Data.ContactDetails pContactDetails, bool isFromCreditPayment = false)
		{
			try
			{
                if ((mclsTerminalDetails.ShowCustomerSelection || pContactDetails.ContactID != 0) && 
                    (enumContactGroupCategory == Data.ContactGroupCategory.CUSTOMER || enumContactGroupCategory == Data.ContactGroupCategory.AGENT))
					mclsContactDetails = pContactDetails;
				else
				{
					string strContactCardNo = txtBarCode.Text.Replace(Constants.SWIPE_REWARD_CARD, "").Trim();

					Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction);
                    mConnection = clsContact.Connection; mTransaction = clsContact.Transaction;

					// check using reward card info
					mclsContactDetails = clsContact.DetailsByRewardCardNo(strContactCardNo);
					if (mclsContactDetails.ContactID != 0)
						mboRewardCardSwiped = true;
					else if (mclsContactDetails.ContactID == 0) 
					{
						// check using credit card info
						mclsContactDetails = clsContact.DetailsByCreditCardNo(strContactCardNo);
                        if (mclsContactDetails.ContactID == 0 && strContactCardNo.Length == 7) mclsContactDetails = clsContact.DetailsByCreditCardNo("888880" + strContactCardNo);
                        if (mclsContactDetails.ContactID == 0 && strContactCardNo.Length == 7) mclsContactDetails = clsContact.DetailsByCreditCardNo("800000" + strContactCardNo);
                        if (mclsContactDetails.ContactID == 0 && strContactCardNo.Length == 9) mclsContactDetails = clsContact.DetailsByCreditCardNo(BarcodeHelper.GroupCreditCard_Country_Code + BarcodeHelper.GroupCreditCard_ManufacturerCode + strContactCardNo);
                        if (mclsContactDetails.ContactID == 0 && strContactCardNo.Length == 9) mclsContactDetails = clsContact.DetailsByCreditCardNo(BarcodeHelper.CustomerCode_Country_Code + BarcodeHelper.CustomerCode_ManufacturerCode + strContactCardNo);
                        if (mclsContactDetails.ContactID == 0 && strContactCardNo.Length == 9) mclsContactDetails = clsContact.DetailsByCreditCardNo(BarcodeHelper.GroupCreditCard_Country_Code + BarcodeHelper.GroupCreditCard_ManufacturerCode_Manual + strContactCardNo);
                        if (mclsContactDetails.ContactID == 0 && strContactCardNo.Length == 9) mclsContactDetails = clsContact.DetailsByCreditCardNo(BarcodeHelper.CreditCard_Country_Code + BarcodeHelper.CreditCard_ManufacturerCode + strContactCardNo);

						if (mclsContactDetails.ContactID != 0)
							mboCreditCardSwiped = true;
						else if (mclsContactDetails.ContactID == 0) 
						{
							strContactCardNo = strContactCardNo.Remove(strContactCardNo.Length - 1);
							// check using reward card info
							mclsContactDetails = clsContact.DetailsByRewardCardNo(strContactCardNo);
							if (mclsContactDetails.ContactID != 0)
								mboRewardCardSwiped = true;
							else if (mclsContactDetails.ContactID == 0)
							{
								// check using credit card info
								mclsContactDetails = clsContact.DetailsByCreditCardNo(strContactCardNo);
								if (mclsContactDetails.ContactID != 0)
									mboCreditCardSwiped = true;
								else if (mclsContactDetails.ContactID == 0)
								{ clsContact.CommitAndDispose(); SelectContact(AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER); return;}
							}
						}

					}
					clsContact.CommitAndDispose();
				}

				// Sep 24, 2011      Lemuel E. Aceron
				// Added order slip wherein all punch items will not change sales and inventory
				// a customer named ORDER SLIP should be defined in contacts
				if (mclsContactDetails.ContactName.Trim().ToUpper() == Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER && mboIsInTransaction && enumContactGroupCategory == AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER)
				{
					MessageBox.Show("Sorry you cannot select ORDER SLIP customer when an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
					clsEvent.AddEventLn("Cancelled!"); return;
				}

				switch (enumContactGroupCategory)
				{
					case AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER:

                        // if not from CreditPayment-F3, do not overwrite 
                        if (!isFromCreditPayment)
                        {
                            lblCustomer.Tag = mclsContactDetails.ContactID;
                            lblCustomer.Text = mclsContactDetails.ContactName;
                        }

						if (!mclsTerminalDetails.ShowCustomerSelection) { txtBarCode.Text = string.Empty; txtBarCode.Focus(); }
						clsEvent.AddEventLn("Done! Selected customer: " + lblCustomer.Text);

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

                            if (mboRewardCardSwiped)
                            {
                                mclsSalesTransactionDetails.RewardsCustomerID = mclsContactDetails.ContactID;
                                mclsSalesTransactionDetails.RewardsCustomerName = mclsContactDetails.ContactName;
                                clsSalesTransactions.UpdateRewardsContactUpdate(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo, mclsSalesTransactionDetails.TransactionID, mclsContactDetails.ContactID, mclsContactDetails.ContactName);
                            }

							clsSalesTransactions.UpdateContact(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TransactionDate, mclsContactDetails);
                            clsSalesTransactions.CommitAndDispose();
						}
                        if (mboRewardCardSwiped)
                        {
                            mclsSalesTransactionDetails.RewardsCustomerID = mclsContactDetails.ContactID;
                            mclsSalesTransactionDetails.RewardsCustomerName = mclsContactDetails.ContactName;
                            mclsSalesTransactionDetails.RewardCardActive = mclsContactDetails.RewardDetails.RewardActive;
                            mclsSalesTransactionDetails.RewardCardNo = mclsContactDetails.RewardDetails.RewardCardNo;
                            mclsSalesTransactionDetails.RewardPreviousPoints = mclsContactDetails.RewardDetails.RewardPoints;
                            mclsSalesTransactionDetails.RewardCurrentPoints = mclsSalesTransactionDetails.RewardPreviousPoints;

                            // no need to check if the current customer for the transaction is the default customer
                            //if (mclsSalesTransactionDetails.CustomerID == Constants.C_RETAILPLUS_CUSTOMERID)
                            //{
                            mclsSalesTransactionDetails.CustomerID = mclsContactDetails.ContactID;
                            mclsSalesTransactionDetails.CustomerName = mclsContactDetails.ContactName;
                            mclsSalesTransactionDetails.CustomerDetails = mclsContactDetails;
                            //}
                        }
                        else
                        {
                            mclsSalesTransactionDetails.CustomerID = mclsContactDetails.ContactID;
                            mclsSalesTransactionDetails.CustomerName = mclsContactDetails.ContactName;
                            mclsSalesTransactionDetails.CustomerDetails = mclsContactDetails;
                        }

						break;
					case AceSoft.RetailPlus.Data.ContactGroupCategory.AGENT:
                        lblAgent.Tag = pContactDetails.ContactID;
                        lblAgent.Text = pContactDetails.ContactName;
                        lblAgentPositionDepartment.Text = pContactDetails.PositionName;
                        lblAgentPositionDepartment.Tag = pContactDetails.DepartmentName;
						clsEvent.AddEventLn("Done! Selected agent: " + lblAgent.Text);

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

                            clsSalesTransactions.UpdateAgent(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TransactionDate, pContactDetails);
							clsSalesTransactions.CommitAndDispose();
						}
                        mclsSalesTransactionDetails.AgentID = pContactDetails.ContactID;
                        mclsSalesTransactionDetails.AgentName = pContactDetails.ContactName;
						break;
				}
			}
			catch (Exception ex)
			{ 
                InsertErrorLogToFile(ex, "ERROR!!! Loading contact."); 
            }
		}
Beispiel #32
0
        public void PrintCollectionReceipt()
        {
            try
            {
                if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto)
                {
                    MessageBox.Show("Sorry this option is not applicable for Auto-Print receipt.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                    return;
                }
                if (!mboIsInTransaction)
                {
                    MessageBox.Show("No active transaction is found! Please transact first.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                    return;
                }
                DialogResult loginresult = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.CloseTransaction);

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

                    login.AccessType = AccessTypes.CloseTransaction;
                    login.Header = "Print Collection Receipt";
                    login.TerminalDetails = mclsTerminalDetails;
                    login.ShowDialog(this);
                    loginresult = login.Result;
                    login.Close();
                    login.Dispose();
                }
                if (loginresult == DialogResult.OK)
                {
                    CRSReports.CR rpt = new CRSReports.CR();

                    AceSoft.RetailPlus.Client.ReportDataset rptds = new AceSoft.RetailPlus.Client.ReportDataset();
                    System.Data.DataRow drNew;

                    /****************************sales transaction *****************************/
                    Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                    mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                    Data.SalesTransactionDetails clsSalesTransactionDetails = clsSalesTransactions.Details(mclsSalesTransactionDetails.TransactionNo, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID);

                    Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction);
                    Data.ContactDetails clsContactDetails = clsContact.Details(clsSalesTransactionDetails.CustomerID);

                    if (clsSalesTransactionDetails.isExist)
                    {
                        drNew = rptds.Transactions.NewRow();

                        drNew["TransactionID"] = clsSalesTransactionDetails.TransactionID;
                        drNew["TransactionNo"] = clsSalesTransactionDetails.TransactionNo;
                        drNew["ORNo"] = clsSalesTransactionDetails.ORNo;
                        drNew["CustomerName"] = clsSalesTransactionDetails.CustomerName;
                        drNew["CustomerAddress"] = clsContactDetails.Address;
                        drNew["CustomerTerms"] = clsSalesTransactionDetails.Terms;
                        drNew["CustomerModeOfterms"] = clsSalesTransactionDetails.ModeOfTerms;
                        drNew["CustomerBusinessName"] = clsContactDetails.BusinessName;
                        drNew["CustomerTelNo"] = clsContactDetails.TelephoneNo;
                        drNew["CashierName"] = clsSalesTransactionDetails.CashierName;
                        drNew["CreatedByName"] = clsSalesTransactionDetails.CreatedByName;
                        drNew["AgentName"] = clsSalesTransactionDetails.AgentName;
                        drNew["TerminalNo"] = clsSalesTransactionDetails.TerminalNo;
                        drNew["TransactionDate"] = clsSalesTransactionDetails.TransactionDate;
                        drNew["DateSuspended"] = clsSalesTransactionDetails.DateSuspended.ToString();
                        drNew["DateResumed"] = clsSalesTransactionDetails.DateResumed;
                        drNew["TransactionStatus"] = clsSalesTransactionDetails.TransactionStatus;
                        drNew["SubTotal"] = clsSalesTransactionDetails.SubTotal;
                        drNew["ItemsDiscount"] = clsSalesTransactionDetails.ItemsDiscount;
                        //drNew["SNRItemsDiscount"] = clsSalesTransactionDetails.SNRItemsDiscount;
                        //drNew["PWDItemsDiscount"] = clsSalesTransactionDetails.PWDItemsDiscount;
                        //drNew["OtherItemsDiscount"] = clsSalesTransactionDetails.OtherItemsDiscount;
                        drNew["Discount"] = clsSalesTransactionDetails.Discount;
                        drNew["VAT"] = clsSalesTransactionDetails.VAT;
                        drNew["VATableAmount"] = clsSalesTransactionDetails.VATableAmount;
                        //drNew["ZeroRatedSales"] = clsSalesTransactionDetails.ZeroRatedSales;
                        drNew["LocalTax"] = clsSalesTransactionDetails.LocalTax;
                        drNew["AmountPaid"] = clsSalesTransactionDetails.AmountPaid;
                        drNew["CashPayment"] = clsSalesTransactionDetails.CashPayment;
                        drNew["ChequePayment"] = clsSalesTransactionDetails.ChequePayment;
                        drNew["CreditCardPayment"] = clsSalesTransactionDetails.CreditCardPayment;
                        drNew["CreditPayment"] = clsSalesTransactionDetails.CreditPayment;
                        drNew["DebitPayment"] = clsSalesTransactionDetails.DebitPayment;
                        drNew["BalanceAmount"] = clsSalesTransactionDetails.BalanceAmount;
                        drNew["ChangeAmount"] = clsSalesTransactionDetails.ChangeAmount;
                        drNew["DateClosed"] = clsSalesTransactionDetails.DateClosed;
                        drNew["PaymentType"] = clsSalesTransactionDetails.PaymentType.ToString("d");
                        drNew["Charge"] = clsSalesTransactionDetails.Charge;
                        drNew["isConsignment"] = clsSalesTransactionDetails.isConsignment;
                        drNew["CRNo"] = clsSalesTransactionDetails.CRNo.ToString().PadLeft(15, '0');

                        rptds.Transactions.Rows.Add(drNew);

                        /****************************sales transaction items*****************************/
                        Data.SalesTransactionItems clsSalesTransactionItems = new Data.SalesTransactionItems(mConnection, mTransaction);
                        mConnection = clsSalesTransactionItems.Connection; mTransaction = clsSalesTransactionItems.Transaction;

                        System.Data.DataTable dt = clsSalesTransactionItems.List(clsSalesTransactionDetails.TransactionID, clsSalesTransactionDetails.TransactionDate, "TransactionItemsID", SortOption.Ascending);

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

                            foreach (System.Data.DataColumn dc in rptds.SalesTransactionItems.Columns)
                                drNew[dc] = dr[dc.ColumnName];

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

                    clsSalesTransactions.CommitAndDispose();

                    rpt.SetDataSource(rptds);

                    CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition paramField;
                    CrystalDecisions.Shared.ParameterValues currentValues;
                    CrystalDecisions.Shared.ParameterDiscreteValue discreteParam;

                    paramField = rpt.DataDefinition.ParameterFields["CompanyName"];
                    discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue();
                    discreteParam.Value = CompanyDetails.CompanyName;
                    currentValues = new CrystalDecisions.Shared.ParameterValues();
                    currentValues.Add(discreteParam);
                    paramField.ApplyCurrentValues(currentValues);

                    paramField = rpt.DataDefinition.ParameterFields["PrintedBy"];
                    discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue();
                    discreteParam.Value = mclsSalesTransactionDetails.CashierName;
                    currentValues = new CrystalDecisions.Shared.ParameterValues();
                    currentValues.Add(discreteParam);
                    paramField.ApplyCurrentValues(currentValues);

                    paramField = rpt.DataDefinition.ParameterFields["PackedBy"];
                    discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue();
                    discreteParam.Value = mclsSalesTransactionDetails.WaiterName; // grpItems.Text.Remove(0, 11);
                    currentValues = new CrystalDecisions.Shared.ParameterValues();
                    currentValues.Add(discreteParam);
                    paramField.ApplyCurrentValues(currentValues);

                    paramField = rpt.DataDefinition.ParameterFields["CompanyAddress"];
                    discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue();
                    discreteParam.Value = CompanyDetails.Address1 +
                        ((!string.IsNullOrEmpty(CompanyDetails.Address2) ? Environment.NewLine + CompanyDetails.Address2 + ", " : " ")) +
                        CompanyDetails.City + " " + CompanyDetails.Country +
                        ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "Tel #: " + CompanyDetails.OfficePhone + " " : " ")) +
                        ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "FaxPhone #: " + CompanyDetails.FaxPhone + " " : " "));
                    currentValues = new CrystalDecisions.Shared.ParameterValues();
                    currentValues.Add(discreteParam);
                    paramField.ApplyCurrentValues(currentValues);

                    paramField = rpt.DataDefinition.ParameterFields["BIRInfo"];
                    discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue();
                    discreteParam.Value = "TIN : " + CompanyDetails.TIN + "      VAT Reg." +
                                            Environment.NewLine + "BIR Acc #: " + CONFIG.AccreditationNo + " SN#: " + CONFIG.MachineSerialNo +
                                            Environment.NewLine + "Permit No: FP102014-064-0015149-00000";
                    currentValues = new CrystalDecisions.Shared.ParameterValues();
                    currentValues.Add(discreteParam);
                    paramField.ApplyCurrentValues(currentValues);

                    paramField = rpt.DataDefinition.ParameterFields["TINNo"];
                    discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue();
                    discreteParam.Value = mclsSalesTransactionDetails.CustomerDetails.TINNo; 
                    currentValues = new CrystalDecisions.Shared.ParameterValues();
                    currentValues.Add(discreteParam);
                    paramField.ApplyCurrentValues(currentValues);

                    paramField = rpt.DataDefinition.ParameterFields["LTONo"];
                    discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue();
                    discreteParam.Value = mclsSalesTransactionDetails.CustomerDetails.LTONo; 
                    currentValues = new CrystalDecisions.Shared.ParameterValues();
                    currentValues.Add(discreteParam);
                    paramField.ApplyCurrentValues(currentValues);

                    //foreach (CrystalDecisions.CrystalReports.Engine.ReportObject objPic in rpt.Section1.ReportObjects)
                    //{
                    //    if (objPic.Name.ToUpper() == "PICLOGO1")
                    //    {
                    //        objPic = new Bitmap(Application.StartupPath + "/images/ReportLogo.jpg");
                    //    }
                    //}

                    //CRViewer.Visible = true;
                    //CRViewer.ReportSource = rpt;
                    //CRViewer.Show();

                    try
                    {
                        DateTime logdate = DateTime.Now;
                        string logsdir = System.Configuration.ConfigurationManager.AppSettings["logsdir"].ToString();

                        if (!Directory.Exists(logsdir + logdate.ToString("MMM")))
                        {
                            Directory.CreateDirectory(logsdir + logdate.ToString("MMM"));
                        }
                        string logFile = logsdir + logdate.ToString("MMM") + "/CR_" + clsSalesTransactionDetails.TransactionNo + logdate.ToString("yyyyMMddhhmmss") + ".doc";

                        rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, logFile);
                    }
                    catch { }

                    if (isPrinterOnline(mclsTerminalDetails.SalesInvoicePrinterName))
                    {
                        rpt.PrintOptions.PrinterName = mclsTerminalDetails.SalesInvoicePrinterName;
                        rpt.PrintToPrinter(1, false, 0, 0);
                    }
                    else
                    {
                        clsEvent.AddEventLn("will not print delivery receipt. printer is offline.", true, mclsSysConfigDetails.WillWriteSystemLog);
                    }

                    rpt.Close();
                    rpt.Dispose();

                }
            }
            catch (Exception ex)
            {
                InsertErrorLogToFile(ex);
            }
        }
Beispiel #33
0
        private void TransactionNoWnd_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            switch (e.KeyData)
            {
            case Keys.Escape:
                dialog = DialogResult.Cancel;
                this.Hide();
                break;

            case Keys.Enter:
                if (string.IsNullOrEmpty(txtTerminalNo.Text))
                {
                    MessageBox.Show("Sorry please enter a valid TerminalNo.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (string.IsNullOrEmpty(txtTransactionNo.Text))
                {
                    MessageBox.Show("Sorry please enter a valid TransactionNo.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions();
                TransactionStatus      status = clsSalesTransactions.Status(txtTransactionNo.Text, txtTerminalNo.Text);
                clsSalesTransactions.CommitAndDispose();

                switch (status)
                {
                case TransactionStatus.Closed:
                case TransactionStatus.Reprinted:
                case TransactionStatus.Refund:
                case TransactionStatus.CreditPayment:
                case TransactionStatus.DebitPayment:
                case TransactionStatus.Released:
                case TransactionStatus.ParkingTicket:

                case TransactionStatus.ClosedWalkIn:
                case TransactionStatus.ClosedOutOfStock:
                case TransactionStatus.Consignment:
                case TransactionStatus.ClosedWalkInRefund:
                case TransactionStatus.ClosedOutOfStockRefund:
                case TransactionStatus.ConsignmentRefund:
                    mstrTransactionNo = txtTransactionNo.Text.PadLeft(miTransactionNoLength - 1, '0');
                    mstrTerminalNo    = txtTerminalNo.Text;
                    dialog            = DialogResult.OK;
                    this.Hide();
                    break;

                case TransactionStatus.Open:
                case TransactionStatus.NotYetApplied:

                    MessageBox.Show("Sorry you have entered an invalid Transaction No. Please type a valid Transaction No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;

                case TransactionStatus.Void:
                case TransactionStatus.CancelledCreditPayment:
                case TransactionStatus.Suspended:
                case TransactionStatus.SuspendedOpen:
                case TransactionStatus.OrderSlip:
                default:
                    MessageBox.Show("Sorry the Transaction No. you entered is " + status.ToString("G") + ". " +
                                    "Please enter a valid Transaction No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                }
                //if (status == TransactionStatus.NotYetApplied)
                //{
                //    MessageBox.Show("Sorry you have entered an invalid Transaction No. Please type a valid Transaction No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //    return;
                //}
                //else if (status == TransactionStatus.Closed ||
                //        status == TransactionStatus.Released || status == TransactionStatus.Refund || status == TransactionStatus.CreditPayment)
                //{
                //    mstrTransactionNo = txtTransactionNo.Text.PadLeft(miTransactionNoLength - 1, '0');
                //    mstrTerminalNo = txtTerminalNo.Text;
                //    dialog = DialogResult.OK;
                //    this.Hide();
                //}
                //else
                //{
                //    MessageBox.Show("Sorry the Transaction No. you entered is " + status.ToString("G") + ". " +
                //        "Please enter a valid Transaction No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //    return;
                //}
                break;
            }
        }
Beispiel #34
0
        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;
        }
Beispiel #35
0
        private void UpdateIsConsignment()
        {
            if (!mboIsInTransaction)
            {
                MessageBox.Show("Sorry you cannot consign an empty transaction.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            // 18Feb2016 : Do not allow consignment if items > 1 and AllowMoreThan1ItemIfConsignment is FALSE
            if (!mclsSysConfigDetails.AllowMoreThan1ItemIfConsignment && ItemDataTable.Rows.Count > 1)
            {
                MessageBox.Show("Sorry you cannot tag this transaction is CONSIGNMENT. You are only allowed to consign 1 item, per transaction.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (mclsSalesTransactionDetails.AgentID == Constants.C_RETAILPLUS_AGENTID)
            {
                if (MessageBox.Show("Sorry you need to select an agent before you can consign this transaction! Select now?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                { if (!SelectContact(Data.ContactGroupCategory.AGENT)) return; }
                else
                    return;
            }

            if (mclsSalesTransactionDetails.CustomerID == Constants.ZERO || mclsSalesTransactionDetails.CustomerID == Constants.C_RETAILPLUS_CUSTOMERID)
            {
                if (MessageBox.Show("Sorry you need to select a customer before you can consign this transaction! Select now?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                { if (!SelectContact(Data.ContactGroupCategory.CUSTOMER)) return; }
                else
                    return;
            }

            DialogResult loginresult = GetWriteAccessAndLogin(mclsSalesTransactionDetails.CashierID, AccessTypes.CloseTransaction, "Consign Transaction Access Validation");

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

                    clsSalesTransactions.UpdateisConsignment(mclsSalesTransactionDetails.TransactionID, !mclsSalesTransactionDetails.isConsignment);
                    clsSalesTransactions.CommitAndDispose();

                    mclsSalesTransactionDetails.isConsignment = !mclsSalesTransactionDetails.isConsignment;

                    lblConsignment.Visible = mclsSalesTransactionDetails.isConsignment;

                    InsertAuditLog(AccessTypes.CloseTransaction, "Updating isConsignment: " + mclsSalesTransactionDetails.isConsignment.ToString() + " in the database for transactionno: " + mclsSalesTransactionDetails.TransactionNo + " done.");
                    MessageBox.Show(mclsSalesTransactionDetails.isConsignment ? "This transaction has been saved as consignment." : "This transaction has been saved as NOT consignment", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    InsertErrorLogToFile(ex, "ERROR!!! Updating isConsignment: " + mclsSalesTransactionDetails.isConsignment.ToString() + " in the database for transactionno: " + mclsSalesTransactionDetails.TransactionNo + ". TRACE: ");
                    throw ex;
                }
            }
        }
Beispiel #36
0
        private void LoadItemData()
        {
            try
            {
                System.Data.DataTable dt = new System.Data.DataTable("tblproducts");

                dt.Columns.Add("TransactionItemsID");
                dt.Columns.Add("ProductID");
                dt.Columns.Add("ProductCode");
                dt.Columns.Add("BarCode");
                dt.Columns.Add("ProductDesc");
                dt.Columns.Add("ProductUnitID");
                dt.Columns.Add("ProductUnitCode");
                dt.Columns.Add("Quantity");
                dt.Columns.Add("Price");
                dt.Columns.Add("Discount");
                dt.Columns.Add("ItemDiscount");
                dt.Columns.Add("ItemDiscountType");
                dt.Columns.Add("Amount");
                dt.Columns.Add("VAT");
                dt.Columns.Add("EVAT");
                dt.Columns.Add("LocalTax");
                dt.Columns.Add("VariationsMatrixID");
                dt.Columns.Add("MatrixDescription");
                dt.Columns.Add("ProductGroup");
                dt.Columns.Add("ProductSubGroup");
                dt.Columns.Add("TransactionItemStatus");
                dt.Columns.Add("DiscountCode");
                dt.Columns.Add("DiscountRemarks");
                dt.Columns.Add("ProductPackageID");
                dt.Columns.Add("MatrixPackageID");
                dt.Columns.Add("PackageQuantity");
                dt.Columns.Add("PromoQuantity");
                dt.Columns.Add("PromoValue");
                dt.Columns.Add("PromoInPercent");
                dt.Columns.Add("PromoType");
                dt.Columns.Add("PromoApplied");
                dt.Columns.Add("PurchasePrice");
                dt.Columns.Add("PurchaseAmount");

                Data.SalesTransactions       clsSalesTransactions = new Data.SalesTransactions();
                Data.SalesTransactionDetails det = clsSalesTransactions.Details(mstTransactionNo, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID);
                clsSalesTransactions.CommitAndDispose();

                Data.SalesTransactionItems         clsItems         = new Data.SalesTransactionItems();
                Data.SalesTransactionItemDetails[] TransactionItems = clsItems.Details(det.TransactionID, det.TransactionDate);
                clsItems.CommitAndDispose();

                foreach (Data.SalesTransactionItemDetails item in TransactionItems)
                {
                    if (item.TransactionItemStatus == AceSoft.RetailPlus.TransactionItemStatus.Valid)
                    {
                        System.Data.DataRow dr = dt.NewRow();

                        dr["TransactionItemsID"] = item.TransactionItemsID;
                        dr["ProductID"]          = item.ProductID;
                        dr["ProductCode"]        = item.ProductCode;
                        dr["BarCode"]            = item.BarCode;
                        dr["ProductDesc"]        = item.Description;
                        dr["ProductUnitID"]      = item.ProductUnitID;
                        dr["ProductUnitCode"]    = item.ProductUnitCode;
                        dr["Quantity"]           = item.Quantity;
                        dr["Price"]            = item.Price;
                        dr["Discount"]         = item.Discount;
                        dr["ItemDiscount"]     = item.ItemDiscount;
                        dr["ItemDiscountType"] = item.ItemDiscountType;
                        dr["Amount"]           = item.Amount;
                        dr["VAT"]                   = item.VAT;
                        dr["EVAT"]                  = item.EVAT;
                        dr["LocalTax"]              = item.LocalTax;
                        dr["VariationsMatrixID"]    = item.VariationsMatrixID;
                        dr["MatrixDescription"]     = item.MatrixDescription;
                        dr["ProductGroup"]          = item.ProductGroup;
                        dr["ProductSubGroup"]       = item.ProductSubGroup;
                        dr["TransactionItemStatus"] = item.TransactionItemStatus;
                        dr["DiscountCode"]          = item.DiscountCode;
                        dr["DiscountRemarks"]       = item.DiscountRemarks;
                        dr["ProductPackageID"]      = item.ProductPackageID;
                        dr["MatrixPackageID"]       = item.MatrixPackageID;
                        dr["PackageQuantity"]       = item.PackageQuantity;
                        dr["PromoQuantity"]         = item.PromoQuantity;
                        dr["PromoValue"]            = item.PromoValue;
                        dr["PromoInPercent"]        = item.PromoInPercent;
                        dr["PromoType"]             = item.PromoType;
                        dr["PromoApplied"]          = item.PromoApplied;
                        dr["PurchasePrice"]         = item.PurchasePrice;
                        dr["PurchaseAmount"]        = item.PurchaseAmount;

                        dt.Rows.Add(dr);
                    }
                }
                this.dgStyle.MappingName = dt.TableName;
                dgItems.DataSource       = dt;

                if (dgItems.VisibleRowCount > 0)
                {
                    dgItems.Select(0);
                }
                dgItems.CurrentRowIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #37
0
		private void UnPackTransaction()
		{
			if (!mboIsInTransaction)
			{
				MessageBox.Show("Sorry you cannot unpack an empty transaction.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				return;
			}

			if (mclsSalesTransactionDetails.WaiterID == Constants.C_RETAILPLUS_WAITERID)
			{
				if (MessageBox.Show("Sorry you need to select waiter/packer before you can un-pack! Select now?", "RetailPlus", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK)
				{ if (!SelectWaiter()) return; }
				else
					return;
			}

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

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

					clsSalesTransactions.UnPack(mclsSalesTransactionDetails.TransactionID);
					clsSalesTransactions.CommitAndDispose();

					MessageBox.Show("UnPacking Done!", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
				}
				catch (Exception ex)
				{
					InsertErrorLogToFile(ex, "ERROR!!! UnPacking sales transaction to database. TRACE: ");
					throw ex;
				}
			}
		}
Beispiel #38
0
        private void EnterCreditItemizePayment()
        {
            if (!SuspendTransactionAndContinue()) return;

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

            if (loginresult == DialogResult.OK)
            {
                LoadOptions();
                if (!CheckIfOKToSell(true)) return;

                ContactSelectWnd clsContactWnd = new ContactSelectWnd();
                clsContactWnd.EnableContactAddUpdate = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.Contacts) == System.Windows.Forms.DialogResult.OK;
                clsContactWnd.SysConfigDetails = mclsSysConfigDetails;
                clsContactWnd.TerminalDetails = mclsTerminalDetails;
                clsContactWnd.HasCreditOnly = true;
                clsContactWnd.ShowDialog(this);
                DialogResult result = clsContactWnd.Result;
                mclsContactDetails = clsContactWnd.Details;
                clsContactWnd.Close();
                clsContactWnd.Dispose();

                if (result == DialogResult.OK)
                {
                    CreditsItemizeWnd creditWnd = new CreditsItemizeWnd();
                    creditWnd.TerminalDetails = mclsTerminalDetails;
                    creditWnd.SysConfigDetails = mclsSysConfigDetails;
                    creditWnd.CashierID = mclsSalesTransactionDetails.CashierID;
                    creditWnd.CashierName = mclsSalesTransactionDetails.CashierName;
                    creditWnd.CustomerDetails = mclsContactDetails;
                    creditWnd.ShowDialog(this);

                    Keys keyData = creditWnd.KeyData;
                    string strTransactionNoToReprint = creditWnd.TransactionNoToReprint;
                    string strTerminalNoToReprint = creditWnd.TerminalNoToReprint;

                    decimal AmountPaid = creditWnd.AmountPayment;
                    decimal CashPayment = creditWnd.CashPayment;
                    decimal ChequePayment = creditWnd.ChequePayment;
                    decimal CreditCardPayment = creditWnd.CreditCardPayment;
                    decimal DebitPayment = creditWnd.DebitPayment;
                    decimal BalanceAmount = creditWnd.BalanceAmount;
                    decimal ChangeAmount = creditWnd.ChangeAmount;

                    DataGridViewSelectedRowCollection dgvItemsSelectedRows = creditWnd.dgvItemsSelectedRows;
                    PaymentTypes PaymentType = creditWnd.PaymentType;
                    ArrayList arrCashPaymentDetails = creditWnd.CashPaymentDetails;
                    ArrayList arrChequePaymentDetails = creditWnd.ChequePaymentDetails;
                    ArrayList arrCreditCardPaymentDetails = creditWnd.CreditCardPaymentDetails;
                    ArrayList arrDebitPaymentDetails = creditWnd.DebitPaymentDetails;
                    result = creditWnd.Result;

                    // do not dispose here coz the dgvItemsSelectedRows is also disposed
                    //creditWnd.Close();
                    //creditWnd.Dispose();

                    if (result == DialogResult.OK)
                    {
                        if (keyData == Keys.F12)
                        {
                            ReprintTransaction(strTransactionNoToReprint, strTerminalNoToReprint);
                            return;
                        }

                        bool boActivateSuspendedAccount = true;

                        if (!mclsContactDetails.CreditDetails.CreditActive)
                        {
                            if (MessageBox.Show("Account is InActive, would you like to re-activate? Remarks: " + Environment.NewLine + mclsContactDetails.Remarks + Environment.NewLine + Environment.NewLine + "Press [yes] to automatically activate or [no] to disregard activation.", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
                                boActivateSuspendedAccount = false;
                        }

                        Int64 iCollectionReceiptNo = 0;
                        if (mclsSysConfigDetails.CreditPaymentType == CreditPaymentType.MPC)
                        {
                            decimal decRetValue = 0;
                            if (ShowNoControl(this, out decRetValue, decimal.Parse(iCollectionReceiptNo.ToString()), "Enter Collection Receipt (CR) No.") != System.Windows.Forms.DialogResult.OK)
                            {
                                MessageBox.Show("Sorry you cannot issue a Credit Payment without the collection receipt no. Please enter CR No first.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return;
                            }
                            else 
                            {
                                iCollectionReceiptNo = Int64.Parse(decRetValue.ToString());
                            }
                        }

                        Cursor.Current = Cursors.WaitCursor;

                        try
                        {
                            LocalDB clsLocalDB = new LocalDB(mConnection, mTransaction);
                            mConnection = clsLocalDB.Connection; mTransaction = clsLocalDB.Transaction;

                            mclsSalesTransactionDetails = new Data.SalesTransactionDetails();
                            mclsSalesTransactionDetails.TransactionItemsList = new System.Collections.Generic.List<Data.SalesTransactionItemDetails>();
                            mclsSalesTransactionDetails.CustomerDetails = mclsContactDetails;
                            mclsSalesTransactionDetails.TransactionStatus = TransactionStatus.CreditPayment;
                            mclsSalesTransactionDetails.CRNo = iCollectionReceiptNo;

                            Data.Products clsProducts = new Data.Products(mConnection, mTransaction);
                            mConnection = clsProducts.Connection; mTransaction = clsProducts.Transaction;

                            if (clsProducts.Details(Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE).ProductID == 0)
                            {
                                clsProducts.CREATE_CREDITPAYMENT_PRODUCT();
                                Methods.InsertAuditLog(mclsTerminalDetails, "System Administrator", AccessTypes.EnterCreditPayment, "CREDIT PAYMENT product has been created coz it's not configured");
                            }

                            /************** April 21, 2006: added transaction no. ***************/
                            lblCustomer.Tag = mclsContactDetails.ContactID;
                            lblCustomer.Text = mclsContactDetails.ContactName;

                            clsEvent.AddEvent("[" + lblCashier.Text + "] Creating " + Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE + " transaction for customer: ");
                            LoadContact(AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER, mclsContactDetails);

                            if (!this.CreateTransaction()) return;
                            
                            txtBarCode.Text = Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE;
                            ReadBarCode();
                            int iRow = dgItems.CurrentRowIndex;

                            Data.SalesTransactionItemDetails clsItemDetails = getCurrentRowItemDetails();
                            clsItemDetails.Price = AmountPaid;
                            clsItemDetails.Amount = AmountPaid;

                            clsItemDetails = ComputeItemTotal(clsItemDetails); // set the grossales, vat, discounts, etc.(Details);

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

                            ApplyChangeQuantityPriceAmountDetails(iRow, clsItemDetails, "Change Quantity, Price, Amount for Credit Payment");
                            // re-instantiate the status
                            mclsSalesTransactionDetails.TransactionStatus = TransactionStatus.CreditPayment;

                            mclsSalesTransactionDetails.AmountDue = AmountPaid;
                            mclsSalesTransactionDetails.AmountPaid = AmountPaid;
                            mclsSalesTransactionDetails.ChangeAmount = ChangeAmount;
                            mclsSalesTransactionDetails.CashPayment = CashPayment;
                            mclsSalesTransactionDetails.ChequePayment = ChequePayment;
                            mclsSalesTransactionDetails.PaymentType = PaymentType;
                            mclsSalesTransactionDetails.CRNo = iCollectionReceiptNo;

                            // for assignment of payments
                            mclsSalesTransactionDetails.PaymentDetails = AssignArrayListPayments(arrCashPaymentDetails, arrChequePaymentDetails, arrCreditCardPaymentDetails, null, arrDebitPaymentDetails);
                            
                            SavePayments(arrCashPaymentDetails, arrChequePaymentDetails, arrCreditCardPaymentDetails, null, arrDebitPaymentDetails);

                            // save the details of credit payments
                            SaveCreditPayments(dgvItemsSelectedRows, arrCashPaymentDetails, arrChequePaymentDetails, arrCreditCardPaymentDetails, null, arrDebitPaymentDetails, boActivateSuspendedAccount);

                            //OpenDrawerDelegate opendrawerDel = new OpenDrawerDelegate(OpenDrawer);
                            //Invoke(opendrawerDel);
                            OpenDrawer();

                            //update the transaction table 
                            Int64 iTransactionID = Convert.ToInt64(lblTransNo.Tag);
                            string strORNo = ""; // no need to put an OR no for credit payment coz it's already declared before
                            clsSalesTransactions.Close(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.TerminalNo, strORNo, 0, 0, AmountPaid, AmountPaid, AmountPaid, 0, 0, 0, 0, 0, 0, 0, 0, 0, DiscountTypes.NotApplicable, 0, 0, 0, 0, 0, 0, 0, 0, 0, AmountPaid, CashPayment, ChequePayment, CreditCardPayment, 0, DebitPayment, 0, 0, 0, 0, PaymentType, null, null, 0, 0, null, null, mclsSalesTransactionDetails.CashierID, lblCashier.Text, TransactionStatus.CreditPayment);
                            
                            // 05Mar2015 : MPC - Update the CRNo as per Ms. Norma
                            clsSalesTransactions.UpdateCRNo(mclsSalesTransactionDetails.BranchID, mclsSalesTransactionDetails.TerminalNo, mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.CRNo);

                            //UpdateTerminalReportDelegate updateterminalDel = new UpdateTerminalReportDelegate(UpdateTerminalReport);
                            UpdateTerminalReport(TransactionStatus.CreditPayment, 0, 0, AmountPaid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CashPayment, ChequePayment, CreditCardPayment, 0, DebitPayment, 0, 0, PaymentType);
                            
                            //UpdateCashierReportDelegate updatecashierDel = new UpdateCashierReportDelegate(UpdateCashierReport);
                            UpdateCashierReport(TransactionStatus.CreditPayment, 0, 0, AmountPaid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CashPayment, ChequePayment, CreditCardPayment, 0, DebitPayment, 0, 0, PaymentType);

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

                            clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE);

                            //enable IsCreditAllowed
                            //already done when paying creditpayment

                            //// 3Nov2014 : automatically deposit the change if credit payment
                            //#region Auto deposit for creditpayment
                            //if (mclsSysConfigDetails.WillDepositChangeOfCreditPayment)
                            //{
                            //    InsertAuditLog(AccessTypes.Deposit, "Auto depositing change of trx #: " + mclsSalesTransactionDetails.TransactionNo + ".");
                            //    clsEvent.AddEventLn("Auto depositing change of trx #: " + mclsSalesTransactionDetails.TransactionNo + ".");

                            //    Data.Deposits clsDeposit = new Data.Deposits(mConnection, mTransaction);
                            //    mConnection = clsDeposit.Connection; mTransaction = clsDeposit.Transaction;

                            //    Data.DepositDetails clsDepositDetails = new Data.DepositDetails()
                            //    {
                            //        BranchDetails = mclsTerminalDetails.BranchDetails,
                            //        TerminalNo = mclsTerminalDetails.TerminalNo,
                            //        Amount = mclsSalesTransactionDetails.ChangeAmount,
                            //        PaymentType = mclsSalesTransactionDetails.PaymentType,
                            //        DateCreated = DateTime.Now,
                            //        CashierID = mclsSalesTransactionDetails.CashierID,
                            //        CashierName = mclsSalesTransactionDetails.CashierName,
                            //        ContactID = mclsSalesTransactionDetails.CustomerDetails.ContactID,
                            //        ContactName = mclsSalesTransactionDetails.CustomerDetails.ContactName,
                            //        Remarks = "Auto deposit from trx #: " + mclsSalesTransactionDetails.TransactionNo + ".",
                            //        CreatedOn = DateTime.Now,
                            //        LastModified = DateTime.Now
                            //    };
                            //    clsDeposit.Insert(clsDepositDetails);

                            //    Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction);
                            //    mConnection = clsContact.Connection; mTransaction = clsContact.Transaction;

                            //    clsContact.AddDebit(clsDepositDetails.ContactID, clsDepositDetails.Amount);
                            //    clsDeposit.CommitAndDispose();

                            //    InsertAuditLog(AccessTypes.Deposit, "Deposit: type='" + clsDepositDetails.PaymentType.ToString("G") + "' amount='" + clsDepositDetails.Amount.ToString(",##0.#0") + "'" + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
                            //    clsEvent.AddEventLn("Done! type=" + clsDepositDetails.PaymentType.ToString("G") + " amount=" + clsDepositDetails.Amount.ToString("#,###.#0"));
                            //}
                            //#endregion

                            clsSalesTransactions.CommitAndDispose();
                            clsLocalDB.CommitAndDispose();

                            InsertAuditLog(AccessTypes.CreditPayment, "Pay credit for " + mclsContactDetails.ContactName + "." + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);

                            if (mclsTerminalDetails.AutoPrint == PrintingPreference.AskFirst)
                                if (MessageBox.Show("Would you like to print this transaction?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, (mclsSysConfigDetails.isDefaultButtonYesInPrintTransaction ? MessageBoxDefaultButton.Button1 : MessageBoxDefaultButton.Button2)) == DialogResult.Yes)
                                    mclsTerminalDetails.AutoPrint = PrintingPreference.Normal;

                            // print credit payment as normal transaction if not HP
                            if (mclsSalesTransactionDetails.isConsignment)
                            {
                                // 18Feb2015 : Print DR only if the transaction is consignment
                                clsEvent.AddEventLn("      printing delivery receipt as consginment...", true, mclsSysConfigDetails.WillWriteSystemLog);
                                PrintDeliveryReceipt();
                            }
                            else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.OutOfStockCustomerCode &&
                                (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice ||
                                 mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt ||
                                mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR))
                            {
                                clsEvent.AddEventLn("      printing out of stock orders...", true, mclsSysConfigDetails.WillWriteSystemLog);
                                PrintOSReceipt();
                            }
                            else if (mclsSalesTransactionDetails.CustomerDetails.ContactCode == mclsSysConfigDetails.WalkInCustomerCode &&
                            (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice ||
                             mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt ||
                            mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR))
                            {
                                clsEvent.AddEventLn("      printing walk-in customer quote form...", true, mclsSysConfigDetails.WillWriteSystemLog);
                                PrintWalkInReceipt();
                            }
                            else if (mclsSysConfigDetails.CreditPaymentType == CreditPaymentType.Houseware)
                            {
                                // do another report for credit payment if HP
                                PrintCreditPayment();

                                // do this twice as per request of CN trader's and CS
                                PrintCreditPayment();
                            }
                            else if (mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoice ||
                                mclsTerminalDetails.ReceiptType == TerminalReceiptType.DeliveryReceipt ||
                                mclsTerminalDetails.ReceiptType == TerminalReceiptType.SalesInvoiceAndDR)
                            {
                                clsEvent.AddEventLn("      printing sales invoice...", true, mclsSysConfigDetails.WillWriteSystemLog);
                                PrintCollectionReceipt();
                            }
                            else
                            {
                                // Sep 14, 2014 Control printing in mclsFilePrinter.Write
                                //if (mclsTerminalDetails.AutoPrint == PrintingPreference.Normal)	//print items if not yet printed
                                //{
                                foreach (System.Data.DataRow dr in ItemDataTable.Rows)
                                {
                                    if (dr["Quantity"].ToString() != "VOID")
                                    {
                                        string stItemNo = "" + dr["ItemNo"].ToString();
                                        string stProductCode = "" + dr["ProductCode"].ToString();
                                        if (dr["MatrixDescription"].ToString() != string.Empty && dr["MatrixDescription"].ToString() != null) stProductCode += "-" + dr["MatrixDescription"].ToString();
                                        string stProductUnitCode = "" + dr["ProductUnitCode"].ToString();
                                        decimal decQuantity = Convert.ToDecimal(dr["Quantity"]);
                                        decimal decPrice = Convert.ToDecimal(dr["Price"]);
                                        decimal decDiscount = Convert.ToDecimal(dr["Discount"]);
                                        decimal decAmount = Convert.ToDecimal(dr["Amount"]);
                                        decimal decVAT = Convert.ToDecimal(dr["VAT"]);
                                        decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                                        decimal decPromoApplied = Convert.ToDecimal(dr["PromoApplied"]);
                                        string stDiscountCode = "" + dr["DiscountCode"].ToString();
                                        DiscountTypes ItemDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["ItemDiscountType"].ToString());

                                        PrintItem(stItemNo, stProductCode, stProductUnitCode, decQuantity, decPrice, decDiscount, decPromoApplied, decAmount, decVAT, decEVAT, stDiscountCode, ItemDiscountType);
                                    }
                                }
                                //}
                                // Sep 14, 2014 Control printing in mclsFilePrinter.Write

                                PrintReportFooterSection(true, TransactionStatus.CreditPayment, 0, 0, AmountPaid, 0, 0, AmountPaid, CashPayment, ChequePayment, CreditCardPayment, 0, DebitPayment, 0, 0, ChangeAmount, arrChequePaymentDetails, arrCreditCardPaymentDetails, null, arrDebitPaymentDetails);
                            }
                            
                            this.LoadOptions();
                        }
                        catch (Exception ex)
                        {
                            InsertErrorLogToFile(ex, "ERROR!!! Credit payment procedure. Err Description: ");
                        }
                        Cursor.Current = Cursors.Default;
                    }

                    creditWnd.Close();
                    creditWnd.Dispose();
                }
            }
        }
Beispiel #39
0
        private bool SuspendTransaction(bool ShowNotificationWindow = true)
		{
			bool boRetValue = false;

			if (!mboIsInTransaction)
			{
				MessageBox.Show("Sorry you cannot suspend an empty transaction.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				return boRetValue;
			}
            //if (mboIsRefund)
            //{
            //    MessageBox.Show("Sorry you cannot suspend a REFUND transaction.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //    return boRetValue;
            //}

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

			if (loginresult == DialogResult.OK)
			{
                if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.Closed)
                {
                    this.LoadOptions();
                    boRetValue = true;
                    return boRetValue;
                }
                        
				if (mclsSalesTransactionDetails.CustomerID == Constants.C_RETAILPLUS_CUSTOMERID)
				{
					try
					{
						clsEvent.AddEvent("[" + lblCashier.Text + "] Suspending transaction no. " + lblTransNo.Text);

                        Data.ContactDetails details = new Data.ContactDetails();
                        DialogResult addresult = System.Windows.Forms.DialogResult.Cancel;

                        switch (mclsSysConfigDetails.ContactAddWndType)
                        {
                            case ContactAddWndType.ContactAddWnd:
                            case ContactAddWndType.ContactAddNoLTOWnd:
                                ContactAddWnd clsContactAddWnd = new ContactAddWnd();
                                clsContactAddWnd.Caption = "Suspend Transaction: Please Enter Customer Name";
                                clsContactAddWnd.ContactDetails = details;
                                clsContactAddWnd.TerminalDetails = mclsTerminalDetails;
                                clsContactAddWnd.SysConfigDetails = mclsSysConfigDetails;
                                clsContactAddWnd.ShowDialog(this);
                                addresult = clsContactAddWnd.Result;
                                details = clsContactAddWnd.ContactDetails;
                                clsContactAddWnd.Close();
                                clsContactAddWnd.Dispose();
                                break;
                            case ContactAddWndType.ContactAddHCareWnd:
                                ContactAddHCareWnd clsContactAddHCareWnd = new ContactAddHCareWnd();
                                clsContactAddHCareWnd.Caption = "Suspend Transaction: Please Enter Customer Name";
                                clsContactAddHCareWnd.ContactDetails = details;
                                clsContactAddHCareWnd.TerminalDetails = mclsTerminalDetails;
                                clsContactAddHCareWnd.CashierID = mclsSalesTransactionDetails.CashierID;
                                clsContactAddHCareWnd.ShowDialog(this);
                                addresult = clsContactAddHCareWnd.Result;
                                details = clsContactAddHCareWnd.ContactDetails;
                                clsContactAddHCareWnd.Close();
                                clsContactAddHCareWnd.Dispose();
                                break;
                            default:
                                ContactAddDetWnd clsContactAddDetWnd = new ContactAddDetWnd();
                                clsContactAddDetWnd.Caption = "Suspend Transaction: Please Enter Customer Name";
                                clsContactAddDetWnd.ContactDetails = details;
                                clsContactAddDetWnd.TerminalDetails = mclsTerminalDetails;
                                clsContactAddDetWnd.ShowDialog(this);
                                addresult = clsContactAddDetWnd.Result;
                                details = clsContactAddDetWnd.ContactDetails;
                                clsContactAddDetWnd.Close();
                                clsContactAddDetWnd.Dispose();
                                break;
                        }
                        
						if (addresult == DialogResult.OK)
						{
                            Cursor.Current = Cursors.WaitCursor;

                            LoadContact(Data.ContactGroupCategory.CUSTOMER, details);

							lblCustomer.Text = details.ContactName;
							lblCustomer.Tag = details.ContactID.ToString();

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

                            clsSalesTransactions.Suspend(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.GrossSales, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.NetSales, details);

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

                            clsContact.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, mclsSalesTransactionDetails.TransactionDate);

							InsertAuditLog(AccessTypes.SuspendTransaction, "Suspend transaction #: " + lblTransNo.Text + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);

							if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto)
								PrintReportFooterSection(true, TransactionStatus.Suspended, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.Charge, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, null, null, null);

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

                            // Added Jun 30, 2013
                            if (mclsTerminalDetails.IsParkingTerminal)
                            {
                                if (MessageBox.Show("Would you like to print the Parking Ticket?", "Print Parking Ticket", MessageBoxButtons.YesNo,  MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                                    PrintParkingTicket();
                            }

                            this.LoadOptions();

							MessageBox.Show("Transaction has been SUSPENDED. Press OK button to continue...", "RetailPlus", MessageBoxButtons.OK);

							boRetValue = true;

                            Cursor.Current = Cursors.Default;
						}
						else { clsEvent.AddEventLn("Cancelled!"); }
					}
					catch (Exception ex)
					{ 
                        InsertErrorLogToFile(ex, "ERROR!!! Suspending transaction."); 
                    }
				}
				else
				{
					try
					{
                        
                        clsEvent.AddEvent("[" + lblCashier.Text + "] Suspending transaction no. " + lblTransNo.Text);

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

                        clsSalesTransactions.Suspend(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.GrossSales, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.NetSales);

                        InsertAuditLog(AccessTypes.SuspendTransaction, "Suspend transaction #: " + lblTransNo.Text + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);

                        if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto)
                            PrintReportFooterSection(true, TransactionStatus.Suspended, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.Charge, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, null, null, null);

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

                        // Added Jun 30, 2013
                        if (mclsTerminalDetails.IsParkingTerminal)
                        {
                            if (MessageBox.Show("Would you like to print the Parking Ticket?", "Print Parking Ticket", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                                PrintParkingTicket();
                        }

                        this.LoadOptions();

                        MessageBox.Show("Transaction has been SUSPENDED. Press OK button to continue...", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        boRetValue = true;
                        
					}
					catch (Exception ex)
					{ 
                        InsertErrorLogToFile(ex, "ERROR!!! Suspending transaction."); 
                    }
				}
			}
			return boRetValue;
		}
Beispiel #40
0
        private void TransactionNoWnd_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            switch (e.KeyData)
            {
                case Keys.Escape:
                    dialog = DialogResult.Cancel;
                    this.Hide();
                    break;

                case Keys.Enter:
                    Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions();
                    TransactionStatus status = clsSalesTransactions.Status(txtTransactionNo.Text);
                    clsSalesTransactions.CommitAndDispose();

                    if (status == TransactionStatus.NotYetApplied)
                    {
                        MessageBox.Show("Sorry you have entered an invalid Transaction No." +
                            "Please type a valid Transaction No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    else if (status == TransactionStatus.Closed || status == TransactionStatus.Released || status == TransactionStatus.Refund)
                    {
                        mstrTransactionNo = txtTransactionNo.Text.PadLeft(miTransactionNoLength - 1, '0');
                        mstrTerminalNo = txtTerminalNo.Text;
                        dialog = DialogResult.OK;
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Sorry the Transaction No. you entered is " + status.ToString("G") + ". " +
                            "Please enter a valid Transaction No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    break;
            }
        }
Beispiel #41
0
		private void InitializeTransaction(Int64 UID, bool WillLoadOptions = false)
		{
			try
			{
				clsEvent.AddEvent("Checking for pending transaction.");

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

				string stTransactionNo = null;
                bool HasPendingTransaction = clsSalesTransactions.HasPendingTransaction(UID, mclsTerminalDetails.BranchID, mclsTerminalDetails.TerminalNo, out stTransactionNo);

				if (HasPendingTransaction)
				{ clsEvent.AddEventLn(stTransactionNo + " found pending."); LoadTransaction(stTransactionNo, mclsTerminalDetails.TerminalNo); }
				else
                { clsEvent.AddEventLn("None."); if (WillLoadOptions) this.LoadOptions(); }
                clsSalesTransactions.CommitAndDispose();
			}
			catch (Exception ex)
			{
                InsertErrorLogToFile(ex, "ERROR!!! Initializing transaction using username : " + lblCashier.Text);
			}
		}
Beispiel #42
0
		private void AddItem(Data.SalesTransactionItemDetails clsItemDetails)
		{
			try
			{
                clsItemDetails.ItemNo = Convert.ToString(ItemDataTable.Rows.Count + 1);
                clsItemDetails.TransactionDate = mclsSalesTransactionDetails.TransactionDate;
                clsItemDetails.PaxNo = 0;

				clsItemDetails = ApplyPromo(clsItemDetails);
                clsItemDetails = ComputeItemTotal(clsItemDetails); // set the grossales, vat, discounts, etc.

				System.Data.DataRow dr = ItemDataTable.NewRow();
				dr = setCurrentRowItemDetails(dr, clsItemDetails);

				clsItemDetails.TransactionItemsID = AddItemToDB(clsItemDetails);
				dr["TransactionItemsID"] = clsItemDetails.TransactionItemsID;

				// Added May 7, 2011 to Cater Reserved and Commit functionality    
				ReservedAndCommitItem(clsItemDetails, clsItemDetails.TransactionItemStatus);

				try { dgItems.UnSelect(dgItems.CurrentRowIndex); }
				catch { }

				ItemDataTable.Rows.Add(dr);
                mclsSalesTransactionDetails.TransactionItemsList.Add(clsItemDetails);

				dgItems.CurrentRowIndex = ItemDataTable.Rows.Count;
				try
				{
					dgItems.Select(dgItems.CurrentRowIndex);
					dgItems.CurrentRowIndex = dgItems.CurrentRowIndex;
				}
				catch { }

				SetItemDetails();
				ComputeSubTotal(); setTotalDetails();

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

                clsSalesTransactions.UpdateSubTotal(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.GrossSales, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.NetSales, mclsSalesTransactionDetails.ItemsDiscount, mclsSalesTransactionDetails.SNRItemsDiscount, mclsSalesTransactionDetails.PWDItemsDiscount, mclsSalesTransactionDetails.OtherItemsDiscount, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.SNRDiscount, mclsSalesTransactionDetails.PWDDiscount, mclsSalesTransactionDetails.OtherDiscount, mclsSalesTransactionDetails.TransDiscount, mclsSalesTransactionDetails.TransDiscountType, mclsSalesTransactionDetails.VAT, mclsSalesTransactionDetails.VATableAmount, mclsSalesTransactionDetails.ZeroRatedSales, mclsSalesTransactionDetails.NonVATableAmount, mclsSalesTransactionDetails.VATExempt, mclsSalesTransactionDetails.EVAT, mclsSalesTransactionDetails.EVATableAmount, mclsSalesTransactionDetails.NonEVATableAmount, mclsSalesTransactionDetails.LocalTax, mclsSalesTransactionDetails.DiscountCode, mclsSalesTransactionDetails.DiscountRemarks, mclsSalesTransactionDetails.Charge, mclsSalesTransactionDetails.ChargeAmount, mclsSalesTransactionDetails.ChargeCode, mclsSalesTransactionDetails.ChargeRemarks, mclsSalesTransactionDetails.ChargeType);
                clsSalesTransactions.CommitAndDispose();

				try
				{
					DisplayItemToTurretDelegate DisplayItemToTurretDel = new DisplayItemToTurretDelegate(DisplayItemToTurret);
					DisplayItemToTurretDel.BeginInvoke(clsItemDetails.ProductCode, clsItemDetails.ProductUnitCode, clsItemDetails.Quantity, clsItemDetails.Price, clsItemDetails.Discount, clsItemDetails.PromoApplied, clsItemDetails.Amount, clsItemDetails.VAT, clsItemDetails.EVAT, null, null);
				}
				catch { }
				if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto)
				{
					PrintItemDelegate PrintItemDel = new PrintItemDelegate(PrintItem);
					PrintItemDel.BeginInvoke(clsItemDetails.ItemNo, clsItemDetails.ProductCode, clsItemDetails.ProductUnitCode, clsItemDetails.Quantity, clsItemDetails.Price, clsItemDetails.Discount, clsItemDetails.PromoApplied, clsItemDetails.Amount, clsItemDetails.VAT, clsItemDetails.EVAT, clsItemDetails.DiscountCode, clsItemDetails.ItemDiscountType, null, null);
				}
			}
			catch (Exception ex)
			{
				InsertErrorLogToFile(ex, "ERROR!!! Adding sales item. TRACE: ");
				throw ex;
			}
		}
Beispiel #43
0
        private void LoadData()
        {
            try
            {
                Data.SalesTransactions clsTransactions = new Data.SalesTransactions();
                System.Data.DataTable  dt = clsTransactions.ListForPaymentDataTable(mclsCustomerDetails.ContactID);

                clsTransactions.CommitAndDispose();

                dgvItems.MultiSelect         = true;
                dgvItems.AutoGenerateColumns = true;
                dgvItems.AutoSize            = false;
                dgvItems.DataSource          = dt.TableName;
                dgvItems.DataSource          = dt;

                dgvItems.Columns["TransactionID"].Visible = false;
                dgvItems.Columns["PaxNo"].Visible         = false;
                dgvItems.Columns["CustomerID"].Visible    = false;
                dgvItems.Columns["CustomerName"].Visible  = false;
                dgvItems.Columns["ItemsDiscount"].Visible = false;

                dgvItems.Columns["TransactionNo"].Width   = 250;
                dgvItems.Columns["TransactionDate"].Width = 120;
                int iWidth = (dgvItems.Width - dgvItems.Columns["TransactionNo"].Width - dgvItems.Columns["TransactionDate"].Width) / 6;
                dgvItems.Columns["SubTotal"].Width   = iWidth;
                dgvItems.Columns["Discount"].Width   = iWidth;
                dgvItems.Columns["AmountPaid"].Width = iWidth;
                dgvItems.Columns["Credit"].Width     = iWidth;
                dgvItems.Columns["CreditPaid"].Width = iWidth;
                dgvItems.Columns["Balance"].Width    = iWidth;

                dgvItems.Columns["TransactionNo"].HeaderText   = "Trans. No";
                dgvItems.Columns["TransactionDate"].HeaderText = "Trans. Date";
                dgvItems.Columns["SubTotal"].HeaderText        = "SubTotal";
                dgvItems.Columns["Discount"].HeaderText        = "Discount";
                dgvItems.Columns["AmountPaid"].HeaderText      = "Amt. Paid";
                dgvItems.Columns["Credit"].HeaderText          = "Credit";
                dgvItems.Columns["CreditPaid"].HeaderText      = "Credit Paid";
                dgvItems.Columns["Balance"].HeaderText         = "Balance";

                dgvItems.Columns["SubTotal"].HeaderCell.Style.Alignment   = DataGridViewContentAlignment.MiddleRight;
                dgvItems.Columns["Discount"].HeaderCell.Style.Alignment   = DataGridViewContentAlignment.MiddleRight;
                dgvItems.Columns["AmountPaid"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                dgvItems.Columns["Credit"].HeaderCell.Style.Alignment     = DataGridViewContentAlignment.MiddleRight;
                dgvItems.Columns["Balance"].HeaderCell.Style.Alignment    = DataGridViewContentAlignment.MiddleRight;

                dgvItems.Columns["SubTotal"].DefaultCellStyle.Alignment   = DataGridViewContentAlignment.MiddleRight;
                dgvItems.Columns["Discount"].DefaultCellStyle.Alignment   = DataGridViewContentAlignment.MiddleRight;
                dgvItems.Columns["AmountPaid"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                dgvItems.Columns["Credit"].DefaultCellStyle.Alignment     = DataGridViewContentAlignment.MiddleRight;
                dgvItems.Columns["CreditPaid"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                dgvItems.Columns["Balance"].DefaultCellStyle.Alignment    = DataGridViewContentAlignment.MiddleRight;

                dgvItems.Columns["SubTotal"].DefaultCellStyle.Format   = "#,##0.#0";
                dgvItems.Columns["Discount"].DefaultCellStyle.Format   = "#,##0.#0";
                dgvItems.Columns["AmountPaid"].DefaultCellStyle.Format = "#,##0.#0";
                dgvItems.Columns["Credit"].DefaultCellStyle.Format     = "#,##0.#0";
                dgvItems.Columns["CreditPaid"].DefaultCellStyle.Format = "#,##0.#0";
                dgvItems.Columns["Balance"].DefaultCellStyle.Format    = "#,##0.#0";

                dgvItems.ReadOnly = true;
                dgvItems.Select();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }