public void AddCreditBillTransactions(CreditBillTransaction creditBillTransaction) { using (Billing_Customized_Entities addBilledProducts = new Billing_Customized_Entities()) { addBilledProducts.CreditBillTransactions.Add(creditBillTransaction); addBilledProducts.SaveChanges(); } }
public bool UpdateCashierTransaction(CreditBillTransaction creditBillTransaction) { if (creditBillTransaction != null) { cashierDataAccess.AddCreditBillTransaction(creditBillTransaction); return(true); } return(false); }
public void UpdateBillDetailsForCreditBill(string currentBillNumber, string mobileNumber, string customerName, decimal paidAmount, decimal totalGST, decimal billAmount, decimal totalAmount, DataGridView purchasedProductsFromGridView) { List <CreditBillSalesDetail> purchased = new List <CreditBillSalesDetail>(); CreditBill salesDetail = new CreditBill(); CreditBillTransaction creditBillTransaction = new CreditBillTransaction(); List <Products> productDetails = new List <Products>(); if (purchasedProductsFromGridView.Rows.Count > 0) { for (int i = 0; i < purchasedProductsFromGridView.Rows.Count; i++) { CreditBillSalesDetail billedProducts = new CreditBillSalesDetail { ProductId = Convert.ToInt64(purchasedProductsFromGridView.Rows[i].Cells[1].Value), ProductName = purchasedProductsFromGridView.Rows[i].Cells[2].Value.ToString(), Quantity = Convert.ToDecimal(purchasedProductsFromGridView.Rows[i].Cells[3].Value), BillAmount = Convert.ToDecimal(purchasedProductsFromGridView.Rows[i].Cells[5].Value), TotalAmount = Convert.ToDecimal(purchasedProductsFromGridView.Rows[i].Cells[8].Value), GSTAmount = Convert.ToDecimal(purchasedProductsFromGridView.Rows[i].Cells[7].Value), SoldDate = DateTime.Today, BillNumber = Convert.ToInt64(currentBillNumber) }; purchased.Add(billedProducts); Products product = new Products { ProductId = Convert.ToInt64(purchasedProductsFromGridView.Rows[i].Cells[1].Value), Quantity = Convert.ToDecimal(purchasedProductsFromGridView.Rows[i].Cells[3].Value), }; productDetails.Add(product); } salesDetail.BillNos = Convert.ToInt64(currentBillNumber); salesDetail.GSTAmount = totalGST; salesDetail.BillAmount = billAmount; salesDetail.TotalAmount = Math.Round(totalAmount, MidpointRounding.ToEven); salesDetail.SoldDate = DateTime.Today; salesDetail.PaidAmount = Math.Round(paidAmount, MidpointRounding.ToEven); creditBillTransaction.BillNos = Convert.ToInt64(currentBillNumber); creditBillTransaction.GSTAmount = totalGST; creditBillTransaction.BillAmount = billAmount; creditBillTransaction.TotalAmount = Math.Round(totalAmount, MidpointRounding.ToEven); creditBillTransaction.BillDate = DateTime.Today; creditBillTransaction.TransactionDate = DateTime.Today; creditBillTransaction.PaidAmount = Math.Round(paidAmount, MidpointRounding.ToEven); creditBillTransaction.CustomerName = customerName; creditBillTransaction.MobileNumber = Convert.ToInt64(mobileNumber); creditBillTransaction.TotalOutstanding = Math.Round(totalAmount, MidpointRounding.ToEven) - Math.Round(paidAmount, MidpointRounding.ToEven); } Task.Run(() => cashierDataAccess.AddSalesDetailsForCreditBill(salesDetail)); Task.Run(() => cashierDataAccess.UpdateCreditBillSalesDetails(purchased)); Task.Run(() => cashierDataAccess.AddCreditBillTransactions(creditBillTransaction)); cashierDataAccess.UpdateQuantity(productDetails); }
public void AddCreditBillTransaction(CreditBillTransaction creditBillTransaction) { using (Billing_Customized_Entities creditTransactions = new Billing_Customized_Entities()) { creditTransactions.CreditBillTransactions.Add(creditBillTransaction); var bill = creditTransactions.CreditBills.FirstOrDefault(obj => obj.BillNos.Equals(creditBillTransaction.BillNos) && obj.SoldDate == creditBillTransaction.BillDate); if (bill != null) { bill.PaidAmount += creditBillTransaction.PaidAmount; } creditTransactions.SaveChanges(); } }
private void CheckAnyOutstandingAmount(CreditBillTransaction creditBillTransaction) { if (creditBillTransaction.TotalOutstanding.Equals(0)) { MessageBox.Show("This Bill Has Been Closed, No Outstanding Amount"); } else { retrivedCreditBillTransaction = creditBillTransaction; Update_Button.Enabled = true; Retrieved_Date_Textbox.Text = Picker.Value.Date.ToString("dd-MM-yyyy"); Bill_Number_Textbox.Text = Bill_No_Textbox.Text; Total_Amount_Textbox.Text = string.Format("{0:0.00}", creditBillTransaction.TotalAmount); Total_Outstanding_Textbox.Text = string.Format("{0:0.00}", creditBillTransaction.TotalOutstanding); progressBar.Close(); } }
private void UpdateButtonDoWork(object sender, DoWorkEventArgs e) { decimal receivedAmount = Convert.ToDecimal(Amount_Payable_Textbox.Text); CreditBillTransaction creditBillTransaction = new CreditBillTransaction() { CustomerName = retrivedCreditBillTransaction.CustomerName, MobileNumber = retrivedCreditBillTransaction.MobileNumber, BillNos = retrivedCreditBillTransaction.BillNos, BillDate = retrivedCreditBillTransaction.BillDate, TransactionDate = DateTime.Today, BillAmount = retrivedCreditBillTransaction.BillAmount, GSTAmount = retrivedCreditBillTransaction.GSTAmount, TotalAmount = retrivedCreditBillTransaction.TotalAmount, PaidAmount = Math.Round(receivedAmount, MidpointRounding.ToEven), TotalOutstanding = Math.Round(retrivedCreditBillTransaction.TotalOutstanding - receivedAmount, MidpointRounding.ToEven), }; e.Result = cashier.UpdateCashierTransaction(creditBillTransaction); }
private void Reset_Button_Click(object sender, EventArgs e) { try { Get_Details_Button.Enabled = true; Amount_Payable_Textbox.ReadOnly = false; Pending_Transaction_Checkbox.Checked = false; Picker.ResetText(); Bill_No_Textbox.Text = Bill_Number_Textbox.Text = Retrieved_Date_Textbox.Text = Total_Amount_Textbox.Text = string.Empty; Total_Outstanding_Textbox.Text = Amount_Payable_Textbox.Text = string.Empty; Update_Button.Enabled = Print_Button.Enabled = false; Credit_Tracker_Listview.Items.Clear(); retrivedCreditBillTransaction = null; CreditBillTracker_Load(null, null); } catch (Exception ex) { MessageBox.Show(ex.StackTrace.ToString(), "Error Occured at Credit Bill Tracker", MessageBoxButtons.OK); } }