public override void saveButton_Click(object sender, EventArgs e) { if (categoryComboBox.SelectedIndex != -1 && categoryComboBox.SelectedIndex != 0) { foreach (DataGridViewRow row in displayDataGridView.Rows) { if ((bool)row.Cells["selectGV"].FormattedValue == true) { float disc, pm, bp, sp; int pID; 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); } } MainClass.ShowMsg("Product Pricing Updated Successfully...", "Success", "Success"); } }
public override void saveButton_Click(object sender, EventArgs e) { if (displayDataGridView.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(supplierComboBox.SelectedValue)); foreach (DataGridViewRow row in displayDataGridView.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.checkProductPriceExistance(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.ShowMsg("Purchase Invoice Created Successfully.", "Success", "Success"); } else { MainClass.ShowMsg("Unable to create purchase invoice.", "Error", "Error"); } sc.Complete(); } } }