Example #1
0
 private void btnDel_Click(object sender, RoutedEventArgs e)
 {
     if (dgZak.SelectedItem != null)
     {
         Zakazi zak   = dgZak.SelectedItem as Zakazi;
         int    idZak = Convert.ToInt32(zak.idZakaza);
         int    Stol  = Convert.ToInt32(zak.Stol);
         if (MessageBox.Show("Вы точно хотите удалить этот заказ?", "Внимание", MessageBoxButton.YesNoCancel) == MessageBoxResult.Yes)
         {
             foreach (var item in db.ZakazBluda)
             {
                 if (item.idZakaza == idZak)
                 {
                     db.ZakazBluda.Remove(item);
                 }
             }
             db.Zakazi.Remove(zak);
             foreach (var item in db.Stoli)
             {
                 if (Stol == item.idStola)
                 {
                     item.IsBusy = true;
                 }
             }
             db.SaveChanges();
             dgZak.ItemsSource  = db.Zakazi.Where(t => t.DateCloseZakaz.ToString() == "").ToList();
             dgZakC.ItemsSource = db.Zakazi.Where(t => t.DateCloseZakaz.ToString() != "").ToList();
         }
     }
 }
Example #2
0
        private void btnCloseZak_Click(object sender, RoutedEventArgs e)
        {
            if (dgZak.SelectedItem != null)
            {
                Zakazi zak   = dgZak.SelectedItem as Zakazi;
                int    idZak = Convert.ToInt32(zak.idZakaza);
                int    Stol  = Convert.ToInt32(zak.Stol);
                if (zak.Closed == false)
                {
                    if (MessageBox.Show("Вы уверены что хотите закрыть заказ?", "Внимание", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        foreach (var item in db.Zakazi)
                        {
                            if (idZak == item.idZakaza)
                            {
                                item.DateCloseZakaz = DateTime.Now;
                                item.Closed         = true;
                                if (item.TypeZakaz == 2)
                                {
                                    BookingStol t = (BookingStol)db.BookingStol.Where(tt => tt.idStol == item.Stoli.idStola && tt.Status == false).FirstOrDefault();
                                    t.Status = true;
                                }
                            }
                        }
                    }

                    foreach (var i in db.Stoli)
                    {
                        if (Stol == i.idStola)
                        {
                            i.IsBusy = true;
                        }
                    }
                    db.SaveChanges();

                    dgZak.ItemsSource  = db.Zakazi.Where(t => t.DateCloseZakaz.ToString() == "").ToList();
                    dgZakC.ItemsSource = db.Zakazi.Where(t => t.DateCloseZakaz.ToString() != "").ToList();

                    foreach (var item in db.Employee)
                    {
                        if (item.idEmployee == zak.Employee)
                        {
                            item.NumberOfSales = 0;
                            item.NumberOfSales++;
                        }
                    }
                    db.SaveChanges();
                }
                else
                {
                    MessageBox.Show("Заказ уже закрыт!");
                }
            }
            else
            {
                MessageBox.Show("Выберите заказ!");
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Zakazi zakazi = new Zakazi();

            txtStol.Text           = stol.ToString();
            txtSumma.Text          = summ.ToString();
            txtSummaS.Text         = summS.ToString();
            txtDateOpen.Text       = open.ToString();
            txtDateClose.Text      = close.ToString();
            dgZakBludo.ItemsSource = db.ZakazBluda.Where(t => t.idZakaza == idZak).ToArray().ToList();
        }
Example #4
0
        private void dgZakC_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Zakazi zakazi = dgZakC.SelectedItem as Zakazi;
            int    idZak  = Convert.ToInt32(zakazi.idZakaza);
            int    stol   = Convert.ToInt32(zakazi.Stol);
            double summ   = Convert.ToInt32(zakazi.SummaZakaza);
            double summS  = Convert.ToDouble(zakazi.SummaZakazaS);
            string open   = Convert.ToString(zakazi.DateOpenZakaz);
            string close  = Convert.ToString(zakazi.DateCloseZakaz);

            new ZakazInfoWindow(idZak, stol, summ, summS, open, close).ShowDialog();
        }
Example #5
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (stat == 0)
            {
                Zakazi zak = new Zakazi();

                if (lblDate.Content != "")
                {
                    zak.DateOpenZakaz = DateTime.Parse(lblDate.Content.ToString());
                    zak.TypeZakaz     = 2;
                }
                else
                {
                    zak.DateOpenZakaz = DateTime.Now;
                    lblDate.Content   = DateTime.Now;
                    zak.TypeZakaz     = 1;
                }

                zak.Stol = idTable;

                zak.SummaZakaza = 0;
                var emp = db.Employee.Where(i => i.Login.UserName == Login).FirstOrDefault();
                zak.Employee = emp.idEmployee;


                zak.Closed = false;
                db.Zakazi.Add(zak);
                db.SaveChanges();
                idZak = zak.idZakaza;

                txtbStol.Text     = Convert.ToString(idTable);
                txtbEmployee.Text = emp.Surname.ToString();

                btnAdd.IsEnabled = true;
            }
            else
            {
                idZak = stat;
                var zakaz = db.Zakazi.Where(i => i.idZakaza == stat).FirstOrDefault();
                txtbEmployee.Text = zakaz.Employee1.Surname;
                if (zakaz.idSCard != null)
                {
                    txtbSkidCard.Text    = zakaz.idSCard;
                    cbSearchSC.IsChecked = true;
                    txtItogS.Text        = zakaz.SummaZakazaS.ToString();
                }
                if (zakaz.TypeZakaz == 1)
                {
                    lblStasus.Content = "Обычный";
                }
                else
                {
                    lblStasus.Content = "Предзаказ";
                }
                lblDate.Content        = zakaz.DateOpenZakaz.ToString();
                txtItog.Text           = zakaz.SummaZakaza.ToString();
                txtbStol.Text          = zakaz.Stol.ToString();
                dgOrdBludo.ItemsSource = db.ZakazBluda.Where(i => i.idZakaza == idZak).ToList();
                btnAdd.IsEnabled       = true;
                btnDel.IsEnabled       = true;
                btnSave.IsEnabled      = true;
                Summa = zakaz.SummaZakaza;
                //SummaS = (double)zakaz.SummaZakazaS;
            }
        }
Example #6
0
        private void dgZak_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Zakazi zakazi = dgZak.SelectedItem as Zakazi;

            new RegOrders(zakazi.Stol, zakazi.idZakaza, Login).ShowDialog();
        }
Example #7
0
 private void btnReports_Click(object sender, RoutedEventArgs e)
 {
     Zakazi zak111 = dgZak.SelectedItem as Zakazi;
 }