private void DeletePayment() { if (!mboCreditPaymentReversal) { MessageBox.Show("Sorry you are not allowed to reverse payments, please consult your system administrator.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); } else { if (dgvItems.SelectedRows.Count == 1) { foreach (DataGridViewRow dr in dgvItems.SelectedRows) { DateTime TransactionDate = DateTime.Parse(dr.Cells["TransactionDate"].Value.ToString()); if (TransactionDate < mclsCustomerDetails.CreditDetails.LastBillingDate) { MessageBox.Show("Sorry you cannot reverse payment's that are already included in billing statement last: " + mclsCustomerDetails.CreditDetails.LastBillingDate.ToString("MMM dd, yyyy"), "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); break; } else { decimal AmountPaid = decimal.Parse(dr.Cells["Amount"].Value.ToString()); if (MessageBox.Show("Are you sure you want to delete this Payment? " + "If you delete this payment, the current credit of " + mclsCustomerDetails.ContactName + " will be: " + Environment.NewLine + " " + mclsCustomerDetails.Credit.ToString("#,##0.#0") + " + " + AmountPaid.ToString("#,##0.#0") + " = " + (mclsCustomerDetails.Credit + AmountPaid).ToString("#,##0.#0"), "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { Int32 BranchID = Int32.Parse(dr.Cells["BranchID"].Value.ToString()); string TerminalNo = dr.Cells["TerminalNo"].Value.ToString(); string TransactionNo = dr.Cells["TransactionNo"].Value.ToString(); Int64 TransactionID = Int64.Parse(dr.Cells["TransactionID"].Value.ToString()); // put the automatic adjustment outside AceSoft.RetailPlus.Client.LocalDB clsLocalConnection = new AceSoft.RetailPlus.Client.LocalDB(); clsLocalConnection.GetConnection(); Data.Creditors clsCreditors = new Data.Creditors(clsLocalConnection.Connection, clsLocalConnection.Transaction); switch (mclsSysConfigDetails.CreditPaymentType) { case CreditPaymentType.Houseware: clsCreditors.DeleteCreditTransaction(BranchID, TerminalNo, TransactionID); clsCreditors.AutoAdjustCredit(mclsCustomerDetails, mclsCustomerDetails.Credit + AmountPaid); break; case CreditPaymentType.Normal: case CreditPaymentType.MPC: default: clsCreditors.AdjustCredit(BranchID, TerminalNo, TransactionID, mclsCustomerDetails, mclsCustomerDetails.Credit + AmountPaid, AmountPaid); clsCreditors.DeleteCreditTransaction(BranchID, TerminalNo, TransactionID); break; } clsLocalConnection.CommitAndDispose(); mclsCustomerDetails.Credit = mclsCustomerDetails.Credit + AmountPaid; this.Hide(); dialog = System.Windows.Forms.DialogResult.OK; } } } } } }
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; } }