private void idBtnEdit_Click(object sender, EventArgs e) { if (IsDgvRowsPresent()) { var rowIndex = idDgvMastersItem.SelectedCells[0].RowIndex; var id = idDgvMastersItem.Rows[rowIndex].Cells[0].Value.ToString(); var ObjCustInfo = ItemsBl.GetItemPerId(id); var obj = new Items(ObjCustInfo); obj.Show(); this.Close(); } }
public void UpdateInvoiceDgv(string ItemId, string Qty) { var GstInfo = MastersBl.GetTaxInfo(); var ObjItemInfo = ItemsBl.GetItemPerId(ItemId); DataTable dt = new DataTable(); dt = idDgvInvoice.DataSource as DataTable; DataRow dtr = dt.NewRow(); var ErrorCounter = 0; var ErrorMessage = "Following fields should not be empty \n\n"; if (string.IsNullOrEmpty(ItemId)) { ErrorCounter++; ErrorMessage += ErrorCounter.ToString() + "] " + "Please Select Item \n"; } if (string.IsNullOrEmpty(Qty)) { ErrorCounter++; ErrorMessage += ErrorCounter.ToString() + "] " + "Please Enter Qty \n"; } if (!string.IsNullOrEmpty(Qty)) { var temp = 0; var result = int.TryParse(Qty, out temp); if (result == false) { ErrorCounter++; ErrorMessage += ErrorCounter.ToString() + "] " + "Please enter quantity in numeric format \n"; } } var rowCount = dt.Rows.Count; for (var i = 0; i < rowCount; i++) { var ExistingValue = dt.Rows[i]["Item"].ToString().Trim(); if (ExistingValue == ObjItemInfo.Name) { ErrorCounter++; ErrorMessage += ErrorCounter.ToString() + "] " + "Item already added. \n"; } } if (ErrorCounter > 0) { MessageBox.Show(ErrorMessage, "Warning !..."); return; } var SrNo = dt.Rows.Count; dtr["Sr.no"] = SrNo + 1; var ItemName = ObjItemInfo.Name; if (!string.IsNullOrEmpty(ObjItemInfo.PartNumber)) { ItemName += " [ " + ObjItemInfo.PartNumber + " ]"; } dtr["Item"] = ItemName; dtr["Quantity"] = Qty; dtr["UOM"] = ObjItemInfo.Unit; dtr["HSN"] = ObjItemInfo.Hsn; double PerPrice = double.Parse(ObjItemInfo.Rate); var TaxableAmount = PerPrice * double.Parse(Qty); dtr["TaxableAmount"] = TaxableAmount; if (ObjItemInfo.SGST == "true") { double sgstTaxAmount = 0; double sgstRate = double.Parse(GstInfo.SGST); if (sgstRate > 0) { sgstTaxAmount = TaxableAmount * (sgstRate / 100); dtr["SGST(Rs)"] = sgstTaxAmount; } else { dtr["SGST(Rs)"] = "0"; } } else { dtr["CGST(Rs)"] = "0"; } if (ObjItemInfo.CGST == "true") { double cgstTaxAmount = 0; double cgstRate = double.Parse(GstInfo.CGST); if (cgstRate > 0) { cgstTaxAmount = TaxableAmount * (cgstRate / 100); dtr["CGST(Rs)"] = cgstTaxAmount; } else { dtr["CGST(Rs)"] = "0"; } } else { dtr["CGST(Rs)"] = "0"; } if (ObjItemInfo.IGST == "true") { double igstTaxAmount = 0; double igstRate = double.Parse(GstInfo.CGST); if (igstRate > 0) { igstTaxAmount = TaxableAmount * (igstRate / 100); dtr["IGST(Rs)"] = igstTaxAmount; } else { dtr["IGST(Rs)"] = "0"; } } else { dtr["IGST(Rs)"] = "0"; } double totalAmount = TaxableAmount + double.Parse(dtr["IGST(Rs)"].ToString()) + double.Parse(dtr["CGST(Rs)"].ToString()) + double.Parse(dtr["SGST(Rs)"].ToString()); dtr["TotalAmount"] = totalAmount; dt.Rows.Add(dtr); idTxtQty.Text = ""; idCmbAddItem.SelectedIndex = -1; }