Exemplo n.º 1
0
 protected void ProRPT_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     switch (e.CommandName.ToString())
     {
     case "del":
         int id = Convert.ToInt32(e.CommandArgument);
         cartBll.DelByIDS(CartCookID, buser.GetLogin().UserName, id.ToString());
         break;
     }
     MyBind();
 }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            B_User.CheckIsLogged(Request.RawUrl);
            if (!IsPostBack)
            {
                M_UserInfo mu = buser.GetLogin(false);
                switch (SType)
                {
                case 1:    //酒店
                //{
                //    M_Cart_Hotel model = new M_Cart_Hotel();
                //    model.UserID = buser.GetLogin().UserID;
                //    //model.HotelName = Request["HotelName"];
                //    model.GoDate = Convert.ToDateTime(Request["GoDate"]);
                //    model.OutDate = Convert.ToDateTime(Request["OutDate"]);
                //    //-------------联系人(全部都进行一定的规范)
                //    model.Guest.Add(new M_Cart_Contract(Server.UrlDecode(Request["GuestName"]), Request["GuestMobile"], "", ""));
                //    for (int i = 0; i < Request["ContractName"].Split(',').Length; i++)
                //    {
                //        string name = Request["ContractName"].Split(',')[i];
                //        string mobile = Request["ContractMobile"].Split(',')[i];
                //        model.Contract.Add(new M_Cart_Contract(Server.UrlDecode(name), Request["ContractMobile"], "", ""));
                //    }
                //    //-------------购物车
                //    ProModel pro = new ProModel() { ProID = DataConvert.CLng(Request["ProID"]), Pronum = DataConvert.CLng(Request["Pronum"]) };
                //    string addition = JsonConvert.SerializeObject(model);
                //    int cartid = AddCart(pro, mu, addition);
                //    Response.Redirect("/Cart/GetOrderInfo.aspx?ProClass=8&ids=" + cartid);
                //}
                //break;

                case 2:    //旅游
                {
                    M_Cart_Travel model       = new M_Cart_Travel();
                    JArray        proArr      = (JArray)JsonConvert.DeserializeObject(Pros_Hid);
                    JArray        guestArr    = (JArray)JsonConvert.DeserializeObject(Guest_Hid);
                    JArray        contractArr = (JArray)JsonConvert.DeserializeObject(Contract_Hid);
                    if (string.IsNullOrEmpty(Pros_Hid) || string.IsNullOrEmpty(Guest_Hid) || string.IsNullOrEmpty(Contract_Hid))
                    {
                        function.WriteErrMsg("生成订单失败,提交的信息不完全!");
                    }
                    foreach (JObject pro in proArr)        //赋值店铺信息
                    {
                        ProModel  proMod  = JsonConvert.DeserializeObject <ProModel>(pro.ToString());
                        M_Product proInfo = proBll.GetproductByid(proMod.ProID);
                        proMod.ProName = proInfo.Proname;
                        proMod.StoreID = proInfo.UserShopID;
                        double  price   = proInfo.LinPrice;
                        DataRow priceDR = proBll.GetPriceByCode(proMod.code, proInfo.Wholesalesinfo, ref price);
                        if (priceDR != null)
                        {
                            proMod.ProName += "(" + priceDR["Proname"] + ")";
                        }
                        model.ProList.Add(proMod);
                    }
                    foreach (JObject guest in guestArr)
                    {
                        model.Guest.Add(JsonConvert.DeserializeObject <M_Cart_Contract>(guest.ToString()));
                    }
                    foreach (JObject contract in contractArr)
                    {
                        model.Contract.Add(JsonConvert.DeserializeObject <M_Cart_Contract>(contract.ToString()));
                    }
                    //-------------购物车
                    string addition = JsonConvert.SerializeObject(model);
                    if (!string.IsNullOrEmpty(Request.Form["ctl00$Content$IDS_Hid"]))
                    {
                        cartBll.DelByIDS(CartCookID, mu.UserName, Request.Form["ctl00$Content$IDS_Hid"]);
                    }
                    //-------------跳转
                    string ids = "";
                    foreach (ProModel pro in model.ProList)
                    {
                        ids += AddCart(pro, mu, addition) + ",";
                    }
                    ids = ids.TrimEnd(',');
                    int proclass = (SType == 1 ? 8 : 7);
                    Response.Redirect("/Cart/GetOrderInfo.aspx?ProClass=" + proclass + "&ids=" + ids);
                }
                break;

                case 3:    //航班
                           //Response.Redirect("/Cart/GetOrderInfo.aspx?ProClass=&ids=" + ids);
                    break;

                default:
                    function.WriteErrMsg("未知的提交类型");
                    break;
                }
            }
        }
Exemplo n.º 3
0
        public ContentResult OrderCom()
        {
            M_APIResult retMod = new M_APIResult(M_APIResult.Failed);

            switch (action)
            {
            case "cart_del":
            {
                cartBll.DelByIDS(CartCookID, buser.GetLogin().UserName, ids);
                retMod.retcode = M_APIResult.Success;
            }
            break;

            case "setnum":      //兼容
            case "cart_setnum": //ID,数量,Cookies,可不登录,数量不能小于1
            {
                int id     = DataConverter.CLng(GetParam("id"));
                int pronum = DataConverter.CLng(GetParam("pronum"));
                if (id < 1 || pronum < 1)
                {
                    retMod.retmsg = "商品ID与数量不能小于1";
                }
                else if (string.IsNullOrEmpty(CartCookID))
                {
                    retMod.retmsg = "CartCookID不存在";
                }
                else
                {
                    cartBll.UpdateProNum(CartCookID, mu.UserID, id, pronum);
                    retMod.retcode = M_APIResult.Success;
                }
            }
            break;

            case "deladdress":
            {
                int id = DataConverter.CLng(GetParam("id"));
                if (mu == null || mu.UserID == 0 || id < 1)
                {
                    return(Content(Failed.ToString()));
                }
                else
                {
                    receBll.U_DelByID(id, mu.UserID); return(Content(Success.ToString()));
                }
            }

            case "arrive":
            {
                string    flow   = GetParam("flow");
                double    money  = double.Parse(GetParam("money"));
                DataTable cartdt = cartBll.SelByCartID(CartCookID, mu.UserID, -100, ids);
                if (cartdt.Rows.Count < 1)
                {
                    retMod.retmsg = "购物车为空"; return(Content(retMod.ToString()));
                }
                M_Arrive        avMod  = avBll.SelModelByFlow(flow, mu.UserID);
                M_Arrive_Result arrMod = avBll.U_CheckArrive(avMod, mu.UserID, cartdt, money);
                if (arrMod.enabled)
                {
                    retMod.retcode = M_APIResult.Success;
                    //已优惠金额,优惠后金额
                    retMod.result = Newtonsoft.Json.JsonConvert.SerializeObject(arrMod);
                }
                else
                {
                    retMod.retmsg = arrMod.err;
                }
            }
            break;

            default:
                retMod.retmsg = "[" + action + "]接口不存在";
                break;
            }
            return(Content(retMod.ToString()));
        }