Esempio n. 1
0
        public NV_BaiViet_AnPham_ChiTiet GetById(int id)
        {
            using (SqlConnection myConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("NV_BaiViet_AnPham_getByID", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    SqlParameter pID = new SqlParameter("@id", SqlDbType.VarChar, 10);
                    pID.Value = id;
                    myCommand.Parameters.Add(pID);


                    DataTable dt;
                    NV_BaiViet_AnPham_ChiTiet model = new NV_BaiViet_AnPham_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_BaiViet_AnPham_ChiTiet(dt);
                    }
                    return(model);
                }
            }
        }
Esempio n. 2
0
        public NV_BaiViet_AnPham_ChiTiet GetByUrl(string url)
        {
            string    sql = "select top 1 *,(select TenAnh from Image i where i.ImageID=bv.HinhAnh) as AnhDaiDien from BaiViet_AnPham bv where Duyet=1 and Url='" + url + "'";
            DataTable dt  = Sys_Common.getDataByQuery(sql);
            NV_BaiViet_AnPham_ChiTiet bv = new NV_BaiViet_AnPham_ChiTiet();

            if (dt != null && dt.Rows.Count > 0)
            {
                bv = new NV_BaiViet_AnPham_ChiTiet(dt);
            }
            return(bv);
        }
Esempio n. 3
0
        public bool Update(NV_BaiViet_AnPham_ChiTiet model)
        {
            using (SqlConnection myConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("NV_BaiViet_AnPham_update", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

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

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

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


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

                    //SqlParameter pNgayxuatban = new SqlParameter("@NgayXuatBan", SqlDbType.DateTime);
                    //pNgayxuatban.Value = model.NgayXuatBan;
                    //myCommand.Parameters.Add(pNgayxuatban);

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

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

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

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

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

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

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

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

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

                    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 pNoiBat = new SqlParameter("@NoiBat", SqlDbType.Bit);
                    pNoiBat.Value = model.NoiBat;
                    myCommand.Parameters.Add(pNoiBat);

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

                    SqlParameter pTonTai = new SqlParameter("@TonTai", SqlDbType.Bit);
                    pTonTai.Value = model.TonTai;
                    myCommand.Parameters.Add(pTonTai);

                    SqlParameter pLang = new SqlParameter("@Lang", SqlDbType.VarChar, 10);
                    pLang.Value = model.Lang;
                    myCommand.Parameters.Add(pLang);

                    //SqlParameter pNguoiTao = new SqlParameter("@NguoiTao", SqlDbType.Int);
                    //pNguoiTao.Value = model.NguoiTao;
                    //myCommand.Parameters.Add(pNguoiTao);
                    try
                    {
                        myConnection.Open();
                        myCommand.ExecuteNonQuery();
                        return(true);
                    }
                    catch
                    {
                        return(false);
                    }
                }
            }
        }