Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
0
        private void MyBind()
        {
            int guestnum = 0, totalnum = 0;

            if (!string.IsNullOrEmpty(ids))
            {
                M_Cart        cartMod  = cartBll.SelReturnModel(DataConvert.CLng(ids.Split(',')[0]));
                M_Cart_Travel traveMod = JsonConvert.DeserializeObject <M_Cart_Travel>(cartMod.Additional);
                Pros                = JsonConvert.SerializeObject(traveMod.ProList);
                Guest_Hid2.Value    = JsonConvert.SerializeObject(traveMod.Guest);
                Contract_Hid2.Value = JsonConvert.SerializeObject(traveMod.Contract);
                guestnum            = traveMod.Guest.Count;
            }
            //绑定显示商品
            if (!string.IsNullOrEmpty(Pros))
            {
                JArray    proArr      = (JArray)JsonConvert.DeserializeObject(Pros);
                DataTable proDT       = CreateProDT();//仅用于展示,不参与逻辑
                double    proAllMoney = 0;
                for (int i = 0; i < proArr.Count; i++)
                {
                    DataRow   proDR  = proDT.NewRow();
                    M_Product proMod = proBll.GetproductByid(Convert.ToInt32(proArr[i]["ProID"].ToString()));
                    switch ((M_Product.ClassType)proMod.ProClass)
                    {
                    case M_Product.ClassType.LY:
                    case M_Product.ClassType.JD:
                        break;

                    default:
                        function.WriteErrMsg("[" + proMod.Proname + "]商品类型不正确");
                        break;
                    }
                    if (proMod.ID > 0)
                    {
                        proDR["ID"]      = proMod.ID;
                        proDR["ProName"] = proMod.Proname;
                        proDR["Pronum"]  = proArr[i]["Pronum"].ToString();
                        //----如果传递了编号,则读取多价格信息
                        double  price   = proMod.LinPrice;
                        DataRow priceDR = proBll.GetPriceByCode(proArr[i]["code"], proMod.Wholesalesinfo, ref price);
                        proDR["Price"] = price;
                        if (priceDR != null)
                        {
                            proDR["ProName"] += "(" + priceDR["Proname"] + ")";
                        }
                        //----
                        proDR["AllMoney"] = Convert.ToInt32(proDR["Pronum"]) * Convert.ToDouble(proDR["Price"]);
                        proDR["GoDate"]   = DataConvert.CDate(proArr[i]["GoDate"]);
                        proDR["Remind"]   = HttpUtility.UrlDecode(proArr[i]["Remind"].ToString());
                        proDT.Rows.Add(proDR);
                        proAllMoney += Convert.ToDouble(proDR["AllMoney"]);
                        totalnum    += Convert.ToInt32(proDR["Pronum"]);
                    }
                }
                AllMoney_sp.InnerText  = proAllMoney.ToString("0.00");
                ProList_RPT.DataSource = proDT;
                ProList_RPT.DataBind();
                function.Script(this, "AddGuests(" + (string.IsNullOrEmpty(ids) ? totalnum : guestnum) + ");");
            }
        }