public override void deleteBtn_Click(object sender, EventArgs e) { if (edit == 1) { DialogResult dr = MessageBox.Show("Are you sure you want to delete " + rolesText.Text + "?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { obj.sr_deleteRoles(roleID); MainClass.showMSG(rolesText.Text + " Deleted successfully", "Success..", "Success"); MainClass.disable_reset(panel6); loaddata(); } } }
public override void saveBtn_Click(object sender, EventArgs e) { if (rolesText.Text == "") { rolesErrorLabel.Visible = true; } else { rolesErrorLabel.Visible = false; } if (statusDropdown.SelectedIndex == -1) { statusErrorLabel.Visible = true; } else { statusErrorLabel.Visible = false; } if (rolesErrorLabel.Visible || statusErrorLabel.Visible) { MainClass.showMSG("Fields with * are mandatory.", "Error", "Error"); } else { if (edit == 0) //code for save { role r = new role(); r.r_name = rolesText.Text; if (statusDropdown.SelectedIndex == 0) { r.r_status = 1; } else { r.r_status = 0; } //obj.roles.InsertOnSubmit(r); obj.st_InsertRoles(rolesText.Text, r.r_status); obj.SubmitChanges(); MainClass.showMSG(rolesText.Text + " added successfully", "Success.", "Success"); MainClass.disable_reset(panel6); loaddata(); } else if (edit == 1) //code for update { byte stat; if (statusDropdown.SelectedIndex == 0) { stat = 1; } else { stat = 0; } obj.st_UpdateRoles(rolesText.Text, stat, roleID); //var data = obj.roles.Single(x => x.r_id == roleID); // db roleId = DG // data.r_name = rolesText.Text; // if (statusDropdown.SelectedIndex == 0) // { // data.r_status = 1; // } // else // { // data.r_status = 0; // } // obj.SubmitChanges(); MainClass.showMSG(rolesText.Text + " update successfully", "Success..", "Success"); MainClass.disable_reset(panel6); loaddata(); } } }
private void Roles_Load(object sender, EventArgs e) { MainClass.disable_reset(panel6); }