Beispiel #1
0
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  BasicMethod
        #region  ExtensionMethod

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XCWeiXin.Model.wx_book_product GetModel(int id)
        {
            Model.wx_book_product product = new Model.wx_book_product();
            product         = dal.GetModel(id);
            product.albums  = new wx_book_albums().GetModelList("productId=" + id);
            product.attrs   = new DAL.wx_book_productAttr_value().GetAttrModelList(id);
            product.skulist = new DAL.wx_book_sku().GetpSkuModelList(id);

            return(product);
        }
Beispiel #2
0
        /// <summary>
        /// 绑定预订信息
        /// </summary>
        /// <param name="id"></param>
        private void BindProductInfo(int id)
        {
            hidid.Value = id.ToString();
            Model.wx_book_product product = spBll.GetModel(id);
            ddlCategoryId.SelectedValue = product.categoryId.Value.ToString();
            ddlCatalog.SelectedValue    = product.catalogId.ToString();
            hidCatalogId.Value          = product.catalogId.ToString();
            txtproductName.Text         = product.productName;
            txtunit.Text = product.unit;
            txtsku.Text  = product.sku;
            if (product.upselling)
            {
                radType.Items[0].Selected = true;
            }
            else
            {
                radType.Items[1].Selected = true;
            }

            if (product.latest)
            {
                cblActionType.Items[0].Selected = true;
            }
            if (product.hotsale)
            {
                cblActionType.Items[1].Selected = true;
            }
            if (product.recommended)
            {
                cblActionType.Items[2].Selected = true;
            }
            if (product.specialOffer)
            {
                cblActionType.Items[3].Selected = true;
            }

            txtcostPrice.Text   = product.costPrice.ToString();
            txtmarketPrice.Text = product.marketPrice.ToString();
            txtsalePrice.Text   = product.salePrice.ToString();
            txtstock.Text       = product.stock.ToString();

            txtsort_id.Text          = product.sort_id == null ? "99" : product.sort_id.ToString();
            txtshortDesc.Text        = product.shortDesc;
            txtdescription.InnerText = product.description;

            rptAlbumList.DataSource = product.albums;
            rptAlbumList.DataBind();

            //绑定属性html
            BindAttrHtml(product.catalogId);
        }
Beispiel #3
0
        /// <summary>
        ///  设置操作
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidId")).Value);

            BLL.wx_book_product   bll   = new BLL.wx_book_product();
            Model.wx_book_product model = bll.GetModel(id);
            switch (e.CommandName)
            {
            case "lbtnIslatest":    //最新
                if (model.latest)
                {
                    bll.UpdateField(id, "latest=0");
                }
                else
                {
                    bll.UpdateField(id, "latest=1");
                }
                break;

            case "lbtnIshotsale":
                if (model.hotsale)
                {
                    bll.UpdateField(id, "hotsale=0");
                }
                else
                {
                    bll.UpdateField(id, "hotsale=1");
                }
                break;

            case "lbtnIsspecialOffer":
                if (model.specialOffer)
                {
                    bll.UpdateField(id, "specialOffer=0");
                }
                else
                {
                    bll.UpdateField(id, "specialOffer=1");
                }
                break;
            }
            this.RptBind(this.category_id, CombSqlTxt(this.keywords), "sort_id asc,id desc");
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XCWeiXin.Model.wx_book_product GetModel(int id)
        {
            Model.wx_book_product product = new Model.wx_book_product();
            StringBuilder         strSql  = new StringBuilder();

            strSql.Append("select  top 1 id,wid,categoryId,brandId,sku,productName,shortDesc,unit,weight,description,seo_title,seo_keywords,seo_description,focusImgUrl,thumbnailsUrll,recommended,latest,hotsale,specialOffer,costPrice,marketPrice,salePrice,upselling,stock,addDate,vistiCounts,sort_id,productionDate,ExpiryEndDate,updateDate,catalogId from wx_book_product ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            XCWeiXin.Model.wx_book_product model = new XCWeiXin.Model.wx_book_product();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                product = DataRowToModel(ds.Tables[0].Rows[0]);
            }


            return(product);
        }
Beispiel #5
0
        public void bookDetailPage()
        {
            BLL.wx_book_product artDal = new BLL.wx_book_product();
            int pid = MyCommFun.RequestInt("pid");

            Model.wx_book_product product = artDal.GetModel(pid);
            if (product != null)
            {
                string skuStr      = "[";
                string availSkuStr = "{";
                if (product.skulist != null && product.skulist.Count > 0)
                {
                    // string skuStr = "[{ \"pList\": [\"H\", \"H/VVS/32分/14号\"], \"pName\": \"戒指手寸\" }]";
                    // string   availSku = "{ \"戒指手寸:F-G/VVS/33分/12号\": { \"pid\": 12700, \"stockCount\": \"\", \"stockPrice\": \"1000\", \"maketPrice\": \"0\" },  }";

                    skuStr += "{ \"pList\": [";
                    //暂时只支持一种配件
                    for (int i = 0; i < product.skulist.Count; i++)
                    {
                        product.skulist[i].price += product.salePrice;
                        product.skulist[i].price *= 100;
                        if (i != (product.skulist.Count - 1))
                        {
                            skuStr      += "\"" + product.skulist[i].attributeValue + "\",";
                            availSkuStr += "\"" + product.skulist[0].attrName + ":" + product.skulist[i].attributeValue + "\": { \"pid\": " + product.skulist[i].id + ", \"stockCount\": \"\", \"stockPrice\": \"" + product.skulist[i].price + "\", \"maketPrice\": \"" + product.marketPrice * 100 + "\" }, ";
                        }
                        else
                        {
                            skuStr      += "\"" + product.skulist[i].attributeValue + "\"";
                            availSkuStr += "\"" + product.skulist[0].attrName + ":" + product.skulist[i].attributeValue + "\": { \"pid\": " + product.skulist[i].id + ", \"stockCount\": \"\", \"stockPrice\": \"" + product.skulist[i].price + "\", \"maketPrice\": \"" + product.marketPrice * 100 + "\" }";
                        }
                    }
                    skuStr += "], \"pName\": \"" + product.skulist[0].attrName + "\" }";

                    //XCWeiXin.DAL.bookSKUDal skuDal = new DAL.bookSKUDal();
                    //IList<Model.bookSKU> skulist = skuDal.SKUConvert(product.skulist);
                    //this.Document.SetValue("skulist", skulist[0]);
                }
                skuStr      += "]";
                availSkuStr += "}";
                if (availSkuStr == "{}")
                {
                    availSkuStr = "{ \"\": { \"pid\": 0, \"stockCount\": \"\", \"stockPrice\": \"" + product.salePrice + "\", \"maketPrice\": \"" + product.marketPrice * 100 + "\" } }";
                }
                this.Document.SetValue("skuStr", skuStr);
                this.Document.SetValue("availSkuStr", availSkuStr);
                this.Document.SetValue("model", product);
            }


            /*
             * BLL.wx_book_product artDal = new BLL.wx_book_product();
             * int pid = MyCommFun.RequestInt("pid");
             * Model.wx_book_product product = artDal.GetModel(pid);
             * int catalogId = product.catalogId;
             * BLL.wx_book_catalog_attribute caBll = new BLL.wx_book_catalog_attribute();
             * IList<Model.wx_book_catalog_attribute> attrlist = caBll.GetModelList("catalogId=" + catalogId + " order by sort_id asc");
             *
             * Model.wx_book_catalog_attribute attr = new Model.wx_book_catalog_attribute();
             *      string skuStr = "{";
             *      string availSkuStr = "{";
             *
             * for (int i = 0; i < attrlist.Count; i++)
             * {
             *  attr = attrlist[i];
             *
             * //    attrStr.Append(" <dt>" + attr.aName + "</dt>");
             *  string[] attrvalueArr = Utils.SplitString(attr.aValue, "\r\n");
             *
             *  if (product != null)
             *  {
             *
             *      if (attrvalueArr != null && attrvalueArr.Length > 0)
             *      {
             *          // string skuStr = "[{ \"pList\": [\"H\", \"H/VVS/32分/14号\"], \"pName\": \"戒指手寸\" }]";
             *          // string   availSku = "{ \"戒指手寸:F-G/VVS/33分/12号\": { \"pid\": 12700, \"stockCount\": \"\", \"stockPrice\": \"1000\", \"maketPrice\": \"0\" },  }";
             *
             *          skuStr += "{ \"pList\": [";
             *          //暂时只支持一种配件
             *          for (int j = 0; j < attrvalueArr.Length; j++)
             *          {
             *              product.skulist[i].price += product.salePrice;
             *              product.skulist[i].price *= 100;
             *              if (i != (product.skulist.Count - 1))
             *              {
             *                  skuStr += "\"" + product.skulist[i].attributeValue + "\",";
             *                  availSkuStr += "\"" + product.skulist[0].attrName + ":" + product.skulist[i].attributeValue + "\": { \"pid\": " + product.skulist[i].id + ", \"stockCount\": \"\", \"stockPrice\": \"" + product.skulist[i].price + "\", \"maketPrice\": \"" + product.marketPrice * 100 + "\" }, ";
             *              }
             *              else
             *              {
             *                  skuStr += "\"" + product.skulist[i].attributeValue + "\"";
             *                  availSkuStr += "\"" + product.skulist[0].attrName + ":" + product.skulist[i].attributeValue + "\": { \"pid\": " + product.skulist[i].id + ", \"stockCount\": \"\", \"stockPrice\": \"" + product.skulist[i].price + "\", \"maketPrice\": \"" + product.marketPrice * 100 + "\" }";
             *              }
             *          }
             *          skuStr += "], \"pName\": \"" + product.skulist[0].attrName + "\" }";
             *
             *          //XCWeiXin.DAL.bookSKUDal skuDal = new DAL.bookSKUDal();
             *          //IList<Model.bookSKU> skulist = skuDal.SKUConvert(product.skulist);
             *          //this.Document.SetValue("skulist", skulist[0]);
             *      }
             *      skuStr += "]";
             *      availSkuStr += "}";
             *      if (availSkuStr == "{}")
             *      {
             *          availSkuStr = "{ \"\": { \"pid\": 0, \"stockCount\": \"\", \"stockPrice\": \"" + product.salePrice + "\", \"maketPrice\": \"" + product.marketPrice * 100 + "\" } }";
             *      }
             *      this.Document.SetValue("skuStr", skuStr);
             *      this.Document.SetValue("availSkuStr", availSkuStr);
             *      this.Document.SetValue("model", product);
             *
             *  }
             * }
             */
        }
Beispiel #6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.wx_book_product model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_book_product(");
            strSql.Append("wid,categoryId,brandId,sku,productName,shortDesc,unit,weight,description,seo_title,seo_keywords,seo_description,focusImgUrl,thumbnailsUrll,recommended,latest,hotsale,specialOffer,costPrice,marketPrice,salePrice,upselling,stock,addDate,vistiCounts,sort_id,productionDate,ExpiryEndDate,updateDate,catalogId)");
            strSql.Append(" values (");
            strSql.Append("@wid,@categoryId,@brandId,@sku,@productName,@shortDesc,@unit,@weight,@description,@seo_title,@seo_keywords,@seo_description,@focusImgUrl,@thumbnailsUrll,@recommended,@latest,@hotsale,@specialOffer,@costPrice,@marketPrice,@salePrice,@upselling,@stock,@addDate,@vistiCounts,@sort_id,@productionDate,@ExpiryEndDate,@updateDate,@catalogId)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",             SqlDbType.Int,          4),
                new SqlParameter("@categoryId",      SqlDbType.Int,          4),
                new SqlParameter("@brandId",         SqlDbType.Int,          4),
                new SqlParameter("@sku",             SqlDbType.VarChar,     20),
                new SqlParameter("@productName",     SqlDbType.VarChar,    500),
                new SqlParameter("@shortDesc",       SqlDbType.VarChar,    500),
                new SqlParameter("@unit",            SqlDbType.VarChar,     10),
                new SqlParameter("@weight",          SqlDbType.Float,        8),
                new SqlParameter("@description",     SqlDbType.VarChar,   2000),
                new SqlParameter("@seo_title",       SqlDbType.VarChar,    200),
                new SqlParameter("@seo_keywords",    SqlDbType.VarChar,    300),
                new SqlParameter("@seo_description", SqlDbType.VarChar,    500),
                new SqlParameter("@focusImgUrl",     SqlDbType.VarChar,    800),
                new SqlParameter("@thumbnailsUrll",  SqlDbType.VarChar,    800),
                new SqlParameter("@recommended",     SqlDbType.Bit,          1),
                new SqlParameter("@latest",          SqlDbType.Bit,          1),
                new SqlParameter("@hotsale",         SqlDbType.Bit,          1),
                new SqlParameter("@specialOffer",    SqlDbType.Bit,          1),
                new SqlParameter("@costPrice",       SqlDbType.Float,        8),
                new SqlParameter("@marketPrice",     SqlDbType.Float,        8),
                new SqlParameter("@salePrice",       SqlDbType.Float,        8),
                new SqlParameter("@upselling",       SqlDbType.Bit,          1),
                new SqlParameter("@stock",           SqlDbType.Int,          4),
                new SqlParameter("@addDate",         SqlDbType.DateTime),
                new SqlParameter("@vistiCounts",     SqlDbType.Int,          4),
                new SqlParameter("@sort_id",         SqlDbType.Int,          4),
                new SqlParameter("@productionDate",  SqlDbType.DateTime),
                new SqlParameter("@ExpiryEndDate",   SqlDbType.DateTime),
                new SqlParameter("@updateDate",      SqlDbType.DateTime),
                new SqlParameter("@catalogId",       SqlDbType.Int,          4),
                new SqlParameter("@ReturnValue",     SqlDbType.Int)
            };
            parameters[0].Value      = model.wid;
            parameters[1].Value      = model.categoryId;
            parameters[2].Value      = model.brandId;
            parameters[3].Value      = model.sku;
            parameters[4].Value      = model.productName;
            parameters[5].Value      = model.shortDesc;
            parameters[6].Value      = model.unit;
            parameters[7].Value      = model.weight;
            parameters[8].Value      = model.description;
            parameters[9].Value      = model.seo_title;
            parameters[10].Value     = model.seo_keywords;
            parameters[11].Value     = model.seo_description;
            parameters[12].Value     = model.focusImgUrl;
            parameters[13].Value     = model.thumbnailsUrll;
            parameters[14].Value     = model.recommended;
            parameters[15].Value     = model.latest;
            parameters[16].Value     = model.hotsale;
            parameters[17].Value     = model.specialOffer;
            parameters[18].Value     = model.costPrice;
            parameters[19].Value     = model.marketPrice;
            parameters[20].Value     = model.salePrice;
            parameters[21].Value     = model.upselling;
            parameters[22].Value     = model.stock;
            parameters[23].Value     = model.addDate;
            parameters[24].Value     = model.vistiCounts;
            parameters[25].Value     = model.sort_id;
            parameters[26].Value     = model.productionDate;
            parameters[27].Value     = model.ExpiryEndDate;
            parameters[28].Value     = model.updateDate;
            parameters[29].Value     = model.catalogId;
            parameters[30].Direction = ParameterDirection.Output;

            List <CommandInfo> sqllist = new List <CommandInfo>();
            CommandInfo        cmd     = new CommandInfo(strSql.ToString(), parameters);

            sqllist.Add(cmd);


            #region  //图片相册
            if (model.albums != null)
            {
                StringBuilder strSql2;
                foreach (Model.wx_book_albums modelt in model.albums)
                {
                    strSql2 = new StringBuilder();
                    strSql2.Append("insert into  wx_book_albums(");
                    strSql2.Append("productId,thumb_path,original_path,remark,add_time,wid)");
                    strSql2.Append(" values (");
                    strSql2.Append("@productId,@thumb_path,@original_path,@remark,@add_time,@wid)");
                    SqlParameter[] parameters2 =
                    {
                        new SqlParameter("@productId",     SqlDbType.Int,        4),
                        new SqlParameter("@thumb_path",    SqlDbType.NVarChar, 255),
                        new SqlParameter("@original_path", SqlDbType.NVarChar, 255),
                        new SqlParameter("@remark",        SqlDbType.NVarChar, 500),
                        new SqlParameter("@add_time",      SqlDbType.DateTime,  30),
                        new SqlParameter("@wid",           SqlDbType.Int, 4)
                    };
                    parameters2[0].Direction = ParameterDirection.InputOutput;
                    parameters2[1].Value     = modelt.thumb_path;
                    parameters2[2].Value     = modelt.original_path;
                    parameters2[3].Value     = modelt.remark;
                    parameters2[4].Value     = DateTime.Now.ToString();
                    parameters2[5].Value     = model.wid;
                    cmd = new CommandInfo(strSql2.ToString(), parameters2);
                    sqllist.Add(cmd);
                }
            }
            #endregion

            #region  //商品属性
            if (model.attrs != null)
            {
                StringBuilder strSql3;
                foreach (Model.wx_book_productAttr_value modelt in model.attrs)
                {
                    strSql3 = new StringBuilder();
                    strSql3.Append("insert into  wx_book_productAttr_value(");
                    strSql3.Append("productId,attributeId,paValue)");
                    strSql3.Append(" values (");
                    strSql3.Append("@productId,@attributeId,@paValue)");
                    SqlParameter[] parameters3 =
                    {
                        new SqlParameter("@productId",   SqlDbType.Int,      4),
                        new SqlParameter("@attributeId", SqlDbType.Int,      4),
                        new SqlParameter("@paValue",     SqlDbType.NVarChar, 300)
                    };
                    parameters3[0].Direction = ParameterDirection.InputOutput;
                    parameters3[1].Value     = modelt.attributeId;
                    parameters3[2].Value     = modelt.paValue;
                    cmd = new CommandInfo(strSql3.ToString(), parameters3);
                    sqllist.Add(cmd);
                }
            }
            #endregion

            #region  //商品配件sku|规格
            if (model.skulist != null)
            {
                StringBuilder strSql4;
                foreach (Model.wx_book_sku modelt in model.skulist)
                {
                    strSql4 = new StringBuilder();
                    strSql4.Append("insert into  wx_book_sku(");
                    strSql4.Append("productId,attributeId,attributeValue,price)");
                    strSql4.Append(" values (");
                    strSql4.Append("@productId,@attributeId,@attributeValue,@price)");
                    SqlParameter[] parameters4 =
                    {
                        new SqlParameter("@productId",      SqlDbType.Int,        4),
                        new SqlParameter("@attributeId",    SqlDbType.Int,        4),
                        new SqlParameter("@attributeValue", SqlDbType.NVarChar, 300),
                        new SqlParameter("@price",          SqlDbType.Float,     10),
                    };
                    parameters4[0].Direction = ParameterDirection.InputOutput;
                    parameters4[1].Value     = modelt.attributeId;
                    parameters4[2].Value     = modelt.attributeValue;
                    parameters4[3].Value     = modelt.price;
                    cmd = new CommandInfo(strSql4.ToString(), parameters4);
                    sqllist.Add(cmd);
                }
            }
            #endregion



            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return((int)parameters[30].Value);
        }