Esempio n. 1
0
    private void SplitTheBill()
    {
        var originalItems = GetRowsFrom(OriginalBillItems);
        //var newItems = GetRowsFrom(NewBillItems);
        // The long version of the line above....
        List <OrderItem> newItems = new List <OrderItem>();

        foreach (GridViewRow row in NewBillItems.Rows)
        {
            var qtyLabel   = row.FindControl("Quantity") as Label;
            var nameLabel  = row.FindControl("ItemName") as Label;
            var priceLabel = row.FindControl("Price") as Label;
            var data       = new OrderItem()
            {
                Quantity = int.Parse(qtyLabel.Text),
                ItemName = nameLabel.Text,
                Price    = decimal.Parse(priceLabel.Text)
            };

            newItems.Add(data);
        }

        int billId = int.Parse(BillToSplit.Value);

        WaiterController controller = new WaiterController();

        controller.SplitBill(billId, originalItems, newItems);
    }
Esempio n. 2
0
    private void SplitTheBill()
    {
        var originalItems = GetRowsFrom(OriginalBillItems);
        var newItems      = GetRowsFrom(NewBillItems);
        int billId        = int.Parse(BillToSplit.Value);

        WaiterController controller = new WaiterController();

        controller.SplitBill(billId, originalItems, newItems);
    }
    protected void SplitBill_Click(object sender, EventArgs e)
    {
        // Get the original bill items
        List<OrderItem> originalItems = new List<OrderItem>();
        foreach(GridViewRow row in OriginalBillItems.Rows)
        {
            var qtyLabel = row.FindControl("Quantity") as Label;
            var nameLabel = row.FindControl("ItemName") as Label;
            var priceLabel = row.FindControl("Price") as Label;
            originalItems.Add(new OrderItem()
                {
                    ItemName = nameLabel.Text,
                    Quantity = int.Parse(qtyLabel.Text),
                    Price = decimal.Parse(priceLabel.Text)
                });
        }

        // Get the new bill items
        List<OrderItem> newBillItems = new List<OrderItem>();
        foreach (GridViewRow row in NewBillItems.Rows)
        {
            var qtyLabel = row.FindControl("Quantity") as Label;
            var nameLabel = row.FindControl("ItemName") as Label;
            var priceLabel = row.FindControl("Price") as Label;
            newBillItems.Add(new OrderItem()
            {
                ItemName = nameLabel.Text,
                Quantity = int.Parse(qtyLabel.Text),
                Price = decimal.Parse(priceLabel.Text)
            });
        }

        // Call the BLL to split the bill
        int billId = int.Parse(BillToSplit.Value); // from our HiddenField

        WaiterController controller = new WaiterController();
        controller.SplitBill(billId, originalItems, newBillItems);

        ActiveBills.DataBind(); // Refresh the drop-down
        OriginalBillItems.DataSource = null;
        OriginalBillItems.DataBind();
        NewBillItems.DataSource = null;

        NewBillItems.DataBind();
        // Probably should include a message to the user about the new bill.....
    }
Esempio n. 4
0
    protected void SplitBill_Click(object sender, EventArgs e)
    {
        // Get the original bill items
        List <OrderItem> originalItems = new List <OrderItem>();

        foreach (GridViewRow row in OriginalBillItems.Rows)
        {
            var qtyLabel   = row.FindControl("Quantity") as Label;
            var nameLabel  = row.FindControl("Name") as Label;
            var priceLabel = row.FindControl("Price") as Label;
            originalItems.Add(new OrderItem()
            {
                ItemName = nameLabel.Text,
                Quantity = int.Parse(qtyLabel.Text),
                Price    = decimal.Parse(priceLabel.Text)
            });
        }

        // Get the new bill items
        List <OrderItem> newBillItems = new List <OrderItem>();

        foreach (GridViewRow row in NewBillItems.Rows)
        {
            var qtyLabel   = row.FindControl("Quantity") as Label;
            var nameLabel  = row.FindControl("Name") as Label;
            var priceLabel = row.FindControl("Price") as Label;
            newBillItems.Add(new OrderItem()
            {
                ItemName = nameLabel.Text,
                Quantity = int.Parse(qtyLabel.Text),
                Price    = decimal.Parse(priceLabel.Text)
            });
        }

        // Call the BLL to split the bill
        int billid = int.Parse(BillToSplit.Value); // from our HiddenField

        WaiterController controller = new WaiterController();

        controller.SplitBill(billid, originalItems, newBillItems);
    }