예제 #1
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();
        }
예제 #2
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();
        }
예제 #3
0
 private void button5_Click(object sender, EventArgs e)
 {
     using (var context = new FlowerContext())
     {
         context.FlowersInShop.Load();
         dataGridView1.DataSource = context.FlowersInShop.Where(x => x.Flower == textBox5.Text).ToList();
     }
 }
예제 #4
0
 private void button4_Click(object sender, EventArgs e)
 {
     using (var context = new FlowerContext())
     {
         context.PreOrders.Load();
         dataGridView2.DataSource = context.PreOrders.Local.Where(x => x.FIO == textBox4.Text).ToList();
     }
 }
예제 #5
0
 private void AdminF_Load(object sender, EventArgs e)
 {
     using (var context = new FlowerContext())
     {
         context.Flowers.Load();
         context.FlowersInShop.Load();
         dataGridView1.DataSource = context.Flowers.Local.ToList();
         dataGridView2.DataSource = context.FlowersInShop.Local.ToList();
     }
 }
예제 #6
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();
     }
 }
예제 #7
0
 public ManagerForm()
 {
     InitializeComponent();
     using (var context = new FlowerContext())
     {
         context.FlowersInShop.Load();
         context.PreOrders.Load();
         context.Sells.Load();
         flowersInShop            = context.FlowersInShop.ToList();
         dataGridView1.DataSource = context.FlowersInShop.Local.ToList();
         dataGridView2.DataSource = context.PreOrders.Local.ToList();
         dataGridView3.DataSource = context.Sells.Local.ToList();
     }
     comboBox1.Items.AddRange(flowersInShop.Select(x => x.Flower).ToArray());
 }
예제 #8
0
 private void button6_Click(object sender, EventArgs e)
 {
     using (var context = new FlowerContext())
     {
         using (StreamWriter sw = new StreamWriter($"{Directory.GetCurrentDirectory()}\\1.txt"))
         {
             context.Sells.Load();
             var list = context.Sells.ToList();
             foreach (var item in list)
             {
                 sw.WriteLine($"Цветок - {item.FlowerName}");
                 sw.WriteLine($"Количество - {item.FlowerName}");
             }
         }
     }
 }
예제 #9
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();
            }
        }