Esempio n. 1
0
 public void AddCompany(company company)
 {
     try
     {
         using (db_consolesEntities db = new db_consolesEntities())
         {
             Validate(company);
             db.companies.Add(company);
             db.SaveChanges();
             ListUpdated?.Invoke();
         }
     }
     catch (ArgumentException)
     { throw; }
     catch (Exception ex)
     {
         throw new Exception("Something wrong happened while adding a new company.");
     }
 }
Esempio n. 2
0
 public void UpdateCompany(company company)
 {
     try
     {
         using (db_consolesEntities db = new db_consolesEntities())
         {
             Validate(company);
             db.Entry(company).State = System.Data.EntityState.Modified;
             db.SaveChanges();
             ListUpdated?.Invoke();
         }
     }
     catch (ArgumentException)
     { throw; }
     catch (Exception)
     {
         throw new Exception("Something wrong happened while updating the company's info.");
     }
 }
Esempio n. 3
0
 private void Edit(object sender, RoutedEventArgs ev)
 {
     try
     {
         if (dgCompanies.SelectedItem != null)
         {
             wndAddCompany newCompany      = new wndAddCompany();
             company       selectedCompany = (company)dgCompanies.SelectedItem;
             newCompany.Company = admin.GetCompany(selectedCompany.ID);
             newCompany.admin   = admin;
             newCompany.isEdit  = true;
             newCompany.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Company", MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }