/// <summary> /// Saving a new lesson /// </summary> private void SaveLesson() { //Make new instance of DB class DBRepository DB = DBRepository.GetInstance(); //Check if the Textboxes are empty if (string.IsNullOrEmpty(TB_Title.Text) || string.IsNullOrEmpty(TB_Subject.Text) || string.IsNullOrEmpty(TB_Made_By.Text) || string.IsNullOrEmpty(TB_Desc.Text)) { MessageBox.Show("Not everything has been filled!"); } //If not empty else { //Get Teacher ID int Teacher_ID = DB.FindTeacherID(TB_Made_By.Text).TeacherIdentification; //Insert new Lesson Lesson L = new Lesson(TB_Title.Text, 0, CB_Lesson_Status.SelectedItem.ToString(), TB_Desc.Text, TB_Subject.Text, Teacher_ID); DB.CreateNewLesson(L); //Necessary for which group to save to int Group_ID; //Get Group and Lesson ID if (CB_Classes.SelectedIndex == 0) { int Lesson_ID = DB.FindLessonIDByName(TB_Title.Text); //Insert Lesson into all groups (Using 0) DB.InsertLessonForGroups(Lesson_ID, 0); //Inserting Images into Lesson Saving_Images_To_Lesson(Lesson_ID); //Inserting Art objects into Lesson Saving_Artobjects_To_Lesson(Lesson_ID); } else { Group_ID = DB.FindGroupID(CB_Classes.SelectedItem.ToString()).Get_Group_ID(); int Lesson_ID = DB.FindLessonIDByName(TB_Title.Text); //Insert Lesson into chosen group DB.InsertLessonForGroups(Lesson_ID, Group_ID); //Inserting Images into Lesson Saving_Images_To_Lesson(Lesson_ID); //Inserting Art objects into Lesson Saving_Artobjects_To_Lesson(Lesson_ID); } MessageBox.Show("Saved lesson!"); } }