コード例 #1
0
ファイル: OrderForm.cs プロジェクト: AWalicode/Restaurant
        /*
         *
         * Konwertuje dane przychodzące z serwisu na List<DishGroup>
         * Generuje menu
         * @param {Object} sender - objekt wywołujący zdarzenie
         * @param {EventArgs} e - Event
         * @return void
         * @return void
         */
        private void OrderForm_Load(object sender, EventArgs e)
        {
            Client = new DishServiceClient();
            var dishGroups = new List <DishGroup>();

            foreach (var dg in Client.GetAllGroupedDishes())
            {
                dishGroups.Add(new DishGroup(dg));
            }
            menuTableLayout.ColumnCount = 3;
            menuTableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F));
            menuTableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
            menuTableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F));

            orderTableLayout.ColumnCount = 3;
            orderTableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 80F));
            orderTableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 10F));
            orderTableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 10F));

            foreach (var dg in dishGroups)
            {
                AddNewRowToMenu(dg.Name, null, null);
                foreach (var dish in dg.Meals)
                {
                    var addOrderButton = new ButtonWithData();
                    addOrderButton.Text      = "Dodaj: " + dish.Price + "zł";
                    addOrderButton.Click    += AddOrder_BtnClick;
                    addOrderButton.Dish      = dish;
                    addOrderButton.GroupName = dg.Name;
                    addOrderButton.Additions = dg.Additions.ToList();
                    AddNewRowToMenu(dish.Name, dish.Description, addOrderButton);
                }
            }
        }
コード例 #2
0
ファイル: OrderForm.cs プロジェクト: AWalicode/Restaurant
        /*
         * Dodaje wiersz do zamówienia
         * @param {int} id - identyfikator dania z zamówienia
         * @return void
         */
        public void AddNewRowToOrder(int id)
        {
            var dwa   = Order.DishWithAdditionses.ElementAt(id);
            var label = new Label();

            orderTableLayout.RowCount++;
            orderTableLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, 50));
            var dishName = dwa.Name.Trim() + "( ";

            foreach (var add in dwa.GetAdditions())
            {
                dishName += add.Name.Trim() + ", ";
            }

            dishName       += " )";
            label.Text      = dishName;
            label.TextAlign = ContentAlignment.MiddleLeft;
            label.AutoSize  = true;
            orderTableLayout.Controls.Add(label);
            orderTableLayout.Controls.Add(new Label {
                Text = dwa.Price.ToString().Trim() + "zł"
            });
            var removeDishButton = new ButtonWithData();

            removeDishButton.Text   = "Usuń";
            removeDishButton.Click += RemoveDish_BtnClick;
            removeDishButton.Id     = id;
            orderTableLayout.Controls.Add(removeDishButton);
        }