public override void button3_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count > 0) { Int64 purchaseInvoiceID; insertion i = new insertion(); updation u = new updation(); using (TransactionScope sc = new TransactionScope()) { purchaseInvoiceID = i.insertPurchaseInvoice(DateTime.Today, retrival.USER_ID, Convert.ToInt32(supplierDD.SelectedValue)); foreach (DataGridViewRow row in dataGridView1.Rows) { co += i.insertPurchaseInvoiceDetails(purchaseInvoiceID, Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToInt32(row.Cells["quantGV"].Value.ToString()), Convert.ToSingle(row.Cells["totalGV"].Value.ToString())); if (r.checkproductPriceExistence(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()))) { u.updateProductPrice(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToSingle(row.Cells["pupGV"].Value.ToString())); } else { i.insertProductPrice(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToSingle(row.Cells["pupGV"].Value.ToString())); } int q; object ob = r.getProductQuantity(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString())); if (ob != null) { q = Convert.ToInt32(ob); q += Convert.ToInt32(row.Cells["quantGV"].Value.ToString()); u.updateStock(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), q); } else { i.insertStock(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToInt32(row.Cells["quantGV"].Value.ToString())); } } if (co > 0) { MainClass.showMG("Purchase Invoice Created Successfullly..", "success", "success"); } else { MainClass.showMG("error", "error", "error"); } sc.Complete(); } } }
public override void button3_Click(object sender, EventArgs e) { int che = 0; try { if (categoryDD.SelectedIndex != -1 && categoryDD.SelectedIndex != 0) { foreach (DataGridViewRow row in dataGridView1.Rows) { if ((bool)row.Cells["selectGV"].FormattedValue == true) { che++; Int64 pID; float disc, pm, bp, sp; pID = Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()); bp = Convert.ToSingle(row.Cells["BuyingPriceGv"].Value.ToString()); disc = row.Cells["DiscountGV"].Value == null ? 0 : Convert.ToSingle(row.Cells["DiscountGV"].Value.ToString()); pm = row.Cells["profitMarginGV"].Value == null ? 0 : Convert.ToSingle(row.Cells["profitMarginGV"].Value.ToString()); if (disc == 0 && pm == 0) { sp = bp; } else { sp = Convert.ToSingle(row.Cells["FinalPriceGV"].Value.ToString()); } u.updateProductPrice(pID, bp, sp, disc, pm); } } if (che > 0) { MainClass.showMG("Product Pricing updated Successfully....", "Success", "success"); che = 0; } else { MainClass.showMG("please Select The CheckBox....", "Error", "Error"); che = 0; } } } catch (Exception) { } }