Exemple #1
0
 public override void deleteBtn_Click(object sender, EventArgs e)
 {
     if (edit == 1)
     {
         DialogResult dr = MessageBox.Show("Are you sure you want to delete " + roleTxt.Text + "?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             obj.st_deleteRoles(roleID);
             MainClass.showMSG(roleTxt.Text + " deleted successfully,", "Success", "Success");
             MainClass.disable_reset(panel6);
             loadData();
         }
     }
 }
Exemple #2
0
        public override void saveBtn_Click(object sender, EventArgs e)
        {
            if (roleTxt.Text == "")
            {
                roleErrorLabel.Visible = true;
            }
            else
            {
                roleErrorLabel.Visible = false;
            }
            if (roleDropDown.SelectedIndex == -1)
            {
                statusErrorLabel.Visible = true;
            }
            else
            {
                statusErrorLabel.Visible = false;
            }
            if (roleErrorLabel.Visible || statusErrorLabel.Visible)
            {
                MainClass.showMSG("Fields with * are madatory", "Stop", "Error");
            }
            else
            {
                if (edit == 0) //Code for SAVE OPERATION
                {
                    role r = new role();
                    r.r_name = roleTxt.Text;
                    if (roleDropDown.SelectedIndex == 0)
                    {
                        r.r_status = 1;
                    }
                    else
                    {
                        r.r_status = 0;
                    }
                    //obj.roles.InsertOnSubmit(r);
                    obj.st_insertRoles(roleTxt.Text, r.r_status);
                    obj.SubmitChanges();
                    MainClass.showMSG(roleTxt.Text + " added successfully,", "Success", "Success");
                    MainClass.disable_reset(panel6);
                    loadData();
                }
                else if (edit == 1)  //Code for UPDATE operation
                {
                    byte stat;
                    if (roleDropDown.SelectedIndex == 0)
                    {
                        stat = 1;
                    }
                    else
                    {
                        stat = 0;
                    }
                    obj.st_updateRoles(roleTxt.Text, stat, roleID);

                    /* var data = obj.roles.Single(x => x.r_id == roleID);
                     * data.r_name = roleTxt.Text;
                     * if (roleDropDown.SelectedIndex == 0)
                     * {
                     *   data.r_status = 1;
                     * }
                     * else
                     * {
                     *   data.r_status = 0;
                     * }
                     * obj.SubmitChanges(); */
                    MainClass.showMSG(roleTxt.Text + " updated successfully,", "Success", "Success");
                    MainClass.disable_reset(panel6);
                    loadData();
                }
            }
        }
Exemple #3
0
 private void Roles_Load(object sender, EventArgs e)
 {
     MainClass.disable_reset(panel6);
 }