private void toolThem_Click(object sender, EventArgs e)
        {
            status = ThamSo.Controll.Addnew;
            this.Allow(true);
            DataRow row = NVctrl.NewRow();

            row["MaNV"]       = "";
            row["HoTenNV"]    = "";
            row["NgaySinh"]   = "01/01/1900";
            row["DiaChi"]     = "";
            row["MaPhongBan"] = "";
            row["MaChucVu"]   = "";
            row["GhiChu"]     = "";
            NVctrl.Add(row);
            bindingNavigatorNV.BindingSource.MoveLast();
            txtMaNV.Focus();
        }
예제 #2
0
        private void LuuNV_Click(object sender, EventArgs e)
        {
            if (Them_bool == true && Sua_bool == false)
            {
                var entity = new nhanvien();

                entity.tennv    = tennvtxt.Text;
                entity.ngaysinh = ngaysinhnv.Value;
                entity.gioitinh = gioitinhtxt.Text;
                entity.sdt      = sdttxt.Text;
                entity.diachi   = diachitxt.Text;
                entity.socmtnd  = socmtndtxt.Text;
                entity.quyenhan = quyenhantxt.Text;

                var nv = new NhanVienController();
                int t  = nv.Add(entity);
                if (t > 0)
                {
                    HienthiNV();
                }
                else
                {
                    MessageBox.Show("Thêm nhân viên lỗi!");
                }
            }
            if (Them_bool == false && Sua_bool == true)
            {
                var entity = new nhanvien();
                entity.manv     = Convert.ToInt32(manvtxt.Text);
                entity.tennv    = tennvtxt.Text;
                entity.ngaysinh = ngaysinhnv.Value;
                entity.gioitinh = gioitinhtxt.Text;
                entity.sdt      = sdttxt.Text;
                entity.diachi   = diachitxt.Text;
                entity.socmtnd  = socmtndtxt.Text;
                entity.quyenhan = quyenhantxt.Text;

                var nv = new NhanVienController();
                if (nv.edit(entity))
                {
                    HienthiNV();
                }
                else
                {
                    MessageBox.Show("Sửa lỗi!");
                }
            }
            btn_edit(false);
        }