private void UserInformation_Load(object sender, EventArgs e)
        {
            taikhoan    tk         = new taikhoan();
            nhanvien    nv         = new nhanvien();
            AccountDAO1 accountDAO = new AccountDAO1();
            StaffDAO1   staffDAO   = new StaffDAO1();

            tk                  = accountDAO.getAccountLogedin();
            nv                  = staffDAO.getStaffLogedin();
            txtName.Text        = nv.hoten;
            txtCMND.Text        = nv.cnmd;
            txtPhoneNumber.Text = nv.sdt;
            txtPermission.Text  = nv.chucvu;
            current_gender      = (int)nv.gioitinh;
            if (nv.gioitinh == 1)
            {
                cbFemale.Checked = true;
            }
            else
            {
                cbMale.Checked = true;
            }
            txtUsername.Text = tk.tentaikhoan;
            txtBirth.Text    = nv.ngaysinh.ToString();
        }
Example #2
0
 private void iconButton1_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc muốn đổi mật khẩu?", "Thông báo", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
     {
         AccountDAO1 accountDAO1 = new AccountDAO1();
         try
         {
             StaffDAO1 staff = new StaffDAO1();
             taikhoan  tk    = new taikhoan();
             tk.manv        = staff.getIDbyUsername(Program.idLoged);
             tk.tentaikhoan = Program.idLoged;
             tk.matkhau     = Script.MD5Hash(txtPass.Text);
             if (accountDAO1.Edit(tk) == 1)
             {
                 MessageBox.Show("Cập nhập mật khẩu thành công");
                 LoadData();
             }
             else
             {
                 MessageBox.Show("Đổi mật khẩu thất bại");
             }
         }
         catch
         {
             MessageBox.Show("Có lỗi xảy ra!!!");
         }
     }
 }
Example #3
0
 private void iconbtnAccept_Click(object sender, EventArgs e)
 {
     if (txtOldPass.TextLength == 0 || txtConfirmPass.TextLength == 0 || txtNewpass.TextLength == 0)
     {
         MessageBox.Show("Vẫn còn thông tin bị bỏ sót");
     }
     else if (txtNewpass.Text != txtConfirmPass.Text)
     {
         MessageBox.Show("Mật khẩu không khớp với nhau");
     }
     else if (txtNewpass.TextLength < 6)
     {
         MessageBox.Show("Mật khẩu quá ngắn");
     }
     else
     {
         if (MessageBox.Show("Bạn có chắc muốn đổi mật khẩu?", "Thông báo", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
         {
             AccountDAO1 accountDAO1 = new AccountDAO1();
             if (accountDAO1.getAccountLogedin().matkhau != Script.MD5Hash(txtOldPass.Text))
             {
                 MessageBox.Show("mật khẩu cũ không đúng");
             }
             else
             {
                 try
                 {
                     StaffDAO1 staff = new StaffDAO1();
                     taikhoan  tk    = new taikhoan();
                     tk.manv        = staff.getIDbyUsername(Program.idLoged);
                     tk.tentaikhoan = Program.idLoged;
                     tk.matkhau     = Script.MD5Hash(txtNewpass.Text);
                     if (accountDAO1.Edit(tk) == 1)
                     {
                         MessageBox.Show("Thêm thành công");
                     }
                     else
                     {
                         MessageBox.Show("Đổi mật khẩu thất bại");
                     }
                 }
                 catch
                 {
                     MessageBox.Show("Có lỗi xảy ra!!!");
                 }
             }
         }
     }
 }
Example #4
0
        private void iconbtnDelete_Click(object sender, EventArgs e)
        {
            string      username = txtUsername.Text;
            AccountDAO1 account  = new AccountDAO1();

            if (username != Program.idLoged && account.Delete(username) == 1)
            {
                MessageBox.Show("Xóa tài khoản thành công");
                LoadData();
                Clear();
            }
            else
            {
                MessageBox.Show("Xóa tài khoản thất bại");
            }
        }
Example #5
0
        private void iconbtnAdd_Click(object sender, EventArgs e)
        {
            AccountDAO1 accountDAO1 = new AccountDAO1();
            taikhoan    tk          = new taikhoan();

            tk.tentaikhoan = txt_tk.Text;
            tk.matkhau     = Script.MD5Hash(txt_mk.Text);
            tk.manv        = txt_manv.Text;
            if (accountDAO1.create(tk) == 1)
            {
                MessageBox.Show("Thêm thành công");
            }
            else
            {
                MessageBox.Show("Thêm thất bại");
            }
        }
Example #6
0
        private void LoadData()
        {
            AccountDAO1 account = new AccountDAO1();

            dgvListAccount.DataSource = account.listCustom().ToList();
        }