Exemplo n.º 1
0
        private void addbtn_Click(object sender, EventArgs e)
        {
            //kiem man nhan vien da ton tai chua
            if (NhanVienController.GetNV(this.txtmanv.Text.Trim()) != null)
            {
                return;
            }

            bool check = false;

            if (KiemTraErr(check) == true)
            {
                return;
            }

            ClassNhanVien nv = new ClassNhanVien();

            nv.MaNV  = this.txtmanv.Text.Trim();
            nv.TenNV = this.txtTenNv.Text.Trim();
            if (this.checkFemale.Checked == true)
            {
                nv.GioiTinh = "Nu";
            }
            else
            {
                nv.GioiTinh = "Nam";
            }
            nv.SDT      = this.txtsdt.Text.Trim();
            nv.NgaySinh = this.Ngaysinhpicker.Value;
            nv.MaChucVu = this.cbbChucVu.Text.Trim();
            nv.Email    = this.txtemail.Text.Trim();
            nv.DiaChi   = this.txtDiachi.Text.Trim();

            //add xuong csdl
            if (NhanVienController.AddNV(nv) == false)
            {
                MessageBox.Show("Loi khi them nhan vien", "Loi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            ClearControls();

            ShowData();
        }