Exemplo n.º 1
0
 /// <summary>
 /// 添加订单
 /// </summary>
 protected string addcart(int spid)
 {
     try
     {
         if (spid <= 0)
         {
             return("{\"result\":0,\"msg\":\"id错误\"}");
         }
         Model.goodsInfo go = BLL.goodsBLL.GetModel(spid);
         if (go != null && go.GoodsId == spid)
         {
             Model.g_orderInfo gor = new g_orderInfo();
             gor.uid         = uid;
             gor.companyid   = 0;
             gor.goods_count = Convert.ToInt32(Request.Form["number"]);
             gor.goodsid     = spid;
             gor.totalprice  = Convert.ToDecimal(Request.Form["total_price"]);
             gor.ordertype   = go.GoodsType;
             string resultMsg = "";
             int    result    = new BLL.g_orderBLL().add(gor, ref resultMsg);
             if (result > 0)
             {
                 return("{\"result\":" + result + ",\"msg\":\"\"}");
             }
             return("{\"result\":" + result + ",\"msg\":\"" + resultMsg.Replace("\"", "").Replace("\r", "").Replace("\n", "") + "\"}");
         }
         return("{\"result\":0,\"msg\":\"无对应的商品信息\"}");
     }
     catch (Exception exc) {
         return("{\"result\":0,\"msg\":\"" + exc.Message.Replace("\"", "").Replace("\r", "").Replace("\n", "") + "\"}");
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 添加订单
        /// </summary>
        public void addorder()
        {
            BLL.g_orderBLL    gorderbll = new BLL.g_orderBLL();
            Model.g_orderInfo gorder    = new Model.g_orderInfo();

            int overwritegoodsid = Common.Utils.ObjectToint(Request.Form["hidoosid"]);

            if (overwritegoodsid <= 0)
            {
                Response.Write("<script>parent.successful('商品ID错误');</script>");
                return;
            }
            goodsInfo goodsinfo = BLL.goodsBLL.GetModel(overwritegoodsid);

            if (goodsinfo == null || goodsinfo.GoodsId != overwritegoodsid)
            {
                Response.Write("<script>parent.successful('不存在对应的商品');</script>");
                return;
            }

            int count = Common.Utils.ObjectToint(Request.Form["inputcount"]);

            if (count <= 0)
            {
                Response.Write("<script>parent.successful('至少要购买1份');</script>");
                return;
            }
            gorder.goodsid   = overwritegoodsid;
            gorder.ordertype = goodsinfo.GoodsType;
            //gorder.pay_price = Common.Utils.ObjectTodecimal(Request.Form["h_moneysum"], 2);
            //gorder.totalprice = Common.Utils.ObjectTodecimal(Request.Form["h_moneysum"], 2);
            gorder.goods_count = count;
            gorder.uid         = base.uid;

            decimal orderprice = goodsinfo.Price * gorder.goods_count;

            gorder.totalprice = orderprice;
            gorder.pay_price  = orderprice;

            string resultMeg = "";
            int    result    = gorderbll.add(gorder, ref resultMeg);

            if (result > 0)
            {
                if (gorder.ordertype == (int)Common.enum_goodstype.goodstype_2)
                {
                    Response.Write("<script>parent.successful('" + result + "');</script>");
                }
                else
                {
                    Response.Write("<script>parent.successful2('" + result + "');</script>");
                }

                return;
            }
            else
            {
                Response.Write("<script>parent.fail('" + resultMeg.Replace("'", "").Replace("\n", "").Replace("\r", "") + "');</script>");
                return;
            }
        }