Ejemplo n.º 1
0
 private void deleteSkatesButton_Click(object sender, RoutedEventArgs e)
 {
     if (SkatesGrid.SelectedItems.Count > 0)
     {
         for (int i = 0; i < SkatesGrid.SelectedItems.Count; i++)
         {
             WFAEntity.API.Skates_hire objectSkates = SkatesGrid.SelectedItems[i] as WFAEntity.API.Skates_hire;
             // if (objectSkates != null)
             try
             {
                 using (WFAEntity.API.MyDBContext objectMyDBContext =
                            new WFAEntity.API.MyDBContext())
                 {
                     WFAEntity.API.Skates_hire Skates = WFAEntity.API.DatabaseRequest.GetSkatesById(objectMyDBContext, objectSkates.ID_skates_hire);
                     objectMyDBContext.Skates_hire.Attach(Skates);
                     objectMyDBContext.Skates_hire.Remove(Skates);
                     objectMyDBContext.SaveChanges();
                 }
                 //this.ShowAll(SELECTED_TAB.STUDENT);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
     }
 }
Ejemplo n.º 2
0
 public static void Fill()
 {
     using (WFAEntity.API.MyDBContext objectMyDBContext = new WFAEntity.API.MyDBContext())
     {
         if (objectMyDBContext.Database.Exists() == false)
         {
             Employees employe1 = new Employees("Владимир", "Савин", "Алексеевич", "Пушкина, 4", "02.15.2003", "Администратор", "KING", "1111", "29541514");
             objectMyDBContext.Employees.Add(employe1);
             objectMyDBContext.SaveChanges();
             Employees employe2 = new Employees("Мишуто", "Максим", "Витальевич", "Блохина, 2", "06.04.2004", "Посетитель", "Maks", "1234", "1445124785");
             objectMyDBContext.Employees.Add(employe2);
             objectMyDBContext.SaveChanges();
             Employees employe3 = new Employees("Абрамович", "Даниил", "Владимирович", "Пушкина, 2", "03.09.2003", "Кассир", "ABR", "1234", "1445124785");
             objectMyDBContext.Employees.Add(employe3);
             objectMyDBContext.SaveChanges();
             Skates_hire skatesHire1 = new Skates_hire("1", "10:00", "1", "м", employe1);
             objectMyDBContext.Skates_hire.Add(skatesHire1);
             objectMyDBContext.SaveChanges();
             Skates_hire skatesHire2 = new Skates_hire("2", "20:00", "2", "м", employe2);
             objectMyDBContext.Skates_hire.Add(skatesHire2);
             objectMyDBContext.SaveChanges();
             Skates_hire skatesHire3 = new Skates_hire("3", "11:00", "3", "м", employe1);
             objectMyDBContext.Skates_hire.Add(skatesHire3);
             objectMyDBContext.SaveChanges();
             Skates_hire skatesHire4 = new Skates_hire("4", "12:00", "4", "м", employe2);
             objectMyDBContext.Skates_hire.Add(skatesHire4);
             objectMyDBContext.SaveChanges();
             Client client1 = new Client("Игорев", "Игорь", "Игоревич", "Блохина 46", "294512486");
             objectMyDBContext.Client.Add(client1);
             objectMyDBContext.SaveChanges();
             Other_services service1 = new Other_services("Коньки на прокат", "10", employe2);
             objectMyDBContext.Other_services.Add(service1);
             objectMyDBContext.SaveChanges();
             MK_schedule MK_schedule1 = new MK_schedule("16.02.2020", "200", "17:00", "18:00", employe2, service1);
             objectMyDBContext.MK_schedule.Add(MK_schedule1);
             objectMyDBContext.SaveChanges();
             Ticket ticket1 = new Ticket("5", "200", "Есть", client1, MK_schedule1, service1, skatesHire2);
             objectMyDBContext.Ticket.Add(ticket1);
             objectMyDBContext.SaveChanges();
         }
     }
 }
Ejemplo n.º 3
0
 public Ticket(string Cost, string Amount, string Status, Client Client, MK_schedule MK_schedule, Other_services Other_services, Skates_hire Skates_hire, int ID_Ticket = 0)
 {
     this.Cost   = Cost;
     this.Amount = Amount;
     this.Status = Status;
     //this.Client = Client;
     this.ID_Client         = Client.ID_Client;
     this.ID_MK_schedule    = MK_schedule.ID_MK_schedule;
     this.ID_other_services = Other_services.ID_other_services;
     this.ID_skates_hire    = Skates_hire.ID_skates_hire;
     this.ID_Ticket         = ID_Ticket;
 }
Ejemplo n.º 4
0
 private void ButtonAddEditSkates_Click(object sender, RoutedEventArgs e)
 {
     if (!IsEdit)
     {
         if (textBlockAddEditSize.Text != string.Empty)
         {
             using (WFAEntity.API.MyDBContext objectMyDBContext =
                        new WFAEntity.API.MyDBContext())
             {
                 WFAEntity.API.Skates_hire objectSkates = new WFAEntity.API.Skates_hire(
                     textBlockAddEditSize.Text,
                     textBlockAddEditTime.Text,
                     textBlockAddEditCount.Text,
                     textBlockAddEditType.Text,
                     (WFAEntity.API.Employees)ComboBoxAddEditEmployess.SelectedItem
                     );
                 try
                 {
                     objectMyDBContext.Skates_hire.Add(objectSkates);
                     objectMyDBContext.SaveChanges();
                     MessageBox.Show("Коньки добавлены");
                     this.DialogResult = true;
                     AF.ShowAll();
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error);
                 }
             }
         }
         else
         {
             MessageBox.Show("Заполните все поля!", "Ошибка!");
             this.DialogResult = false;
         }
     }
     else
     {
         using (WFAEntity.API.MyDBContext objectMyDBContext =
                    new WFAEntity.API.MyDBContext())
         {
             WFAEntity.API.Skates_hire objectSkates = new WFAEntity.API.Skates_hire(
                 textBlockAddEditSize.Text,
                 textBlockAddEditTime.Text,
                 textBlockAddEditType.Text,
                 textBlockAddEditCount.Text,
                 (WFAEntity.API.Employees)ComboBoxAddEditEmployess.SelectedItem
                 );
             try
             {
                 objectMyDBContext.Skates_hire.AddOrUpdate(EditSkates);
                 objectMyDBContext.SaveChanges();
                 MessageBox.Show("Клиент Редактирован");
                 this.DialogResult = true;
                 AF.ShowAll();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
     }
 }