Example #1
0
        private void button3_Click_1(object sender, EventArgs e)
        {
            MessageBox.Show("Пред заказ выполнен успешно");
            string    preOrder = "";
            PreOrders asd      = new PreOrders();

            using (var context = new FlowerContext())
            {
                foreach (var order in orders)
                {
                    preOrder += context.FlowersInShop.FirstOrDefault(x => x.Flower == order.flower).Id + ",";
                }
                preOrder = preOrder.Substring(0, preOrder.Length - 1);
                if (context.PreOrders.FirstOrDefault() != null)
                {
                    asd = context.PreOrders.FirstOrDefault(x => x.id == context.PreOrders.Max(y => y.id));
                }
                context.PreOrders.Add(new PreOrders {
                    FIO = textBox3.Text, id = asd.id + 1, idFlower = preOrder
                });
                context.SaveChanges();
                context.PreOrders.Load();
                dataGridView2.DataSource = context.PreOrders.Local.ToList();
            }
            textBox3.Clear();
            textBox1.Clear();
            orders.Clear();
        }
Example #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Заказ успешен");
            textBox1.Clear();
            using (var context = new FlowerContext())
            {
                foreach (var order in orders)
                {
                    var fl = context.FlowersInShop.FirstOrDefault(x => x.Flower == order.flower);
                    fl.Count -= order.count;
                    context.SaveChanges();
                }

                context.FlowersInShop.Load();
                dataGridView1.DataSource = context.FlowersInShop.Local.ToList();
            }
            using (var context = new FlowerContext())
            {
                var listOrders = GetSellsList(orders);
                foreach (var item in listOrders)
                {
                    context.Sells.Add(item);
                }
                context.SaveChanges();
                context.Sells.Load();
                dataGridView3.DataSource = context.Sells.Local.ToList();
            }
            orders.Clear();
        }
Example #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (var context = new FlowerContext())
     {
         var asd = context.FlowersInShop.Find(int.Parse(textBox1.Text));
         asd.Price = int.Parse(textBox2.Text);
         context.SaveChanges();
         context.FlowersInShop.Load();
         dataGridView2.DataSource = context.FlowersInShop.Local.ToList();
     }
 }
Example #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            var flower = new Flowers();

            flower.id         = int.Parse(textBox3.Text);
            flower.FlowerName = textBox4.Text;
            flower.Photo      = textBox5.Text;
            flower.DateReleas = textBox6.Text;
            using (var context = new FlowerContext())
            {
                context.Flowers.Add(flower);
                context.SaveChanges();
                context.Flowers.Load();
                dataGridView1.DataSource = context.Flowers.Local.ToList();
            }
        }