Exemple #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_shop_product GetModel(int id, int wid)
        {
            Model.wx_shop_product product = new Model.wx_shop_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_shop_product ");
            strSql.Append(" where id=@id and wid=@wid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",  SqlDbType.Int, 4),
                new SqlParameter("@wid", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;
            parameters[1].Value = wid;
            MxWeiXinPF.Model.wx_shop_product model = new MxWeiXinPF.Model.wx_shop_product();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

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


            return(product);
        }
Exemple #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_shop_product DataRowToModel(DataRow row)
        {
            MxWeiXinPF.Model.wx_shop_product model = new MxWeiXinPF.Model.wx_shop_product();
            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["wid"] != null && row["wid"].ToString() != "")
                {
                    model.wid = int.Parse(row["wid"].ToString());
                }
                if (row["categoryId"] != null && row["categoryId"].ToString() != "")
                {
                    model.categoryId = int.Parse(row["categoryId"].ToString());
                }
                if (row["brandId"] != null && row["brandId"].ToString() != "")
                {
                    model.brandId = int.Parse(row["brandId"].ToString());
                }
                if (row["sku"] != null)
                {
                    model.sku = row["sku"].ToString();
                }
                if (row["productName"] != null)
                {
                    model.productName = row["productName"].ToString();
                }
                if (row["shortDesc"] != null)
                {
                    model.shortDesc = row["shortDesc"].ToString();
                }
                if (row["unit"] != null)
                {
                    model.unit = row["unit"].ToString();
                }
                if (row["weight"] != null && row["weight"].ToString() != "")
                {
                    model.weight = decimal.Parse(row["weight"].ToString());
                }
                if (row["description"] != null)
                {
                    model.description = row["description"].ToString();
                }
                if (row["seo_title"] != null)
                {
                    model.seo_title = row["seo_title"].ToString();
                }
                if (row["seo_keywords"] != null)
                {
                    model.seo_keywords = row["seo_keywords"].ToString();
                }
                if (row["seo_description"] != null)
                {
                    model.seo_description = row["seo_description"].ToString();
                }
                if (row["focusImgUrl"] != null)
                {
                    model.focusImgUrl = row["focusImgUrl"].ToString();
                }
                if (row["thumbnailsUrll"] != null)
                {
                    model.thumbnailsUrll = row["thumbnailsUrll"].ToString();
                }
                if (row["recommended"] != null && row["recommended"].ToString() != "")
                {
                    if ((row["recommended"].ToString() == "1") || (row["recommended"].ToString().ToLower() == "true"))
                    {
                        model.recommended = true;
                    }
                    else
                    {
                        model.recommended = false;
                    }
                }
                if (row["latest"] != null && row["latest"].ToString() != "")
                {
                    if ((row["latest"].ToString() == "1") || (row["latest"].ToString().ToLower() == "true"))
                    {
                        model.latest = true;
                    }
                    else
                    {
                        model.latest = false;
                    }
                }
                if (row["hotsale"] != null && row["hotsale"].ToString() != "")
                {
                    if ((row["hotsale"].ToString() == "1") || (row["hotsale"].ToString().ToLower() == "true"))
                    {
                        model.hotsale = true;
                    }
                    else
                    {
                        model.hotsale = false;
                    }
                }
                if (row["specialOffer"] != null && row["specialOffer"].ToString() != "")
                {
                    if ((row["specialOffer"].ToString() == "1") || (row["specialOffer"].ToString().ToLower() == "true"))
                    {
                        model.specialOffer = true;
                    }
                    else
                    {
                        model.specialOffer = false;
                    }
                }
                if (row["costPrice"] != null && row["costPrice"].ToString() != "")
                {
                    model.costPrice = decimal.Parse(row["costPrice"].ToString());
                }
                if (row["marketPrice"] != null && row["marketPrice"].ToString() != "")
                {
                    model.marketPrice = decimal.Parse(row["marketPrice"].ToString());
                }
                if (row["salePrice"] != null && row["salePrice"].ToString() != "")
                {
                    model.salePrice = decimal.Parse(row["salePrice"].ToString());
                }
                if (row["upselling"] != null && row["upselling"].ToString() != "")
                {
                    if ((row["upselling"].ToString() == "1") || (row["upselling"].ToString().ToLower() == "true"))
                    {
                        model.upselling = true;
                    }
                    else
                    {
                        model.upselling = false;
                    }
                }
                if (row["stock"] != null && row["stock"].ToString() != "")
                {
                    model.stock = int.Parse(row["stock"].ToString());
                }
                if (row["addDate"] != null && row["addDate"].ToString() != "")
                {
                    model.addDate = DateTime.Parse(row["addDate"].ToString());
                }
                if (row["vistiCounts"] != null && row["vistiCounts"].ToString() != "")
                {
                    model.vistiCounts = int.Parse(row["vistiCounts"].ToString());
                }
                if (row["sort_id"] != null && row["sort_id"].ToString() != "")
                {
                    model.sort_id = int.Parse(row["sort_id"].ToString());
                }
                if (row["productionDate"] != null && row["productionDate"].ToString() != "")
                {
                    model.productionDate = DateTime.Parse(row["productionDate"].ToString());
                }
                if (row["ExpiryEndDate"] != null && row["ExpiryEndDate"].ToString() != "")
                {
                    model.ExpiryEndDate = DateTime.Parse(row["ExpiryEndDate"].ToString());
                }
                if (row["updateDate"] != null && row["updateDate"].ToString() != "")
                {
                    model.updateDate = DateTime.Parse(row["updateDate"].ToString());
                }

                if (row["catalogId"] != null && row["catalogId"].ToString() != "")
                {
                    model.catalogId = int.Parse(row["catalogId"].ToString());
                }
            }
            return(model);
        }
Exemple #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MxWeiXinPF.Model.wx_shop_product model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        #region 修改商品的主表

                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update wx_shop_product set ");
                        strSql.Append("wid=@wid,");
                        strSql.Append("categoryId=@categoryId,");
                        strSql.Append("brandId=@brandId,");
                        strSql.Append("sku=@sku,");
                        strSql.Append("productName=@productName,");
                        strSql.Append("shortDesc=@shortDesc,");
                        strSql.Append("unit=@unit,");
                        strSql.Append("weight=@weight,");
                        strSql.Append("description=@description,");
                        strSql.Append("seo_title=@seo_title,");
                        strSql.Append("seo_keywords=@seo_keywords,");
                        strSql.Append("seo_description=@seo_description,");
                        strSql.Append("focusImgUrl=@focusImgUrl,");
                        strSql.Append("thumbnailsUrll=@thumbnailsUrll,");
                        strSql.Append("recommended=@recommended,");
                        strSql.Append("latest=@latest,");
                        strSql.Append("hotsale=@hotsale,");
                        strSql.Append("specialOffer=@specialOffer,");
                        strSql.Append("costPrice=@costPrice,");
                        strSql.Append("marketPrice=@marketPrice,");
                        strSql.Append("salePrice=@salePrice,");
                        strSql.Append("upselling=@upselling,");
                        strSql.Append("stock=@stock,");
                        strSql.Append("addDate=@addDate,");
                        strSql.Append("vistiCounts=@vistiCounts,");
                        strSql.Append("sort_id=@sort_id,");
                        strSql.Append("productionDate=@productionDate,");
                        strSql.Append("ExpiryEndDate=@ExpiryEndDate,");
                        strSql.Append("updateDate=@updateDate,");
                        strSql.Append("catalogId=@catalogId");
                        strSql.Append(" where id=@id");
                        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("@id",              SqlDbType.Int, 4)
                        };
                        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].Value = model.id;

                        DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters);

                        #endregion

                        #region  //添加/修改相册
                        new wx_shop_albums().DeleteList(conn, trans, model.albums, model.id);
                        if (model.albums != null)
                        {
                            StringBuilder strSql3;
                            foreach (Model.wx_shop_albums modelt in model.albums)
                            {
                                strSql3 = new StringBuilder();
                                if (modelt.id > 0)
                                {
                                    strSql3.Append("update  wx_shop_albums set ");
                                    strSql3.Append("productId=@productId,");
                                    strSql3.Append("thumb_path=@thumb_path,");
                                    strSql3.Append("original_path=@original_path,");
                                    strSql3.Append("remark=@remark");
                                    strSql3.Append(" where id=@id");
                                    SqlParameter[] parameters3 =
                                    {
                                        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("@id",            SqlDbType.Int, 4)
                                    };
                                    parameters3[0].Value = modelt.productId;
                                    parameters3[1].Value = modelt.thumb_path;
                                    parameters3[2].Value = modelt.original_path;
                                    parameters3[3].Value = modelt.remark;
                                    parameters3[4].Value = modelt.id;
                                    DbHelperSQL.ExecuteSql(conn, trans, strSql3.ToString(), parameters3);
                                }
                                else
                                {
                                    strSql3.Append("insert into wx_shop_albums(");
                                    strSql3.Append("productId,thumb_path,original_path,remark)");
                                    strSql3.Append(" values (");
                                    strSql3.Append("@productId,@thumb_path,@original_path,@remark)");
                                    SqlParameter[] parameters3 =
                                    {
                                        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)
                                    };
                                    parameters3[0].Value = modelt.productId;
                                    parameters3[1].Value = modelt.thumb_path;
                                    parameters3[2].Value = modelt.original_path;
                                    parameters3[3].Value = modelt.remark;
                                    DbHelperSQL.ExecuteSql(conn, trans, strSql3.ToString(), parameters3);
                                }
                            }
                        }
                        #endregion


                        //删除原来的属性和配件
                        StringBuilder strDeleteSql = new StringBuilder();
                        strDeleteSql.Append("delete from wx_shop_productAttr_value where productId=@productId;");
                        strDeleteSql.Append("delete from wx_shop_sku where productId=productId");
                        SqlParameter[] parameters4 =
                        {
                            new SqlParameter("@productId", SqlDbType.Int, 4)
                        };
                        parameters4[0].Value = model.id;
                        DbHelperSQL.ExecuteSql(conn, trans, strDeleteSql.ToString(), parameters4);



                        #region  //添加新属性
                        if (model.attrs != null)
                        {
                            StringBuilder strSql5;
                            foreach (Model.wx_shop_productAttr_value modelt in model.attrs)
                            {
                                strSql5 = new StringBuilder();
                                strSql5.Append("insert into  wx_shop_productAttr_value(");
                                strSql5.Append("productId,attributeId,paValue)");
                                strSql5.Append(" values (");
                                strSql5.Append("@productId,@attributeId,@paValue)");
                                SqlParameter[] parameters5 =
                                {
                                    new SqlParameter("@productId",   SqlDbType.Int,      4),
                                    new SqlParameter("@attributeId", SqlDbType.Int,      4),
                                    new SqlParameter("@paValue",     SqlDbType.NVarChar, 300)
                                };
                                parameters5[0].Value = model.id;
                                parameters5[1].Value = modelt.attributeId;
                                parameters5[2].Value = modelt.paValue;
                                DbHelperSQL.ExecuteSql(conn, trans, strSql5.ToString(), parameters5);
                            }
                        }
                        #endregion

                        #region  //添加商品配件sku|规格
                        if (model.skulist != null)
                        {
                            StringBuilder strSql6;
                            foreach (Model.wx_shop_sku modelt in model.skulist)
                            {
                                strSql6 = new StringBuilder();
                                strSql6.Append("insert into  wx_shop_sku(");
                                strSql6.Append("productId,attributeId,attributeValue,price)");
                                strSql6.Append(" values (");
                                strSql6.Append("@productId,@attributeId,@attributeValue,@price)");
                                SqlParameter[] parameters6 =
                                {
                                    new SqlParameter("@productId",      SqlDbType.Int,        4),
                                    new SqlParameter("@attributeId",    SqlDbType.Int,        4),
                                    new SqlParameter("@attributeValue", SqlDbType.NVarChar, 300),
                                    new SqlParameter("@price",          SqlDbType.Float,     10),
                                };
                                parameters6[0].Value = model.id;
                                parameters6[1].Value = modelt.attributeId;
                                parameters6[2].Value = modelt.attributeValue;
                                parameters6[3].Value = modelt.price;

                                DbHelperSQL.ExecuteSql(conn, trans, strSql6.ToString(), parameters6);
                            }
                        }
                        #endregion


                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemple #4
0
        /// <summary>
        /// 商品录入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //string[] txtattr = Request.Form.GetValues("txtattr");
            //string[] ddlattr = Request.Form.GetValues("ddlattr");

            #region 商品基本信息
            string strErr = "";

            if (this.txtproductName.Text.Trim().Length == 0)
            {
                strErr += "商品名称不能为空!\\n";
            }

            if (!MyCommFun.isDecimal(txtcostPrice.Text))
            {
                strErr += "成本格式错误!\\n";
            }
            if (!MyCommFun.isDecimal(txtmarketPrice.Text))
            {
                strErr += "市场价格式错误!\\n";
            }
            if (!MyCommFun.isDecimal(txtsalePrice.Text))
            {
                strErr += "销售价格式错误!\\n";
            }
            if (!MyCommFun.isNumber(txtstock.Text))
            {
                strErr += "库存格式错误!\\n";
            }

            if (!MyCommFun.isNumber(txtsort_id.Text))
            {
                strErr += "排序号格式错误!\\n";
            }


            if (strErr != "")
            {
                JscriptMsg(strErr, "back", "Error");
                return;
            }

            Model.wx_userweixin weixin = GetWeiXinCode();


            int    wid        = weixin.id;
            int    categoryId = int.Parse(this.ddlCategoryId.SelectedItem.Value);
            int    catalogId  = int.Parse(this.ddlCatalog.SelectedItem.Value);
            int    brandId    = 0;
            string sku        = this.txtsku.Text;//货号
            if (sku.Trim() == "")
            {
                sku = Utils.Number(8, true);
            }
            string  productName = this.txtproductName.Text;
            string  shortDesc   = this.txtshortDesc.Text;
            string  unit        = "";
            decimal weight      = 0;
            string  description = this.txtdescription.Value;
            //string seo_title = this.txtseo_title.Text;
            //string seo_keywords = this.txtseo_keywords.Text;
            //string seo_description = this.txtseo_description.Text;
            //string focusImgUrl = this.txtfocusImgUrl.Text;
            //string thumbnailsUrll = this.txtthumbnailsUrll.Text;

            bool recommended  = false;
            bool latest       = false;
            bool hotsale      = false;
            bool specialOffer = false;

            int count = cblActionType.Items.Count;

            for (int i = 0; i < count; i++)
            {
                if (cblActionType.Items[i].Selected)
                {
                    if (cblActionType.Items[i].Value == "latest")
                    {
                        latest = true;
                    }
                    else if (cblActionType.Items[i].Value == "hotsale")
                    {
                        hotsale = true;
                    }
                    else if (cblActionType.Items[i].Value == "recommended")
                    {
                        recommended = true;
                    }
                    else if (cblActionType.Items[i].Value == "specialOffer")
                    {
                        specialOffer = true;
                    }
                }
            }

            decimal costPrice   = decimal.Parse(this.txtcostPrice.Text);
            decimal marketPrice = decimal.Parse(this.txtmarketPrice.Text);
            decimal salePrice   = decimal.Parse(this.txtsalePrice.Text);

            bool upselling = true;//上架
            if (radType.SelectedItem.Value == "2")
            {
                upselling = false;
            }
            int      stock       = int.Parse(this.txtstock.Text);
            DateTime addDate     = DateTime.Now;
            int      vistiCounts = 0;
            int      sort_id     = int.Parse(this.txtsort_id.Text);
            //DateTime productionDate = DateTime.Parse(this.txtproductionDate.Text);
            //DateTime ExpiryEndDate = DateTime.Parse(this.txtExpiryEndDate.Text);
            DateTime updateDate = DateTime.Now;

            MxWeiXinPF.Model.wx_shop_product model = new MxWeiXinPF.Model.wx_shop_product();
            model.wid         = wid;
            model.categoryId  = categoryId;
            model.brandId     = brandId;
            model.sku         = sku;
            model.productName = productName;
            model.shortDesc   = shortDesc;
            model.unit        = unit;
            model.weight      = weight;
            model.description = description;
            //model.seo_title = seo_title;
            //model.seo_keywords = seo_keywords;
            //model.seo_description = seo_description;
            //model.focusImgUrl = focusImgUrl;
            //model.thumbnailsUrll = thumbnailsUrll;
            model.recommended  = recommended;
            model.latest       = latest;
            model.hotsale      = hotsale;
            model.specialOffer = specialOffer;
            model.costPrice    = costPrice;
            model.marketPrice  = marketPrice;
            model.salePrice    = salePrice;
            model.upselling    = upselling;
            model.stock        = stock;
            model.addDate      = addDate;
            model.vistiCounts  = vistiCounts;
            model.sort_id      = sort_id;
            //model.productionDate = productionDate;
            //model.ExpiryEndDate = ExpiryEndDate;
            model.updateDate = updateDate;
            model.catalogId  = catalogId;
            #endregion

            #region 保存相册====================
            //检查是否有自定义图片

            string[] albumArr  = Request.Form.GetValues("hid_photo_name");
            string[] remarkArr = Request.Form.GetValues("hid_photo_remark");
            if (albumArr != null && albumArr.Length > 0)
            {
                List <Model.wx_shop_albums> ls = new List <Model.wx_shop_albums>();
                for (int i = 0; i < albumArr.Length; i++)
                {
                    string[] imgArr = albumArr[i].Split('|');
                    if (imgArr.Length == 3)
                    {
                        if (!string.IsNullOrEmpty(remarkArr[i]))
                        {
                            ls.Add(new Model.wx_shop_albums {
                                original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i]
                            });
                        }
                        else
                        {
                            ls.Add(new Model.wx_shop_albums {
                                original_path = imgArr[1], thumb_path = imgArr[2]
                            });
                        }
                    }
                }
                model.albums = ls;
            }
            #endregion

            //属性和sku配件列表
            model.attrs   = AddAttr();
            model.skulist = AddSku();


            MxWeiXinPF.BLL.wx_shop_product bll = new MxWeiXinPF.BLL.wx_shop_product();
            int id = bll.Add(model);
            AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加商品信息,商品信息主键id:" + id); //记录日志

            string frompage = MyCommFun.QueryString("frompage");
            if (frompage == "")
            {
                JscriptMsg("***商品录入成功,请继续录入***!", "product_add.aspx", "Success");
            }
            else
            {
                JscriptMsg("***商品录入成功***!", frompage, "Success");
            }
        }
Exemple #5
0
        /// <summary>
        /// 商品录入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //string[] txtattr = Request.Form.GetValues("txtattr");
            //string[] ddlattr = Request.Form.GetValues("ddlattr");

            #region 商品基本信息
            string strErr = "";

            if (this.txtproductName.Text.Trim().Length == 0)
            {
                strErr += "商品名称不能为空!\\n";
            }

            if (!MyCommFun.isDecimal(txtcostPrice.Text))
            {
                strErr += "成本格式错误!\\n";
            }
            if (!MyCommFun.isDecimal(txtmarketPrice.Text))
            {
                strErr += "市场价格式错误!\\n";
            }
            if (!MyCommFun.isDecimal(txtsalePrice.Text))
            {
                strErr += "销售价格式错误!\\n";
            }
            if (!MyCommFun.isNumber(txtstock.Text))
            {
                strErr += "库存格式错误!\\n";
            }

            if (!MyCommFun.isNumber(txtsort_id.Text))
            {
                strErr += "排序号格式错误!\\n";
            }

            if (strErr != "")
            {
                JscriptMsg(strErr, "back", "Error");
                return;
            }

            Model.wx_userweixin weixin = GetWeiXinCode();

            int wid = weixin.id;
            int categoryId = int.Parse(this.ddlCategoryId.SelectedItem.Value);
            int catalogId = int.Parse(this.ddlCatalog.SelectedItem.Value);
            int brandId = 0;
            string sku = this.txtsku.Text;//货号
            if (sku.Trim() == "")
            {
                sku = Utils.Number(8, true);
            }
            string productName = this.txtproductName.Text;
            string shortDesc = this.txtshortDesc.Text;
            string unit = "";
            decimal weight = 0;
            string description = this.txtdescription.Value;
            //string seo_title = this.txtseo_title.Text;
            //string seo_keywords = this.txtseo_keywords.Text;
            //string seo_description = this.txtseo_description.Text;
            //string focusImgUrl = this.txtfocusImgUrl.Text;
            //string thumbnailsUrll = this.txtthumbnailsUrll.Text;

            bool recommended = false;
            bool latest = false;
            bool hotsale = false;
            bool specialOffer = false;

            int count=cblActionType.Items.Count;

            for (int i = 0; i < count; i++)
            {
                if (cblActionType.Items[i].Selected)
                {
                    if (cblActionType.Items[i].Value == "latest")
                    {
                        latest = true;
                    }
                    else if (cblActionType.Items[i].Value == "hotsale")
                    {
                        hotsale = true;
                    }
                    else if (cblActionType.Items[i].Value == "recommended")
                    {
                        recommended = true;
                    }
                    else if (cblActionType.Items[i].Value == "specialOffer")
                    {
                        specialOffer = true;
                    }
                }
            }

            decimal costPrice = decimal.Parse(this.txtcostPrice.Text);
            decimal marketPrice = decimal.Parse(this.txtmarketPrice.Text);
            decimal salePrice = decimal.Parse(this.txtsalePrice.Text);

            bool upselling = true;//上架
            if (radType.SelectedItem.Value == "2")
            {
                upselling = false;
            }
            int stock = int.Parse(this.txtstock.Text);
            DateTime addDate = DateTime.Now;
            int vistiCounts = 0;
            int sort_id = int.Parse(this.txtsort_id.Text);
            //DateTime productionDate = DateTime.Parse(this.txtproductionDate.Text);
            //DateTime ExpiryEndDate = DateTime.Parse(this.txtExpiryEndDate.Text);
            DateTime updateDate = DateTime.Now;

            MxWeiXinPF.Model.wx_shop_product model = new MxWeiXinPF.Model.wx_shop_product();
            model.wid = wid;
            model.categoryId = categoryId;
            model.brandId = brandId;
            model.sku = sku;
            model.productName = productName;
            model.shortDesc = shortDesc;
            model.unit = unit;
            model.weight = weight;
            model.description = description;
            //model.seo_title = seo_title;
            //model.seo_keywords = seo_keywords;
            //model.seo_description = seo_description;
            //model.focusImgUrl = focusImgUrl;
            //model.thumbnailsUrll = thumbnailsUrll;
            model.recommended = recommended;
            model.latest = latest;
            model.hotsale = hotsale;
            model.specialOffer = specialOffer;
            model.costPrice = costPrice;
            model.marketPrice = marketPrice;
            model.salePrice = salePrice;
            model.upselling = upselling;
            model.stock = stock;
            model.addDate = addDate;
            model.vistiCounts = vistiCounts;
            model.sort_id = sort_id;
            //model.productionDate = productionDate;
            //model.ExpiryEndDate = ExpiryEndDate;
            model.updateDate = updateDate;
            model.catalogId = catalogId;
            #endregion

            #region 保存相册====================
            //检查是否有自定义图片

            string[] albumArr = Request.Form.GetValues("hid_photo_name");
            string[] remarkArr = Request.Form.GetValues("hid_photo_remark");
            if (albumArr != null && albumArr.Length > 0)
            {
                List<Model.wx_shop_albums> ls = new List<Model.wx_shop_albums>();
                for (int i = 0; i < albumArr.Length; i++)
                {
                    string[] imgArr = albumArr[i].Split('|');
                    if (imgArr.Length == 3)
                    {
                        if (!string.IsNullOrEmpty(remarkArr[i]))
                        {
                            ls.Add(new Model.wx_shop_albums { original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] });
                        }
                        else
                        {
                            ls.Add(new Model.wx_shop_albums { original_path = imgArr[1], thumb_path = imgArr[2] });
                        }
                    }
                }
                model.albums = ls;
            }
            #endregion

            //属性和sku配件列表
            model.attrs = AddAttr();
            model.skulist = AddSku();

            MxWeiXinPF.BLL.wx_shop_product bll = new MxWeiXinPF.BLL.wx_shop_product();
               int id= bll.Add(model);
            AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加商品信息,商品信息主键id:" + id); //记录日志

            string frompage = MyCommFun.QueryString("frompage");
            if (frompage == "")
            {
                JscriptMsg("***商品录入成功,请继续录入***!", "product_add.aspx", "Success");
            }
            else
            {
                JscriptMsg("***商品录入成功***!", frompage, "Success");
            }
        }
Exemple #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_shop_product GetModel(int id)
        {
            Model.wx_shop_product product = new Model.wx_shop_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_shop_product ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

            MxWeiXinPF.Model.wx_shop_product model = new MxWeiXinPF.Model.wx_shop_product();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                product= DataRowToModel(ds.Tables[0].Rows[0]);
            }

            return product;
        }
Exemple #7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_shop_product DataRowToModel(DataRow row)
        {
            MxWeiXinPF.Model.wx_shop_product model=new MxWeiXinPF.Model.wx_shop_product();
            if (row != null)
            {
                if(row["id"]!=null && row["id"].ToString()!="")
                {
                    model.id=int.Parse(row["id"].ToString());
                }
                if(row["wid"]!=null && row["wid"].ToString()!="")
                {
                    model.wid=int.Parse(row["wid"].ToString());
                }
                if(row["categoryId"]!=null && row["categoryId"].ToString()!="")
                {
                    model.categoryId=int.Parse(row["categoryId"].ToString());
                }
                if(row["brandId"]!=null && row["brandId"].ToString()!="")
                {
                    model.brandId=int.Parse(row["brandId"].ToString());
                }
                if(row["sku"]!=null)
                {
                    model.sku=row["sku"].ToString();
                }
                if(row["productName"]!=null)
                {
                    model.productName=row["productName"].ToString();
                }
                if(row["shortDesc"]!=null)
                {
                    model.shortDesc=row["shortDesc"].ToString();
                }
                if(row["unit"]!=null)
                {
                    model.unit=row["unit"].ToString();
                }
                if(row["weight"]!=null && row["weight"].ToString()!="")
                {
                    model.weight=decimal.Parse(row["weight"].ToString());
                }
                if(row["description"]!=null)
                {
                    model.description=row["description"].ToString();
                }
                if(row["seo_title"]!=null)
                {
                    model.seo_title=row["seo_title"].ToString();
                }
                if(row["seo_keywords"]!=null)
                {
                    model.seo_keywords=row["seo_keywords"].ToString();
                }
                if(row["seo_description"]!=null)
                {
                    model.seo_description=row["seo_description"].ToString();
                }
                if(row["focusImgUrl"]!=null)
                {
                    model.focusImgUrl=row["focusImgUrl"].ToString();
                }
                if(row["thumbnailsUrll"]!=null)
                {
                    model.thumbnailsUrll=row["thumbnailsUrll"].ToString();
                }
                if(row["recommended"]!=null && row["recommended"].ToString()!="")
                {
                    if((row["recommended"].ToString()=="1")||(row["recommended"].ToString().ToLower()=="true"))
                    {
                        model.recommended=true;
                    }
                    else
                    {
                        model.recommended=false;
                    }
                }
                if(row["latest"]!=null && row["latest"].ToString()!="")
                {
                    if((row["latest"].ToString()=="1")||(row["latest"].ToString().ToLower()=="true"))
                    {
                        model.latest=true;
                    }
                    else
                    {
                        model.latest=false;
                    }
                }
                if(row["hotsale"]!=null && row["hotsale"].ToString()!="")
                {
                    if((row["hotsale"].ToString()=="1")||(row["hotsale"].ToString().ToLower()=="true"))
                    {
                        model.hotsale=true;
                    }
                    else
                    {
                        model.hotsale=false;
                    }
                }
                if(row["specialOffer"]!=null && row["specialOffer"].ToString()!="")
                {
                    if((row["specialOffer"].ToString()=="1")||(row["specialOffer"].ToString().ToLower()=="true"))
                    {
                        model.specialOffer=true;
                    }
                    else
                    {
                        model.specialOffer=false;
                    }
                }
                if(row["costPrice"]!=null && row["costPrice"].ToString()!="")
                {
                    model.costPrice=decimal.Parse(row["costPrice"].ToString());
                }
                if(row["marketPrice"]!=null && row["marketPrice"].ToString()!="")
                {
                    model.marketPrice=decimal.Parse(row["marketPrice"].ToString());
                }
                if(row["salePrice"]!=null && row["salePrice"].ToString()!="")
                {
                    model.salePrice=decimal.Parse(row["salePrice"].ToString());
                }
                if(row["upselling"]!=null && row["upselling"].ToString()!="")
                {
                    if((row["upselling"].ToString()=="1")||(row["upselling"].ToString().ToLower()=="true"))
                    {
                        model.upselling=true;
                    }
                    else
                    {
                        model.upselling=false;
                    }
                }
                if(row["stock"]!=null && row["stock"].ToString()!="")
                {
                    model.stock=int.Parse(row["stock"].ToString());
                }
                if(row["addDate"]!=null && row["addDate"].ToString()!="")
                {
                    model.addDate=DateTime.Parse(row["addDate"].ToString());
                }
                if(row["vistiCounts"]!=null && row["vistiCounts"].ToString()!="")
                {
                    model.vistiCounts=int.Parse(row["vistiCounts"].ToString());
                }
                if(row["sort_id"]!=null && row["sort_id"].ToString()!="")
                {
                    model.sort_id=int.Parse(row["sort_id"].ToString());
                }
                if(row["productionDate"]!=null && row["productionDate"].ToString()!="")
                {
                    model.productionDate=DateTime.Parse(row["productionDate"].ToString());
                }
                if(row["ExpiryEndDate"]!=null && row["ExpiryEndDate"].ToString()!="")
                {
                    model.ExpiryEndDate=DateTime.Parse(row["ExpiryEndDate"].ToString());
                }
                if(row["updateDate"]!=null && row["updateDate"].ToString()!="")
                {
                    model.updateDate=DateTime.Parse(row["updateDate"].ToString());
                }

                if (row["catalogId"] != null && row["catalogId"].ToString() != "")
                {
                    model.catalogId = int.Parse(row["catalogId"].ToString());
                }

            }
            return model;
        }