Пример #1
0
        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);
            }
        }
Пример #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");
             }
         }
     }
 }
Пример #3
0
        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);
            }
        }
 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();
         }
     }
 }
Пример #5
0
        public static bool TestConnection(string chuoiketnoi)
        {
            var canConnect = false;

            var connectionString = chuoiketnoi;

            var connection = new OleDbConnection(connectionString);

            try
            {
                using (connection)
                {
                    connection.Open();

                    canConnect = true;
                }
            }
            catch (Exception)
            {
                Thongbao.Loi("Không thể kết nối Cơ sở dữ liệu");
            }
            finally
            {
                connection.Close();
            }

            return(canConnect);
        }
Пример #6
0
        public static bool TestConnection(string serverName, string initialCatalog, string userId, string password, bool integratedSecurity)
        {
            var canConnect = false;

            var connectionString = integratedSecurity ? string.Format("Data Source={0};Initial Catalog={1};Integrated Security=SSPI;", serverName, initialCatalog)
                                                      : string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3};", serverName, initialCatalog, userId, password);

            var connection = new OleDbConnection(connectionString);

            try
            {
                using (connection)
                {
                    connection.Open();

                    canConnect = true;
                }
            }
            catch (Exception)
            {
                Thongbao.Loi("Không thể kết nối Cơ sở dữ liệu");
            }
            finally
            {
                connection.Close();
            }

            return(canConnect);
        }
 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);
 }
Пример #8
0
 private bool CheckDataInput()
 {
     if (txtUser.Text.Trim().Length != 0 && txtPass.Text.Trim().Length != 0)
     {
         return(true);
     }
     Thongbao.Loi("Điền tên đăng nhập và mật khẩu!");
     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 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");
         }
     }
 }
Пример #11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int?ID = (int)lueDiaDiemCf.EditValue;

            if (ID == null)
            {
                return;
            }
            bool kt = Common.setIDPhong((int)ID);

            if (kt)
            {
                HeThong.Thongbao.Canhbao("Cấu hình thành công !");
            }
            else
            {
                Thongbao.Canhbao("Thất bại !");
            }
        }
Пример #12
0
 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();
         }
     }
 }
Пример #13
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            IsAdmin = false;
            if (!CheckDataInput())
            {
                return;
            }
            var wait = Thongbao.Loading();

            try
            {
                NhanVien       objnhanvien = new NhanVien();
                Func.UserLogin ul          = new HeThong.Func.UserLogin();
                objnhanvien = ul.GetUserByMaNV(txtUser.Text.Trim(), txtPass.Text.Trim());
                if (objnhanvien != null)
                {
                    //Kiểm tra tài khoản khóa/kích hoạt
                    if ((bool)objnhanvien.IsLock)
                    {
                        Thongbao.Canhbao("Tài khoản đang bị khóa hoặc chưa kích hoạt, liên hệ quản trị viên...");
                        return;
                    }


                    UsersLogin = objnhanvien;
                    if (ckNho.Checked)
                    {
                        //lưu lại pass and user
                        HeThong.Properties.Settings.Default.Username = txtUser.Text.Trim();
                        HeThong.Properties.Settings.Default.Password = txtPass.Text.Trim();
                    }
                    else
                    {
                        HeThong.Properties.Settings.Default.Username = string.Empty;
                        HeThong.Properties.Settings.Default.Password = string.Empty;
                    }
                    HeThong.Properties.Settings.Default.RememberCheck = ckNho.Checked;
                    HeThong.Properties.Settings.Default.Save();
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    wait.Close();
                    wait.Dispose();
                    Thongbao.Loi("Người dùng hoặc mật khẩu không đúng");
                    return;
                }
            }
            catch {
                wait.Close();
                wait.Dispose();
                Thongbao.Loi("Lỗi kết nối mạng. Vui lòng thử lại sau");
                return;
            }
            finally
            {
                if (!wait.IsDisposed)
                {
                    wait.Close();
                    wait.Dispose();
                }
            }
        }