public NV_DonViKinhDoanh_ChiTiet GetById(int id) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_DonViKinhDoanh_getByID", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@ID", SqlDbType.Int); pID.Value = id; myCommand.Parameters.Add(pID); DataTable dt; NV_DonViKinhDoanh_ChiTiet model = new NV_DonViKinhDoanh_ChiTiet(); myConnection.Open(); using (SqlDataAdapter mData = new SqlDataAdapter(myCommand)) { dt = new DataTable(); mData.Fill(dt); } if (dt != null && dt.Rows.Count > 0) { model = new NV_DonViKinhDoanh_ChiTiet(dt); } return(model); } } }
public bool update(NV_DonViKinhDoanh_ChiTiet model) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_DonViKinhDoanh_update", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@ID", SqlDbType.Int); pID.Value = model.ID; myCommand.Parameters.Add(pID); SqlParameter pTenDonVi = new SqlParameter("@TenDonVi", SqlDbType.NVarChar, 250); pTenDonVi.Value = model.TenDonVi; myCommand.Parameters.Add(pTenDonVi); SqlParameter pSoGiayPhep = new SqlParameter("@SoGiayPhep", SqlDbType.NVarChar, 50); pSoGiayPhep.Value = model.SoGiayPhep; myCommand.Parameters.Add(pSoGiayPhep); SqlParameter pNgayCap = new SqlParameter("@NgayCap", SqlDbType.DateTime); pNgayCap.Value = model.NgayCap; myCommand.Parameters.Add(pNgayCap); SqlParameter pDienThoai = new SqlParameter("@DienThoai", SqlDbType.NVarChar, 50); pDienThoai.Value = model.DienThoai; myCommand.Parameters.Add(pDienThoai); SqlParameter pThongTinLienHe = new SqlParameter("@ThongTinLienHe", SqlDbType.NVarChar, 250); pThongTinLienHe.Value = model.ThongTinLienHe; myCommand.Parameters.Add(pThongTinLienHe); SqlParameter pChuKinhDoanh = new SqlParameter("@ChuKinhDoanh", SqlDbType.NVarChar, 250); pChuKinhDoanh.Value = model.ChuKinhDoanh; myCommand.Parameters.Add(pChuKinhDoanh); SqlParameter pLinhVuc = new SqlParameter("@LinhVuc", SqlDbType.NVarChar, 50); pLinhVuc.Value = model.LinhVuc; myCommand.Parameters.Add(pLinhVuc); SqlParameter pThuocTinh = new SqlParameter("@ThuocTinh", SqlDbType.VarChar, 10); pThuocTinh.Value = model.ThuocTinh; myCommand.Parameters.Add(pThuocTinh); SqlParameter pThuocHuyen = new SqlParameter("@ThuocHuyen", SqlDbType.VarChar, 10); pThuocHuyen.Value = model.ThuocHuyen; myCommand.Parameters.Add(pThuocHuyen); SqlParameter pThuocXa = new SqlParameter("@ThuocXa", SqlDbType.VarChar, 10); pThuocXa.Value = model.ThuocXa; myCommand.Parameters.Add(pThuocXa); SqlParameter pDiaChi = new SqlParameter("@DiaChi", SqlDbType.NVarChar, 250); pDiaChi.Value = model.DiaChi; myCommand.Parameters.Add(pDiaChi); SqlParameter pStt = new SqlParameter("@Stt", SqlDbType.Int); pStt.Value = model.Stt; myCommand.Parameters.Add(pStt); try { myConnection.Open(); myCommand.ExecuteNonQuery(); return(true); } catch { return(false); } } } }