コード例 #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
ファイル: goods.cs プロジェクト: tcld2269/hmdfs
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public hm.Model.goods GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,storeId,storeName,name,sn,catId,catName,marketPrice,storePrice,freightPrice,buyScore,giveScore,picSmall,picNormal,picBig,summary,remark,favCount,stock,clickNum,saleNum,isSku,isShow,isNew,isRecommend,isHot,addTime,updateTime,orders,status from goods ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

            hm.Model.goods model=new hm.Model.goods();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["id"]!=null && ds.Tables[0].Rows[0]["id"].ToString()!="")
                {
                    model.id=int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if(ds.Tables[0].Rows[0]["storeId"]!=null && ds.Tables[0].Rows[0]["storeId"].ToString()!="")
                {
                    model.storeId=int.Parse(ds.Tables[0].Rows[0]["storeId"].ToString());
                }
                if(ds.Tables[0].Rows[0]["storeName"]!=null && ds.Tables[0].Rows[0]["storeName"].ToString()!="")
                {
                    model.storeName=ds.Tables[0].Rows[0]["storeName"].ToString();
                }
                if(ds.Tables[0].Rows[0]["name"]!=null && ds.Tables[0].Rows[0]["name"].ToString()!="")
                {
                    model.name=ds.Tables[0].Rows[0]["name"].ToString();
                }
                if(ds.Tables[0].Rows[0]["sn"]!=null && ds.Tables[0].Rows[0]["sn"].ToString()!="")
                {
                    model.sn=ds.Tables[0].Rows[0]["sn"].ToString();
                }
                if(ds.Tables[0].Rows[0]["catId"]!=null && ds.Tables[0].Rows[0]["catId"].ToString()!="")
                {
                    model.catId=int.Parse(ds.Tables[0].Rows[0]["catId"].ToString());
                }
                if(ds.Tables[0].Rows[0]["catName"]!=null && ds.Tables[0].Rows[0]["catName"].ToString()!="")
                {
                    model.catName=ds.Tables[0].Rows[0]["catName"].ToString();
                }
                if(ds.Tables[0].Rows[0]["marketPrice"]!=null && ds.Tables[0].Rows[0]["marketPrice"].ToString()!="")
                {
                    model.marketPrice=decimal.Parse(ds.Tables[0].Rows[0]["marketPrice"].ToString());
                }
                if(ds.Tables[0].Rows[0]["storePrice"]!=null && ds.Tables[0].Rows[0]["storePrice"].ToString()!="")
                {
                    model.storePrice=decimal.Parse(ds.Tables[0].Rows[0]["storePrice"].ToString());
                }
                if(ds.Tables[0].Rows[0]["freightPrice"]!=null && ds.Tables[0].Rows[0]["freightPrice"].ToString()!="")
                {
                    model.freightPrice=decimal.Parse(ds.Tables[0].Rows[0]["freightPrice"].ToString());
                }
                if(ds.Tables[0].Rows[0]["buyScore"]!=null && ds.Tables[0].Rows[0]["buyScore"].ToString()!="")
                {
                    model.buyScore=int.Parse(ds.Tables[0].Rows[0]["buyScore"].ToString());
                }
                if(ds.Tables[0].Rows[0]["giveScore"]!=null && ds.Tables[0].Rows[0]["giveScore"].ToString()!="")
                {
                    model.giveScore=int.Parse(ds.Tables[0].Rows[0]["giveScore"].ToString());
                }
                if(ds.Tables[0].Rows[0]["picSmall"]!=null && ds.Tables[0].Rows[0]["picSmall"].ToString()!="")
                {
                    model.picSmall=ds.Tables[0].Rows[0]["picSmall"].ToString();
                }
                if(ds.Tables[0].Rows[0]["picNormal"]!=null && ds.Tables[0].Rows[0]["picNormal"].ToString()!="")
                {
                    model.picNormal=ds.Tables[0].Rows[0]["picNormal"].ToString();
                }
                if(ds.Tables[0].Rows[0]["picBig"]!=null && ds.Tables[0].Rows[0]["picBig"].ToString()!="")
                {
                    model.picBig=ds.Tables[0].Rows[0]["picBig"].ToString();
                }
                if(ds.Tables[0].Rows[0]["summary"]!=null && ds.Tables[0].Rows[0]["summary"].ToString()!="")
                {
                    model.summary=ds.Tables[0].Rows[0]["summary"].ToString();
                }
                if(ds.Tables[0].Rows[0]["remark"]!=null && ds.Tables[0].Rows[0]["remark"].ToString()!="")
                {
                    model.remark=ds.Tables[0].Rows[0]["remark"].ToString();
                }
                if(ds.Tables[0].Rows[0]["favCount"]!=null && ds.Tables[0].Rows[0]["favCount"].ToString()!="")
                {
                    model.favCount=int.Parse(ds.Tables[0].Rows[0]["favCount"].ToString());
                }
                if(ds.Tables[0].Rows[0]["stock"]!=null && ds.Tables[0].Rows[0]["stock"].ToString()!="")
                {
                    model.stock=int.Parse(ds.Tables[0].Rows[0]["stock"].ToString());
                }
                if(ds.Tables[0].Rows[0]["clickNum"]!=null && ds.Tables[0].Rows[0]["clickNum"].ToString()!="")
                {
                    model.clickNum=int.Parse(ds.Tables[0].Rows[0]["clickNum"].ToString());
                }
                if(ds.Tables[0].Rows[0]["saleNum"]!=null && ds.Tables[0].Rows[0]["saleNum"].ToString()!="")
                {
                    model.saleNum=int.Parse(ds.Tables[0].Rows[0]["saleNum"].ToString());
                }
                if(ds.Tables[0].Rows[0]["isSku"]!=null && ds.Tables[0].Rows[0]["isSku"].ToString()!="")
                {
                    model.isSku=int.Parse(ds.Tables[0].Rows[0]["isSku"].ToString());
                }
                if(ds.Tables[0].Rows[0]["isShow"]!=null && ds.Tables[0].Rows[0]["isShow"].ToString()!="")
                {
                    model.isShow=int.Parse(ds.Tables[0].Rows[0]["isShow"].ToString());
                }
                if(ds.Tables[0].Rows[0]["isNew"]!=null && ds.Tables[0].Rows[0]["isNew"].ToString()!="")
                {
                    model.isNew=int.Parse(ds.Tables[0].Rows[0]["isNew"].ToString());
                }
                if(ds.Tables[0].Rows[0]["isRecommend"]!=null && ds.Tables[0].Rows[0]["isRecommend"].ToString()!="")
                {
                    model.isRecommend=int.Parse(ds.Tables[0].Rows[0]["isRecommend"].ToString());
                }
                if(ds.Tables[0].Rows[0]["isHot"]!=null && ds.Tables[0].Rows[0]["isHot"].ToString()!="")
                {
                    model.isHot=int.Parse(ds.Tables[0].Rows[0]["isHot"].ToString());
                }
                if(ds.Tables[0].Rows[0]["addTime"]!=null && ds.Tables[0].Rows[0]["addTime"].ToString()!="")
                {
                    model.addTime=DateTime.Parse(ds.Tables[0].Rows[0]["addTime"].ToString());
                }
                if(ds.Tables[0].Rows[0]["updateTime"]!=null && ds.Tables[0].Rows[0]["updateTime"].ToString()!="")
                {
                    model.updateTime=DateTime.Parse(ds.Tables[0].Rows[0]["updateTime"].ToString());
                }
                if(ds.Tables[0].Rows[0]["orders"]!=null && ds.Tables[0].Rows[0]["orders"].ToString()!="")
                {
                    model.orders=int.Parse(ds.Tables[0].Rows[0]["orders"].ToString());
                }
                if(ds.Tables[0].Rows[0]["status"]!=null && ds.Tables[0].Rows[0]["status"].ToString()!="")
                {
                    model.status=int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }