コード例 #1
0
    /// <summary>
    /// 删除一条食物
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        //获取要删除的食物的索引
        LinkButton lbton = (LinkButton)sender;
        DataListItem gvr = (DataListItem)lbton.Parent;
        int foodindex = gvr.ItemIndex;

        OrderFoodControl ofc = new OrderFoodControl();
        OrderControl oc = new OrderControl();
        foodlist = oc.GetProductCarFoodList(userid);
        fooditemlist = oc.GetFoodItemByOrderFoodList(foodlist);

        int foodid = fooditemlist.ElementAt(foodindex).FoodId;
        int orderid = fooditemlist.ElementAt(foodindex).OrderId;
        Session["OrderId"] = orderid;

        //删除订单食物,如果订单里面没有食物了,就删除这个订单
        ofc.DeleteOrderFood(orderid, foodid);
        if(1 == foodlist.Count)
        {
            OrderData _order = new OrderData();
            _order.DeleteOrder(_order.GetOrderById(orderid));
        }
        Response.Write("<script language=javascript>window.location.href=window.location.href;</script>");
    }
コード例 #2
0
    protected void FoodNum_TextChanged(object sender, EventArgs e)
    {
        //获取修改了的TextBox的FoodItem项的索引
        TextBox tb = (TextBox)sender;
        if (tb.Text == "0")
        {
            Page.Response.Write("<script>alert('食物数量不能为0!您可以选择删除该食物。')</script>");
            Response.Write("<script language=javascript>window.location.href=window.location.href;</script>");
            return;
        }
        DataListItem gvr = (DataListItem)tb.Parent;
        int foodindex = gvr.ItemIndex;

        //调用逻辑层修改食物数量
        int userid = Convert.ToInt32(Session["UserId"]);
        OrderFoodControl ofc = new OrderFoodControl();
        OrderControl oc = new OrderControl();
        foodlist = oc.GetProductCarFoodList(userid);
        fooditemlist = oc.GetFoodItemByOrderFoodList(foodlist);
        int foodid = fooditemlist.ElementAt(foodindex).FoodId;
        int foodnum = Convert.ToInt32(tb.Text.ToString());
        ofc.ModifyFoodNum(userid, foodid, foodnum);
        Response.Write("<script language=javascript>window.location.href=window.location.href;</script>");
    }
コード例 #3
0
ファイル: MyOrder.aspx.cs プロジェクト: DaiLiRong/BespeakMeal
    /// <summary>
    /// 按了查看后显示OrderDetailPanel,隐藏OrderListPanel
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        //获取订单的索引
        LinkButton lbton = (LinkButton)sender;
        DataListItem gvr = (DataListItem)lbton.Parent;
        int foodindex = gvr.ItemIndex;

        //获取这个页面上的所有OrderItem,通过foodindex索引得到orderid
        userid = Convert.ToInt32(Session["UserId"]);
        OrderControl oc = new OrderControl();
        IList<OrderItem> orderlisttemp = oc.GetOrderItemListByUserId(userid);
        //按时间排序
        var orderlist1 = orderlisttemp.OrderByDescending(st => st.OrderTime);
        IList<OrderItem> orderlist = new List<OrderItem>();
        foreach (var v in orderlist1)
        {
            orderlist.Add(v);
        }
        //将订单信息保存在Session中
        Session["OrderId"] = orderlist[foodindex].OrderId;
        //Session["OrderReference"] = orderlist[foodindex].OrderReference;
        //Session["OrderTime"] = orderlist[foodindex].OrderTime;
        //Session["OrderStatus"] = orderlist[foodindex].Status;
        Session["OrderTotal"] = orderlist[foodindex].Total;
        //Session["OrderRequest"] = orderlist[foodindex].OtherReq;

        //显示OrderDetailPanel,隐藏OrderListPanel
        OrderDetailPanel.Visible = true;
        OrderListPanel.Visible = false;

        //在OrderDetailPanel中显示该订单信息
        OrderReferenceLabel.Text = orderlist[foodindex].OrderReference;
        OrderTimeLabel.Text = orderlist[foodindex].OrderTime.ToLongDateString() +
            orderlist[foodindex].OrderTime.ToLongTimeString();
        UserNameLabel.Text = Convert.ToString(Session["UserName"]);
        StatusLabel.Text = orderlist[foodindex].Status;
        Total.Text = orderlist[foodindex].Total.ToString();

        //根据订单状态判断显示内容
        switch (orderlist[foodindex].Status)
        {
            case "未付款":
                StatusLabel.ForeColor = System.Drawing.Color.Red;
                PayNowLink.Visible = true;
                CancelLink.Visible = true;
                ConfirmLink.Visible = false;
                break;
            case "已付款":
                StatusLabel.ForeColor = System.Drawing.Color.Green;
                PayNowLink.Visible = false;
                CancelLink.Visible = false;
                ConfirmLink.Visible = false;
                break;
            case "正在送":
                StatusLabel.ForeColor = System.Drawing.Color.Green;
                PayNowLink.Visible = false;
                CancelLink.Visible = false;
                ConfirmLink.Visible = true;
                break;
            case "交易成功":
                StatusLabel.ForeColor = System.Drawing.Color.Green;
                PayNowLink.Visible = false;
                CancelLink.Visible = false;
                ConfirmLink.Visible = false;
                break;
            case "订单已取消":
                StatusLabel.ForeColor = System.Drawing.Color.Gray;
                PayNowLink.Visible = false;
                CancelLink.Visible = false;
                ConfirmLink.Visible = false;
                break;
        }

        //绑定订单食物的菜单到DataList中显示
        //获取购物车信息:食物图片、食物名字、单价、数量、总价
        //从OrderFood中获取的项有:订单Id(购物车)、食物Id、数量
        OrderFoodData _orderFood = new OrderFoodData();
        IList<OrderFood> foodlist = _orderFood.GetOrderFoodListByOrderId(orderlist[foodindex].OrderId);
        if (0 == foodlist.Count)//购物车没有食物,将不显示
        {
            FoodList.Visible = false;
            return;
        }
        else
        {
            FoodList.Visible = true;
        }
        IList<FoodItem> fooditemlist = oc.GetFoodItemByOrderFoodList(foodlist);

        //Total.Text = totalmomey.ToString();
        //将所有菜单绑定到DataList中显示出来
        FoodList.DataSource = fooditemlist;
        FoodList.DataBind();
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Panel1.Visible = true;
        userid = Convert.ToInt32(Session["UserId"]);
        //获取购物车信息:食物图片、食物名字、单价、数量、总价
        //从OrderFood中获取的项有:订单Id(购物车)、食物Id、数量
        OrderControl oc = new OrderControl();
        foodlist = oc.GetProductCarFoodList(userid);
        if (0 == foodlist.Count)//购物车没有食物,将不显示
        {
            Panel1.Visible = false;
            return;
        }
        fooditemlist = oc.GetFoodItemByOrderFoodList(foodlist);

        double totalmomey = GetTotalMomey(fooditemlist);
        Total.Text = totalmomey.ToString();
        Session["OrderTotal"] = Convert.ToString(totalmomey);
        //将所有菜单绑定到DataList中显示出来
        if (!IsPostBack)
        {
            ProductCar.DataSource = fooditemlist;
            ProductCar.DataBind();
            //ProductCar.
        }
    }