コード例 #1
0
ファイル: Add.aspx.cs プロジェクト: tcld2269/hmdfs
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(this.txtTitle.Text.Trim().Length==0)
            {
                strErr+="商品名称不能为空!\\n";
            }
            if (this.ddrCat.SelectedValue == "0")
            {
                strErr += "请选择所属分类!\\n";
            }

            if(strErr!="")
            {
                MessageBox.Show(this,strErr);
                return;
            }

            string picSmall = "", picNormal = "", picBig = "";
            if (flPic.HasFile)
            {
                string result = Common.CommonHelper.Imageupload(flPic, "goods");
                if (result.IndexOf('|') > -1)
                {
                    picSmall = result.Split('|')[3];
                    picNormal = result.Split('|')[2];
                    picBig = result.Split('|')[1];
                }
            }
            int isShow = 0, isNew = 0, isRecommend = 0, isHot = 0;
            foreach (ListItem item in cbl.Items)
            {
                if (item.Value == "show" & item.Selected == true)
                {
                    isShow = 1;
                }
                if (item.Value == "new" & item.Selected == true)
                {
                    isNew = 1;
                }
                if (item.Value == "recommend" & item.Selected == true)
                {
                    isRecommend = 1;
                }
                if (item.Value == "hot" & item.Selected == true)
                {
                    isHot = 1;
                }
            }

            hm.Model.goods model = new hm.Model.goods();
            model.storeId = 1;
            model.storeName = "测试商家";
            model.name = txtTitle.Text;
            model.sn = txtSn.Text;
            model.catId = int.Parse(this.ddrCat.SelectedValue);
            model.catName = this.ddrCat.Items[ddrCat.SelectedIndex].Text;
            model.marketPrice = decimal.Parse(txtMarketPrice.Text);
            model.storePrice = decimal.Parse(txtStorePrice.Text);
            model.freightPrice = decimal.Parse(txtFreightPrice.Text);
            model.buyScore = int.Parse(txtBuyScore.Text);
            model.giveScore = 0;///TODO 赠送积分待完善
            model.picSmall = picSmall;
            model.picNormal = picNormal;
            model.picBig = picBig;
            model.summary = txtSummary.Text;
            model.remark = content.Value;
            model.favCount = 0;
            model.stock = int.Parse(txtStock.Text);
            model.clickNum = 0;
            model.saleNum = 0;
            model.isSku = 0;
            model.isShow = isShow;
            model.isNew = isNew;
            model.isRecommend = isRecommend;
            model.isHot = isHot;
            model.addTime = DateTime.Now;
            model.updateTime = DateTime.Now;
            model.orders = 1000;
            model.status = StatusHelpercs.Goods_Status_Normal;

            int goodsId = bll.Add(model);
            //录入默认图片
            BLL.goodsPic pbll = new BLL.goodsPic();
            Model.goodsPic gmodel = new Model.goodsPic();
            gmodel.goodsId = goodsId;
            gmodel.goodsName = txtTitle.Text;
            gmodel.picBig = picBig;
            gmodel.picNormal = picNormal;
            gmodel.picSmall = picSmall;
            gmodel.orders = 1;
            gmodel.isShow = 1;
            gmodel.isDefault = 1;
            gmodel.addTime = DateTime.Now;
            pbll.Add(gmodel);

            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
コード例 #2
0
ファイル: PicList.aspx.cs プロジェクト: tcld2269/hmdfs
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.QueryString["act"] == null)
                {
                    BindData();
                }
                string pId = "";
                if (Request.QueryString["id"] != null)
                {
                    goodsId = Request.QueryString["id"];
                }
            }
            if (RequsetAjax("addPic"))
            {
                try
                {
                    string goodsId = Request.Form["goodsId"].ToString();
                    string pic = Request.Form["pic"].ToString();
                    Model.goodsPic model = new Model.goodsPic();
                    model.goodsId = int.Parse(goodsId);
                    model.goodsName = new BLL.goods().GetModel(int.Parse(goodsId)).name;
                    model.picBig = pic;
                    model.picNormal = pic;
                    model.picSmall = pic.Replace(".jpg", "_small.jpg");
                    model.orders = 10;
                    model.isShow = 1;
                    model.isDefault = 0;
                    model.addTime = DateTime.Now;
                    bll.Add(model);

                    Response.Write("{\"status\":1,\"msg\":\"成功!\"}");
                }
                catch { Response.Write("{\"status\":0,\"msg\":\"失败!\"}"); }
                Response.End();
            }
            if (RequsetAjax("editOrders"))
            {
                try
                {
                    string id = Request.Form["id"].ToString();
                    string orders = Request.Form["orders"].ToString();
                    Model.goodsPic model = bll.GetModel(int.Parse(id));
                    model.orders = int.Parse(orders);
                    bll.Update(model);

                    Response.Write("{\"status\":1,\"msg\":\"成功!\"}");
                }
                catch { Response.Write("{\"status\":0,\"msg\":\"失败!\"}"); }
                Response.End();
            }
            if (RequsetAjax("editDefault"))
            {
                try
                {
                    string id = Request.Form["id"].ToString();
                    Model.goodsPic model = bll.GetModel(int.Parse(id));

                    BLL.sqlHelper.ExecSql("update goodsPic set isDefault=0 where goodsId=" + model.goodsId.ToString());

                    model.isDefault = 1;
                    bll.Update(model);

                    Response.Write("{\"status\":1,\"msg\":\"成功!\"}");
                }
                catch { Response.Write("{\"status\":0,\"msg\":\"失败!\"}"); }
                Response.End();
            }
            if (RequsetAjax("del"))
            {
                //删除
                try
                {
                    string id = Request.Form["id"].ToString();
                    bll.Delete(int.Parse(id));

                    Response.Write("{\"status\":1,\"msg\":\"成功!\"}");
                }
                catch { Response.Write("{\"status\":0,\"msg\":\"失败!\"}"); }
                Response.End();
            }
        }