Esempio n. 1
0
 private void setButton_Click(object sender, EventArgs e)
 {
     int index = dataGridView1.SelectedCells[0].RowIndex;
     switch (entityType)
     {
         case EntityType.Classes:
             {
                 SchoolClass schoolClass =
                     (from sc in EntitiesHolder.Entities.SchoolClass
                      select sc).ToArray()[index];
                 ClassEditForm classForm = new ClassEditForm(
                     schoolClass.idSchool,
                     schoolClass.idClassType,
                     schoolClass.nameClass,
                     schoolClass.boysAmount,
                     schoolClass.girlsAmount);
                 while (true)
                 {
                     try
                     {
                         classForm.ShowDialog();
                     }
                     catch (EmptyValueException) { }
                     if (!classForm.Cancel)
                     {
                         try
                         {
                             SchoolClassCustomEntity sc = new SchoolClassCustomEntity();
                             sc.SetValue(
                                 schoolClass.idClass,
                                 classForm.SchoolId,
                                 classForm.ClassTypeId,
                                 classForm.ClassName,
                                 classForm.BoysAmount,
                                 classForm.GirlsAmount);
                         }
                         catch (CapacityOverflowException)
                         {
                             MessageBox.Show("Достигнуто предельное число записей");
                             return;
                         }
                         catch (ValueAlreadyExistsException)
                         {
                             MessageBox.Show("Такое значение уже есть в базе");
                             continue;
                         }
                     }
                     break;
                 }
                 break;
             }
         case EntityType.Employees:
             {
                 Employee emp =
                     (from sc in EntitiesHolder.Entities.Employee
                      select sc).ToArray()[index];
                 EmployessEditForm empForm = new EmployessEditForm(
                     emp.nameEmployee,
                     emp.gender.Value,
                     emp.idSchool.Value,
                     emp.idEmployeeType.Value,
                     emp.address,
                     emp.education,
                     emp.idSubject.Value,
                     emp.rank.Value,
                     emp.idDistrict.Value);
                 while (true)
                 {
                     try
                     {
                         empForm.ShowDialog();
                     }
                     catch (EmptyValueException) { }
                     if (!empForm.Cancel)
                     {
                         try
                         {
                             EmployeeCustomEntity em = new EmployeeCustomEntity();
                             em.SetValue(
                                 emp.idEmployee,
                                 empForm.SchoolId,
                                 empForm.EmployeeTypeId,
                                 empForm.EmpName,
                                 empForm.Gender,
                                 empForm.Address,
                                 empForm.Education,
                                 empForm.Category,
                                 empForm.SubjectId,
                                 empForm.DistrictId);
                         }
                         catch (CapacityOverflowException)
                         {
                             MessageBox.Show("Достигнуто предельное число записей");
                             return;
                         }
                         catch (ValueAlreadyExistsException)
                         {
                             MessageBox.Show("Такое значение уже есть в базе");
                             continue;
                         }
                     }
                     break;
                 }
                 break;
             }
         case EntityType.Quarters:
             {
                 SchoolQuarters sq =
                     (from sc in EntitiesHolder.Entities.SchoolQuarters
                      select sc).ToArray()[index];
                 SchoolQuartersEditForm sqForm = new SchoolQuartersEditForm(
                     sq.idSchool,
                     sq.idQuartersType,
                     sq.area.Value);
                 while (true)
                 {
                     try
                     {
                         sqForm.ShowDialog();
                     }
                     catch (EmptyValueException) { }
                     if (!sqForm.Cancel)
                     {
                         try
                         {
                             SchoolQuartersCustomEntity sqe = new SchoolQuartersCustomEntity();
                             sqe.SetValue(
                                 sq.idSchool,
                                 sq.idQuartersType,
                                 sqForm.Area);
                         }
                         catch (CapacityOverflowException)
                         {
                             MessageBox.Show("Достигнуто предельное число записей");
                             return;
                         }
                         catch (ValueAlreadyExistsException)
                         {
                             MessageBox.Show("Такое значение уже есть в базе");
                             continue;
                         }
                     }
                     break;
                 }
                 break;
             }
         case EntityType.Schools:
             {
                 School s =
                     (from sc in EntitiesHolder.Entities.School
                      select sc).ToArray()[index];
                 SchoolEditForm sForm = new SchoolEditForm(
                     s.nameSchool,
                     s.idSchoolPropertyType.Value,
                     s.idSchoolBuildingPropertyType.Value,
                     s.computersAmount.Value,
                     s.address,
                     s.idDistrict.Value);
                 while (true)
                 {
                     try
                     {
                         sForm.ShowDialog();
                     }
                     catch (EmptyValueException) { }
                     if (!sForm.Cancel)
                     {
                         try
                         {
                             SchoolCustomEntity se = new SchoolCustomEntity();
                             se.SetValue(
                                 s.idSchool,
                                 sForm.SchoolName,
                                 sForm.IdSPType,
                                 sForm.IdSPBType,
                                 sForm.Amount,
                                 sForm.Address,
                                 sForm.DistrictId);
                         }
                         catch (CapacityOverflowException)
                         {
                             MessageBox.Show("Достигнуто предельное число записей");
                             return;
                         }
                         catch (ValueAlreadyExistsException)
                         {
                             MessageBox.Show("Такое значение уже есть в базе");
                             continue;
                         }
                     }
                     break;
                 }
                 break;
             }
         case EntityType.Tools:
             {
                 SchoolTools st =
                     (from sc in EntitiesHolder.Entities.SchoolTools
                      select sc).ToArray()[index];
                 SchoolToolsEditForm stForm = new SchoolToolsEditForm(
                     st.idSchool,
                     st.idToolType,
                     st.amount.Value);
                 while (true)
                 {
                     try
                     {
                         stForm.ShowDialog();
                     }
                     catch (EmptyValueException) { }
                     if (!stForm.Cancel)
                     {
                         try
                         {
                             SchoolToolsCustomEntity ste = new SchoolToolsCustomEntity();
                             ste.SetValue(
                                 st.idSchool,
                                 st.idToolType,
                                 stForm.Amount);
                         }
                         catch (CapacityOverflowException)
                         {
                             MessageBox.Show("Достигнуто предельное число записей");
                             return;
                         }
                         catch (ValueAlreadyExistsException)
                         {
                             MessageBox.Show("Такое значение уже есть в базе");
                             continue;
                         }
                     }
                     break;
                 }
                 break;
             }
         case EntityType.Vehicles:
             {
                 SchoolVehicles sv =
                     (from sc in EntitiesHolder.Entities.SchoolVehicles
                      select sc).ToArray()[index];
                 SchoolVehiclesEditForm svForm = new SchoolVehiclesEditForm(
                     sv.idSchool,
                     sv.idVehicleType,
                     sv.amount.Value);
                 while (true)
                 {
                     try
                     {
                         svForm.ShowDialog();
                     }
                     catch (EmptyValueException) { }
                     if (!svForm.Cancel)
                     {
                         try
                         {
                             SchoolVehiclesCustomEntity sve = new SchoolVehiclesCustomEntity();
                             sve.AddValue(
                                 sv.idSchool,
                                 sv.idVehicleType,
                                 svForm.Amount);
                         }
                         catch (CapacityOverflowException)
                         {
                             MessageBox.Show("Достигнуто предельное число записей");
                             return;
                         }
                         catch (ValueAlreadyExistsException)
                         {
                             MessageBox.Show("Такое значение уже есть в базе");
                             continue;
                         }
                     }
                     break;
                 }
                 break;
             }
     }
     FillTable();
 }
Esempio n. 2
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();
 }