Exemple #1
0
        private void buttonRepeat_Click(object sender, EventArgs e)
        {
            List <int> orderLines = new List <int>();
            double     sum        = 0;

            var lines = (from line in ctx.HISTORY_LINES
                         where line.HL_ORDER_HEADER == history_header
                         select line).ToList();

            foreach (var line in lines)
            {
                var x = new ORDER_LINES
                {
                    OL_ITEM     = line.HL_ITEM,
                    OL_QUANTITY = line.HL_QUANTITY
                };

                var item = (from i in ctx.ITEMS
                            where i.I_ID == x.OL_ITEM
                            select i).First();

                sum += (double)item.I_PRICE * x.OL_QUANTITY;

                ctx.ORDER_LINES.Add(x);
                ctx.SaveChanges();

                orderLines.Add(x.OL_ID);
            }

            FormOrderHeader orderHeader = new FormOrderHeader(orderLines, user_id, sum);

            orderHeader.ShowDialog(this);
            orderHeader.Dispose();
            this.Close();
        }
        private void buttonOrder_Click(object sender, EventArgs e)
        {
            if (orderLines.Count() == 0)
            {
                MessageBox.Show("Страви не обрано!", "Замовлення");
                return;
            }

            finished = true;

            FormOrderHeader orderHeader = new FormOrderHeader(orderLines, user_id, sum);

            orderHeader.ShowDialog(this);
            orderHeader.Dispose();
            this.Close();
        }