Ejemplo n.º 1
0
 private void btnKhoiP_Click(object sender, EventArgs e)
 {
     if (txtPass1.Text != txtPass2.Text)
     {
         Thongbao.Canhbao("Hai mật khẩu điền không giống nhau.");
         return;
     }
     if (gvMain.GetFocusedRowCellValue("ID") == null)
     {
         Thongbao.Hoi("Mời bạn chọn hàng có nhân viên cần khôi phục");
     }
     else
     {
         int          id_tmp = (int)gvMain.GetFocusedRowCellValue("ID");
         DialogResult f      = Thongbao._CauHoi("Bạn có chắc chắn khôi phục!");
         if (f == System.Windows.Forms.DialogResult.Yes)
         {
             HeThong.Func.UserLogin lg = new HeThong.Func.UserLogin();
             var delete = (from a in db.NhanViens where a.ID == (int)id_tmp select a).Single();
             delete.Password = lg.HashPassword(txtPass1.Text);
             try
             {
                 db.SubmitChanges();
                 Thongbao.ThanhCong("Đã thay đổi mật khẩu thành công!");
             }
             catch (Exception)
             {
                 MessageBox.Show("LỖI DATABASE");
             }
         }
     }
 }
Ejemplo n.º 2
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (ID == null)
     {
         HeThong.Func.UserLogin lg = new HeThong.Func.UserLogin();
         if (checkvali_null())
         {
             return;
         }
         obj.MaNV     = txtMaNV.Text;
         obj.TenNV    = txtHVT.Text;
         obj.SDT      = txtSDT.Text;
         obj.IsGV     = true;
         obj.DiaChi   = txtDiaChi.Text;
         obj.GioiTinh = ckNam.Checked;
         obj.Tuoi     = (int)txtTuoi.Value;
         obj.IsLock   = true;
         obj.Password = lg.HashPassword("123456");
         obj.IDKhoa   = (int)lueKhoa.EditValue;
         db.NhanViens.InsertOnSubmit(obj);
         try
         {
             db.SubmitChanges();
             this.DialogResult = System.Windows.Forms.DialogResult.OK;
             this.Close();
         }
         catch (Exception ex)
         {
             HeThong.Thongbao.Loi(ex.ToString());
         }
     }
     else
     {
         obj.MaNV     = txtMaNV.Text;
         obj.TenNV    = txtHVT.Text;
         obj.SDT      = txtSDT.Text;
         obj.IsGV     = true;
         obj.DiaChi   = txtDiaChi.Text;
         obj.GioiTinh = ckNam.Checked;
         obj.Tuoi     = (int)txtTuoi.Value;
         obj.IDKhoa   = (int)lueKhoa.EditValue;
         try
         {
             db.SubmitChanges();
             this.DialogResult = System.Windows.Forms.DialogResult.OK;
             this.Close();
         }
         catch (Exception ex)
         {
             HeThong.Thongbao.Loi(ex.ToString());
         }
     }
 }
        private bool kiemtraMKcu()
        {
            HeThong.Func.UserLogin dt = new HeThong.Func.UserLogin();
            NhanVien ob = HeThong.Common.User;

            if (ob.Password == dt.HashPassword(txtPassOld.Text))
            {
                return(true);
            }
            Thongbao.Hoi("Mật khẩu cũ không chính xác.");
            return(false);
        }
 private void btnDoiMatKhau_Click(object sender, EventArgs e)
 {
     HeThong.Func.UserLogin dtb = new HeThong.Func.UserLogin();
     if (checkPass())
     {
         NhanVien ob = HeThong.Common.User;
         ob.Password = dtb.HashPassword(txtPassNew1.Text);
         if (dtb.ChangePassword(ob))
         {
             Thongbao.ThanhCong("Đổi mật khẩu thành công!");
         }
         else
         {
             Thongbao.Canhbao("Đổi mật khẩu thất bại");
         }
     }
 }