public static void Save_Invoice(InvoiceForm f) { //save Invoice try { if (f.bunifuDatepicker1.Value != null && (f.Textbox1ID.Text != "" || f.Textbox1ID.Text != null)) { //save Invoiec int InvID = int.Parse(f.Textbox1ID.Text); DateTime InvDate = f.bunifuDatepicker1.Value; int InvSupplier = int.Parse(f.comboBox1.SelectedValue.ToString()); Invoice inv = new Invoice(InvID, InvDate, InvSupplier); inv.AddInvoice(dt); //save InvoiceDetails InvoiceDetails invDetails; foreach (DataGridViewRow r in f.dataGridView11.Rows) { string MedecineID = r.Cells["ProductID"].Value.ToString(); string VAT = r.Cells["VAT"].Value.ToString(); string Price = r.Cells["Price"].Value.ToString(); string Discount = r.Cells["Discount"].Value.ToString(); string quantity = r.Cells["Quantity"].Value.ToString(); string expiryDate = r.Cells["Date"].Value.ToString(); invDetails = new InvoiceDetails(MedecineID, InvID, quantity, Price, VAT.Replace("%", ""), expiryDate, Discount.Replace("%", "")); invDetails.AddInvoiceDetails(dt); Stocks.UpdateStocks(dt, int.Parse(MedecineID), int.Parse(quantity)); } } else { MessageBox.Show("Please Fill ID and Date "); } } catch { //ADD DELETE FUNCTION MessageBox.Show("ERROR!!"); } }