Example #1
0
		private void CreditsItemizeWnd_KeyDown(object sender, KeyEventArgs e)
		{
			switch (e.KeyData)
			{
				case Keys.Escape:
                    if (grpSearch.Visible)
                    {
                        grpSearch.Visible = false;
                        dgvItems.Focus();
                        cmdEnter.Text = "Enter";
                    }
                    else
                    {
                        this.Hide();
                    }
					break;

				case Keys.Enter:
                    if (grpSearch.Visible)
                    {
                        LoadData();
                    }
					else if (Convert.ToDecimal(lblBalanceSelected.Text) > 0)
					{
                        Data.Products clsProducts = new Data.Products();
                        if (clsProducts.Details(Data.Products.DEFAULT_CREDIT_PAYMENT_BARCODE).ProductID == 0)
                        {
                            clsProducts.CREATE_CREDITPAYMENT_PRODUCT();
                            Methods.InsertAuditLog(TerminalDetails, "System Administrator", AccessTypes.EnterCreditPayment, "CREDIT PAYMENT product has been created coz it's not configured");
                        }
                        clsProducts.CommitAndDispose();
                        
                        dialog = ShowPayment();
                        if (dialog == DialogResult.OK)
                        { mKeyData = Keys.Enter; this.Hide(); }
					}
					else
						this.Hide();

					break;

                case Keys.F3:
                    CreditSalesWnd clsCreditSalesWnd = new CreditSalesWnd();
                    clsCreditSalesWnd.TerminalDetails = TerminalDetails;
                    clsCreditSalesWnd.SysConfigDetails = mclsSysConfigDetails;
                    clsCreditSalesWnd.CustomerDetails = mclsCustomerDetails;
                    clsCreditSalesWnd.ShowDialog(this);
                    clsCreditSalesWnd.Close();
                    clsCreditSalesWnd.Dispose();
                    break;

                case Keys.F4:
                    CreditPaymentsWnd clsCreditPaymentsWnd = new CreditPaymentsWnd();
                    clsCreditPaymentsWnd.TerminalDetails = TerminalDetails;
                    clsCreditPaymentsWnd.SysConfigDetails = mclsSysConfigDetails;
                    clsCreditPaymentsWnd.CustomerDetails = mclsCustomerDetails;
                    clsCreditPaymentsWnd.CashierID = CashierID;
                    clsCreditPaymentsWnd.ShowDialog(this);
                    DialogResult result = clsCreditPaymentsWnd.Result;
                    mclsCustomerDetails = clsCreditPaymentsWnd.CustomerDetails;
                    clsCreditPaymentsWnd.Close();
                    clsCreditPaymentsWnd.Dispose();

                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        LoadData();
                    }
                    break;

                case Keys.F5:
                    if (!lblF5.Visible) return;
                    grpSearch.Visible = !grpSearch.Visible;
                    if (grpSearch.Visible)
                    {
                        txtTrxStartDate.Focus();
                        cmdEnter.Text = "Search";
                    }
                    else
                    {
                        dgvItems.Focus();
                        cmdEnter.Text = "Enter";
                    }
                    break;
                case Keys.F11:
                    if (!lblF11.Visible) return;
                    if (dgvItems.Rows.Count > 0)
                    {
                        PrintSOA();
                    }
                    break;
                case Keys.F12:
                    if (!lblF12.Visible) return;
                    TransactionNoToReprint = ""; TerminalNoToReprint = "";
                    foreach (DataGridViewRow dr in dgvItems.SelectedRows)
                    {
                        TransactionNoToReprint = dr.Cells["TransactionNo"].Value.ToString();
                        TerminalNoToReprint = dr.Cells["TerminalNo"].Value.ToString();
                        dialog = System.Windows.Forms.DialogResult.OK;
                        mKeyData = Keys.F12;
                        this.Hide();
                        break;
                    }
                    break;

			}
		}
		private void CreditVerificationWnd_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
            DialogResult result; 
            keyCommand = e.KeyData;
			switch (e.KeyData)
			{
				case Keys.Escape:
					dialog = DialogResult.Cancel;
					this.Hide(); 
					break;

                case Keys.Enter:
                    dialog = DialogResult.OK;
                    this.Hide();
                    break;

                case Keys.F3:
                    if (mContactDetails.ContactID == 0) return;
                    CreditSalesWnd clsCreditSalesWnd = new CreditSalesWnd();
                    clsCreditSalesWnd.TerminalDetails = TerminalDetails;
                    clsCreditSalesWnd.SysConfigDetails = SysConfigDetails;
                    clsCreditSalesWnd.CustomerDetails = mContactDetails;
                    clsCreditSalesWnd.ShowDialog(this);
                    clsCreditSalesWnd.Close();
                    clsCreditSalesWnd.Dispose();
                    break;

                case Keys.F4:
                    if (mContactDetails.ContactID == 0) return;
                    CreditPaymentsWnd clsCreditPaymentsWnd = new CreditPaymentsWnd();
                    clsCreditPaymentsWnd.TerminalDetails = TerminalDetails;
                    clsCreditPaymentsWnd.SysConfigDetails = SysConfigDetails;
                    clsCreditPaymentsWnd.CustomerDetails = mContactDetails;
                    clsCreditPaymentsWnd.CashierID = CashierID;
                    clsCreditPaymentsWnd.ShowDialog(this);
                    result = clsCreditPaymentsWnd.Result;
                    clsCreditPaymentsWnd.Close();
                    clsCreditPaymentsWnd.Dispose();

                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        LoadData();
                        txtScan.Text = mContactDetails.CreditDetails.CreditCardNo;
                    }
                    break;

                case Keys.F6:
                    Data.ContactDetails details;
				    ContactSelectWnd clsContactWnd = new ContactSelectWnd();
                    clsContactWnd.EnableContactAddUpdate = true;
                    clsContactWnd.TerminalDetails = TerminalDetails;
				    clsContactWnd.ContactGroupCategory = Data.ContactGroupCategory.CUSTOMER;
				    clsContactWnd.ShowDialog(this);
				    details = clsContactWnd.Details;
				    result = clsContactWnd.Result;
				    clsContactWnd.Close();
				    clsContactWnd.Dispose();
                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        switch (SysConfigDetails.CreditPaymentType)
                        {
                            case CreditPaymentType.Houseware:
                                LoadData();
                                txtScan.Text = details.CreditDetails.CreditCardNo;
                                break;
                            case CreditPaymentType.Normal:
                            case CreditPaymentType.MPC:
                            default:
                                txtScan.Text = details.ContactCode;
                                LoadData();
                                txtScan.Text = details.ContactCode;
                                break;
                        }
                        
                    }
                    break;

                case Keys.F7:
                    if (mContactDetails.ContactID != 0 && mboCreditAmountDueAdjustment)
                    {
                        if (mContactDetails.CreditDetails.CardTypeDetails.WithGuarantor)
                        {
                            CreditBillWGuaWnd clsCreditBillWGuaWnd = new CreditBillWGuaWnd();
                            clsCreditBillWGuaWnd.CreditorDetails = mContactDetails;
                            clsCreditBillWGuaWnd.GuarantorDetails = mGuarantorDetails;
                            clsCreditBillWGuaWnd.TerminalDetails = TerminalDetails;
                            clsCreditBillWGuaWnd.ShowDialog(this);
                            result = clsCreditBillWGuaWnd.Result;
                            clsCreditBillWGuaWnd.Close();
                            clsCreditBillWGuaWnd.Dispose();
                        }
                        else 
                        {
                            CreditBillNoGuaWnd clsCreditBillNoGuaWnd = new CreditBillNoGuaWnd();
                            clsCreditBillNoGuaWnd.CreditorDetails = mContactDetails;
                            clsCreditBillNoGuaWnd.GuarantorDetails = mGuarantorDetails;
                            clsCreditBillNoGuaWnd.TerminalDetails = TerminalDetails;
                            clsCreditBillNoGuaWnd.ShowDialog(this);
                            result = clsCreditBillNoGuaWnd.Result;
                            clsCreditBillNoGuaWnd.Close();
                            clsCreditBillNoGuaWnd.Dispose();
                        }
                        if (result == System.Windows.Forms.DialogResult.OK)
                        {
                            Methods.InsertAuditLog(TerminalDetails, CashierName, AccessTypes.CreditAmountDueAdjustment, "Adjust the billing statement of " + mContactDetails.ContactName + ".");

                            MessageBox.Show("Billing has been adjusted.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            LoadData();
                            txtScan.Text = mContactDetails.CreditDetails.CreditCardNo;
                        }
                    }
                    break;
                case Keys.F8:
                    if (mContactDetails.ContactID != 0 && mboCreditAmountDueAdjustment)
                    {
                        NoControl clsNoControl = new NoControl();
                        clsNoControl.Caption = "Enter new current Credit amount.";
                        clsNoControl.NoValue = mContactDetails.Credit;
                        clsNoControl.ShowDialog(this);
                        result = clsNoControl.Result;
                        decimal decAmount = clsNoControl.NoValue;
                        clsNoControl.Close();
                        clsNoControl.Dispose();
                        if (result == System.Windows.Forms.DialogResult.OK)
                        {
                            if (MessageBox.Show("Are you sure you want adjust the credit balance of " + mContactDetails.ContactName + " from: " + mContactDetails.Credit.ToString("#,##0.#0") + " to " + decAmount.ToString("#,##0.#0"), "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                            {
                                AceSoft.RetailPlus.Client.LocalDB clsLocalConnection = new AceSoft.RetailPlus.Client.LocalDB();
                                clsLocalConnection.GetConnection();

                                Data.Creditors clsCreditors = new Data.Creditors(clsLocalConnection.Connection, clsLocalConnection.Transaction);

                                clsCreditors.AutoAdjustCredit(mContactDetails, decAmount);

                                clsLocalConnection.CommitAndDispose();

                                Methods.InsertAuditLog(TerminalDetails, CashierName, AccessTypes.CreditAmountDueAdjustment, "Adjust the credit balance of " + mContactDetails.ContactName + " from: " + mContactDetails.Credit.ToString("#,##0.#0") + " to " + decAmount.ToString("#,##0.#0"));

                                MessageBox.Show("Current credit has been adjusted.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                LoadData();
                                txtScan.Text = mContactDetails.CreditDetails.CreditCardNo;
                            }
                        }
                    }
                    break;
                case Keys.F11:
                    if (!lblF11.Visible) return;
                    if (dgvItems.Rows.Count > 0)
                    {
                        PrintSOA();
                    }
                    break;
				case Keys.F12:
                    if (mContactDetails.ContactID == 0)
                    {
                        MessageBox.Show("Please select a valid card to print the verification slip.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (mContactDetails.CreditDetails.CardTypeDetails.WithGuarantor && !mGuarantorDetails.CreditDetails.CreditActive)
                    {
                        MessageBox.Show("Sorry printing verification slip is not allowed. Your GUARANTOR credit status InActive.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (mContactDetails.CreditDetails.ExpiryDate < new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23,59,59))
                    {
                        MessageBox.Show("Sorry printing verification slip is not allowed. Your card is already expired.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (!mContactDetails.CreditDetails.CreditActive)
                    {
                        MessageBox.Show("Sorry printing verification slip is not allowed for InActive Credit Cards.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    else
                    {
                        dialog = DialogResult.OK;
                        this.Hide();
                    }
					break;
			}
		}