Ejemplo n.º 1
0
 private void addButton_Click(object sender, EventArgs e)
 {
     switch (entityType)
     {
         case EntityType.Classes:
             {
                 ClassEditForm classForm = new ClassEditForm();
                 if (!allSchools)
                 {
                     classForm.SchoolId = schoolId;
                 }
                 while (true)
                 {
                     try
                     {
                         classForm.ShowDialog();
                     }
                     catch (EmptyValueException) { }
                     if (!classForm.Cancel)
                     {
                         try
                         {
                             SchoolClassCustomEntity sc = new SchoolClassCustomEntity();
                             sc.AddValue(
                                 classForm.SchoolId,
                                 classForm.ClassTypeId,
                                 classForm.ClassName,
                                 classForm.BoysAmount,
                                 classForm.GirlsAmount);
                         }
                         catch (ValueAlreadyExistsException)
                         {
                             MessageBox.Show("Такое значение уже есть в базе");
                             continue;
                         }
                     }
                     break;
                 }
                 break;
             }
         case EntityType.Employees:
             {
                 EmployessEditForm empForm = new EmployessEditForm();
                 if (!allSchools)
                 {
                     empForm.SchoolId = schoolId;
                 }
                 while (true)
                 {
                     try
                     {
                         empForm.ShowDialog();
                     }
                     catch (EmptyValueException) { }
                     if (!empForm.Cancel)
                     {
                         try
                         {
                             string edu = empForm.Education;
                             EmployeeCustomEntity emp = new EmployeeCustomEntity();
                             emp.AddValue(
                                 empForm.SchoolId,
                                 empForm.EmployeeTypeId,
                                 empForm.EmpName,
                                 empForm.Gender,
                                 empForm.Address,
                                 empForm.Education,
                                 empForm.Category,
                                 empForm.SubjectId,
                                 empForm.DistrictId);
                         }
                         catch (ValueAlreadyExistsException)
                         {
                             MessageBox.Show("Такое значение уже есть в базе");
                             continue;
                         }
                     }
                     break;
                 }
                 break;
             }
         case EntityType.Quarters:
             {
                 SchoolQuartersEditForm scForm = new SchoolQuartersEditForm();
                 if (!allSchools)
                 {
                     scForm.SchoolId = schoolId;
                 }
                 while (true)
                 {
                     try
                     {
                         scForm.ShowDialog();
                     }
                     catch (EmptyValueException) { }
                     if (!scForm.Cancel)
                     {
                         try
                         {
                             SchoolQuartersCustomEntity sc = new SchoolQuartersCustomEntity();
                             sc.AddValue(
                                 scForm.SchoolId,
                                 scForm.QuartersTypeId,
                                 scForm.Area);
                         }
                         catch (ValueAlreadyExistsException)
                         {
                             MessageBox.Show("Такое значение уже есть в базе");
                             continue;
                         }
                     }
                     break;
                 }
                 break;
             }
         case EntityType.Schools:
             {
                 SchoolEditForm scForm = new SchoolEditForm();
                 while (true)
                 {
                     try
                     {
                         scForm.ShowDialog();
                     }
                     catch (EmptyValueException) { }
                     if (!scForm.Cancel)
                     {
                         try
                         {
                             SchoolCustomEntity sc = new SchoolCustomEntity();
                             sc.AddValue(
                                 scForm.SchoolName,
                                 scForm.IdSPType,
                                 scForm.IdSPBType,
                                 scForm.Amount,
                                 scForm.Address,
                                 scForm.DistrictId);
                         }
                         catch (ValueAlreadyExistsException)
                         {
                             MessageBox.Show("Такое значение уже есть в базе");
                             continue;
                         }
                     }
                     break;
                 }
                 break;
             }
         case EntityType.Tools:
             {
                 SchoolToolsEditForm stForm = new SchoolToolsEditForm();
                 if (!allSchools)
                 {
                     stForm.SchoolId = schoolId;
                 }
                 while (true)
                 {
                     try
                     {
                         stForm.ShowDialog();
                     }
                     catch (EmptyValueException) { }
                     if (!stForm.Cancel)
                     {
                         try
                         {
                             SchoolToolsCustomEntity st = new SchoolToolsCustomEntity();
                             st.AddValue(
                                 stForm.SchoolId,
                                 stForm.ToolTypeId,
                                 stForm.Amount);
                         }
                         catch (ValueAlreadyExistsException)
                         {
                             MessageBox.Show("Такое значение уже есть в базе");
                             continue;
                         }
                     }
                     break;
                 }
                 break;
             }
         case EntityType.Vehicles:
             {
                 SchoolVehiclesEditForm svForm = new SchoolVehiclesEditForm();
                 if (!allSchools)
                 {
                     svForm.idSchool = schoolId;
                 }
                 while (true)
                 {
                     try
                     {
                         svForm.ShowDialog();
                     }
                     catch (EmptyValueException) { }
                     if (!svForm.Cancel)
                     {
                         try
                         {
                             SchoolVehiclesCustomEntity sv = new SchoolVehiclesCustomEntity();
                             sv.AddValue(
                                 svForm.idSchool,
                                 svForm.idVehicleType,
                                 svForm.Amount);
                         }
                         catch (ValueAlreadyExistsException)
                         {
                             MessageBox.Show("Такое значение уже есть в базе");
                             continue;
                         }
                     }
                     break;
                 }
                 break;
             }
     }
     FillTable();
 }