Example #1
0
 private void BtnXoaUser_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult result = MessageBox.Show("Bạn có chắc chắn muốn xóa tài khoản "
                                               + txtUserName.Text.Trim(), "Thông Báo", MessageBoxButtons.YesNo);
         if (DialogResult.Yes == result)
         {
             UsersBus.DeleteUsers(idUpdate);
             // MessageBox.Show("Xóa Thành Công", "Thông Báo");
         }
     }
     catch (Exception)
     {
         MessageBox.Show(" XóaThất Bại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     finally
     {
         btnAddUser.Enabled    = true;
         btnUpdateUser.Enabled = false;
         btnXoaUser.Enabled    = false;
         ClearTextBoxUser();
         LoadDataListViewUser();
     }
 }
        private void Button1_Click(object sender, EventArgs e)
        {
            if (!ValidateTextBox())
            {
                lbThongBao.Text = "Vui Lòng Điền Đầy Đủ";
                return;
            }
            if (txtPassword2.Text.Trim() != txtPassword.Text.Trim())
            {
                lbThongBao.Text = "Mật Khẩu Nhập Lại Sai ";
                return;
            }

            try
            {
                Users user = Login.Account;
                user.Password = txtPassword2.Text;
                UsersBus.UpdateUsers(user);

                lbThongBao.Text = "Thành Công";
            }
            catch (Exception)
            {
                lbThongBao.Text = "Thất Bại";
            }
            finally
            {
                txtPassword2.Text = "";
                txtPassword.Text  = "";
            }
        }
Example #3
0
 public void LoadDataListViewUser()
 {
     listViewUser.Items.Clear();
     foreach (var item in UsersBus.getAllUsers())
     {
         var row = new string[] { item.Id.ToString(), item.Name, item.Username, item.Role };
         var lvi = new ListViewItem(row);
         lvi.Tag = item;
         listViewUser.Items.Add(lvi);
     }
 }
Example #4
0
        private void BtnUpdateUser_Click(object sender, EventArgs e)
        {
            if (!ValidateUsers())
            {
                MessageBox.Show("Vui Lòng Điền Đầy Đủ", "Thông Báo");
                return;
            }
            if (!string.IsNullOrEmpty(UsersBus.GetUsersByUserName(txtUserName.Text.Trim()).Name))
            {
                if (UsersBus.GetUsersByUserName(txtUserName.Text.Trim()).Id != idUpdate)
                {
                    MessageBox.Show("Tên đã tồn tại trong hệ thống", "Thông Báo");
                    return;
                }
            }
            if (!string.IsNullOrEmpty(UsersBus.GetUsersByEmail(txtEmail.Text.Trim()).Email))
            {
                if (UsersBus.GetUsersByEmail(txtEmail.Text.Trim()).Id != idUpdate)
                {
                    MessageBox.Show("Email đã tồn tại trong hệ thống", "Thông Báo");
                    return;
                }
            }

            try
            {
                Users users = new Users();
                users.Name     = txtNameUser.Text.Trim();
                users.Username = txtUserName.Text.Trim();
                users.Password = txtPassword.Text.Trim();
                users.Ghichu   = txtGhiChu.Text.Trim();
                users.Role     = CbRole.SelectedItem.ToString();
                users.Email    = txtEmail.Text.Trim();
                users.Id       = idUpdate;

                UsersBus.UpdateUsers(users);
            }
            catch (Exception)
            {
                MessageBox.Show("Vui Lòng Điền Theo Định Dạng", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                btnUpdateUser.Enabled = false;
                btnXoaUser.Enabled    = false;
                btnAddUser.Enabled    = true;
                LoadDataListViewUser();
                TextBoxClear();
            }
        }
        private void BtnForgetPassword_Click(object sender, EventArgs e)
        {
            if (!ValidateB())
            {
                lbShow.Text = "Vui Lòng Điền Đầy Đủ";
                return;
            }
            Users user = UsersBus.GetUsersByUserNameAndEmail(txtTk.Text.Trim(), txtEmail.Text.Trim());

            if (user == null)
            {
                lbShow.Text = "Sai Thông Tin";
                return;
            }
            lbShow.Text   = "Thành Công";
            lbNameTK.Text = user.Username;
            lbMK.Text     = user.Password;
            lbEmail.Text  = user.Email;
        }
Example #6
0
 private void ListViewUser_SelectedIndexChanged(object sender, EventArgs e)
 {
     btnUpdateUser.Enabled = true;
     btnXoaUser.Enabled    = true;
     btnAddUser.Enabled    = false;
     try
     {
         var   localuser = (Users)listViewUser.SelectedItems[0].Tag;
         Users users     = UsersBus.GetUsersByUserName(localuser.Username);
         txtNameUser.Text = users.Name;
         txtUserName.Text = users.Username;
         txtPassword.Text = users.Password;
         txtGhiChu.Text   = users.Ghichu;
         CbRole.Text      = users.Role;
         txtEmail.Text    = users.Email;
         idUpdate         = users.Id;
     }
     catch (Exception)
     {
         idUpdate = 0;
     }
 }
        private void Button1_Click(object sender, EventArgs e)
        {
            Users users = new Users();

            users.Username = txtUsername.Text.Trim();
            users.Password = txtPassword.Text.Trim();
            if (string.IsNullOrEmpty(txtUsername.Text) || string.IsNullOrEmpty(txtPassword.Text))
            {
                lbThongBao.Text = "Vui Lòng Nhập Đầy Đủ";
                return;
            }
            if (UsersBus.CheckUsers(users))
            {
                Account = UsersBus.GetUsersByUserName(users.Username);
                this.Hide();
                MainAdmin main = new MainAdmin();
                main.Show();
            }
            else
            {
                lbThongBao.Text = "Tài Khoản Hoặc Mật Khẩu Sai";
            }
        }