示例#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 " + 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();
         }
     }
 }
示例#2
0
        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();
                }
            }
        }
示例#3
0
        public override void saveBtn_Click(object sender, EventArgs e)
        {
            if (nametextbox.Text == "")
            {
                namerrorlbl.Visible = true;
            }
            else
            {
                namerrorlbl.Visible = false;
            }
            if (usernametextbox.Text == "")
            {
                usernameerrorlbl.Visible = true;
            }
            else
            {
                usernameerrorlbl.Visible = false;
            }
            if (passwordtextbox.Text == "")
            {
                passworderrorlbl.Visible = true;
            }
            else
            {
                passworderrorlbl.Visible = false;
            }
            if (conpasswordtextbox.Text == "")
            {
                conpasserrorlbl.Visible = true;
            }
            else
            {
                conpasserrorlbl.Visible = false;
            }
            if (passwordtextbox.Text != conpasswordtextbox.Text)
            {
                missmatchlbl.Visible = true;
            }
            else
            {
                missmatchlbl.Visible = false;
            }
            if (phone1textbox.Text == "")
            {
                phone1errorlbl.Visible = true;
            }
            else
            {
                phone1errorlbl.Visible = false;
            }
            if (phone2textbox.Text == "")
            {
                phone2errorlbl.Visible = true;
            }
            else
            {
                phone2errorlbl.Visible = false;
            }
            if (rolecombobox.SelectedIndex == -1)
            {
                roleerrorlbl.Visible = true;
            }
            else
            {
                roleerrorlbl.Visible = false;
            }
            if (statuscombobox.SelectedIndex == -1)
            {
                statuserrorlbl.Visible = true;
            }
            else
            {
                statuserrorlbl.Visible = false;
            }

            if (namerrorlbl.Visible || usernameerrorlbl.Visible || passworderrorlbl.Visible || conpasserrorlbl.Visible || passworderrorlbl.Visible || phone1errorlbl.Visible ||
                phone2errorlbl.Visible || roleerrorlbl.Visible || statuserrorlbl.Visible)
            {
                MainClass.showMSG("Fields with * are mandatory.", "Stop...", "Error");
            }
            else
            {
                if (edit == 0) //code for SAVE operation
                {
                }
                else if (edit == 1) // code for UPDATE operation
                {
                }
            }
        }