private void btnRoiKhoiNhom_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //xóa khoi db
            if (gvNhomNV.GetFocusedRowCellValue("ID") == null)
            {
                Thongbao.Hoi("Mời bạn chọn hàng nhóm nhân viên");
            }
            else
            {
                if (gvNV.GetFocusedRowCellValue("ID") == null)
                {
                    Thongbao.Hoi("Mời bạn chọn hàng nhân viên");
                    return;
                }
                int ID_Nhom = (int)gvNhomNV.GetFocusedRowCellValue("ID");
                int ID_NV   = (int)gvNV.GetFocusedRowCellValue("ID");

                var delete = (from a in db.pqNhomNhanViens where a.GroupID == ID_Nhom && a.MaNV == ID_NV select a).Single();
                db.pqNhomNhanViens.DeleteOnSubmit(delete);
                try { db.SubmitChanges(); }
                catch (Exception)
                {
                    MessageBox.Show("Rời khỏi nhóm không thành công, vui lòng kiểm tra lại.");
                }
                loadNVTrongNhom(ID_Nhom);
            }
        }
Beispiel #2
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");
             }
         }
     }
 }
        private void btnThemVaoNhom_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (gvNhomNV.GetFocusedRowCellValue("ID") == null)
            {
                Thongbao.Hoi("Mời bạn chọn hàng nhóm nhân viên");
                return;
            }
            if (gvNV.GetFocusedRowCellValue("ID") == null)
            {
                Thongbao.Hoi("Mời bạn chọn hàng nhân viên");
                return;
            }
            int ID_Nhom = (int)gvNhomNV.GetFocusedRowCellValue("ID");
            int ID_NV   = (int)gvNV.GetFocusedRowCellValue("ID");

            if ((from a in db.pqNhomNhanViens where a.GroupID == ID_Nhom && a.MaNV == ID_NV select a).Count() == 0)
            {
                pqNhomNhanVien nv = new pqNhomNhanVien();
                nv.GroupID = ID_Nhom;
                nv.MaNV    = ID_NV;
                db.pqNhomNhanViens.InsertOnSubmit(nv);
                try
                {
                    db.SubmitChanges();
                }
                catch (Exception)
                {
                    MessageBox.Show("LỖI DATABASE");
                }
                loadNVTrongNhom(ID_Nhom);
            }
        }
 private void btnHuyKichHoat_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (gvMain.GetFocusedRowCellValue("ID") == null)
     {
         Thongbao.Hoi("Mời bạn chọn hàng cần hủy kích hoạt.");
     }
     else
     {
         int          id_tmp = (int)gvMain.GetFocusedRowCellValue("ID");
         DialogResult f      = Thongbao._CauHoi("Có chắc chắn hủy kích hoạt tài khoản");
         if (f == System.Windows.Forms.DialogResult.Yes)
         {
             var delete = (from a in db.NhanViens where a.ID == (int)id_tmp select a).Single();
             delete.IsLock = true;
             try
             {
                 db.SubmitChanges();
             }
             catch (Exception)
             {
                 MessageBox.Show("LỖI DATABASE");
             }
             loadNV();
         }
     }
 }
 private bool kiemtragiong()
 {
     if (txtPassNew1.Text == txtPassNew2.Text)
     {
         return(true);
     }
     Thongbao.Hoi("Mật khẩu mới không giống nhau.");
     return(false);
 }
        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 btnXoa_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (gvNhomNV.GetFocusedRowCellValue("ID") == null)
     {
         Thongbao.Hoi("Mời bạn chọn hàng cần xóa.");
     }
     else
     {
         int          id_tmp = (int)gvNhomNV.GetFocusedRowCellValue("ID");
         DialogResult f      = Thongbao._CauHoi();
         if (f == System.Windows.Forms.DialogResult.Yes)
         {
             var delete = (from a in db.pqForms where a.ID == (int)id_tmp select a).Single();
             db.pqForms.DeleteOnSubmit(delete);
             try { db.SubmitChanges(); }
             catch (Exception) { MessageBox.Show("Xóa không thành công, vui lòng kiểm tra lại."); }
             loadNhomNV();
         }
     }
 }