Esempio n. 1
0
 private void addBTN_Click(object sender, EventArgs e)
 {
     if (user.Position != Admin)
     {
         MessageBox.Show("Вы можете только просматривать!");
         return;
     }
     if (currentModel == Employee)
     {
         EmpForm emp = new EmpForm(new Employee(), 1);
         if (emp.ShowDialog() == DialogResult.Yes)
         {
             repository.Employees.Add(emp.Employee);
             objectsCB.Items.Add(emp.Employee.FullName);
             repository.Save();
         }
         return;
     }
     if (currentModel == Customer)
     {
         CustForm cust = new CustForm(new Customer(), 1);
         if (cust.ShowDialog() == DialogResult.Yes)
         {
             repository.Customers.Add(cust.Customer);
             objectsCB.Items.Add(cust.Customer.FullName);
             repository.Save();
         }
         return;
     }
     if (currentModel == Hall)
     {
         HallForm hall = new HallForm(new Hall(), 1);
         if (hall.ShowDialog() == DialogResult.Yes)
         {
             repository.Halls.Add(hall.Hall);
             objectsCB.Items.Add(hall.Hall.Name);
             repository.Save();
         }
         return;
     }
     if (currentModel == Rent)
     {
         RentForm rent = new RentForm(new Rent(), 1, repository.Customers, repository.Halls, repository.Rents);
         if (rent.ShowDialog() == DialogResult.Yes)
         {
             repository.Rents.Add(rent.Rent);
             objectsCB.Items.Add(rent.Rent.TimeStart.ToString());
             repository.Save();
         }
         return;
     }
     MessageBox.Show("Выберите модель!");
 }
Esempio n. 2
0
 private void editBTN_Click(object sender, EventArgs e)
 {
     if (user.Position != Admin)
     {
         MessageBox.Show("Вы можете только просматривать!");
         return;
     }
     if (currentModel == Employee && currentId != -1)
     {
         Employee employee = repository.Employees.FirstOrDefault(em => em.ID == currentId);
         if (employee == null)
         {
             return;
         }
         EmpForm emp = new EmpForm(employee, 0);
         if (emp.ShowDialog() == DialogResult.Yes)
         {
             objectsCB.SelectedItem = employee.FullName;
             repository.Save();
         }
         return;
     }
     if (currentModel == Customer && currentId != -1)
     {
         Customer customer = repository.Customers.FirstOrDefault(c => c.ID == currentId);
         if (customer == null)
         {
             return;
         }
         CustForm cust = new CustForm(customer, 0);
         if (cust.ShowDialog() == DialogResult.Yes)
         {
             objectsCB.SelectedItem = customer.FullName;
             repository.Save();
         }
         return;
     }
     if (currentModel == Hall && currentId != -1)
     {
         Hall hall = repository.Halls.FirstOrDefault(h => h.ID == currentId);
         if (hall == null)
         {
             return;
         }
         HallForm hal = new HallForm(hall, 0);
         if (hal.ShowDialog() == DialogResult.Yes)
         {
             objectsCB.SelectedItem = hall.Name;
             repository.Save();
         }
         return;
     }
     if (currentModel == Rent && currentId != -1)
     {
         Rent rent = repository.Rents.FirstOrDefault(r => r.ID == currentId);
         if (rent == null)
         {
             return;
         }
         RentForm ren = new RentForm(rent, 0, repository.Customers, repository.Halls, repository.Rents);
         if (ren.ShowDialog() == DialogResult.Yes)
         {
             objectsCB.SelectedItem = rent.TimeStart.ToString();
             repository.Save();
         }
         return;
     }
     MessageBox.Show("Выберите модель!");
 }