Exemple #1
0
        private void btn_user_delete_Click(object sender, EventArgs e)
        {
            int          id           = Convert.ToInt32(dgv_users.Rows[dgv_users.CurrentRow.Index].Cells[0].Value);
            DialogResult dialogResult = MessageBox.Show("Are you sure to delete this user?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dialogResult == DialogResult.Yes)
            {
                AddUser_Bus.deleteUser(id);
                getAllUsers();
            }
        }
Exemple #2
0
 private void btn_add_user_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(txt_name.Text))
     {
         MessageBox.Show("Name field is required");
         txt_name.Focus();
     }
     else if (String.IsNullOrEmpty(txt_username.Text))
     {
         MessageBox.Show("Username field is required");
         txt_username.Focus();
     }
     else if (String.IsNullOrEmpty(txt_password.Text))
     {
         MessageBox.Show("Password field is required");
         txt_password.Focus();
     }
     else if (String.IsNullOrEmpty(txt_cpassword.Text))
     {
         MessageBox.Show("Confirm Password field is required");
         txt_cpassword.Focus();
     }
     else if (String.IsNullOrEmpty(combo_role.Text))
     {
         MessageBox.Show("Role field is required");
         combo_role.Focus();
     }
     else if (!txt_phone.MaskCompleted)
     {
         MessageBox.Show("Phone field is required");
         txt_phone.Focus();
     }
     else
     {
         if (txt_password.Text == txt_cpassword.Text)
         {
             AddUser_Model add_user = new AddUser_Model()
             {
                 name     = txt_name.Text,
                 username = txt_username.Text,
                 password = txt_password.Text,
                 phone    = txt_phone.Text,
                 role     = combo_role.Text,
             };
             bool user_added = AddUser_Bus.addUser(add_user);
             if (user_added)
             {
                 ResetAllControls(this);
                 MessageBox.Show("New User added.");
                 this.Close();
             }
             else
             {
                 MessageBox.Show("This Username already exist.");
             }
         }
         else
         {
             MessageBox.Show("Your password does not match with confirm password");
         }
     }
 }