private void btnChangeBarcode_Click(object sender, EventArgs e) { if (txtBarcode.Text != "") { clsProductItem prod = clsProductItem.SearchProduct(txtBarcode.Text.Trim()); if (prod != null) { frmInput input = new frmInput(); input.Title = "Change Barcode"; input.Caption = "New Barcode"; input.withDecimal = false; input.IsNumericOnly = false; if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (txtBarcode.Text.Trim() != input.Text.Trim()) { clsProductItem tmp = clsProductItem.SearchProduct(input.Value.Trim()); if (tmp != null) { MessageBox.Show("Change Barcode", "Barcode already exists!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { clsProductItem.ChangeBarcode(txtBarcode.Text.Trim(), input.Value.Trim()); txtBarcode.Text = input.Value.Trim(); txtSearchString.Text = input.Value.Trim(); btnSearch.PerformClick(); } } } } } }
private void btnPrintBarcode_Click(object sender, EventArgs e) { if (txtBarcode.Text != "") { frmInput input = new frmInput(); input.Title = "Print Barcode"; input.Caption = "Enter Quantity to Print"; input.withDecimal = false; input.IsNumericOnly = true; input.Value = "1"; if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK) { int qty = Convert.ToInt32(input.Value); Receipt m_receipt = new Receipt(); m_receipt.InitializePrinter(); if (qty > 0) { for (int ctr = 0; ctr < qty; ctr++) { m_receipt.PrintHeader(new List <string>() { txtDesc.Text }, PrintFontAlignment.Center, PrintFontSize.BigReg); m_receipt.PrintBarcode(txtBarcode.Text, 2); m_receipt.FormFeed(); } } //m_receipt.FormFeed(); m_receipt.ExecPrint(); } } }
private void btnRemoveInventory_Click(object sender, EventArgs e) { if (txtBarcode.Text.Trim() != "") { string OrigQtValue = txtTotalQty.Text; frmInput input = new frmInput(); input.Title = "Remove Inventory"; input.Caption = "Quantity"; input.IsNumericOnly = true; if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK) { clsProductItem fi = clsProductItem.SearchProduct(txtBarcode.Text); if (Convert.ToDouble(input.Value) <= 0) { MessageBox.Show("Quantity must be more than 0", "Remove Item", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (fi != null && fi.StocksRemainingQty - Convert.ToDouble(input.Value) >= 0) { frmInput inputReason = new frmInput(); inputReason.Title = "Remove Inventory"; inputReason.Caption = "Reason for Removing"; inputReason.Value = "Transfer Inventory"; if (inputReason.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (input.Value.Trim() == "") { MessageBox.Show("Must enter reason for removal of inventory", "Remove Items", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } clsInventory itemIventory = new clsInventory(); itemIventory.BarCode = txtBarcode.Text; itemIventory.Capital = Convert.ToDouble(txtCapital.Text); itemIventory.Quantity = -(Convert.ToDouble(input.Value)); itemIventory.Remarks = inputReason.Value; itemIventory.ExpiryDate = dtInventory.Value; itemIventory.DateAdded = dtInventory.Value; itemIventory.Save(); fi.TotalInventoryQty = clsInventory.GetTotalInventoryQty(fi.BarCode); fi.Save(); UpdateList(txtSearchString.Text); UpdateItemDisplay(fi.BarCode); } } else if (fi == null) { MessageBox.Show(string.Format("Product not found"), "Remove Inventory", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(string.Format("Removing quantity greater than available quantity not allowed"), "Remove Inventory", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
public void CheckOut() { double totalamount = 0; Receipt or = new Receipt(); or.InitializePrinter(); or.OpenDrawer(); frmInput payment = new frmInput(); payment.Title = "Actual Cash on Hand"; payment.Caption = "Amount"; payment.IsNumericOnly = true; payment.Value = "0"; if (payment.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (payment.Value != "" && Convert.ToDouble(payment.Value) > 0) { CashCount cc = new CashCount(); if (cc.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } else { totalamount = cc.TotalAmount; } if (Convert.ToDouble(payment.Value) != totalamount) { MessageBox.Show("Cash count doesn't match with your total Amount", "Cash Count", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //btnSearch.PerformClick(); UpdateCheckout(); clsCheckOut ckout = new clsCheckOut(); ckout.ActualAmount = double.Parse(payment.Value); ckout.ExpectedAmount = expectedCOH; ckout.Timestamp = dtPickStart.Value; ckout.UserId = lstUsers[cboCashier.SelectedIndex].UserId; ckout.UserName = lstUsers[cboCashier.SelectedIndex].UserName; lstCheckOutItems[lstCheckOutItems.Count - 1].ActualAmount = ckout.ActualAmount; ckout.LstItems = this.lstCheckOutItems; ckout.Save(); isCheckout = false; UpdateCheckout(); btnPrint.PerformClick(); } } }
private void btnCheckOut_Click(object sender, EventArgs e) { //frmChkOutLight chkout = new frmChkOutLight(); //chkout.ShowDialog(); btnSearch.PerformClick(); if (cboCashier.SelectedIndex == 0) { MessageBox.Show("Please select cashier.", "Checkout", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } double totalamount = 0; if (MessageBox.Show("Would you like to perform Cash Count?", "Cash Count", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { CashCount cc = new CashCount(); if (cc.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } else { totalamount = cc.TotalAmount; } } frmInput payment = new frmInput(); payment.Title = "Actual Cash on Hand"; payment.Caption = "Amount"; payment.IsNumericOnly = true; payment.Value = totalamount.ToString(); if (payment.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (payment.Value != "") { clsCheckOut ckout = new clsCheckOut(); ckout.ActualAmount = double.Parse(payment.Value); ckout.ExpectedAmount = expectedCOH; ckout.Timestamp = dtPickStart.Value; ckout.UserId = lstUsers[cboCashier.SelectedIndex - 1].UserId; ckout.UserName = lstUsers[cboCashier.SelectedIndex - 1].UserName; ckout.Save(); btnSearch.PerformClick(); } } }
private void btnAddCategory_Click(object sender, EventArgs e) { frmInput input = new frmInput(); input.Title = "Category"; input.Caption = "Add Category"; input.Value = ""; if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (input.Value.Trim() != "") { if (dbConnect.AddCategory(input.Value.Trim())) { UpdateGrid(); } } } }
private void dgvExpenses_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (dgvExpenses.SelectedRows != null && dgvExpenses.SelectedRows.Count == 1) { clsExpenses exp = new clsExpenses(); exp.Expense_id = Convert.ToInt32(dgvExpenses.SelectedRows[0].Cells[0].Value); exp.UserId = m_user.UserId; exp.UserName = m_user.UserName; exp.Amount = Convert.ToDouble(dgvExpenses.SelectedRows[0].Cells[3].Value); exp.Description = dgvExpenses.SelectedRows[0].Cells[2].Value.ToString(); exp.Timestamp = Convert.ToDateTime(dgvExpenses.SelectedRows[0].Cells[1].Value.ToString()); frmInput InputExpense = new frmInput(); InputExpense.Title = "Expense Description"; InputExpense.Caption = "Description"; InputExpense.IsNumericOnly = false; InputExpense.Value = exp.Description; if (InputExpense.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (InputExpense.Value != "") { exp.Description = InputExpense.Value; InputExpense.Title = "Expense Amount"; InputExpense.Caption = "Amount"; InputExpense.IsNumericOnly = true; InputExpense.Value = exp.Amount.ToString(); if (InputExpense.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (InputExpense.Value != "") { exp.Amount = Convert.ToDouble(InputExpense.Value); exp.Save(); btnSearch.PerformClick(); } } } } } }
private void btnAddExpenses_Click(object sender, EventArgs e) { if (clsUtil.GetApproval(m_user, UserAccess.Cashier)) { clsExpenses exp = new clsExpenses(); exp.UserId = m_user.UserId; exp.UserName = m_user.UserName; exp.Amount = 0; exp.Description = ""; exp.Timestamp = DateTime.Now; frmInput InputExpense = new frmInput(); InputExpense.Title = "Expense Description"; InputExpense.Caption = "Description"; InputExpense.IsNumericOnly = false; InputExpense.Value = ""; if (InputExpense.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (InputExpense.Value != "") { exp.Description = InputExpense.Value; InputExpense.Title = "Expense Amount"; InputExpense.Caption = "Amount"; InputExpense.IsNumericOnly = true; InputExpense.Value = "0"; if (InputExpense.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (InputExpense.Value != "") { exp.Amount = Convert.ToDouble(InputExpense.Value); exp.Save(); } } } } } }
private void btnChange_Click(object sender, EventArgs e) { if (lstTemp.SelectedIndex >= 0) { SelectedTempOR = tmpReceipt[lstTemp.SelectedIndex]; if (SelectedTempOR != null) { string tmpTable = SelectedTempOR.CashierName; frmInput input = new frmInput(); input.withDecimal = true; input.IsNumericOnly = false; input.Title = "Customer Reference"; input.Value = tmpTable; if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK) { tmpReceipt[lstTemp.SelectedIndex].CashierName = input.Value; tmpReceipt[lstTemp.SelectedIndex].SaveTemp(input.Value); LoadTempReceipt(); } } } }
private void btnAddInventory_Click(object sender, EventArgs e) { frmInput input = new frmInput(); input.withDecimal = true; input.IsNumericOnly = false; input.Value = ""; input.Caption = "Enter Supplier/Reference Num"; if (input.ShowDialog() == System.Windows.Forms.DialogResult.Cancel || input.Value == "") { return; } foreach (KeyValuePair <string, clsPurchasedItem> items in m_receipt.PurchasedItems) { clsPurchasedItem prod = items.Value; clsInventory itemIventory = new clsInventory(); itemIventory.BarCode = prod.BarCode; itemIventory.Capital = prod.Capital; itemIventory.Quantity = prod.Qty; itemIventory.Remarks = input.Value; itemIventory.DateAdded = dtInventory.Value; itemIventory.Save(); clsProductItem item = clsProductItem.SearchProduct(prod.BarCode); if (item != null) { item.Capital = prod.Capital; item.TotalInventoryQty += prod.Qty; item.Amount = prod.Amount; item.Save(); } } DialogResult = System.Windows.Forms.DialogResult.OK; }
private void btnCheckOut_Click(object sender, EventArgs e) { btnSearch.PerformClick(); frmInput payment = new frmInput(); payment.Title = "Actual Cash on Hand"; payment.Caption = "Amount"; payment.IsNumericOnly = true; payment.Value = actualCOH.ToString(); if (payment.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (payment.Value != "") { clsCheckOut ckout = new clsCheckOut(); ckout.ActualAmount = double.Parse(payment.Value); ckout.ExpectedAmount = expectedCOH; ckout.Timestamp = dtPickStart.Value; ckout.UserId = lstUsers[cboCashier.SelectedIndex].UserId; ckout.UserName = lstUsers[cboCashier.SelectedIndex].UserName; ckout.Save(); UpdateCheckout(); } } }
private void AddProduct(string barcode) { if (barcode != "") { clsProductItem prod = clsProductItem.SearchProduct(barcode); clsPurchasedItem purchased = null; if (prod != null) { if (m_receipt.PurchasedItems.ContainsKey(prod.BarCode)) { m_receipt.PurchasedItems[prod.BarCode].UserID = m_user.UserId; m_receipt.PurchasedItems[prod.BarCode].Qty += 1; purchased = m_receipt.PurchasedItems[prod.BarCode]; } else { purchased = new clsPurchasedItem(prod); purchased.UserID = m_user.UserId; if (purchased.Description.ToUpper().Contains("NEW ITEM")) { purchased.BarCode = ""; clsProductItem item = new clsProductItem(); frmInput nobarcode = new frmInput(); nobarcode.Title = "No Barcode"; nobarcode.Caption = "Product Description"; nobarcode.IsNumericOnly = false; nobarcode.Value = purchased.Description; if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (nobarcode.Value != "") { item.Description = nobarcode.Value; if (MessageBox.Show("Item have Barcode?", "New Item", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { nobarcode = new frmInput(); nobarcode.Title = "No Barcode"; nobarcode.Caption = "Scan Barcode"; nobarcode.IsNumericOnly = false; nobarcode.withDecimal = false; nobarcode.Value = ""; if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (nobarcode.Value != "") { item.BarCode = nobarcode.Value; clsProductItem proditem = clsProductItem.SearchProduct(item.BarCode); if (proditem != null) { MessageBox.Show("Product already exist!", "New Item", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } } } else { Dictionary <int, string> lstCategories = dbConnect.GetCategories(); int catId = 1; foreach (KeyValuePair <int, string> category in lstCategories) { if (category.Value == purchased.Category) { catId = category.Key; } } item.BarCode = dbConnect.GetNextSKU().ToString(catId.ToString().Trim() + "000000"); } nobarcode = new frmInput(); nobarcode.Title = "No Barcode"; nobarcode.Caption = "Capital Amount"; nobarcode.IsNumericOnly = true; nobarcode.withDecimal = true; nobarcode.Value = "0"; if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (nobarcode.Value != "") { item.Capital = Convert.ToDouble(nobarcode.Value); nobarcode = new frmInput(); nobarcode.Title = "No Barcode"; nobarcode.Caption = "Retail Amount"; nobarcode.IsNumericOnly = true; nobarcode.withDecimal = true; nobarcode.Value = "0"; if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (nobarcode.Value != "") { item.Amount = Convert.ToDouble(nobarcode.Value); if (MessageBox.Show("Sold in Wholesale?", "New Item", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { nobarcode = new frmInput(); nobarcode.Title = "WholeSale"; nobarcode.Caption = "Quantity per Set(Box/Case/Rim)"; nobarcode.IsNumericOnly = true; nobarcode.withDecimal = false; nobarcode.Value = ""; if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (nobarcode.Value != "") { item.WSMinimum = Convert.ToInt32(nobarcode.Value); nobarcode = new frmInput(); nobarcode.Title = "WholeSale"; nobarcode.Caption = "Amount per Set(Box/Case/Rim)"; nobarcode.IsNumericOnly = true; nobarcode.withDecimal = true; nobarcode.Value = ""; if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (nobarcode.Value != "") { item.WSAmount = Convert.ToDouble(nobarcode.Value) / item.WSMinimum; item.Category = prod.Category; item.CategoryId = prod.CategoryId; item.CriticalLevel = 10; item.Imagepath = ""; item.QtySold = 0; item.TotalInventoryQty = 0; item.Save(); purchased = new clsPurchasedItem(clsProductItem.SearchProduct(item.BarCode)); } } } } } else { item.WSAmount = item.Amount; item.Category = prod.Category; item.CategoryId = prod.CategoryId; item.CriticalLevel = 10; item.Imagepath = ""; item.QtySold = 0; item.TotalInventoryQty = 0; item.WSMinimum = 1; item.Save(); purchased = new clsPurchasedItem(clsProductItem.SearchProduct(item.BarCode)); } } } } } } } } if (purchased.BarCode != "") { m_receipt.PurchasedItems.Add(purchased.BarCode, purchased); } else { return; } } UpdatePurchases(); if (purchased != null && purchased.BarCode != "") { UpdateProductDisplay(purchased.BarCode); } } else { //MessageBox.Show("Barcode/Product Code not found", "Add Item", MessageBoxButtons.OK, MessageBoxIcon.Information); string result = SearchProduct(barcode); txtBarcode.Text = result; if (result != "") { AddProduct(result); } } } txtBarcode.SelectAll(); }
private void CreateCheckOutItems() { lstCheckOutItems = new List <clsCheckOutItem>(); clsCheckOutItem item = new clsCheckOutItem() { Description = "Initial Cash", ExpectedAmount = initCash, ActualAmount = initCash }; if (item.ActualAmount - item.ExpectedAmount != 0) { item.Remarks = string.Format("{0} [{1:0.00}]", item.ActualAmount - item.ExpectedAmount > 0 ? "Over" : (item.ActualAmount - item.ExpectedAmount == 0 ? "Match" : "Short"), item.ActualAmount - item.ExpectedAmount); } else { item.Remarks = "Match"; } lstCheckOutItems.Add(item); AddItemToGrid(item); item = new clsCheckOutItem() { Description = "Expenses", ExpectedAmount = TotalExpenses, ActualAmount = TotalExpenses }; if (item.ActualAmount - item.ExpectedAmount != 0) { item.Remarks = string.Format("{0} [{1:0.00}]", item.ActualAmount - item.ExpectedAmount > 0 ? "Over" : (item.ActualAmount - item.ExpectedAmount == 0 ? "Match" : "Short"), item.ActualAmount - item.ExpectedAmount); } else { item.Remarks = "Match"; } lstCheckOutItems.Add(item); AddItemToGrid(item); item = new clsCheckOutItem() { Description = "Deposit Cash", ExpectedAmount = depositCash, ActualAmount = depositCash }; if (item.ActualAmount - item.ExpectedAmount != 0) { item.Remarks = string.Format("{0} [{1:0.00}]", item.ActualAmount - item.ExpectedAmount > 0 ? "Over" : (item.ActualAmount - item.ExpectedAmount == 0 ? "Match" : "Short"), item.ActualAmount - item.ExpectedAmount); } else { item.Remarks = "Match"; } lstCheckOutItems.Add(item); AddItemToGrid(item); item = new clsCheckOutItem() { Description = "Total Sales", ExpectedAmount = totalSales, ActualAmount = totalSales }; if (item.ActualAmount - item.ExpectedAmount != 0) { item.Remarks = string.Format("{0} [{1:0.00}]", item.ActualAmount - item.ExpectedAmount > 0 ? "Over" : (item.ActualAmount - item.ExpectedAmount == 0 ? "Match" : "Short"), item.ActualAmount - item.ExpectedAmount); } else { item.Remarks = "Match"; } lstCheckOutItems.Add(item); AddItemToGrid(item); item = new clsCheckOutItem() { Description = "Total Charges", ExpectedAmount = salesinfo[1], ActualAmount = salesinfo[1] }; if (item.ActualAmount - item.ExpectedAmount != 0) { item.Remarks = string.Format("{0} [{1:0.00}]", item.ActualAmount - item.ExpectedAmount > 0 ? "Over" : (item.ActualAmount - item.ExpectedAmount == 0 ? "Match" : "Short"), item.ActualAmount - item.ExpectedAmount); } else { item.Remarks = "Match"; } lstCheckOutItems.Add(item); AddItemToGrid(item); item = new clsCheckOutItem() { Description = "Loading Station Cash In", ExpectedAmount = TotalLoadingStationCashIn, ActualAmount = TotalLoadingStationCashIn }; if (item.ActualAmount - item.ExpectedAmount != 0) { item.Remarks = string.Format("{0} [{1:0.00}]", item.ActualAmount - item.ExpectedAmount > 0 ? "Over" : (item.ActualAmount - item.ExpectedAmount == 0 ? "Match" : "Short"), item.ActualAmount - item.ExpectedAmount); } else { item.Remarks = "Match"; } lstCheckOutItems.Add(item); AddItemToGrid(item); item = new clsCheckOutItem() { Description = "Loading Station Cash Out", ExpectedAmount = TotalLoadingStationCashOut, ActualAmount = TotalLoadingStationCashOut }; if (item.ActualAmount - item.ExpectedAmount != 0) { item.Remarks = string.Format("{0} [{1:0.00}]", item.ActualAmount - item.ExpectedAmount > 0 ? "Over" : (item.ActualAmount - item.ExpectedAmount == 0 ? "Match" : "Short"), item.ActualAmount - item.ExpectedAmount); } else { item.Remarks = "Match"; } lstCheckOutItems.Add(item); AddItemToGrid(item); List <clsLoadAccount> lstLoadAccount = clsLoadAccount.GetLoadAccounts(); if (lstLoadAccount.Count > 0) { foreach (clsLoadAccount account in lstLoadAccount) { item = new clsCheckOutItem() { Description = account.Description, ExpectedAmount = account.AvailableBalance, ActualAmount = 0 }; if (isCheckout) { double remainingBal = account.AvailableBalance; frmInput input = new frmInput(); input.Title = "Actual Remaining Balance"; input.Value = "0"; input.Caption = account.Description; if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK) { item.ActualAmount = double.Parse(input.Value); } } if (item.ActualAmount - item.ExpectedAmount != 0) { item.Remarks = string.Format("{0} [{1:0.00}]", item.ActualAmount - item.ExpectedAmount > 0 ? "Over" : (item.ActualAmount - item.ExpectedAmount == 0 ? "Match" : "Short"), item.ActualAmount - item.ExpectedAmount); } else { item.Remarks = "Match"; } lstCheckOutItems.Add(item); AddItemToGrid(item); } } item = new clsCheckOutItem() { Description = "Cash on Hand", ExpectedAmount = expectedCOH, ActualAmount = actualCOH, }; if (item.ActualAmount - item.ExpectedAmount != 0) { item.Remarks = string.Format("{0} [{1:0.00}]", item.ActualAmount - item.ExpectedAmount > 0 ? "Over" : (item.ActualAmount - item.ExpectedAmount == 0 ? "Match" : "Short"), item.ActualAmount - item.ExpectedAmount); } else { item.Remarks = "Match"; } lstCheckOutItems.Add(item); AddItemToGrid(item); }
private bool CancelPayment() { if (!clsUtil.GetApproval(m_user, UserAccess.Manager)) { return(false); } frmSelectAccounts acct = new frmSelectAccounts(0, m_user); if (acct.ShowDialog() == System.Windows.Forms.DialogResult.OK) { clsAccountInfo a = acct.SelectedAccount; frmInput input = new frmInput(); input.Title = "Retrieve Payment Info"; input.Caption = "Payment Reference"; input.IsHiddenInput = false; input.IsNumericOnly = true; input.withDecimal = false; input.Value = ""; if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK) { clsPaymentInfo payment = clsPaymentInfo.GetPayment(Convert.ToInt32(input.Value)); if (payment != null) { clsChargedTransaction charges = clsChargedTransaction.GetChargedTransaction(payment.OrNum); if (charges != null && payment.PaymentId != 0 && payment.AccountId == a.AccountId) { if (payment.Remarks.ToLower().Contains("interest")) { MessageBox.Show("Interest payment cancellation not allowed!", "Cancel Payment", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (MessageBox.Show(string.Format("Are you sure you want to cancel payment?\nRefno:{0}\nRemarks:{1}\nAmount:P {2:0.00}", payment.PaymentId, payment.Remarks, payment.AmountPaid), "Cancel Payment", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { if (payment.Remarks.ToLower().Contains("principal")) { a.PrincipalBalance += payment.AmountPaid; a.Save(); charges.TransBalance += payment.AmountPaid; charges.SaveChargeTransaction(); if (clsPaymentInfo.CancelPayment(payment.PaymentId)) { MessageBox.Show("Payment successfully cancelled!", "Cancel Payment", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Cancel Payment did not succeed!", "Cancel Payment", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } } } } else { MessageBox.Show("Payment Reference not found under this account", "Cancel Payment", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } return(false); }
private void btnPayment_Click(object sender, EventArgs e) { if (dgvAccounts.SelectedRows.Count > 0) { if (m_Accounts != null) { foreach (clsAccountInfo a in m_Accounts) { if (a.AccountName == dgvAccounts.SelectedRows[0].Cells[1].Value.ToString()) { frmInput payment = new frmInput(); double amountpaid = a.AccountReceivable; double change = 0; payment.Title = "Cash Payment"; payment.Caption = "Amount"; payment.IsNumericOnly = true; payment.Value = a.AccountReceivable.ToString(); if (payment.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (Convert.ToDouble(payment.Value) < a.AccountReceivable) { amountpaid = Convert.ToDouble(payment.Value); } else { amountpaid = a.AccountReceivable; change = Convert.ToDouble(payment.Value) - a.AccountReceivable; } if (amountpaid > 0) { clsPaymentInfo pay = new clsPaymentInfo(); pay.AccountId = a.AccountId; pay.AmountPaid = amountpaid; pay.Timestamp = DateTime.Now; pay.UserId = m_user.UserId; pay.UserName = m_user.UserName; string reference = pay.Save(); string ret = ""; Receipt or = new Receipt(); or.InitializePrinter(); List <string> strmsg = new List <string>(); ret += or.PrintCompanyHeader(); strmsg.Add(""); strmsg.Add("PAYMENT"); ret += or.PrintHeader(strmsg, PrintFontAlignment.Center, PrintFontSize.UnderlineBold); strmsg.Clear(); strmsg.Add(string.Format("Cashier: {0}", m_user.UserName.ToUpper())); strmsg.Add(string.Format("Date: {0}", pay.Timestamp.ToString("yyyy-MM-dd HH:mm:ss"))); strmsg.Add(reference); strmsg.Add(string.Format("Account Name: {0}", a.AccountName)); strmsg.Add(string.Format("Previous Balance: {0}", a.AccountReceivable)); strmsg.Add(string.Format("Amount Paid: {0}", amountpaid)); strmsg.Add(string.Format("Current Balance: {0}", a.AccountReceivable - amountpaid)); a.LoadTransInfo(); //a.PrincipalBalance = clsChargedTransaction.GetPrincipalAmount(a.AccountId); // a.TotalInterest = clsChargedTransaction.GetTotalInterest(a.AccountId); a.LastComputedInterest = DateTime.Today; a.Save(); ret += or.PrintAppend(strmsg, PrintFontAlignment.Left, PrintFontSize.Regular); or.FormFeed(); or.OpenDrawer(); or.ExecPrint(ret); strmsg.Clear(); CloseDrawer drawer = new CloseDrawer(); drawer.Change = change; drawer.ShowDialog(); DisplayAccounts(txtSearch.Text); } } } } } } }