private void txtMaNhanVien_TextChanged(object sender, EventArgs e) { BULNhanVien bul = new BULNhanVien(); List <NhanVien> arr = bul.layNhanVien(); for (int i = 0; i < arr.Count; i++) { if (arr[i].MaNhanVien + "" == txtMaNhanVien.Text) { txtTenNhanVien.Text = arr[i].TenNhanVien; txtTaiKhoan.Text = arr[i].TenTaiKhoan; txtSoDienThoai.Text = arr[i].SoDienThoai; txtChungMinhThu.Text = arr[i].ChungMinhThu; BULTaiKhoan bultk = new BULTaiKhoan(); txtMatKhau.Text = bultk.layTaiKhoanTheoTenTK(txtTaiKhoan.Text)[0].MatKhau; cbQuyen.Text = bultk.layTaiKhoanTheoTenTK(txtTaiKhoan.Text)[0].Quyen; break; } else { txtTenNhanVien.Text = ""; txtTaiKhoan.Text = ""; txtSoDienThoai.Text = ""; txtChungMinhThu.Text = ""; txtMatKhau.Text = ""; } } }
private void btnDangNhap_Click(object sender, EventArgs e) { TaiKhoan tk = new TaiKhoan(txtTaiKhoan.Text, txtMatKhau.Text); BULTaiKhoan bul = new BULTaiKhoan(); if (bul.dangNhap(tk)) { BULNhanVien bulNV = new BULNhanVien(); frmSieuThi.nv = bulNV.layNhanVienTheoTaiKhoan(txtTaiKhoan.Text); frmSieuThi.tk = bul.layTaiKhoanTheoTenTK(txtTaiKhoan.Text)[0]; frmST.Show(); this.Visible = false; } else { MessageBox.Show("Sai tài khoản - mật khẩu"); } }
private void btnSua_Click(object sender, EventArgs e) { try { BULTaiKhoan bultk = new BULTaiKhoan(); bultk.suaTaiKhoan(new TaiKhoan(txtTaiKhoan.Text, txtMatKhau.Text, cbQuyen.Text)); BULNhanVien bul = new BULNhanVien(); bul.suaNhanVien(new NhanVien(int.Parse(txtMaNhanVien.Text), txtTenNhanVien.Text, txtSoDienThoai.Text, txtChungMinhThu.Text, txtTaiKhoan.Text)); frmST.hienDanhSachNhanVien(); MessageBox.Show("Sửa thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception) { MessageBox.Show("Thao tác thất bạt, dữ liệu sai", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }