public override void saveBtn_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count > 0) { Int64 purchaseInvoiceID; insertions i = new insertions(); updation u = new updation(); //transaction is use jab tak ap ka sara code successfull ni chal jata excecute ni hota or agar ik code ni chalta tou dusre ko bi roll back kar deta hai jo successfull chala ho //transaction rokti hai invalid operations ko using (TransactionScope sc = new TransactionScope()) { purchaseInvoiceID = i.insertPurchaseInvoice(DateTime.Today, retrieval.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["quantityGV"].Value.ToString()), Convert.ToSingle(row.Cells["TotGV"].Value.ToString())); if (r.checkProductPriceExist(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()))) { u.updateProductPriceWRTPI(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())); } //for stocks 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["quantityGV"].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["quantityGV"].Value.ToString())); } } if (CO > 0) { MainClass.ShowMSG("Purchase Invoice Created SuccessFully", "Success", "Success"); PurchaseInvoiceDetail sr = new PurchaseInvoiceDetail(); sr.Show(); } else { MainClass.ShowMSG("Unable to create Purchase Invoice", "Error", "Error"); } sc.Complete(); } } }
public override void saveBtn_Click(object sender, EventArgs e) { if (proTxt.Text == "") { proErrorLabel.Visible = true; } else { proErrorLabel.Visible = false; } if (barTxt.Text == "") { barErrorLabel.Visible = true; } else { barErrorLabel.Visible = false; } if (dateTimePicker.Value < DateTime.Now) { expErrorLabel.Visible = true; expErrorLabel.Text = "Invalid date"; } else { expErrorLabel.Visible = false; } //-1 is equal to blank if (categoryCB.SelectedIndex == -1 || categoryCB.SelectedIndex == 0) { categoryErrorLabel.Visible = true; } else { categoryErrorLabel.Visible = false; } if (proErrorLabel.Visible || barErrorLabel.Visible || expErrorLabel.Visible) { MainClass.ShowMSG("Feild with * are mandatory", "Stop", "Error");//error is a type of message } else { if (edit == 0)//for save operations { insertions i = new insertions(); if (dateTimePicker.Value.Date == DateTime.Now.Date) { i.insertproducts(proTxt.Text, barTxt.Text, Convert.ToInt32(categoryCB.SelectedValue)); } else { i.insertproducts(proTxt.Text, barTxt.Text, Convert.ToInt32(categoryCB.SelectedValue), dateTimePicker.Value); } r.showProduct(dataGridView1, proIDGV, proNameGV, expiryGV, catGV, barcodeGV, catIDGV); MainClass.disable_reset(leftPanel); } else if (edit == 1)// for update operations { DialogResult dr = MessageBox.Show("Are you sure , you want to update record?", "Question..", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { updation u = new updation(); if (dateTimePicker.Value.Date == DateTime.Now.Date) { u.updateProducts(proID, proTxt.Text, barTxt.Text, Convert.ToInt32(categoryCB.SelectedValue)); } else { u.updateProducts(proID, proTxt.Text, barTxt.Text, Convert.ToInt32(categoryCB.SelectedValue), dateTimePicker.Value); } r.showProduct(dataGridView1, proIDGV, proNameGV, barcodeGV, expiryGV, catGV, catIDGV); MainClass.disable_reset(leftPanel); } } } }
public override void saveBtn_Click(object sender, EventArgs e) { if (nameTxt.Text == "") { nameErrorLabel.Visible = true; } else { nameErrorLabel.Visible = false; } if (usernameTxt.Text == "") { usernameErrorLabel.Visible = true; } else { usernameErrorLabel.Visible = false; } if (passTxt.Text == "") { passErrorLabel.Visible = true; } else { passErrorLabel.Visible = false; } if (phoneTxt.Text == "") { phoneErrorLabel.Visible = true; } else { phoneErrorLabel.Visible = false; } if (emailTxt.Text == "") { emailErrorLabel.Visible = true; } else { emailErrorLabel.Visible = false; } //-1 is equal to blank if (statusDD.SelectedIndex == -1) { statusErrorLabel.Visible = true; } else { statusErrorLabel.Visible = false; } if (nameErrorLabel.Visible || usernameErrorLabel.Visible || passErrorLabel.Visible || phoneErrorLabel.Visible || emailErrorLabel.Visible || statusErrorLabel.Visible) { MainClass.ShowMSG("Feild with * are mandatory", "Stop", "Error");//error is a type of message } else { if (statusDD.SelectedIndex == 0) { stat = 1; } else if (statusDD.SelectedIndex == 1) { stat = 0; } if (edit == 0)//for save operations { insertions i = new insertions(); i.insertUser(nameTxt.Text, usernameTxt.Text, passTxt.Text, emailTxt.Text, phoneTxt.Text, stat); r.showUsers(dataGridView1, userIDGV, NameGV, UserNameGV, PassGV, EmailGV, PhoneGV, stausGV); MainClass.disable_reset(leftPanel); } else if (edit == 1)// for update operations { DialogResult dr = MessageBox.Show("Are you sure , you want to update record?", "Question..", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { updation u = new updation(); if (statusDD.SelectedIndex == 0) { stat = 1; } else if (statusDD.SelectedIndex == 1) { stat = 0; } u.updateUser(userID, nameTxt.Text, usernameTxt.Text, passTxt.Text, emailTxt.Text, phoneTxt.Text, stat); r.showUsers(dataGridView1, userIDGV, NameGV, UserNameGV, PassGV, EmailGV, PhoneGV, stausGV); MainClass.disable_reset(leftPanel); } } } }
public override void saveBtn_Click(object sender, EventArgs e) { if (categoryTxt.Text == "") { categoryErrorLabel.Visible = true; } else { categoryErrorLabel.Visible = false; } if (activeCB.SelectedIndex == -1) { activeErrorLabel.Visible = true; } else { activeErrorLabel.Visible = false; } if (categoryErrorLabel.Visible || activeErrorLabel.Visible) { MainClass.ShowMSG("Feild with * are mandatory", "Stop", "Error");//error is a type of message } else { if (activeCB.SelectedIndex == 0) { stat = 1; } else if (activeCB.SelectedIndex == 1) { stat = 0; } if (edit == 0)//for save operations { insertions i = new insertions(); i.insertCat(categoryTxt.Text, stat); r.showCategories(dataGridView1, catIDGV, NameGV, stausGV); MainClass.disable_reset(leftPanel); } else if (edit == 1)// for update operations { DialogResult dr = MessageBox.Show("Are you sure , you want to update record?", "Question..", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { updation u = new updation(); if (activeCB.SelectedIndex == 0) { stat = 1; } else if (activeCB.SelectedIndex == 1) { stat = 0; } u.updateCat(categoryID, categoryTxt.Text, stat); r.showCategories(dataGridView1, catIDGV, NameGV, stausGV); MainClass.disable_reset(leftPanel); } } } }
public override void saveBtn_Click(object sender, EventArgs e) { if (supplierCompantTxt.Text == "") { suppliernameErrorLabel.Visible = true; } else { suppliernameErrorLabel.Visible = false; } if (personNameTxt.Text == "") { personErrorLabel.Visible = true; } else { personErrorLabel.Visible = false; } if (Phone1Txt.Text == "") { phoneErrorLabel.Visible = true; } else { phoneErrorLabel.Visible = false; } if (addressTxt.Text == "") { addressErrorLabel.Visible = true; } else { addressErrorLabel.Visible = false; } //-1 is equal to blank if (statusDD.SelectedIndex == -1) { statusErrorLabel.Visible = true; } else { statusErrorLabel.Visible = false; } if (suppliernameErrorLabel.Visible || personErrorLabel.Visible || phoneErrorLabel.Visible || addressErrorLabel.Visible || statusErrorLabel.Visible) { MainClass.ShowMSG("Feild with * are mandatory", "Stop", "Error");//error is a type of message } else { if (statusDD.SelectedIndex == 0) { stat = 1; } else if (statusDD.SelectedIndex == 1) { stat = 0; } if (edit == 0)//for save operations { insertions i = new insertions(); if (Phone2Txt.Text == "" && ntnTxt.Text != "") { i.insertSuppliers(supplierCompantTxt.Text, personNameTxt.Text, Phone1Txt.Text, addressTxt.Text, stat, null, ntnTxt.Text); } else if (Phone2Txt.Text != "" && ntnTxt.Text == "") { i.insertSuppliers(supplierCompantTxt.Text, personNameTxt.Text, Phone1Txt.Text, addressTxt.Text, stat, Phone2Txt.Text, null); } else if (Phone2Txt.Text == "" && ntnTxt.Text == "") { i.insertSuppliers(supplierCompantTxt.Text, personNameTxt.Text, Phone1Txt.Text, addressTxt.Text, stat, null, null); } else { i.insertSuppliers(supplierCompantTxt.Text, personNameTxt.Text, Phone1Txt.Text, addressTxt.Text, stat, Phone2Txt.Text, ntnTxt.Text); } r.showSuppliers(dataGridView1, supIDGV, comNameGV, personGV, phone1GV, phone2GV, addressGV, ntnGV, stausGV); MainClass.disable_reset(leftPanel); } else if (edit == 1)// for update operations { DialogResult dr = MessageBox.Show("Are you sure , you want to update record?", "Question..", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { updation u = new updation(); if (statusDD.SelectedIndex == 0) { stat = 1; } else if (statusDD.SelectedIndex == 1) { stat = 0; } if (Phone2Txt.Text == "" && ntnTxt.Text != "") { u.updateSuppliers(supplierID, supplierCompantTxt.Text, personNameTxt.Text, Phone1Txt.Text, addressTxt.Text, stat, null, ntnTxt.Text); } else if (Phone2Txt.Text != "" && ntnTxt.Text == "") { u.updateSuppliers(supplierID, supplierCompantTxt.Text, personNameTxt.Text, Phone1Txt.Text, addressTxt.Text, stat, Phone2Txt.Text, null); } else if (Phone2Txt.Text == "" && ntnTxt.Text == "") { u.updateSuppliers(supplierID, supplierCompantTxt.Text, personNameTxt.Text, Phone1Txt.Text, addressTxt.Text, stat, null, null); } else { u.updateSuppliers(supplierID, supplierCompantTxt.Text, personNameTxt.Text, Phone1Txt.Text, addressTxt.Text, stat, Phone2Txt.Text, ntnTxt.Text); } r.showSuppliers(dataGridView1, supIDGV, comNameGV, personGV, phone1GV, phone2GV, addressGV, ntnGV, stausGV); MainClass.disable_reset(leftPanel); } } } }