public NV_DiVatCoVat_ChiTiet GetByUrl(string url) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_DiVatCoVat_getByUrl", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pUrlName = new SqlParameter("@Url", SqlDbType.NVarChar, 200); pUrlName.Value = url; myCommand.Parameters.Add(pUrlName); DataTable dt; NV_DiVatCoVat_ChiTiet model = new NV_DiVatCoVat_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_DiVatCoVat_ChiTiet(dt.Rows[0]); } return(model); } } }
public NV_DiVatCoVat_ChiTiet GetById(int id) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_DiVatCoVat_getByID", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@ID", SqlDbType.Int); pID.Value = id; myCommand.Parameters.Add(pID); DataTable dt; NV_DiVatCoVat_ChiTiet model = new NV_DiVatCoVat_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_DiVatCoVat_ChiTiet(dt.Rows[0]); } return(model); } } }
public bool update(NV_DiVatCoVat_ChiTiet model) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_DiVatCoVat_update", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@ID", SqlDbType.Int); pID.Value = model.ID; myCommand.Parameters.Add(pID); SqlParameter pTen = new SqlParameter("@Ten", SqlDbType.NVarChar, 200); pTen.Value = model.Ten; myCommand.Parameters.Add(pTen); SqlParameter pTenKhac = new SqlParameter("@TenKhac", SqlDbType.NVarChar, 200); pTenKhac.Value = model.TenKhac; myCommand.Parameters.Add(pTenKhac); SqlParameter pSoDangKy = new SqlParameter("@MaSo", SqlDbType.NVarChar, 50); pSoDangKy.Value = model.MaSo; myCommand.Parameters.Add(pSoDangKy); SqlParameter pNgayDangKy = new SqlParameter("@NgayGiamDinh", SqlDbType.DateTime); pNgayDangKy.Value = model.NgayGiamDinh; myCommand.Parameters.Add(pNgayDangKy); SqlParameter pHoiDongGiamDinh = new SqlParameter("@HoiDongGiamDinh", SqlDbType.Int); pHoiDongGiamDinh.Value = model.HoiDongGiamDinh; myCommand.Parameters.Add(pHoiDongGiamDinh); SqlParameter pGhiChuGiamDinh = new SqlParameter("@GhiChuGiamDinh", SqlDbType.NVarChar, 2000); pGhiChuGiamDinh.Value = model.GhiChuGiamDinh; myCommand.Parameters.Add(pGhiChuGiamDinh); SqlParameter pPhanLoai = new SqlParameter("@PhanLoai", SqlDbType.Int); pPhanLoai.Value = model.PhanLoai; myCommand.Parameters.Add(pPhanLoai); SqlParameter pSoLuong = new SqlParameter("@SoLuong", SqlDbType.Int); pSoLuong.Value = model.SoLuong; myCommand.Parameters.Add(pSoLuong); SqlParameter pThanhPhanHopThanh = new SqlParameter("@ThanhPhanHopThanh", SqlDbType.NVarChar, 2000); pThanhPhanHopThanh.Value = model.ThanhPhanHopThanh; myCommand.Parameters.Add(pThanhPhanHopThanh); SqlParameter pKichThuoc = new SqlParameter("@KichThuocTrongLuong", SqlDbType.NVarChar, 2000); pKichThuoc.Value = model.KichThuocTrongLuong; myCommand.Parameters.Add(pKichThuoc); SqlParameter pTrongLuong = new SqlParameter("@MieuTaHienVat", SqlDbType.NVarChar, 2000); pTrongLuong.Value = model.MieuTaHienVat; myCommand.Parameters.Add(pTrongLuong); SqlParameter pDauTichDacBiet = new SqlParameter("@DauTichDacBiet", SqlDbType.NVarChar, 2000); pDauTichDacBiet.Value = model.DauTichDacBiet; myCommand.Parameters.Add(pDauTichDacBiet); SqlParameter pChatLieu = new SqlParameter("@ChatLieu", SqlDbType.NVarChar, 2000); pChatLieu.Value = model.ChatLieu; myCommand.Parameters.Add(pChatLieu); SqlParameter pNguonGoc = new SqlParameter("@NguonGoc", SqlDbType.NVarChar, 2000); pNguonGoc.Value = model.NguonGoc; myCommand.Parameters.Add(pNguonGoc); SqlParameter pThoiky = new SqlParameter("@Thoiky", SqlDbType.Int); pThoiky.Value = model.Thoiky; myCommand.Parameters.Add(pThoiky); SqlParameter pNienDai = new SqlParameter("@NienDai", SqlDbType.NVarChar, 1000); pNienDai.Value = model.NienDai; myCommand.Parameters.Add(pNienDai); SqlParameter pTinhTrang = new SqlParameter("@TinhTrang", SqlDbType.NVarChar, 4000); pTinhTrang.Value = model.TinhTrang; myCommand.Parameters.Add(pTinhTrang); SqlParameter pChuSoHuu = new SqlParameter("@ChuSoHuu", SqlDbType.NVarChar, 1000); pChuSoHuu.Value = model.ChuSoHuu; myCommand.Parameters.Add(pChuSoHuu); SqlParameter pNoiLuuTru = new SqlParameter("@NoiLuuTru", SqlDbType.Int); pNoiLuuTru.Value = model.NoiLuuTru; myCommand.Parameters.Add(pNoiLuuTru); SqlParameter pThayDoiChuSoHuu = new SqlParameter("@ThayDoiChuSoHuu", SqlDbType.NVarChar, 2000); pThayDoiChuSoHuu.Value = model.ThayDoiChuSoHuu; myCommand.Parameters.Add(pThayDoiChuSoHuu); SqlParameter pVideo = new SqlParameter("@Video", SqlDbType.NVarChar, 100); pVideo.Value = model.Video; myCommand.Parameters.Add(pVideo); SqlParameter pAnhDaiDien = new SqlParameter("@AnhDaiDien", SqlDbType.Int); pAnhDaiDien.Value = model.AnhDaiDien; myCommand.Parameters.Add(pAnhDaiDien); SqlParameter pBoAnh = new SqlParameter("@BoAnh", SqlDbType.NVarChar, 100); pBoAnh.Value = model.BoAnh; myCommand.Parameters.Add(pBoAnh); SqlParameter pFileDinhKem = new SqlParameter("@FileDinhKem", SqlDbType.NVarChar, 100); pFileDinhKem.Value = model.FileDinhKem; myCommand.Parameters.Add(pFileDinhKem); SqlParameter pGioiThieu = new SqlParameter("@GioiThieu", SqlDbType.NText); pGioiThieu.Value = model.GioiThieu; myCommand.Parameters.Add(pGioiThieu); SqlParameter pDiaDiemPhatHien = new SqlParameter("@DiaDiemPhatHien", SqlDbType.NVarChar, 200); pDiaDiemPhatHien.Value = model.DiaDiemPhatHien; myCommand.Parameters.Add(pDiaDiemPhatHien); SqlParameter pDiSanID = new SqlParameter("@DiSanID", SqlDbType.Int); pDiSanID.Value = model.DiSanID; myCommand.Parameters.Add(pDiSanID); SqlParameter pTrangThai = new SqlParameter("@TrangThai", SqlDbType.Bit); pTrangThai.Value = model.TrangThai; myCommand.Parameters.Add(pTrangThai); SqlParameter pIsMuseum = new SqlParameter("@IsMuseum", SqlDbType.Bit); pIsMuseum.Value = model.IsMuseum; myCommand.Parameters.Add(pIsMuseum); SqlParameter pUrlName = new SqlParameter("@UrlName", SqlDbType.NVarChar, 200); pUrlName.Value = model.UrlName; myCommand.Parameters.Add(pUrlName); SqlParameter pLang = new SqlParameter("@Lang", SqlDbType.VarChar, 10); pLang.Value = model.Lang; myCommand.Parameters.Add(pLang); try { myConnection.Open(); myCommand.ExecuteNonQuery(); return(true); } catch { return(false); } } } }