private void txtpass_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (txtid.Text == "admin" && txtpass.Password.ToString() == "admin") { MainWindow wd = new MainWindow(); wd.Show(); this.Close(); } else if (txtid.Text != "admin") { string a = txtid.Text; NhanVien nv = new NhanVien(); foreach (NhanVien n in dc.NhanViens.Where(x => x.taikhoan == a)) { nv = n; } if (txtpass.Password.ToString() == nv.matkhau) { frmNVdangnhap.stringnvid = nv.nvid.ToString(); frmNVdangnhap frm = new frmNVdangnhap(); frm.Show(); this.Close(); } else { MessageBox.Show("Tài Khoản Hoặc Mặt Khẩu Không Đúng !"); } } } }
private void btnthoat_Click(object sender, RoutedEventArgs e) { frmNVdangnhap.stringnvid = manvkh; frmNVdangnhap frm = new frmNVdangnhap(); frm.Show(); this.Close(); }
private void btnThem_Click(object sender, RoutedEventArgs e) { try { kiemtra(); KhachHang kh = new KhachHang(); kh.hoten = txtname.Text; kh.diachi = txtdiachi.Text; kh.diachitt = txtdiachitt.Text; kh.cmnd = int.Parse(txtcmnd.Text); kh.ngaysinh = dtpNS.SelectedDate; kh.sdt = int.Parse(txtsdt.Text); if (cbx.Text == "Nam") { kh.gioitinh = true; } else { kh.gioitinh = false; } kh.email = txtemail.Text; if (rdo1.IsChecked == true) { kh.loaikh = true; } else { kh.loaikh = false; } kh.mota = ""; kh.nvid = int.Parse(manvkh); dc.KhachHangs.InsertOnSubmit(kh); dc.SubmitChanges(); frmNVdangnhap.stringnvid = manvkh; frmNVdangnhap frm = new frmNVdangnhap(); frm.Show(); this.Close(); } catch { return; } }