Пример #1
0
        public NV_AnPham_ChiTiet GetById(int id)
        {
            using (SqlConnection myConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("NV_AnPham_getByID", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

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


                    DataTable         dt;
                    NV_AnPham_ChiTiet model = new NV_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_AnPham_ChiTiet(dt);
                    }
                    return(model);
                }
            }
        }
Пример #2
0
        public NV_AnPham_ChiTiet GetByUrl(string url)
        {
            string            sql = "select top 1 * from AnPham where Url='" + url + "'";
            DataTable         dt  = Sys_Common.getDataByQuery(sql);
            NV_AnPham_ChiTiet bv  = new NV_AnPham_ChiTiet();

            if (dt != null && dt.Rows.Count > 0)
            {
                bv = new NV_AnPham_ChiTiet(dt);
            }
            return(bv);
        }
Пример #3
0
        public bool Update(NV_AnPham_ChiTiet model)
        {
            using (SqlConnection myConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("NV_AnPham_update", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

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


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

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

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

                    SqlParameter pMaSach = new SqlParameter("@MaSach", SqlDbType.VarChar, 20);
                    pMaSach.Value = model.MaSach;
                    myCommand.Parameters.Add(pMaSach);

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

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

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

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

                    SqlParameter pKichCo = new SqlParameter("@KichCo", SqlDbType.NVarChar, 50);
                    pKichCo.Value = model.KichCo;
                    myCommand.Parameters.Add(pKichCo);

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

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

                    SqlParameter pNhaXB = new SqlParameter("@NhaXB", SqlDbType.NVarChar, 4000);
                    pNhaXB.Value = model.NhaXB;
                    myCommand.Parameters.Add(pNhaXB);

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

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

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

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

                    try
                    {
                        myConnection.Open();
                        myCommand.ExecuteNonQuery();
                        return(true);
                    }
                    catch
                    {
                        return(false);
                    }
                }
            }
        }