示例#1
0
        protected void EditProductInfo(object sender, EventArgs e)
        {
            string uploadName = imgfile.Value;//获取待上传图片的完整路径,包括文件名
            //string uploadName = InputFile.PostedFile.FileName;
            string pictureName = oldproductimg.Value;//上传后的图片名,以当前时间为文件名,确保文件名没有重复
            if (imgfile.Value != "")
            {
                int idx = uploadName.LastIndexOf(".");
                string suffix = uploadName.Substring(idx);//获得上传的图片的后缀名
                if (suffix.ToLower() != ".bmp" && suffix.ToLower() != ".jpg" && suffix.ToLower() != ".jpeg" && suffix.ToLower() != ".png" && suffix.ToLower() != ".gif")
                {
                    imgnote.InnerHtml = "<span style=\"color:red\">上传文件必须是图片格式!</span>";
                    return;
                }
                pictureName = DateTime.Now.Ticks.ToString() + suffix;
            }
            try
            {
                if (uploadName != "")
                {
                    string path = Server.MapPath("/Files/Product/");
                    imgfile.PostedFile.SaveAs(path + pictureName);
                }
                productinfo data = new productinfo();
                data.productimg = pictureName;
                data.productname = productname.Value.Trim();
                data.productcode = productcode.Value.Trim();
                data.productprice = Convert.ToDecimal(TypeParse.DbObjToString(productprice.Value, "100.00"));
                data.vipprice = Convert.ToDecimal(TypeParse.DbObjToString(vipprice.Value, "100.00"));
                data.productbrief = productbrief.Value;
                data.productintroduce = editor_id.Value;
                data.smallcategoryid = TypeParse.DbObjToInt(scID.SelectedValue, 1);
                data.bigcategoryid = TypeParse.DbObjToInt(bcID.SelectedValue, 1);
                data.productid = TypeParse.DbObjToInt(sproductid.Value, 0);
                data.brand = brand.Value.Trim();
                data.punit = punit.Value.Trim();
                data.tjtypeid = TypeParse.DbObjToInt(tjtypeID.SelectedValue, 1);
                data.placeid = TypeParse.DbObjToInt(placeID.SelectedValue, 1);
                data.salestate = 0;
                data.editdate = DateTime.Now;

                bool result = product.editproduct(data);
                if (result)
                {
                    Response.Write("<script>alert('编辑产品成功!');location.href='/Manager/ProductList.aspx';</script>");
                    return;
                }
                else
                {
                    Response.Write("<script>alert('编辑产品失败!');location.href='/Manager/ProductList.aspx';</script>");
                    return;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#2
0
文件: product.cs 项目: uwitec/shop
        /// <summary>
        /// 添加产品
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static bool addproduct(productinfo data)
        {
            SqlParameter[] parms = new SqlParameter[16];
            parms[0] = new SqlParameter("@productname", SqlDbType.VarChar, 50);
            parms[0].Value = data.productname;
            parms[1] = new SqlParameter("@productprice", SqlDbType.Decimal);
            parms[1].Value = data.productprice;
            parms[2] = new SqlParameter("@productcode", SqlDbType.VarChar, 50);
            parms[2].Value = data.productcode;
            parms[3] = new SqlParameter("@productbrief", SqlDbType.VarChar, 500);
            parms[3].Value = data.productbrief;
            parms[4] = new SqlParameter("@productintroduce", SqlDbType.Text);
            parms[4].Value = data.productintroduce;
            parms[5] = new SqlParameter("@vipprice", SqlDbType.Decimal);
            parms[5].Value = data.vipprice;
            parms[6] = new SqlParameter("@productimg", SqlDbType.VarChar, 50);
            parms[6].Value = data.productimg;
            parms[7] = new SqlParameter("@smallcategoryid", SqlDbType.Int);
            parms[7].Value = data.smallcategoryid;
            parms[8] = new SqlParameter("@bigcategoryid", SqlDbType.Int);
            parms[8].Value = data.bigcategoryid;
            parms[9] = new SqlParameter("@placeid", SqlDbType.Int);
            parms[9].Value = data.placeid;
            parms[10] = new SqlParameter("@brand", SqlDbType.VarChar, 50);
            parms[10].Value = data.brand;
            parms[11] = new SqlParameter("@tjtypeid", SqlDbType.Int);
            parms[11].Value = data.tjtypeid;
            parms[12] = new SqlParameter("@salestate", SqlDbType.Int);
            parms[12].Value = data.salestate;
            parms[13] = new SqlParameter("@punit", SqlDbType.VarChar, 50);
            parms[13].Value = data.punit;
            parms[14] = new SqlParameter("@adddate", SqlDbType.DateTime);
            parms[14].Value = data.adddate;
            parms[15] = new SqlParameter("@editdate", SqlDbType.DateTime);
            parms[15].Value = data.editdate;

            string sql = "insert into product (productname,productprice,productcode,productbrief,productintroduce,vipprice,productimg,smallcategoryid,bigcategoryid,brand,punit,adddate,editdate,salestate,placeid,tjtypeid) values(@productname,@productprice,@productcode,@productbrief,@productintroduce,@vipprice,@productimg,@smallcategoryid,@bigcategoryid,@brand,@punit,@adddate,@editdate,@salestate,@placeid,@tjtypeid)";
            int result = 0;
            try
            {
                result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return result > 0;
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (RouteData.Values["productid"] != null&&RouteData.Values["productid"].ToString()!="0")
            {
                int nid =TypeParse.DbObjToInt(RouteData.Values["productid"].ToString(),0);
                productinfo item = product.getproductinfo(nid);
                pTitleHTML = item.productname;
                pDATA = item;

                //添加浏览历史

                if (Request.Cookies["tfviewhistory"] != null)
                {
                    string vhstr = Request.Cookies["tfviewhistory"].Value.ToString();
                    string[] vh = vhstr.Split(',');
                    int q = 0;
                    for (int p = 0; p < vh.Length; p++)
                    {
                        if (nid.ToString() == vh[p])
                        {
                            q = 1;
                        }
                    }
                    if (q == 0)
                    {
                        vhstr += "," + nid;
                        Response.Cookies["tfviewhistory"].Value = vhstr;
                        Response.Cookies["tfviewhistory"].Expires = DateTime.Now.AddDays(30);
                    }

                }
                else
                {
                    HttpCookie vcookie = new HttpCookie("tfviewhistory");
                    vcookie.Expires = DateTime.Now.AddDays(30);
                    vcookie.Value = nid.ToString();
                    Response.Cookies.Add(vcookie);
                }

            }
            else
            {
                Response.Redirect("/PList");
            }
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["productid"] != null)
            {
                int id = TypeParse.DbObjToInt(Request.QueryString["productid"].ToString(), 0);
                productinfo data = product.getproductinfo(id);
                productinfoDATA = data;
                if (!Page.IsPostBack)
                {
                    productname.Value = data.productname;
                    productcode.Value = data.productcode;
                    productprice.Value = data.productprice.ToString();
                    productbrief.Value = data.productbrief;
                    sproductid.Value = data.productid.ToString();
                    oldproductimg.Value = data.productimg;
                    vipprice.Value = data.vipprice.ToString();
                    editor_id.Value = data.productintroduce;
                    brand.Value=data.brand;
                    punit.Value=data.punit;

                    //大目录
                    List<categoryinfo> bclist = category.getbigcategory();
                    bcID.DataSource = bclist;
                    bcID.DataTextField = "bigcategory";
                    bcID.DataValueField = "bigcategoryid";
                    bcID.DataBind();
                    for (int k = 0; k < bcID.Items.Count; k++)
                    {
                        if (bcID.Items[k].Value == data.bigcategoryid.ToString())
                        {
                            bcID.SelectedIndex = k;
                        }
                    }

                    //小目录
                    List<categoryinfo> sclist = category.getsmallcategorybyid(TypeParse.DbObjToInt(bcID.SelectedValue, 0));
                    scID.DataSource = sclist;
                    scID.DataTextField = "smallcategory";
                    scID.DataValueField = "smallcategoryid";
                    scID.DataBind();
                    for (int n = 0; n < scID.Items.Count; n++)
                    {
                        if (scID.Items[n].Value == data.smallcategoryid.ToString())
                        {
                            scID.SelectedIndex = n;
                        }
                    }

                    //推荐类型
                    List<categoryinfo> tjlist = category.gettjtype();
                    tjtypeID.DataSource = tjlist;
                    tjtypeID.DataTextField = "tjtype";
                    tjtypeID.DataValueField = "tjtypeid";
                    tjtypeID.DataBind();
                    for (int k = 0; k < tjtypeID.Items.Count; k++)
                    {
                        if (tjtypeID.Items[k].Value == data.tjtypeid.ToString())
                        {
                            tjtypeID.SelectedIndex = k;
                        }
                    }

                    //产地
                    List<categoryinfo> cdlist = category.getplace();
                    placeID.DataSource = cdlist;
                    placeID.DataTextField = "place";
                    placeID.DataValueField = "placeid";
                    placeID.DataBind();
                    for (int k = 0; k < placeID.Items.Count; k++)
                    {
                        if (placeID.Items[k].Value == data.placeid.ToString())
                        {
                            placeID.SelectedIndex = k;
                        }
                    }
                }
            }
        }
示例#5
0
文件: product.cs 项目: uwitec/shop
        public static List<productinfo> bindproductlist(int n)
        {
            List<productinfo> list = new List<productinfo>();
            string sql = "SELECT TOP " + n + " a.productid,a.productname,a.productprice,a.productcode,a.productbrief,a.productintroduce,a.vipprice,a.productimg,a.smallcategoryid,a.bigcategoryid,a.brand,a.punit,a.placeid,a.adddate,a.editdate,a.salestate,a.tjtypeid,b.bigcategory,c.smallcategory,d.place from product a ,bigcategory b ,smallcategory c ,place d where a.smallcategoryid=c.smallcategoryid and b.bigcategoryid=c.bigcategoryid and a.placeid=d.placeid ORDER BY a.editdate desc,a.productid desc";

            try
            {
                DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.connectionstring, CommandType.Text, sql).Tables[0];
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        productinfo item = new productinfo();
                        item.productid = TypeParse.DbObjToInt(dr["productid"].ToString(), 0);
                        item.productname = TypeParse.DbObjToString(dr["productname"].ToString(), "");
                        item.vipprice = Convert.ToDecimal(TypeParse.DbObjToString(dr["vipprice"].ToString(), "100.00"));
                        item.productprice = Convert.ToDecimal(TypeParse.DbObjToString(dr["productprice"].ToString(), "100.00"));
                        item.productcode = TypeParse.DbObjToString(dr["productcode"].ToString(), "");
                        item.productbrief = TypeParse.DbObjToString(dr["productbrief"].ToString(), "");
                        item.productintroduce = TypeParse.DbObjToString(dr["productintroduce"].ToString(), "");
                        item.productimg = TypeParse.DbObjToString(dr["productimg"].ToString(), "");
                        item.smallcategoryid = TypeParse.DbObjToInt(dr["smallcategoryid"].ToString(), 0);
                        item.bigcategoryid = TypeParse.DbObjToInt(dr["bigcategoryid"].ToString(), 0);
                        item.brand = TypeParse.DbObjToString(dr["brand"].ToString(), "");
                        item.punit = TypeParse.DbObjToString(dr["punit"].ToString(), "");
                        item.adddate = TypeParse.DbObjToDateTime(dr["adddate"], DateTime.Now);
                        item.editdate = TypeParse.DbObjToDateTime(dr["editdate"], DateTime.Now);
                        item.salestate = TypeParse.DbObjToInt(dr["salestate"].ToString(), 0);
                        item.placeid = TypeParse.DbObjToInt(dr["placeid"].ToString(), 0);
                        item.place = TypeParse.DbObjToString(dr["place"].ToString(), "");
                        item.tjtypeid = TypeParse.DbObjToInt(dr["tjtypeid"].ToString(), 0);
                        list.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return list;
        }
示例#6
0
文件: product.cs 项目: uwitec/shop
        /// <summary>
        /// 得到单个产品信息
        /// </summary>
        /// <param name="wiid"></param>
        /// <returns></returns>
        public static productinfo getproductinfo(int productid)
        {
            SqlParameter[] parms = new SqlParameter[1];
            parms[0] = new SqlParameter("@productid", SqlDbType.Int);
            parms[0].Value = productid;

            productinfo item = new productinfo();
            string sql = "select a.productid,a.productname,a.productprice,a.productcode,a.productbrief,a.productintroduce,a.vipprice,a.productimg,a.smallcategoryid,a.bigcategoryid,a.brand,a.punit,a.placeid,a.adddate,a.editdate,a.salestate,a.tjtypeid,b.bigcategory,c.smallcategory,d.place from product a ,bigcategory b ,smallcategory c ,place d where a.smallcategoryid=c.smallcategoryid and b.bigcategoryid=c.bigcategoryid and a.placeid=d.placeid and productid=@productid";

            try
            {
                SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.connectionstring, CommandType.Text, sql, parms);
                if (dr.Read())
                {
                    item.productid = TypeParse.DbObjToInt(dr["productid"].ToString(), 0);
                    item.productname = TypeParse.DbObjToString(dr["productname"].ToString(), "");
                    item.vipprice = Convert.ToDecimal(TypeParse.DbObjToString(dr["vipprice"].ToString(), "100.00"));
                    item.productprice = Convert.ToDecimal(TypeParse.DbObjToString(dr["productprice"].ToString(), "100.00"));
                    item.productcode = TypeParse.DbObjToString(dr["productcode"].ToString(), "");
                    item.productbrief = TypeParse.DbObjToString(dr["productbrief"].ToString(), "");
                    item.productintroduce = TypeParse.DbObjToString(dr["productintroduce"].ToString(), "");
                    item.productimg = TypeParse.DbObjToString(dr["productimg"].ToString(), "");
                    item.smallcategoryid = TypeParse.DbObjToInt(dr["smallcategoryid"].ToString(), 0);
                    item.bigcategoryid = TypeParse.DbObjToInt(dr["bigcategoryid"].ToString(), 0);
                    item.bigcategory = TypeParse.DbObjToString(dr["bigcategory"].ToString(), "");
                    item.smallcategory = TypeParse.DbObjToString(dr["smallcategory"].ToString(), "");
                    item.brand = TypeParse.DbObjToString(dr["brand"].ToString(), "");
                    item.punit = TypeParse.DbObjToString(dr["punit"].ToString(), "");
                    item.adddate = TypeParse.DbObjToDateTime(dr["adddate"], DateTime.Now);
                    item.editdate = TypeParse.DbObjToDateTime(dr["editdate"], DateTime.Now);
                    item.salestate = TypeParse.DbObjToInt(dr["salestate"].ToString(), 0);
                    item.placeid = TypeParse.DbObjToInt(dr["placeid"].ToString(), 0);
                    item.place = TypeParse.DbObjToString(dr["place"].ToString(), "");
                    item.tjtypeid = TypeParse.DbObjToInt(dr["tjtypeid"].ToString(), 0);
                    dr.Close();
                    dr.Dispose();
                }

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return item;
        }
示例#7
0
文件: product.cs 项目: uwitec/shop
 /// <summary>
 /// 得到产品
 /// </summary>
 /// <param name="pdata"></param>
 /// <returns></returns>
 public static List<productinfo> getproduct(pageinfo pdata)
 {
     List<productinfo> list = new List<productinfo>();
     try
     {
         DataTable dt = pagehelper.getpagedt(pdata);
         if (dt != null)
         {
             foreach (DataRow dr in dt.Rows)
             {
                 productinfo item = new productinfo();
                 item.productid = TypeParse.DbObjToInt(dr["productid"].ToString(), 0);
                 item.productname = TypeParse.DbObjToString(dr["productname"].ToString(), "");
                 item.vipprice =Convert.ToDecimal(TypeParse.DbObjToString(dr["vipprice"].ToString(),"100.00"));
                 item.productprice = Convert.ToDecimal(TypeParse.DbObjToString(dr["productprice"].ToString(), "100.00"));
                 item.productcode = TypeParse.DbObjToString(dr["productcode"].ToString(), "");
                 item.productbrief = TypeParse.DbObjToString(dr["productbrief"].ToString(), "");
                 item.productintroduce = TypeParse.DbObjToString(dr["productintroduce"].ToString(), "");
                 item.productimg = TypeParse.DbObjToString(dr["productimg"].ToString(), "");
                 item.smallcategoryid = TypeParse.DbObjToInt(dr["smallcategoryid"].ToString(), 0);
                 item.bigcategoryid = TypeParse.DbObjToInt(dr["bigcategoryid"].ToString(), 0);
                 item.smallcategory = TypeParse.DbObjToString(dr["smallcategory"].ToString(), "");
                 item.bigcategory = TypeParse.DbObjToString(dr["bigcategory"].ToString(), "");
                 item.brand = TypeParse.DbObjToString(dr["brand"].ToString(), "");
                 item.punit = TypeParse.DbObjToString(dr["punit"].ToString(), "");
                 item.adddate = TypeParse.DbObjToDateTime(dr["adddate"], DateTime.Now);
                 item.editdate = TypeParse.DbObjToDateTime(dr["editdate"], DateTime.Now);
                 item.salestate = TypeParse.DbObjToInt(dr["salestate"].ToString(), 0);
                 item.placeid = TypeParse.DbObjToInt(dr["placeid"].ToString(), 0);
                 item.place = TypeParse.DbObjToString(dr["place"].ToString(), "");
                 list.Add(item);
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
     }
     return list;
 }