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 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 btnLuu_Click(object sender, EventArgs e) { if (ID == null) { HeThong.Func.UserLogin lg = new HeThong.Func.UserLogin(); if (checkvali_null()) { return; } obj.MSV = txtMaNV.Text; obj.TenSV = txtHVT.Text; obj.NgaySinh = (DateTime)(txtNgaySinh.EditValue); obj.DiaChi = txtDiaChi.Text; obj.GioiTinh = ckNam.Checked; obj.IDKhoa = (int)lueKhoa.EditValue; db.SinhViens.InsertOnSubmit(obj); try { db.SubmitChanges(); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } catch (Exception ex) { HeThong.Thongbao.Loi(ex.ToString()); } } else { if (checkvali_null()) { return; } obj.MSV = txtMaNV.Text; obj.TenSV = txtHVT.Text; obj.NgaySinh = (DateTime)(txtNgaySinh.EditValue); obj.DiaChi = txtDiaChi.Text; obj.GioiTinh = ckNam.Checked; 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 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"); } } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //show banner //frmBanner frmb = new frmBanner(); //frmb.Show(); //HeThong.Func.UserLogin d = new HeThong.Func.UserLogin(); //string s = d.HashPassword("luongchung"); //Clipboard.SetText(s); //Thongbao.Canhbao(s); ////show form login // HeThong.fromLogin frm = new HeThong.fromLogin(); // frmb.Close(); //frm.ShowDialog(); //if (frm.DialogResult != DialogResult.OK) { return; } #region Đăng nhập với tài khoản khách NhanVien UsersLogin = new NhanVien(); var wait = Thongbao.Loading(); try { NhanVien objnhanvien = new NhanVien(); HeThong.Func.UserLogin ul = new HeThong.Func.UserLogin(); objnhanvien = ul.GetUserByMaNV("macdinh", "123456"); if (objnhanvien != null) { //Kiểm tra tài khoản khóa/kích hoạt if ((bool)objnhanvien.IsLock) { Thongbao.Canhbao("Hệ thống bị khóa, liên hệ quản trị viên..."); return; } UsersLogin = objnhanvien; } else { wait.Close(); wait.Dispose(); 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(); } } #endregion //Lưu section HeThong.Common.User = UsersLogin; //Vào form main frm_Main frmmain = new frm_Main() { User = UsersLogin }; Application.Run(frmmain); }
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(); } } }