public NV_NgheNhan_ChiTiet GetByUrl(string url) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_NgheNhan_getByUrl", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pUrl = new SqlParameter("@Url", SqlDbType.NVarChar, 100); pUrl.Value = url; myCommand.Parameters.Add(pUrl); DataTable dt; NV_NgheNhan_ChiTiet model = new NV_NgheNhan_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_NgheNhan_ChiTiet(dt.Rows[0]); } return(model); } } } }
public NV_NgheNhan_ChiTiet GetById(int id) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_NgheNhan_getByID", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@ID", SqlDbType.Int); pID.Value = id; myCommand.Parameters.Add(pID); DataTable dt; NV_NgheNhan_ChiTiet model = new NV_NgheNhan_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_NgheNhan_ChiTiet(dt.Rows[0]); } return(model); } } }
public bool update(NV_NgheNhan_ChiTiet model) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_NgheNhan_update", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@ID", SqlDbType.Int); pID.Value = model.ID; myCommand.Parameters.Add(pID); SqlParameter pHoTen = new SqlParameter("@HoTen", SqlDbType.NVarChar, 50); pHoTen.Value = model.HoTen; myCommand.Parameters.Add(pHoTen); SqlParameter pTenKhac = new SqlParameter("@TenKhac", SqlDbType.NVarChar, 50); pTenKhac.Value = model.TenKhac; myCommand.Parameters.Add(pTenKhac); SqlParameter pNgaySinh = new SqlParameter("@NgaySinh", SqlDbType.NVarChar, 100); pNgaySinh.Value = model.NgaySinh; myCommand.Parameters.Add(pNgaySinh); SqlParameter pNgayCap = new SqlParameter("@NgayCap", SqlDbType.DateTime); pNgayCap.Value = model.NgayCap; myCommand.Parameters.Add(pNgayCap); SqlParameter pDanToc = new SqlParameter("@MaDanToc", SqlDbType.VarChar, 5); pDanToc.Value = model.MaDanToc; myCommand.Parameters.Add(pDanToc); SqlParameter pNguyenQuan = new SqlParameter("@NguyenQuan", SqlDbType.NVarChar, 200); pNguyenQuan.Value = model.NguyenQuan; myCommand.Parameters.Add(pNguyenQuan); SqlParameter pDiaChi = new SqlParameter("@DiaChi", SqlDbType.NVarChar, 200); pDiaChi.Value = model.DiaChi; myCommand.Parameters.Add(pDiaChi); SqlParameter pHoKhauThuongTru = new SqlParameter("@HoKhauThuongTru", SqlDbType.NVarChar, 200); pHoKhauThuongTru.Value = model.HoKhauThuongTru; myCommand.Parameters.Add(pHoKhauThuongTru); SqlParameter pDiSanID = new SqlParameter("@DiSanID", SqlDbType.Int); pDiSanID.Value = model.DiSanID; myCommand.Parameters.Add(pDiSanID); SqlParameter pNamBatDau = new SqlParameter("@NamBatDau", SqlDbType.NVarChar, 100); pNamBatDau.Value = model.NamBatDau; myCommand.Parameters.Add(pNamBatDau); SqlParameter pDienThoai = new SqlParameter("@DienThoai", SqlDbType.NVarChar, 50); pDienThoai.Value = model.DienThoai; myCommand.Parameters.Add(pDienThoai); SqlParameter pDiDong = new SqlParameter("@DiDong", SqlDbType.NVarChar, 50); pDiDong.Value = model.DiDong; myCommand.Parameters.Add(pDiDong); SqlParameter pQuyTrinh = new SqlParameter("@QuaTrinh", SqlDbType.NText); pQuyTrinh.Value = model.QuaTrinh; myCommand.Parameters.Add(pQuyTrinh); SqlParameter pTriThucKyNang = new SqlParameter("@TriThucKyNang", SqlDbType.NText); pTriThucKyNang.Value = model.TriThucKyNang; myCommand.Parameters.Add(pTriThucKyNang); SqlParameter pKhenThuong = new SqlParameter("@KhenThuong", SqlDbType.NVarChar, 4000); pKhenThuong.Value = model.KhenThuong; myCommand.Parameters.Add(pKhenThuong); SqlParameter pKyLuat = new SqlParameter("@KyLuat", SqlDbType.NVarChar, 1000); pKyLuat.Value = model.KyLuat; myCommand.Parameters.Add(pKyLuat); SqlParameter pHinhAnh = new SqlParameter("@HinhAnh", SqlDbType.Int); pHinhAnh.Value = model.HinhAnh; myCommand.Parameters.Add(pHinhAnh); SqlParameter pFile = new SqlParameter("@File", SqlDbType.NVarChar, 50); pFile.Value = model.File; myCommand.Parameters.Add(pFile); SqlParameter pUrl = new SqlParameter("@Url", SqlDbType.NVarChar, 100); pUrl.Value = model.Url; myCommand.Parameters.Add(pUrl); SqlParameter pGioiThieu = new SqlParameter("@GioiThieu", SqlDbType.NText); pGioiThieu.Value = model.GioiThieu; myCommand.Parameters.Add(pGioiThieu); SqlParameter pDanhHieu = new SqlParameter("@DanhHieu", SqlDbType.Int); pDanhHieu.Value = model.DanhHieu; myCommand.Parameters.Add(pDanhHieu); SqlParameter pLoaiDiSan = new SqlParameter("@LoaiDiSan", SqlDbType.Int); pLoaiDiSan.Value = model.LoaiDiSan; myCommand.Parameters.Add(pLoaiDiSan); SqlParameter pTenDiSan = new SqlParameter("@TenDiSan", SqlDbType.NVarChar, 500); pTenDiSan.Value = model.TenDiSan; myCommand.Parameters.Add(pTenDiSan); try { myConnection.Open(); myCommand.ExecuteNonQuery(); return(true); } catch { return(false); } } } }