private void AcceptButton_Click(object sender, EventArgs e)
 {
     if (New)
     {
         if (controller.Insert(hall) > 0)
         {
             InsertedHalls.Add(hall);
             if (CustomMessages.YesNoNext(this, "lecture hall"))
             {
                 SetHall(new LectureHall());
             }
             else
             {
                 Close();
             }
         }
     }
     else
     {
         if (controller.Update(hall))
         {
             CustomMessages.Updated(this, "lecture hall");
             SetHall(hall);
         }
     }
 }
Пример #2
0
 private void AcceptButton_Click(object sender, EventArgs e)
 {
     if (New) //creating new subject
     {
         if (controller.Insert(subject) > 0)
         {
             InsertedSubjects.Add(subject);
             if (CustomMessages.YesNoNext(this, "subject"))
             {
                 SetSubject(new Subject());
             }
             else
             {
                 Close();
             }
         }
     }
     else //updating existed subject
     {
         if (controller.Update(subject))
         {
             CustomMessages.Updated(this, "subject");
             SetSubject(subject);
         }
     }
 }
Пример #3
0
 private void AcceptButton_Click(object sender, EventArgs e)
 {
     if (New)
     {
         if (controller.Insert(lecturer) > 0)
         {
             InsertedLecturers.Add(lecturer);
             if (CustomMessages.YesNoNext(this, "lecturer"))
             {
                 SetLecturer(new Lecturer());
             }
             else
             {
                 Close();
             }
         }
     }
     else
     {
         if (controller.Update(lecturer))
         {
             CustomMessages.Updated(this, "lecturer");
             SetLecturer(lecturer);
         }
     }
 }
Пример #4
0
        private void SelectionAcceptButton_Click(object sender, EventArgs e)
        {
            if (SubjectCombobox.SelectedIndex == -1 ||
                HallCombobox.SelectedIndex == -1)
            {
                CustomMessages.ChooseBeforeCarryOn(this, "subject and hall");
                return;
            }

            if (New)
            {
                //databinding by hand
                selection.HallId    = Convert.ToInt32(HallCombobox.SelectedValue);
                selection.SubjectId = Convert.ToInt32(SubjectCombobox.SelectedValue);

                int selection_id = (int)controller.Insert(selection);
                selection.Id = selection_id;
                if (selection_id > 0)
                {
                    selection_time_controller.InsertTimes(selection_id,
                                                          TimetableControl.GetLectureTimes(TimetableControl.IsSelectedCell));
                    selection_lecturer_controller.InsertLecturers(selection_id,
                                                                  checked_lecturers_id.ToList());
                    CustomMessages.Inserted(this, "selection");

                    InsertedSelections.Add(selection);
                    SetAfterInsert();
                }
            }
            else
            {
                //quite the horrible way as I delete everything and re-insert them
                if (controller.Update(selection))
                {
                    selection_time_controller.DeleteBySelection(selection.Id);
                    selection_lecturer_controller.DeleteBySelection(selection.Id);

                    selection_time_controller.InsertTimes(selection.Id,
                                                          TimetableControl.GetLectureTimes(TimetableControl.IsSelectedCell));
                    selection_lecturer_controller.InsertLecturers(selection.Id,
                                                                  checked_lecturers_id.ToList());

                    SetSelection(selection);
                    CustomMessages.Updated(this, "selection");
                    //TimetableControl.ResetLectureTimes();
                    Updated = true;
                }
            }
        }