Esempio n. 1
0
        public ActionResult DoAddGoods(Shop_Photo photo,Shop_Goods goods)
        {
            #region 上传图片
            //上传和返回(保存到数据库中)的路径
            string uppath = string.Empty;
            string savepath = string.Empty;
            if (Request.Files.Count > 0)
            {
                //  HttpPostedFileBase imgFile = Request.Files["imgName"];
                //if (imgFile != null)
                //{
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    //创建图片新的名称
                    string nameImg = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                    //获得上传图片的路径
                    // string strPath = imgFile.FileName[i].ToString();
                    var httpPostedFileBase = Request.Files[i];
                    if (httpPostedFileBase != null)
                    {
                        string strPath = httpPostedFileBase.FileName.ToString();
                        //获得上传图片的类型(后缀名)
                        string type = strPath.Substring(strPath.LastIndexOf(".") + 1).ToLower();
                        if (ValidateImg(type))
                        {
                            //拼写数据库保存的相对路径字符串
                            savepath = "../../../Uploads/Files/";
                            savepath += nameImg + "." + type;
                            //拼写上传图片的路径
                            uppath = Server.MapPath("~/Uploads/Files/");
                            uppath += nameImg + "." + type;
                            //上传图片
                            httpPostedFileBase.SaveAs(uppath);
                        }
                        else
                        {
                            return Content("<script>alert('请上传正确的格式图片');location.href = '/shop/shop/apply';</script>");
                        }

                    }
                    photo.PhotoURL = savepath;
                    photo.PhontName = nameImg;
                    photo.BoolYX = true;

                    //}

                }

            }
            #endregion

            goods.StoreId = Convert.ToInt32(Session["stroeid"]);
            if (BuildFactory.GoodsFactory().Apply(goods,photo))
            {
                return Content("<script>alert('添加成功');window.opener=null;window.close();</script>");
            }
            ;

            return Content("<script>alert('添加失败,请重新申请');location.href = '/shop/shop/addgoods';</script>");
        }
Esempio n. 2
0
        public ActionResult DoOrder(Shop_Goods goods, Shop_Store store, Shop_People people, Shop_Order order, int stock)
        {
            BuyGoods buyGoods= BuildFactory.GoodsFactory().GetBuyTotl(goods.GoodsId);

            if (buyGoods != null && (buyGoods.buyNum + order.buyNum) > stock)
            {

                return Content("<script>alert('订单数已超库存,库存尚余" + (stock - buyGoods.buyNum) + "个,请调整订单数或联系商家!');;</script>");
            }

            if (BuildFactory.GoodsFactory().GenOrder(people,store,order))
            {
                return Content("<script>alert('已发送购买信息,卖家收到信息后会进行联系确认');location.href = 'https://www.alipay.com/'</script>");
            }
            ;

            return Content("<script>alert('购买信息填写出错,请重新填写');;</script>");
        }