public bool DeleteNV(Entities.tblNhanVien nv)
        {
            bool   kt  = false;
            string sql = "Prd_NV_Delete";

            try
            {
                con = ds.getConnect();
                cmd = new SqlCommand(sql, con);
                con.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Id", SqlDbType.NVarChar).Value = nv.Id;
                cmd.ExecuteNonQuery();
                kt = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                cmd.Dispose();
                con.Close();
            }
            return(kt);
        }
        public bool InsertNV(Entities.tblNhanVien nv)
        {
            bool   kt  = false;
            string sql = "Prd_NV_Insert";

            try
            {
                con = ds.getConnect();
                cmd = new SqlCommand(sql, con);
                con.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@MaNV", SqlDbType.NVarChar).Value   = nv.MaNV1;
                cmd.Parameters.Add("@TenNV", SqlDbType.NVarChar).Value  = nv.TenNV1;
                cmd.Parameters.Add("@SDT", SqlDbType.NVarChar).Value    = nv.SDT1;
                cmd.Parameters.Add("@DiaChi", SqlDbType.NVarChar).Value = nv.DiaChi1;
                cmd.ExecuteNonQuery();
                kt = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                cmd.Dispose();
                con.Close();
            }
            return(kt);
        }
 private void btnhoantat_Click(object sender, EventArgs e)
 {
     nv01         = new Entities.tblNhanVien();
     nv01.Id      = int.Parse(txtId.Text);
     nv01.MaNV1   = txtMaNV.Text;
     nv01.TenNV1  = txtTenNV.Text;
     nv01.SDT1    = txtSDT.Text;
     nv01.DiaChi1 = txtDiaChi.Text;
     if (checkmenu == "xoa")
     {
         bool kt = bll_NV.DeleteNV(nv01);
         if (kt)
         {
             MessageBox.Show("Bạn vừa xóa thành công !", "xóa thành công", MessageBoxButtons.OK);
             Reset();
             reload_NV();
             binding();
             return;
         }
         else
         {
             MessageBox.Show("Lỗi, Không thể xóa được!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
             binding();
         }
     }
     if (checkObject())
     {
         if (checkmenu == "add")
         {
             bool kt = bll_NV.InsertNV(nv01);
             if (kt)
             {
                 MessageBox.Show("Bạn vừa lưu thành công !", "Thêm thành công", MessageBoxButtons.OK);
                 Reset();
                 reload_NV();
             }
             else
             {
                 MessageBox.Show("Trùng mã nhân viên, xin vui lòng nhập lại !", "Thêm không thành công", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         if (checkmenu == "sua")
         {
             bool kt = bll_NV.UpdateNV(nv01);
             if (kt)
             {
                 MessageBox.Show("Bạn vừa sửa thành công !", "sửa thành công", MessageBoxButtons.OK);
                 Reset();
                 reload_NV();
                 binding();
             }
             else
             {
                 MessageBox.Show("Lỗi, Không thể sửa được! có thể trùng mã nhân viên", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
 public bool DeleteNV(Entities.tblNhanVien nv)
 {
     return(dal.DeleteNV(nv));
 }
 public bool UpdateNV(Entities.tblNhanVien nv)
 {
     return(dal.UpdateNV(nv));
 }
 public bool InsertNV(Entities.tblNhanVien nv)
 {
     return(dal.InsertNV(nv));
 }