예제 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            if (context.Session["id"] != null)
            {
                string         id      = context.Request.QueryString["Goods_id"];
                string         name    = context.Request.Form["name"];
                string         effect  = context.Request.Form["effect"];
                string         price   = context.Request.Form["price"];
                string         factory = context.Request.Form["factory"];
                string         stock   = context.Request.Form["stock"];
                string         norms   = context.Request.Form["norms"];
                string         type    = context.Request.Form["type"];
                HttpPostedFile imgFile = context.Request.Files[0];
                //Image img = new Bitmap(imgFile.InputStream);
                string newFileName = DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + System.IO.Path.GetExtension(imgFile.FileName).ToLower();
                imgFile.SaveAs(context.Server.MapPath("~/Images/product_img/" + newFileName));

                GoodModel good = new GoodModel(name, effect, Convert.ToDouble(price), norms, factory, Convert.ToInt32(stock), DateTime.Now, newFileName, Convert.ToInt32(type));
                good.GoodsId = Convert.ToInt32(id);
                int i = GoodsBLL.UpdateGood(good);

                if (i > 0)
                {
                    context.Response.Write("修改成功!");
                }
                else
                {
                    context.Response.Write("修改失败!");
                }
                context.Response.Write("<a href='ProcessAdminProduct.ashx'>回到商品首页</a>");
                //context.Response.Write(name + "/" + effect + "/" + price + "/" + factory + "/" + stock + "/"+newFileName);
            }
            else
            {
                context.Response.Redirect("~/admin_login.html");
            }
        }