private void dgvBillBreakupList_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { DealerBillBreakup dealerBillBreakup = (DealerBillBreakup)dgvBillBreakupList.Rows[e.RowIndex].DataBoundItem; if (e.ColumnIndex == ColTotalAmount.Index) { if (dealerBillBreakup.QuantityInBox * dealerBillBreakup.TotalBoxes * dealerBillBreakup.UnitPrice != dealerBillBreakup.TotalAmount) { e.CellStyle.BackColor = RAG_Red; } } else if (e.ColumnIndex == ColTotalQuantity.Index) { if (dealerBillBreakup.QuantityInBox * dealerBillBreakup.TotalBoxes != dealerBillBreakup.TotalQuantity) { e.CellStyle.BackColor = RAG_Red; } } else if (e.ColumnIndex == ColUnitSellingPrice.Index) { if (dealerBillBreakup.UnitSellPrice <= dealerBillBreakup.UnitPrice) { e.CellStyle.BackColor = RAG_Red; } } DataGridView_Selected_Cell_CellFormatting(sender, e); }
private void dgvBillBreakupList_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1 || e.ColumnIndex == -1) { return; } if (GetSelectedCellText(dgvBillBreakupList, e) == "Details") { DealerBillBreakup dealerBillBreakup = ((DealerBillBreakup)dgvBillBreakupList.Rows[e.RowIndex].DataBoundItem); OpenBillBreakupForm(dealerBillBreakup.Id); } }
public void SaveDealerBillBreakup(DealerBillBreakup BillBreakup) { BillBreakup.TimeStamp = DateHelper.GetDateNowString_Sortable(); if (BillBreakup.Id == 0) { context.DealerBillBreakups.Add(BillBreakup); context.SaveChanges(); } else { context.DealerBillBreakups.Attach(BillBreakup); context.Entry(BillBreakup).State = EntityState.Modified; context.SaveChanges(); } }
public void SaveCustomerBillBreakupList(CustomerBill customerBill, List <ProductInCart> productListInCart) { using (var dbContextTransaction = context.Database.BeginTransaction()) { try { SaveCustomerBill(customerBill); foreach (ProductInCart productInCart in productListInCart) { CustomerBillBreakup customerBillBreakup = new CustomerBillBreakup(); customerBillBreakup.CustomerBillId = customerBill.Id; customerBillBreakup.DealerBillBreakupId = productInCart.DealerBillBreakupId; customerBillBreakup.ProductId = productInCart.ProductId; customerBillBreakup.TotalAmount = productInCart.SellingAmount; customerBillBreakup.TotalQuantity = productInCart.SellingQuantity; customerBillBreakup.UnitPrice = productInCart.SellingUnitPrice; customerBillBreakup.TotalBoxes = productInCart.TotalBoxes; customerBillBreakup.QuantityInBox = productInCart.QuantityInBox; SaveCustomerBillBreakup(customerBillBreakup); // Reduce available quantity DealerBillBreakup dealerBillBreakup = context.DealerBillBreakups.Find(customerBillBreakup.DealerBillBreakupId); if (dealerBillBreakup == null) { dbContextTransaction.Rollback(); throw new Exception("Dealer bill breakup is not found"); } else if (dealerBillBreakup.AvailableQuantity < customerBillBreakup.TotalQuantity) { dbContextTransaction.Rollback(); throw new Exception("Available quantity is less than sold quantity"); } dealerBillBreakup.AvailableQuantity = dealerBillBreakup.AvailableQuantity - customerBillBreakup.TotalQuantity; SaveDealerBillBreakup(dealerBillBreakup); } dbContextTransaction.Commit(); } catch (Exception ex) { dbContextTransaction.Rollback(); throw new Exception("Billing failed" + ex.Message); } } }
private void EditBillBreakuDetail() { ShowFormInGroupBox(this, grpBoxBrakupCount, new DealerBillBreakupCountForm(_dealerBillId)); if (_dealerBillBreakupId != 0) { Text = "Edit Dealer Bill Breakup"; dealerBillBreakup = SharedRepo.DBRepo.GetDealerBillBreakupByID(_dealerBillBreakupId); if (dealerBillBreakup == null) { btnSaveBillBreakups.Enabled = false; return; } else { if (dealerBillBreakup.Product != null) { txtSelectedProductName.Text = dealerBillBreakup.Product.Name; } numTotalAmount.Value = dealerBillBreakup.TotalAmount; numTotalBoxes.Value = dealerBillBreakup.TotalBoxes; numQuantityInABox.Value = dealerBillBreakup.QuantityInBox; numTotalQuantity.Value = dealerBillBreakup.TotalQuantity; numAvailableQuantity.Value = dealerBillBreakup.AvailableQuantity; numUnitPrice.Value = dealerBillBreakup.UnitPrice; numUnitSellingPrice.Value = dealerBillBreakup.UnitSellPrice; } } else { Text = "Add Dealer Bill Breakup"; dealerBillBreakup = new DealerBillBreakup(); dealerBillBreakup.DealerBillId = _dealerBillId; dealerBillBreakup.EntryDate = DateHelper.GetTodayDateString(); } }