示例#1
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");
            }
        }
示例#2
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");
            }
        }