private void save_new_details_button_change_Click(object sender, EventArgs e) { try { if (new_password_textBox_change.Text != "" && admin_radioButton.Checked == true && other_radioButton.Checked == false) { Hashtable ht = new Hashtable(); ht.Add("@username", usernameGLOBAL); ht.Add("@password", new_password_textBox_change.Text); if (SQL_TASKS.insert_update_delete("st_updateAdminPASSWORD", ht) > 0) { CodingSourceClass.ShowMsg("Password changed successfully.", "Success"); clear(); sq.Close(); } else { throw new Exception("An error occured."); } } else if (new_password_textBox_change.Text != "" && admin_radioButton.Checked == false && other_radioButton.Checked == true) { Hashtable ht = new Hashtable(); ht.Add("@username", usernameGLOBAL); ht.Add("@password", new_password_textBox_change.Text); if (SQL_TASKS.insert_update_delete("st_updateUSERPASSWORD", ht) > 0) { CodingSourceClass.ShowMsg("Password changed successfully.", "Success"); clear(); sq.Close(); } else { throw new Exception("An error occured."); } } else { throw new Exception("Please fill all required fields properly."); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); sq.Close(); } }
public override void delete_button_Click(object sender, EventArgs e) { try { if (roles_textBox.Text != "" && roles_textBox.Enabled == false) { Hashtable ht = new Hashtable(); DialogResult dr = MessageBox.Show("Are you sure? ", "Question.....", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { //key , value ht.Add("@id", roleID); if (SQL_TASKS.insert_update_delete("st_deleteROLES", ht) > 0) { MainClass.CodingSourceClass.ShowMsg(roles_textBox.Text + " deleted successfully from the system.", "Success"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); LoadRoles(); SQL_TASKS.TotalRecords("getTOTALROLES", total_roles_label); } else { CodingSourceClass.ShowMsg("Unable to delete.", "Error"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); } } } else { CodingSourceClass.ShowMsg("Select a record to delete.", "Error"); enable_crud_buttons(); CodingSourceClass.disable_reset(left_panel); } } catch (Exception ex) { CodingSourceClass.ShowMsg(ex.Message, "Error"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); } }
public override void delete_button_Click(object sender, EventArgs e) { try { if (true) { Hashtable ht = new Hashtable(); DialogResult dr = MessageBox.Show("Are you sure? ", "Question.....", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { ht.Add("@payid", paymentID); if (SQL_TASKS.insert_update_delete("st_deletePAYMENTS", ht) > 0) { CodingSourceClass.ShowMsg("Record deleted successfully from the system.", "Success"); enable_crud_buttons(); CodingSourceClass.disable_reset(left_panel); LoadPayments(); } else { CodingSourceClass.ShowMsg("Unable to delete.An error occured.", "Error"); enable_crud_buttons(); CodingSourceClass.disable_reset(left_panel); } } } else { throw new Exception("Select a record to delete."); } } catch (Exception ex) { CodingSourceClass.ShowMsg(ex.Message, "Error"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); } }
public override void delete_button_Click(object sender, EventArgs e) { try { if (name_textBox.Text != "" && phone_textBox.Text != "" && address_textBox.Text != "" && password_textBox.Text != "" && username_textBox.Text != "" && roles_comboBox.SelectedIndex != -1) { Hashtable ht = new Hashtable(); DialogResult dr = MessageBox.Show("Are you sure? ", "Question.....", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { ht.Add("@id", userID); if (SQL_TASKS.insert_update_delete("st_deleteUSERS", ht) > 0) { CodingSourceClass.ShowMsg("Record deleted successfully from the system.", "Success"); enable_crud_buttons(); CodingSourceClass.disable_reset(left_panel); LoadUsers(); } else { CodingSourceClass.ShowMsg("Unable to delete.An error occured.", "Error"); enable_crud_buttons(); CodingSourceClass.disable_reset(left_panel); } } } else { throw new Exception("Select a record to delete."); } } catch (Exception ex) { CodingSourceClass.ShowMsg(ex.Message, "Error"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); } }
public override void delete_button_Click(object sender, EventArgs e) { try { if (shops_comboBox_sales_invoice.SelectedIndex == -1 || order_details_textBox.Text == "" || amount_textBox_sales_invoice.Text == "") { throw new Exception("Please enter/select a record."); } else { DialogResult dr = MessageBox.Show("SaleInvoice " + bill_no_textBox_salesinvoice.Text + "is associated with Payments,Sales Return and Vendor/Owner Ledger.\nDeleting this invoice will delete the particular data related to that invoice from Payments,Sales Return and Vendor/Owner Ledger.\nAlso particular data of Customer Leder which is associated with Payments will be deleted.\nWe recommend you to not delete this.\nAre you sure you want to delete?", "!!!WARNING!!!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (DialogResult.Yes == dr) { Hashtable ht = new Hashtable(); ht.Add("@salesinvoiceID", salesinvoiceID); if (SQL_TASKS.insert_update_delete("st_deleteSALESINVOICE", ht) > 0) { CodingSourceClass.ShowMsg("Record deleted successfully.", "Success"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); LoadSalesInvoice(); } else { throw new Exception("Unabled to delete record."); } } } } catch (Exception ex) { CodingSourceClass.ShowMsg(ex.Message, "Error"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); } }
public override void delete_button_Click(object sender, EventArgs e) { try { if (shop_name_textBox.Text != "" || vendors_comboBox_shops.SelectedIndex != -1 || shop_branch_address_textBox.Text != "" || managers_comboBox_shops.SelectedIndex != -1) { Hashtable ht = new Hashtable(); DialogResult dr = MessageBox.Show("Are you sure? ", "Question.....", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { ht.Add("@id", shopID); if (SQL_TASKS.insert_update_delete("st_deleteSHOPS", ht) > 0) { CodingSourceClass.ShowMsg("Record deleted successfully from the system.", "Success"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); LoadShops(); } } } else { throw new Exception("Select a record to delete."); } } catch (Exception ex) { CodingSourceClass.ShowMsg(ex.Message, "Error"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); } }
public override void save_button_Click(object sender, EventArgs e) { try { if (shop_comboBox_payments.SelectedIndex == -1 || customer_comboBox_payments.SelectedIndex == -1 || sales_invoice_comboBox_payments.SelectedIndex == -1 || total_amount_textBox_payments.Text == "" || amount_paid_textBox_payments.Text == "" || remaining_amount_textBox_payments.Text == "" || amount_to_pay_textBox_payments.Text == "" || (cash_radioButton_sales_invoice.Checked == false && cheque_radioButton.Checked == false)) { throw new Exception("Please enter/select a record."); } else if ((shop_comboBox_payments.SelectedIndex != -1 && customer_comboBox_payments.SelectedIndex != -1 && sales_invoice_comboBox_payments.SelectedIndex != -1 && total_amount_textBox_payments.Text != "" && amount_paid_textBox_payments.Text != "" && remaining_amount_textBox_payments.Text != "" && amount_to_pay_textBox_payments.Text != "" && cheque_radioButton.Checked == true) && (clearing_date_dateTimePicker.Text == "" || bank_and_branch_textBox.Text == "" || cheque_no_textBox.Text == "")) { throw new Exception("Please enter/select a record."); } else { if (Convert.ToDouble(amount_to_pay_textBox_payments.Text) > Convert.ToDouble(total_amount_textBox_payments.Text)) { throw new Exception("Amount to pay cannot be greater than total amount."); } else { double debit = 0, credit = 0, bal = 0; using (TransactionScope sc = new TransactionScope()) { Hashtable ht = new Hashtable(); if (cash_radioButton_sales_invoice.Checked == true) { ht.Add("@salesinvoiceid", Convert.ToInt32(sales_invoice_comboBox_payments.SelectedValue.ToString())); ht.Add("@amount", Convert.ToInt32(amount_to_pay_textBox_payments.Text)); ht.Add("@date", dateTimePicker_payments.Value); if (LoginCodeClass.isAdmin) { throw new Exception("Admin cannot enter payments."); } else { ht.Add("@userID", LoginCodeClass.USERID); } SQL_TASKS.insert_update_delete("st_insertPAYMENTSwrtCASH", ht); } else { ht.Add("@salesinvoiceid", Convert.ToInt32(sales_invoice_comboBox_payments.SelectedValue.ToString())); ht.Add("@amount", Convert.ToInt32(amount_to_pay_textBox_payments.Text)); ht.Add("@date", dateTimePicker_payments.Value); if (LoginCodeClass.isAdmin) { ht.Add("@userID", LoginCodeClass.idOFadmin); } else { ht.Add("@userID", LoginCodeClass.USERID); } ht.Add("@cheque", cheque_no_textBox.Text); ht.Add("@bank", bank_and_branch_textBox.Text); ht.Add("@clearing", clearing_date_dateTimePicker.Value); SQL_TASKS.insert_update_delete("st_insertPAYMENTSwrtCHEQUE", ht); } Hashtable loadht = new Hashtable(); loadht.Add("@custID", Convert.ToInt32(customer_comboBox_payments.SelectedValue.ToString())); loadht.Add("@shopID", Convert.ToInt32(shop_comboBox_payments.SelectedValue.ToString())); double[] dd = SQL_TASKS.LoadLastBalance("st_getLASTBALANCES", loadht); bal = dd[0]; //customer balance debit = 0; credit = Convert.ToDouble(amount_to_pay_textBox_payments.Text); bal += debit - credit; Hashtable ht2 = new Hashtable(); Int64 salesinvoiceID = Convert.ToInt64(sales_invoice_comboBox_payments.SelectedValue.ToString()); DataRowView drvcustomer = customer_comboBox_payments.SelectedItem as DataRowView; DataRowView drvshop = shop_comboBox_payments.SelectedItem as DataRowView; DataRowView drvsalesinvoice = sales_invoice_comboBox_payments.SelectedItem as DataRowView; ht2.Add("@custID", Convert.ToInt32(customer_comboBox_payments.SelectedValue.ToString())); ht2.Add("@desc", drvcustomer[1].ToString() + " has done the payment of Rs. " + amount_to_pay_textBox_payments.Text + " on bill # " + drvsalesinvoice[1].ToString() + " to " + drvshop[1].ToString()); ht2.Add("@debit", debit); ht2.Add("@credit", credit); ht2.Add("@balance", bal); ht2.Add("@date", dateTimePicker_payments.Value); ht2.Add("@salesinvoiceid", salesinvoiceID); SQL_TASKS.insert_update_delete("st_insertCUSTOMERLEDGER", ht2); bal = dd[1]; //shop balance debit = Convert.ToDouble(amount_to_pay_textBox_payments.Text); credit = 0; bal += debit - credit; Hashtable ht3 = new Hashtable(); ht3.Add("@shopID", Convert.ToInt32(shop_comboBox_payments.SelectedValue.ToString())); ht3.Add("@desc", drvshop[1].ToString() + " has received Rs. " + amount_to_pay_textBox_payments.Text + " as paid from customer " + drvcustomer[1].ToString() + " on bill # " + drvsalesinvoice[1].ToString()); ht3.Add("@debit", debit); ht3.Add("@credit", credit); ht3.Add("@balance", bal); ht3.Add("@date", dateTimePicker_payments.Value); ht3.Add("@salesinvoiceid", salesinvoiceID); SQL_TASKS.insert_update_delete("insertVENDORLEDGER", ht3); Hashtable ht4 = new Hashtable(); if (Convert.ToDouble(amount_to_pay_textBox_payments.Text) == Convert.ToDouble(total_amount_textBox_payments.Text)) { //complete payment ht4.Add("@status", 2); } else if (Convert.ToDouble(amount_to_pay_textBox_payments.Text) < Convert.ToDouble(total_amount_textBox_payments.Text)) { //partial payment ht4.Add("@status", 1); } /*else //if status == 2 * { * ht4.Add("@status", 0); * }*/ ht4.Add("@salesinvoiceid", salesinvoiceID); CodingSourceClass.ShowMsg("Record added successfully into the system.", "Success"); CodingSourceClass.disable_reset(left_panel); LoadPayments(); sc.Complete(); } } } } catch (Exception ex) { CodingSourceClass.ShowMsg(ex.Message, "Error"); } }
public override void save_button_Click(object sender, EventArgs e) { if (roles_textBox.Text == "") { CodingSourceClass.ShowMsg("Please enter/select a role.", "Error"); enable_crud_buttons(); CodingSourceClass.disable_reset(left_panel); } else { if (edit == false) //code for save { Hashtable ht = new Hashtable(); ht.Add("@name", roles_textBox.Text); if (SQL_TASKS.insert_update_delete("st_insertROLES", ht) > 0) { CodingSourceClass.ShowMsg(roles_textBox.Text + " added successfully to the system.", "Success"); LoadRoles(); enable_crud_buttons(); CodingSourceClass.disable_reset(left_panel); SQL_TASKS.TotalRecords("getTOTALROLES", total_roles_label); } else { CodingSourceClass.ShowMsg("Unable to save record.", "Error"); enable_crud_buttons(); CodingSourceClass.disable_reset(left_panel); } } else if (edit == true) //code for update { Hashtable ht = new Hashtable(); ht.Add("@name", roles_textBox.Text); ht.Add("@id", roleID); if (SQL_TASKS.insert_update_delete("st_updateROLES", ht) > 0) { CodingSourceClass.ShowMsg(roles_textBox.Text + " updated successfully.", "Success"); LoadRoles(); enable_crud_buttons(); CodingSourceClass.disable_reset(left_panel); } else { CodingSourceClass.ShowMsg("Unable to update record.", "Error"); enable_crud_buttons(); CodingSourceClass.disable_reset(left_panel); } } } }
public override void save_button_Click(object sender, EventArgs e) { try { if (shop_comboBox_salesreturn.SelectedIndex == -1 || customer_comboBox_salesreturn.SelectedIndex == -1 || sales_invoice_comboBox_salesreturn.SelectedIndex == -1 || total_amount_textBox_salesreturn.Text == "" || amount_paid_textBox_salesreturn.Text == "" || remaining_amount_textBox_salesreturn.Text == "" || amount_to_return_textBox_salesreturn.Text == "" || dateTimePicker_salesreturn.Text == "") { throw new Exception("Please enter/select a record."); } else { double debit = 0, credit = 0, bal = 0; using (TransactionScope sc = new TransactionScope()) { Hashtable ht = new Hashtable(); ht.Add("@salesinvoiceID", Convert.ToInt32(sales_invoice_comboBox_salesreturn.SelectedValue.ToString())); ht.Add("@amount", Convert.ToInt32(amount_to_return_textBox_salesreturn.Text)); ht.Add("@date", dateTimePicker_salesreturn.Value); if (LoginCodeClass.isAdmin) { throw new Exception("Admin cannot perfom current task."); } else { ht.Add("@userID", LoginCodeClass.USERID); } if (SQL_TASKS.insert_update_delete("st_insertSALESRETURN", ht) > 0) { Hashtable loadht = new Hashtable(); loadht.Add("@custID", Convert.ToInt32(customer_comboBox_salesreturn.SelectedValue.ToString())); loadht.Add("@shopID", Convert.ToInt32(shop_comboBox_salesreturn.SelectedValue.ToString())); double[] dd = SQL_TASKS.LoadLastBalance("st_getLASTBALANCES", loadht); bal = dd[0]; //customer balance debit = 0; credit = Convert.ToDouble(amount_to_return_textBox_salesreturn.Text); bal += debit - credit; Hashtable ht2 = new Hashtable(); Int64 salesinvoiceID = Convert.ToInt64(sales_invoice_comboBox_salesreturn.SelectedValue.ToString()); DataRowView drvcustomer = customer_comboBox_salesreturn.SelectedItem as DataRowView; DataRowView drvshop = shop_comboBox_salesreturn.SelectedItem as DataRowView; DataRowView drvsalesinvoice = sales_invoice_comboBox_salesreturn.SelectedItem as DataRowView; ht2.Add("@custID", Convert.ToInt32(customer_comboBox_salesreturn.SelectedValue.ToString())); ht2.Add("@desc", drvcustomer[1].ToString() + " has return the goods worth Rs. " + amount_to_return_textBox_salesreturn.Text + " on bill # " + drvsalesinvoice[1].ToString() + " to " + drvshop[1].ToString() + " shop "); ht2.Add("@debit", debit); ht2.Add("@credit", credit); ht2.Add("@balance", bal); ht2.Add("@date", dateTimePicker_salesreturn.Value); ht2.Add("@salesinvoiceid", salesinvoiceID); SQL_TASKS.insert_update_delete("st_insertCUSTOMERLEDGER", ht2); bal = dd[1]; //shop balance debit = Convert.ToDouble(amount_to_return_textBox_salesreturn.Text); credit = 0; bal += debit - credit; Hashtable ht3 = new Hashtable(); ht3.Add("@shopID", Convert.ToInt32(shop_comboBox_salesreturn.SelectedValue.ToString())); ht3.Add("@desc", drvshop[1].ToString() + " has received Rs. " + amount_to_return_textBox_salesreturn.Text + " as returned from customer " + drvcustomer[1].ToString() + " on bill # " + drvsalesinvoice[1].ToString()); ht3.Add("@debit", debit); ht3.Add("@credit", credit); ht3.Add("@balance", bal); ht3.Add("@date", dateTimePicker_salesreturn.Value); ht3.Add("@salesinvoiceid", salesinvoiceID); SQL_TASKS.insert_update_delete("insertVENDORLEDGER", ht3); CodingSourceClass.ShowMsg("Record added successfully into the system.", "Success"); CodingSourceClass.disable_reset(left_panel); LoadSalesReturn(); sc.Complete(); } else { throw new Exception("Unable to save record."); } } } } catch (Exception ex) { CodingSourceClass.ShowMsg(ex.Message, "Error"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); } }
public override void save_button_Click(object sender, EventArgs e) { try { if (shop_name_textBox.Text == "" || vendors_comboBox_shops.SelectedIndex == -1 || shop_branch_address_textBox.Text == "" || managers_comboBox_shops.SelectedIndex == -1) { throw new Exception("Please enter/select a record."); } else { if (edit == false) //code for save { Hashtable ht = new Hashtable(); ht.Add("@name", shop_name_textBox.Text); ht.Add("@shopvendorID", Convert.ToInt32(vendors_comboBox_shops.SelectedValue.ToString())); ht.Add("@branchaddress", shop_branch_address_textBox.Text); ht.Add("@managerID", Convert.ToInt32(managers_comboBox_shops.SelectedValue.ToString())); if (SQL_TASKS.insert_update_delete("st_insertSHOPS", ht) > 0) { CodingSourceClass.ShowMsg(shop_name_textBox.Text + " added successfully into the system.", "Success"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); LoadShops(); } else { throw new Exception("Unable to save record."); } } else if (edit == true) //code for update { Hashtable ht = new Hashtable(); ht.Add("@name", shop_name_textBox.Text); ht.Add("@shopvendorID", Convert.ToInt32(vendors_comboBox_shops.SelectedValue.ToString())); ht.Add("@branchaddress", shop_branch_address_textBox.Text); ht.Add("@managerID", Convert.ToInt32(managers_comboBox_shops.SelectedValue.ToString())); ht.Add("@shopID", shopID); if (SQL_TASKS.insert_update_delete("st_updateSHOPS", ht) > 0) { CodingSourceClass.ShowMsg(shop_name_textBox.Text + " updated successfully.", "Success"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); LoadShops(); } else { throw new Exception("Unable to update record."); } } } } catch (Exception ex) { CodingSourceClass.ShowMsg(ex.Message, "Error"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); } }
public override void save_button_Click(object sender, EventArgs e) { try { if (vendor_name_textBox.Text == "" || vendor_phone_textBox.Text == "" || vendor_address_textBox.Text == "") { throw new Exception("Please enter/select a record."); } else { if (edit == false) //code for save { Hashtable ht = new Hashtable(); ht.Add("@name", vendor_name_textBox.Text); ht.Add("@phone", vendor_phone_textBox.Text); ht.Add("@address", vendor_address_textBox.Text); if (SQL_TASKS.insert_update_delete("st_insertVENDORS", ht) > 0) { CodingSourceClass.ShowMsg(vendor_name_textBox.Text + " added successfully into the system.", "Success"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); LoadVendors(); } else { throw new Exception("Unable to save record."); } } else if (edit == true) //code for update { Hashtable ht = new Hashtable(); ht.Add("@name", vendor_name_textBox.Text); ht.Add("@phone", vendor_phone_textBox.Text); ht.Add("@address", vendor_address_textBox.Text); ht.Add("@id", vendorID); if (SQL_TASKS.insert_update_delete("st_updateVENDORS", ht) > 0) { CodingSourceClass.ShowMsg("Record updated successfully.", "Success"); CodingSourceClass.disable_reset(left_panel); LoadVendors(); } else { throw new Exception("Unable to update."); } } } } catch (Exception ex) { CodingSourceClass.ShowMsg(ex.Message, "Error"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); LoadVendors(); } }
public override void save_button_Click(object sender, EventArgs e) { try { if (shops_comboBox_customers.SelectedIndex == -1) { throw new Exception("Please enter/select a record."); } else { if (edit == false) //code for save { Hashtable ht = new Hashtable(); ht.Add("@name", customer_name_textBox.Text); ht.Add("@phone", phone_textBox_customers.Text); ht.Add("@shopID", Convert.ToInt32(shops_comboBox_customers.SelectedValue.ToString())); ht.Add("@email", email_textBox_customers.Text); if (SQL_TASKS.insert_update_delete("st_insertCUSTOMERS", ht) > 0) { CodingSourceClass.ShowMsg(customer_name_textBox.Text + " added successfully to the system.", "Success"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); LoadCustomers(); } else { throw new Exception("Unable to save record."); } } else if (edit == true) //code for update { Hashtable ht = new Hashtable(); ht.Add("@name", customer_name_textBox.Text); ht.Add("@phone", phone_textBox_customers.Text); ht.Add("@shopID", Convert.ToInt32(shops_comboBox_customers.SelectedValue.ToString())); ht.Add("@email", email_textBox_customers.Text); ht.Add("@id", customerID); if (SQL_TASKS.insert_update_delete("st_updateCUSTOMERS", ht) > 0) { CodingSourceClass.ShowMsg("Record updated successfully into the system.", "Success"); CodingSourceClass.disable_reset(left_panel); LoadCustomers(); } else { throw new Exception("Unable to update."); } } } } catch (Exception ex) { CodingSourceClass.ShowMsg(ex.Message, "Error"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); } }
private void save_new_details_button_Click(object sender, EventArgs e) { try { if (new_password_textBox.Text == "") { throw new Exception("Password cannot be blank."); } else { SqlCommand sqlcmd = new SqlCommand(); if (admin_radioButton.Checked) //insert new password of admin { Hashtable ht = new Hashtable(); ht.Add("@username", current_username_textBox.Text); ht.Add("@password", new_password_textBox.Text); if (SQL_TASKS.insert_update_delete("st_updateAdminPASSWORD", ht) > 0) { CodingSourceClass.ShowMsg("New Password added successfully.", "Success"); clear(); } else { throw new Exception("An error occured during the process."); } } else if (other_radioButton.Checked && admin_radioButton.Checked == false) { Hashtable ht = new Hashtable(); //insert new password of user ht.Add("@username", current_username_textBox.Text); ht.Add("@password", new_password_textBox.Text); if (SQL_TASKS.insert_update_delete("st_updateUSERPASSWORD", ht) > 0) { CodingSourceClass.ShowMsg("New Password added successfully.", "Success"); clear(); } else { throw new Exception("An error occured during the process."); } } else { throw new Exception("Please select if you are admin or other."); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); sq.Close(); } }
public override void save_button_Click(object sender, EventArgs e) { try { if (name_textBox.Text == "" || phone_textBox.Text == "" || address_textBox.Text == "" || password_textBox.Text == "" || username_textBox.Text == "" || roles_comboBox.SelectedIndex == -1) { throw new Exception("Please enter/select a record."); } else { if (edit == false) //code for save { Hashtable ht = new Hashtable(); ht.Add("@name", name_textBox.Text); ht.Add("@username", username_textBox.Text); ht.Add("@password", password_textBox.Text); ht.Add("@phone", phone_textBox.Text); ht.Add("@address", address_textBox.Text); ht.Add("@roleID", (Convert.ToInt32(roles_comboBox.SelectedValue.ToString()))); if (SQL_TASKS.insert_update_delete("st_insertUSERS", ht) > 0) { CodingSourceClass.ShowMsg(name_textBox.Text + " added successfully to the system.", "Success"); enable_crud_buttons(); CodingSourceClass.disable_reset(left_panel); LoadUsers(); } else { throw new Exception("Unable to save record.An error occured."); } } else if (edit == true) //code for update { Hashtable ht = new Hashtable(); ht.Add("@name", name_textBox.Text); ht.Add("@username", username_textBox.Text); ht.Add("@password", password_textBox.Text); ht.Add("@phone", address_textBox.Text); ht.Add("@address", phone_textBox.Text); ht.Add("@roleID", Convert.ToInt32(roles_comboBox.SelectedValue.ToString())); ht.Add("@id", userID); if (SQL_TASKS.insert_update_delete("st_updateUSERS", ht) > 0) { CodingSourceClass.ShowMsg("Record updated successfully into the system.", "Success"); enable_crud_buttons(); CodingSourceClass.disable_reset(left_panel); LoadUsers(); } else { throw new Exception("Unable to update.An error occured"); } } } } catch (Exception ex) { CodingSourceClass.ShowMsg(ex.Message, "Error"); enable_crud_buttons(); CodingSourceClass.disable_reset(left_panel); } }
public override void save_button_Click(object sender, EventArgs e) { try { if (shops_comboBox_sales_invoice.SelectedIndex == -1 || customers_comboBox_sales_invoice.SelectedIndex == -1 || order_details_textBox.Text == "" || dateTimePicker_sales_invoice.Text == "" || amount_textBox_sales_invoice.Text == "" || (cash_radioButton_sales_invoice.Checked == false && credit_card_radioButton_sales_invoice.Checked == false)) { throw new Exception("Please enter/select a record."); } else { //0 is for crash and 1 is for debit Int16?type = cash_radioButton_sales_invoice.Checked ? Convert.ToInt16(0) : Convert.ToInt16(1); if (type != null) { double debit = 0, credit = 0, bal = 0; if (edit == false) //code for save { using (TransactionScope sc = new TransactionScope()) { Hashtable ht = new Hashtable(); ht.Add("@shopID", Convert.ToInt32(shops_comboBox_sales_invoice.SelectedValue.ToString())); ht.Add("@customerID", Convert.ToInt32(customers_comboBox_sales_invoice.SelectedValue.ToString())); ht.Add("@details", order_details_textBox.Text); ht.Add("@amount", amount_textBox_sales_invoice.Text); ht.Add("@type", type); if (LoginCodeClass.isAdmin) { throw new Exception("Admin cannot make salesinvoice."); } else { ht.Add("@userID", LoginCodeClass.USERID); } ht.Add("@billno", bill_no_textBox_salesinvoice.Text); ht.Add("@status", 0); //0 = not paid, 1 = partially paid, 2 = completely paid if (SQL_TASKS.insert_update_delete("st_insertSALESINVOICE", ht) > 0) { Hashtable loadht = new Hashtable(); loadht.Add("@custID", Convert.ToInt32(customers_comboBox_sales_invoice.SelectedValue.ToString())); loadht.Add("@shopID", Convert.ToInt32(shops_comboBox_sales_invoice.SelectedValue.ToString())); double[] dd = SQL_TASKS.LoadLastBalance("st_getLASTBALANCES", loadht); bal = dd[0]; //customer balance debit = Convert.ToDouble(amount_textBox_sales_invoice.Text); credit = 0; bal += debit - credit; Hashtable ht2 = new Hashtable(); ht2.Add("@custID", Convert.ToInt32(customers_comboBox_sales_invoice.SelectedValue.ToString())); ht2.Add("@desc", order_details_textBox.Text); ht2.Add("@debit", debit); ht2.Add("@credit", credit); ht2.Add("@balance", bal); ht2.Add("@date", dateTimePicker_sales_invoice.Value); ht2.Add("@salesinvoiceid", salesinvoiceID); SQL_TASKS.insert_update_delete("st_insertCUSTOMERLEDGER", ht2); bal = dd[1]; //shop balance debit = 0; credit = Convert.ToDouble(amount_textBox_sales_invoice.Text); bal += debit - credit; Hashtable ht3 = new Hashtable(); ht3.Add("@shopID", Convert.ToInt32(shops_comboBox_sales_invoice.SelectedValue.ToString())); ht3.Add("@desc", order_details_textBox.Text); ht3.Add("@debit", debit); ht3.Add("@credit", credit); ht3.Add("@balance", bal); ht3.Add("@date", dateTimePicker_sales_invoice.Value); ht3.Add("@salesinvoiceid", salesinvoiceID); SQL_TASKS.insert_update_delete("insertVENDORLEDGER", ht3); CodingSourceClass.ShowMsg("Record added successfully into the system.", "Success"); CodingSourceClass.disable_reset(left_panel); LoadSalesInvoice(); sc.Complete(); } else { throw new Exception("Unable to save record."); } } } } else { throw new Exception("Please fill all fields."); } } } catch (Exception ex) { CodingSourceClass.ShowMsg(ex.Message, "Error"); CodingSourceClass.disable_reset(left_panel); enable_crud_buttons(); } }