public NV_DiSanVanHoa_ChiTiet GetById(int id) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_DiSanVanHoa_getByID", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@id", SqlDbType.Int); pID.Value = id; myCommand.Parameters.Add(pID); DataTable dt; NV_DiSanVanHoa_ChiTiet model = new NV_DiSanVanHoa_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_DiSanVanHoa_ChiTiet(dt); } return(model); } } }
public NV_DiSanVanHoa_ChiTiet GetByUrl(string url) { //string sql = "select top 1 *,(select TenAnh from Image where ImageID=AnhBanDo) as TenAnhBanDo from DiSanVanHoa where Url='" + url + "'"; string sql = "select top 1 *,'' as TenAnhBanDo from DiSanVanHoa where Url='" + url + "'"; DataTable dt = Sys_Common.getDataByQuery(sql); NV_DiSanVanHoa_ChiTiet ds = new NV_DiSanVanHoa_ChiTiet(); if (dt != null && dt.Rows.Count > 0) { ds = new NV_DiSanVanHoa_ChiTiet(dt); } return(ds); }
public bool Update(NV_DiSanVanHoa_ChiTiet model) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_DiSanVanHoa_update", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@DiSanID", SqlDbType.Int); pID.Value = model.DiSanID; myCommand.Parameters.Add(pID); SqlParameter pMaDiSan = new SqlParameter("@MaDiSan", SqlDbType.NVarChar, 50); pMaDiSan.Value = model.MaDiSan; myCommand.Parameters.Add(pMaDiSan); SqlParameter pTenDiSan = new SqlParameter("@TenDiSan", SqlDbType.NVarChar, 250); pTenDiSan.Value = model.TenDiSan; myCommand.Parameters.Add(pTenDiSan); SqlParameter pTenGoiKhac = new SqlParameter("@TenGoiKhac", SqlDbType.NVarChar, 250); pTenGoiKhac.Value = model.TenGoiKhac; myCommand.Parameters.Add(pTenGoiKhac); SqlParameter pLoaiDiSan = new SqlParameter("@LoaiDiSan", SqlDbType.Int); pLoaiDiSan.Value = model.LoaiDiSan; myCommand.Parameters.Add(pLoaiDiSan); SqlParameter pChuTheVanHoa = new SqlParameter("@ChuTheVanHoa", SqlDbType.NText); pChuTheVanHoa.Value = model.ChuTheVanHoa; myCommand.Parameters.Add(pChuTheVanHoa); 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 pNgayChungNhan = new SqlParameter("@NgayChungNhan", SqlDbType.DateTime); pNgayChungNhan.Value = model.NgayChungNhan; myCommand.Parameters.Add(pNgayChungNhan); SqlParameter pMota = new SqlParameter("@Mota", SqlDbType.NText); pMota.Value = model.MoTa; myCommand.Parameters.Add(pMota); SqlParameter pHienTrang = new SqlParameter("@HienTrang", SqlDbType.NText); pHienTrang.Value = model.HienTrang; myCommand.Parameters.Add(pHienTrang); SqlParameter pDonViQuanLy = new SqlParameter("@DonViQuanLy", SqlDbType.Int); pDonViQuanLy.Value = model.DonViQuanLy; myCommand.Parameters.Add(pDonViQuanLy); SqlParameter pGiaTriDanhGia = new SqlParameter("@GiaTriDanhGia", SqlDbType.NText); pGiaTriDanhGia.Value = model.GiaTriDanhGia; myCommand.Parameters.Add(pGiaTriDanhGia); SqlParameter pDeXuat = new SqlParameter("@DeXuat", SqlDbType.NText); pDeXuat.Value = model.DeXuat; myCommand.Parameters.Add(pDeXuat); SqlParameter pTaiLieu = new SqlParameter("@TaiLieu", SqlDbType.NVarChar, 500); pTaiLieu.Value = model.TaiLieu; myCommand.Parameters.Add(pTaiLieu); SqlParameter pChiPhiDuyTri = new SqlParameter("@ChiPhiDuyTri", SqlDbType.NVarChar, 500); pChiPhiDuyTri.Value = model.ChiPhiDuyTri; myCommand.Parameters.Add(pChiPhiDuyTri); SqlParameter pSoLuotKhach = new SqlParameter("@SoLuotKhach", SqlDbType.NVarChar, 50); pSoLuotKhach.Value = model.SoLuotKhach; myCommand.Parameters.Add(pSoLuotKhach); SqlParameter pSoDangKy = new SqlParameter("@SoDangKy", SqlDbType.NVarChar, 20); pSoDangKy.Value = model.SoDangKy; myCommand.Parameters.Add(pSoDangKy); SqlParameter pHinhAnh = new SqlParameter("@HinhAnh", SqlDbType.NVarChar, 500); pHinhAnh.Value = model.HinhAnh; myCommand.Parameters.Add(pHinhAnh); SqlParameter pCapDiSan = new SqlParameter("@CapDiSan", SqlDbType.Int); pCapDiSan.Value = model.CapDiSan; myCommand.Parameters.Add(pCapDiSan); SqlParameter pDanhMuc = new SqlParameter("@DanhMucDS", SqlDbType.NVarChar, 250); pDanhMuc.Value = model.DanhMucDS; myCommand.Parameters.Add(pDanhMuc); SqlParameter pUrl = new SqlParameter("@Url", SqlDbType.NVarChar, 250); pUrl.Value = model.Url; myCommand.Parameters.Add(pUrl); SqlParameter pAnhDaiDien = new SqlParameter("@AnhDaiDien", SqlDbType.Int); pAnhDaiDien.Value = model.AnhDaiDien; myCommand.Parameters.Add(pAnhDaiDien); SqlParameter pTrangThai = new SqlParameter("@TrangThai", SqlDbType.Bit); pTrangThai.Value = model.TrangThai; myCommand.Parameters.Add(pTrangThai); SqlParameter pVideo = new SqlParameter("@Video", SqlDbType.NVarChar, 10); pVideo.Value = model.Video; myCommand.Parameters.Add(pVideo); SqlParameter pLyLich = new SqlParameter("@LyLich", SqlDbType.NText); pLyLich.Value = model.LyLich; myCommand.Parameters.Add(pLyLich); SqlParameter pNienDai = new SqlParameter("@NienDai", SqlDbType.NText); pNienDai.Value = model.NienDai; myCommand.Parameters.Add(pNienDai); SqlParameter pMatBangTongThe = new SqlParameter("@MatBangTongThe", SqlDbType.NVarChar, 500); pMatBangTongThe.Value = model.MatBangTongThe; myCommand.Parameters.Add(pMatBangTongThe); SqlParameter pBanDoKhoanhVung = new SqlParameter("@BanDoKhoanhVung", SqlDbType.NVarChar, 500); pBanDoKhoanhVung.Value = model.BanDoKhoanhVung; myCommand.Parameters.Add(pBanDoKhoanhVung); SqlParameter pQuyHoach = new SqlParameter("@QuyHoach", SqlDbType.NVarChar, 500); pQuyHoach.Value = model.QuyHoach; myCommand.Parameters.Add(pQuyHoach); SqlParameter pNoiBat = new SqlParameter("@NoiBat", SqlDbType.Bit); pNoiBat.Value = model.NoiBat; myCommand.Parameters.Add(pNoiBat); SqlParameter pDiSanLQ = new SqlParameter("@DiSanLQ", SqlDbType.Int); pDiSanLQ.Value = model.DiSanLQ; myCommand.Parameters.Add(pDiSanLQ); SqlParameter pAnhBanDo = new SqlParameter("@AnhBanDo", SqlDbType.NVarChar, 500); pAnhBanDo.Value = model.AnhBanDo; myCommand.Parameters.Add(pAnhBanDo); SqlParameter pSTT = new SqlParameter("@STT", SqlDbType.Int); pSTT.Value = model.STT; myCommand.Parameters.Add(pSTT); SqlParameter pFileQuyetDinh = new SqlParameter("@FileQuyetDinh", SqlDbType.NVarChar, 500); pFileQuyetDinh.Value = model.FileQuyetDinh; myCommand.Parameters.Add(pFileQuyetDinh); SqlParameter pThoiGianDienRa = new SqlParameter("@ThoiGianDienRa", SqlDbType.NVarChar, 500); pThoiGianDienRa.Value = model.ThoiGianDienRa; myCommand.Parameters.Add(pThoiGianDienRa); SqlParameter pThongKeHienVat = new SqlParameter("@ThongKeHienVat", SqlDbType.NVarChar, 500); pThongKeHienVat.Value = model.ThongKeHienVat; myCommand.Parameters.Add(pThongKeHienVat); 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); } } } }