private void btnXoa_Click(object sender, EventArgs e)
        {
            NHANVIEN     nv = db.NHANVIENs.SingleOrDefault(p => p.MANV == txtMaNV.Text);
            DialogResult dr = MessageBox.Show("Bạn có muốn xóa nhân viên " + nv.MANV + " !.", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (nv != null && dr == DialogResult.OK)
            {
                db.NHANVIENs.DeleteOnSubmit(nv);
                db.SubmitChanges();
                MessageBox.Show("Xóa thành công!.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadDSNhanVien();
            }
        }
        private void btnThem_Click(object sender, EventArgs e)
        {
            NHANVIEN nv = new NHANVIEN
            {
                MANV     = txtMaNV.Text,
                HOTEN    = txtHoTen.Text,
                GIOITINH = cboGioiTinh.Text,
                NGAYSINH = dtpNgaySinh.Value,
                CMND     = txtCMND.Text,
                DIACHI   = txtDiaChi.Text,
                SDT      = txtSDT.Text,
            };

            //bỏ rdbQuanLy
            if (!rdbThongThuong.Checked)
            {
                nv.TAIKHOAN  = txtMaNV.Text;
                nv.MATKHAU   = EncodeSHA1(txtMatKhau.Text.Trim());
                nv.PHANQUYEN = false;
            }
            else
            {
                nv.TAIKHOAN = null;
                nv.MATKHAU  = null;
            }


            if (db.NHANVIENs.Where(p => p.MANV == txtMaNV.Text).SingleOrDefault() != null)
            {
                MessageBox.Show("Tài khoản bạn nhập bị trùng vui lòng kiểm tra lại !.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (txtMaNV.Text.Trim() == "" || txtHoTen.Text.Trim() == "" || txtCMND.Text.Trim() == "" || txtDiaChi.Text.Trim() == "")
            {
                MessageBox.Show("Một số thông tin còn thiếu!.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!rdbThongThuong.Checked && txtMatKhau.Text.Trim() == "")
            {
                MessageBox.Show("Vui lòng nhập mật khẩu với phân quyền trên !.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                db.NHANVIENs.InsertOnSubmit(nv);
                db.SubmitChanges();
                MessageBox.Show("Tạo nhân viên thành công!.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadDSNhanVien();
            }
        }
        private void dgvNhanVien_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow dgvr = new DataGridViewRow();

            dgvr = dgvNhanVien.Rows[e.RowIndex];
            if (e.RowIndex >= 0)
            {
                txtMaNV.Text      = dgvr.Cells[0].Value.ToString();
                txtHoTen.Text     = dgvr.Cells[1].Value.ToString();
                txtCMND.Text      = dgvr.Cells[2].Value.ToString();
                dtpNgaySinh.Value = DateTime.Parse(dgvr.Cells[3].Value.ToString());
                txtDiaChi.Text    = dgvr.Cells[4].Value.ToString();
                cboGioiTinh.Text  = dgvr.Cells[5].Value.ToString();
                txtSDT.Text       = dgvr.Cells[6].Value.ToString();
            }
            nv = db.NHANVIENs.SingleOrDefault(p => p.MANV == txtMaNV.Text.Trim());
        }
Ejemplo n.º 4
0
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     nv = (from NHANVIEN in db.NHANVIENs
           where NHANVIEN.TAIKHOAN == txtMANV_user.Text.Trim() &&
           NHANVIEN.MATKHAU == EncodeSHA1(txtMatKhau.Text)
           select NHANVIEN
           ).SingleOrDefault();
     if (nv == null)
     {
         MessageBox.Show("Sai mật khẫu hoặc tài khoản !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         nv = new NHANVIEN();
     }
     else
     {
         this.Close();
     }
 }
Ejemplo n.º 5
0
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     if (btnDangNhap.Text == "Đăng xuất")
     {
         DialogResult dr = MessageBox.Show("Bạn có muốn " + btnDangNhap.Text + " không ?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
         if (dr == DialogResult.OK)
         {
             User_form f = new User_form();
             f.ShowDialog();
             nv = f.nv;
             chkPhanQuyen();
         }
     }
     else
     {
         User_form f = new User_form();
         f.ShowDialog();
         nv = f.nv;
         chkPhanQuyen();
     }
 }
Ejemplo n.º 6
0
        private void btnLuuTT_Click(object sender, EventArgs e)
        {
            NHANVIEN nv = db.NHANVIENs.SingleOrDefault(p => p.MANV == lblManv.Text);

            if (nv != null)
            {
                nv.HOTEN    = txtTNV.Text;
                nv.GIOITINH = cboGioiTinh.Text;
                nv.NGAYSINH = dtpNgaySinh.Value;
                nv.DIACHI   = txtDC.Text;
                nv.CMND     = txtCMND.Text;
                nv.SDT      = txtSDT.Text;
                db.SubmitChanges();
                MessageBox.Show("Lưu thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnChinhSuaTT.Enabled = true;
                btnLuuTT.Enabled      = false;
                txtTNV.ReadOnly       = true;
                txtDC.ReadOnly        = true;
                txtSDT.ReadOnly       = true;
                txtCMND.ReadOnly      = true;
                dtpNgaySinh.Enabled   = false;
                cboGioiTinh.Enabled   = false;
            }
        }
Ejemplo n.º 7
0
 partial void DeleteNHANVIEN(NHANVIEN instance);
Ejemplo n.º 8
0
 partial void UpdateNHANVIEN(NHANVIEN instance);
Ejemplo n.º 9
0
 partial void InsertNHANVIEN(NHANVIEN instance);
Ejemplo n.º 10
0
 public Form1(NHANVIEN _nv)
 {
     InitializeComponent();
     nv = _nv;
     chkPhanQuyen();
 }