示例#1
0
        public NV_HoatDongVanHoa_ChiTiet GetByUrl(string url)
        {
            using (SqlConnection myConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("NV_HoatDongVanHoa_getByUrl", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    SqlParameter pID = new SqlParameter("@Url", SqlDbType.NVarChar, 200);
                    pID.Value = url;
                    myCommand.Parameters.Add(pID);

                    DataTable dt;
                    NV_HoatDongVanHoa_ChiTiet model = new NV_HoatDongVanHoa_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_HoatDongVanHoa_ChiTiet(dt);
                    }
                    return(model);
                }
            }
        }
示例#2
0
        public bool Update(NV_HoatDongVanHoa_ChiTiet model)
        {
            using (SqlConnection myConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("NV_HoatDongVanHoa_update", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    SqlParameter pID = new SqlParameter("@HoatDongID", SqlDbType.Int);
                    pID.Value = model.HoatDongID;
                    myCommand.Parameters.Add(pID);

                    SqlParameter pTenGoi = new SqlParameter("@TenGoi", SqlDbType.NVarChar, 250);
                    pTenGoi.Value = model.TenGoi;
                    myCommand.Parameters.Add(pTenGoi);

                    SqlParameter pTenGoiKkhac = new SqlParameter("@TenGoiKhac", SqlDbType.NVarChar, 250);
                    pTenGoiKkhac.Value = model.TenGoiKhac;
                    myCommand.Parameters.Add(pTenGoiKkhac);

                    SqlParameter pNgayDienRa = new SqlParameter("@NgayDienRa", SqlDbType.DateTime);
                    pNgayDienRa.Value = model.NgayDienRa;
                    myCommand.Parameters.Add(pNgayDienRa);


                    SqlParameter pThoiGianDienRa = new SqlParameter("@ThoiGianDienRa", SqlDbType.NVarChar, 200);
                    pThoiGianDienRa.Value = model.ThoiGianDienRa;
                    myCommand.Parameters.Add(pThoiGianDienRa);

                    SqlParameter pDiSanID = new SqlParameter("@DiSanID", SqlDbType.Int);
                    pDiSanID.Value = model.DiSanID;
                    myCommand.Parameters.Add(pDiSanID);

                    SqlParameter pNoiDung = new SqlParameter("@NoiDung", SqlDbType.NText);
                    pNoiDung.Value = model.NoiDung;
                    myCommand.Parameters.Add(pNoiDung);

                    SqlParameter pDiaDiem = new SqlParameter("@DiaDiem", SqlDbType.NVarChar, 200);
                    pDiaDiem.Value = model.DiaDiem;
                    myCommand.Parameters.Add(pDiaDiem);

                    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 pDonViToChuc = new SqlParameter("@DonViToChuc", SqlDbType.Int);
                    pDonViToChuc.Value = model.DonViToChucID;
                    myCommand.Parameters.Add(pDonViToChuc);

                    SqlParameter pGioiThieu = new SqlParameter("@GioiThieu", SqlDbType.NText);
                    pGioiThieu.Value = model.GioiThieu;
                    myCommand.Parameters.Add(pGioiThieu);

                    SqlParameter pDonViQuanLy = new SqlParameter("@DonViQuanLy", SqlDbType.Int);
                    pDonViQuanLy.Value = model.DonViQuanLyID;
                    myCommand.Parameters.Add(pDonViQuanLy);

                    SqlParameter pHinhAnh = new SqlParameter("@HinhAnh", SqlDbType.NVarChar, 500);
                    pHinhAnh.Value = model.HinhAnh;
                    myCommand.Parameters.Add(pHinhAnh);

                    SqlParameter pUrl = new SqlParameter("@Url", SqlDbType.NVarChar, 250);
                    pUrl.Value = model.Url;
                    myCommand.Parameters.Add(pUrl);
                    SqlParameter pDuyet = new SqlParameter("@Duyet", SqlDbType.Bit);
                    pDuyet.Value = model.Duyet;
                    myCommand.Parameters.Add(pDuyet);

                    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);
                    }
                }
            }
        }