private void dgItems_Click(object sender, EventArgs e)
        {
            try { dgItems.Select(dgItems.CurrentRowIndex); }
            catch { }

            if (ItemDataTable.Rows.Count > 0)
            {
                decimal decTotalPayableAmount = Convert.ToDecimal((Convert.ToDecimal(lblSubTotal.Text) - Convert.ToDecimal(lblSubtotalVAT.Text)) - Convert.ToDecimal(lblDiscount.Text) + Convert.ToDecimal(lblCharge.Text) + Convert.ToDecimal(lblVAT.Text));
                decimal decAmountDue = decimal.Parse(dgItems[dgItems.CurrentRowIndex, 1].ToString());
                decimal decAmountPaid = decimal.Parse(dgItems[dgItems.CurrentRowIndex, 2].ToString());
                decimal decBalance = decimal.Parse(dgItems[dgItems.CurrentRowIndex, 3].ToString());
                decimal decChangeAmount = decimal.Parse(dgItems[dgItems.CurrentRowIndex, 4].ToString());

                //insert payment details
                Data.SalesTransactionDetails clsSalesTransactionDetails = mclsSalesTransactionDetails;

                decimal decSplitPercentage = decAmountDue / decTotalPayableAmount;
                clsSalesTransactionDetails.CustomerDetails = new Data.ContactDetails();
                clsSalesTransactionDetails.SubTotal = mclsSalesTransactionDetails.SubTotal * decSplitPercentage;
                clsSalesTransactionDetails.DiscountableAmount = mclsSalesTransactionDetails.DiscountableAmount * decSplitPercentage;
                clsSalesTransactionDetails.Discount = mclsSalesTransactionDetails.Discount * decSplitPercentage;
                clsSalesTransactionDetails.Charge = mclsSalesTransactionDetails.Charge * decSplitPercentage;
                clsSalesTransactionDetails.VAT = mclsSalesTransactionDetails.VAT * decSplitPercentage;
                clsSalesTransactionDetails.VATableAmount = mclsSalesTransactionDetails.VATableAmount * decSplitPercentage;
                clsSalesTransactionDetails.EVAT = mclsSalesTransactionDetails.EVAT * decSplitPercentage;
                clsSalesTransactionDetails.EVATableAmount = mclsSalesTransactionDetails.EVATableAmount * decSplitPercentage;

                PaymentsWnd payment = new PaymentsWnd();
                payment.TerminalDetails = TerminalDetails;
                payment.SysConfigDetails = mclsSysConfigDetails;
                payment.CustomerDetails = mclsCustomerDetails;
                payment.SalesTransactionDetails = clsSalesTransactionDetails;
                payment.CreditCardSwiped = mboCreditCardSwiped;
                payment.IsRefund = mboIsRefund;
                payment.IsCreditChargeExcluded = mboIsCreditChargeExcluded;

                payment.ShowDialog(this);

                DialogResult paymentResult = payment.Result;

                decimal AmountPaid = payment.AmountPaid;
                decimal CashPayment = payment.CashPayment;
                decimal ChequePayment = payment.ChequePayment;
                decimal CreditCardPayment = payment.CreditCardPayment;
                decimal CreditPayment = payment.CreditPayment;
                decimal DebitPayment = payment.DebitPayment;
                decimal CreditChargeAmount = payment.SalesTransactionDetails.CreditChargeAmount;

                decimal BalanceAmount = payment.BalanceAmount;
                decimal ChangeAmount = payment.ChangeAmount;
                PaymentTypes PaymentType = payment.PaymentType;
                ArrayList arrCashPaymentDetails = payment.CashPaymentDetails;
                ArrayList arrChequePaymentDetails = payment.ChequePaymentDetails;
                ArrayList arrCreditCardPaymentDetails = payment.CreditCardPaymentDetails;
                ArrayList arrCreditPaymentDetails = payment.CreditPaymentDetails;
                ArrayList arrDebitPaymentDetails = payment.DebitPaymentDetails;
                decimal RewardPointsPayment = payment.RewardPointsPayment;
                decimal RewardConvertedPayment = payment.RewardConvertedPayment;
                Data.ContactDetails clsCreditorDetails = payment.CreditorDetails;
                payment.Close();
                payment.Dispose();

                if (paymentResult == DialogResult.OK)
                {
                    ItemDataTable.Rows[dgItems.CurrentRowIndex][2] = AmountPaid.ToString("#,##0.#0");
                    ItemDataTable.Rows[dgItems.CurrentRowIndex][3] = "0.00";
                    ItemDataTable.Rows[dgItems.CurrentRowIndex][4] = ChangeAmount.ToString("#,##0.#0");

                    decAmountPaid = 0;
                    foreach (System.Data.DataRow dr in ItemDataTable.Rows)
                    {
                        decAmountPaid += decimal.Parse(dr["AmountPaid"].ToString()) - decimal.Parse(dr["Change"].ToString());
                    }

                    lblAmountPaid.Text = decAmountPaid.ToString("#,##0.#0");
                    ComputePayments();

                    Data.SplitPaymentDetails clsSplitPaymentDetails = new Data.SplitPaymentDetails();

                    clsSplitPaymentDetails.PaxNo = Int32.Parse(ItemDataTable.Rows[dgItems.CurrentRowIndex][0].ToString());
                    clsSplitPaymentDetails.AmountDue = clsSalesTransactionDetails.SubTotal - clsSalesTransactionDetails.Discount + clsSalesTransactionDetails.Charge; ;
                    clsSplitPaymentDetails.AmountPaid = AmountPaid;
                    clsSplitPaymentDetails.CashPayment = CashPayment;
                    clsSplitPaymentDetails.ChequePayment = ChequePayment;
                    clsSplitPaymentDetails.CreditCardPayment = CreditCardPayment;
                    clsSplitPaymentDetails.CreditPayment = CreditPayment;
                    clsSplitPaymentDetails.DebitPayment = DebitPayment;
                    clsSplitPaymentDetails.CreditChargeAmount = CreditChargeAmount;

                    clsSplitPaymentDetails.BalanceAmount = BalanceAmount;
                    clsSplitPaymentDetails.ChangeAmount = ChangeAmount;
                    clsSplitPaymentDetails.PaymentType = PaymentType;
                    clsSplitPaymentDetails.arrCashPaymentDetails = arrCashPaymentDetails;
                    clsSplitPaymentDetails.arrChequePaymentDetails = arrChequePaymentDetails;
                    clsSplitPaymentDetails.arrCreditCardPaymentDetails = arrCreditCardPaymentDetails;
                    clsSplitPaymentDetails.arrCreditPaymentDetails = arrCreditPaymentDetails;
                    clsSplitPaymentDetails.arrDebitPaymentDetails = arrDebitPaymentDetails;
                    clsSplitPaymentDetails.RewardPointsPayment = RewardPointsPayment;
                    clsSplitPaymentDetails.RewardConvertedPayment = RewardConvertedPayment;
                    clsSplitPaymentDetails.clsCreditorDetails = clsCreditorDetails;

                    marrSplitPaymentDetails[dgItems.CurrentRowIndex] = clsSplitPaymentDetails;

                }
            }
        }
示例#2
0
		private DialogResult ShowPayment()
		{
			DialogResult paymentResult = DialogResult.Cancel;

			if (Convert.ToDecimal(lblBalanceSelected.Text) > 0)
			{
                Data.SalesTransactionDetails clsSalesTransactionDetails = new Data.SalesTransactionDetails();
                switch (mclsSysConfigDetails.CreditPaymentType)
                {
                    case CreditPaymentType.Houseware:
                        clsSalesTransactionDetails.SubTotal = Convert.ToDecimal(lblAmountDue.Text);
                        break;
                    case CreditPaymentType.Normal:
                    case CreditPaymentType.MPC:
                    default:
                        clsSalesTransactionDetails.SubTotal = Convert.ToDecimal(lblBalanceSelected.Text);
                        break;
                }
                
                clsSalesTransactionDetails.TransactionStatus = TransactionStatus.CreditPayment;

                PaymentsWnd payment = new PaymentsWnd();
                payment.TerminalDetails = TerminalDetails;
                payment.SysConfigDetails = mclsSysConfigDetails;
                payment.CustomerDetails = mclsCustomerDetails;
                payment.SalesTransactionDetails = clsSalesTransactionDetails;
                payment.CreditCardSwiped = false;
                payment.IsRefund = false;
                payment.isFromCreditPayment = true;
                payment.ShowDialog(this);

                paymentResult = payment.Result;

                mdecAmountPaid = payment.AmountPaid;
                mdecCashPayment = payment.CashPayment;
                mdecChequePayment = payment.ChequePayment;
                mdecCreditCardPayment = payment.CreditCardPayment;
                mdecDebitPayment = payment.DebitPayment;
                mdecBalanceAmount = payment.BalanceAmount;
                mdecChangeAmount = payment.ChangeAmount;
                mPaymentType = payment.PaymentType;
                marrCashPaymentDetails = payment.CashPaymentDetails;
                marrChequePaymentDetails = payment.ChequePaymentDetails;
                marrCreditCardPaymentDetails = payment.CreditCardPaymentDetails;
                marrDebitPaymentDetails = payment.DebitPaymentDetails;
                payment.Close();
                payment.Dispose();

                if (paymentResult == DialogResult.OK)
                {
                    // Nov 2, 2014 do not save do the saving in MainWnd
                    // get the selected Transactions to be paid instead

                    //SavePayments(mdecAmountPaid, mdecCashPayment, mdecChequePayment, mdecCreditCardPayment, mdecDebitPayment,
                    //    marrCashPaymentDetails, marrChequePaymentDetails, marrCreditCardPaymentDetails, marrDebitPaymentDetails);

                    mdgvItemsSelectedRows = dgvItems.SelectedRows;
                }
			}
			return paymentResult;
		}
示例#3
0
		private void CloseTransaction()
		{
			if (!mboIsInTransaction)
			{
				MessageBox.Show("No active transaction found.", "RetailPlus", MessageBoxButtons.OK);
				return;
			}
			if ((mclsSalesTransactionDetails.SubTotal - mclsSalesTransactionDetails.Discount) < 0)
			{
				MessageBox.Show("Sorry you cannot close a less than ZERO transaction.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				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)
			{
                // 02Nov2014 : do not let close the CreditPayment coz the selected transactions to be paid are not identified anymore.
                //           : this should not come to this if no error has encountered
                if (mclsSalesTransactionDetails.TransactionStatus == TransactionStatus.CreditPayment)
                {
                    MessageBox.Show("Sorry there was an error when paying this CREDIT transaction." + Environment.NewLine + "You should VOID this transaction and re-issue the payment.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

				if (mclsSalesTransactionDetails.SubTotal == 0)
				{
                    if (!mclsSysConfigDetails.AllowZeroAmountTransaction)
                    {
                        MessageBox.Show("Sorry you cannot close this ZERO amount transaction." + Environment.NewLine + "You can VOID this transaction instead.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    else if (MessageBox.Show("Are you sure you want to close this  ZERO amount transaction?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                        return;
				}

				try
				{
                    clsEvent.AddEventLn("Closing transaction no. " + lblTransNo.Text, true);

                    clsEvent.AddEventLn("      showing payment screen", true);

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

                    // for checking - why do i need to reconnect in database if the customer is always updated?
                    mclsContactDetails = clsContact.Details(mclsSalesTransactionDetails.CustomerID);
                    LoadContact(Data.ContactGroupCategory.CUSTOMER, mclsContactDetails);
                    clsContact.CommitAndDispose();

                    Data.SalesTransactionItemDetails mTopItemDetails = getCurrentRowItemDetails();

					//insert payment details
					PaymentsWnd payment = new PaymentsWnd();
					payment.TerminalDetails = mclsTerminalDetails;
                    payment.SysConfigDetails = mclsSysConfigDetails;
					payment.CustomerDetails = mclsContactDetails;
					payment.SalesTransactionDetails = mclsSalesTransactionDetails;
					payment.CreditCardSwiped = mboCreditCardSwiped;
					payment.IsRefund = mboIsRefund;
                    payment.IsCreditChargeExcluded = mTopItemDetails.IsCreditChargeExcluded;
                    payment.OfflineProductDesc = (mTopItemDetails.IsCreditChargeExcluded && ItemDataTable.Rows.Count == 1 && mTopItemDetails.BarCode.Length <= 10) ? mTopItemDetails.ProductCode : "";
					payment.ShowDialog(this);

					DialogResult paymentResult = payment.Result;

					decimal AmountPaid = payment.AmountPaid;
					decimal CashPayment = payment.CashPayment;
					decimal ChequePayment = payment.ChequePayment;
					decimal CreditCardPayment = payment.CreditCardPayment;
					decimal CreditPayment = payment.CreditPayment;
					decimal DebitPayment = payment.DebitPayment;
					decimal CreditChargeAmount = payment.SalesTransactionDetails.CreditChargeAmount;

					decimal BalanceAmount = payment.BalanceAmount;
					decimal ChangeAmount = payment.ChangeAmount;
					PaymentTypes PaymentType = payment.PaymentType;
					ArrayList arrCashPaymentDetails = payment.CashPaymentDetails;
					ArrayList arrChequePaymentDetails = payment.ChequePaymentDetails;
					ArrayList arrCreditCardPaymentDetails = payment.CreditCardPaymentDetails;
					ArrayList arrCreditPaymentDetails = payment.CreditPaymentDetails;
					ArrayList arrDebitPaymentDetails = payment.DebitPaymentDetails;
					decimal RewardPointsPayment = payment.RewardPointsPayment;
					decimal RewardConvertedPayment = payment.RewardConvertedPayment;
                    Data.ContactDetails clsCreditorDetails = payment.CreditorDetails;
					payment.Close();
					payment.Dispose();

                    this.KeyPreview = false;
                    clsEvent.AddEventLn("      payment screen closed.", true);

                    if (paymentResult != DialogResult.OK)
                    {
                        clsEvent.AddEventLn(" cancelled.", true);
                    }
                    else
					{
                        // override the customerinformation if it's paid with in-house creditcard
                        if (clsCreditorDetails.ContactID !=0 && clsCreditorDetails.ContactID != mclsSalesTransactionDetails.CustomerID)
                        {
                            mboRewardCardSwiped = false; //reset this to false so that the existing rewards will not be overwritten
                            LoadContact(Data.ContactGroupCategory.CUSTOMER, clsCreditorDetails, true);
                        }

                        CloseTransaction(mTopItemDetails,
                                        AmountPaid, ChangeAmount, BalanceAmount, CashPayment, ChequePayment,
                                        CreditCardPayment, CreditPayment, CreditChargeAmount, DebitPayment,
                                        RewardConvertedPayment, RewardPointsPayment, PaymentType,
                                        arrCashPaymentDetails, arrChequePaymentDetails, arrCreditCardPaymentDetails,
                                        arrCreditPaymentDetails, arrDebitPaymentDetails);

                        clsEvent.AddEventLn(" Loading Options...", true, mclsSysConfigDetails.WillWriteSystemLog);
                        this.LoadOptions();
					}
				}
				catch (Exception ex)
				{
					InsertErrorLogToFile(ex, "ERROR!!! Closing transaction.");
				}
                this.KeyPreview = true;
			}
			Cursor.Current = Cursors.Default;
		}
示例#4
0
		private DialogResult ShowPayment()
		{
			DialogResult paymentResult = DialogResult.Cancel;

			if (Convert.ToDecimal(lblBalance.Text) > 0)
			{
				PaymentsWnd payment = new PaymentsWnd();
				Data.SalesTransactionDetails clsSalesTransactionDetails = new Data.SalesTransactionDetails();
				clsSalesTransactionDetails.SubTotal = mclsCustomerDetails.Credit;

				payment.SalesTransactionDetails = clsSalesTransactionDetails;
				//payment.TransactionNo = string.Empty; //will get from the transction nos.
				payment.CustomerDetails = mclsCustomerDetails;
				//payment.Discount = Convert.ToDecimal(0);
				//payment.SubTotal = mclsCustomerDetails.Credit;
				payment.IsRefund = false;

				payment.ShowDialog(this);

				paymentResult = payment.Result;
			
				mdecAmountPaid = payment.AmountPaid;
				mdecCashPayment = payment.CashPayment;
				mdecChequePayment = payment.ChequePayment;
				mdecCreditCardPayment = payment.CreditCardPayment;
				mdecDebitPayment = payment.DebitPayment;
				mdecBalanceAmount = payment.BalanceAmount;
				mdecChangeAmount = payment.ChangeAmount;
				PaymentTypes mPaymentType = payment.PaymentType;
				marrCashPaymentDetails = payment.CashPaymentDetails;
				marrChequePaymentDetails = payment.ChequePaymentDetails;
				marrCreditCardPaymentDetails = payment.CreditCardPaymentDetails;
				marrDebitPaymentDetails = payment.DebitPaymentDetails;
				payment.Close();
				payment.Dispose();

				if (paymentResult == DialogResult.OK)
				{
					SavePayments(mdecAmountPaid, mdecCashPayment, mdecChequePayment, mdecCreditCardPayment, mdecDebitPayment,
						marrCashPaymentDetails, marrChequePaymentDetails, marrCreditCardPaymentDetails, marrDebitPaymentDetails);
				}
			}
			return paymentResult;
		}