예제 #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>");
    }