private void button_accept_Click(object sender, EventArgs e) { int lectureID; if ((2000 + Convert.ToInt32(textBox_year.Text) < 2100) && (2000 + Convert.ToInt32(textBox_year.Text) > 2000) && (Convert.ToInt32(textBox_month.Text) < 13) && (Convert.ToInt32(textBox_month.Text) > 0)) { if (!(Convert.ToInt32(textBox_day.Text) > DateTime.DaysInMonth(2000 + Convert.ToInt32(textBox_year.Text), Convert.ToInt32(textBox_month.Text)) || Convert.ToInt32(textBox_day.Text) < 0)) { if ((Convert.ToInt32(textBox_StartTime.Text) >= 8 && Convert.ToInt32(textBox_StartTime.Text) <= 21) && (Convert.ToInt32(textBox_EndTime.Text) >= 8 && Convert.ToInt32(textBox_EndTime.Text) <= 21) && (Convert.ToInt32(textBox_StartTime.Text) < Convert.ToInt32(textBox_EndTime.Text))) { if (comboBox_AddRemove.SelectedIndex == 0) { if (comboBox_Lectures.SelectedItem.ToString() != "All") { lectureID = lectureIDS[comboBox_Lectures.SelectedIndex]; SQLFunctions.addChange(textBox_description.Text, Convert.ToInt32(textBox_StartTime.Text), Convert.ToInt32(textBox_EndTime.Text), Convert.ToInt32(textBox_day.Text), Convert.ToInt32(textBox_month.Text), 2000 + Convert.ToInt32(textBox_year.Text), lectureID); } else { SQLFunctions.addChange(textBox_description.Text, Convert.ToInt32(textBox_StartTime.Text), Convert.ToInt32(textBox_EndTime.Text), Convert.ToInt32(textBox_day.Text), Convert.ToInt32(textBox_month.Text), 2000 + Convert.ToInt32(textBox_year.Text), 0); } } else { lectureID = lectureIDS[comboBox_Lectures.SelectedIndex]; SQLFunctions.addChange("Canceled", Convert.ToInt32(textBox_StartTime.Text), Convert.ToInt32(textBox_EndTime.Text), Convert.ToInt32(textBox_day.Text), Convert.ToInt32(textBox_month.Text), 2000 + Convert.ToInt32(textBox_year.Text), lectureID); } FormMenuSecretary secForm = new FormMenuSecretary(id, password); this.Hide(); secForm.Show(); } else { MessageBox.Show("Incorrect values"); } } else { MessageBox.Show("Incorrect values"); } } else { MessageBox.Show("Incorrect values"); } }
private void button_accept_Click(object sender, EventArgs e) { int lectureID; List <int> studentIDs = new List <int>(); string dayForConstraints; string month; if (comboBox_AddRemove.SelectedIndex == 0) { if (verify_details() == true) { SQLFunctions.addChange(textBox_title.Text, textBox_description.Text, Convert.ToInt32(textBox_StartTime.Text), Convert.ToInt32(textBox_EndTime.Text), Convert.ToInt32(textBox_day.Text), Convert.ToInt32(textBox_month.Text), Convert.ToInt32(comboBox_year.Text), lectureIDS[comboBox_Lectures.SelectedIndex]); MessageBox.Show("Lesson was successfuly added"); } } else if (comboBox_AddRemove.SelectedIndex == 1) { lectureID = lectureIDS[comboBox_Lectures.SelectedIndex]; SQLFunctions.addChange(textBox_title.Text, textBox_description.Text, Convert.ToInt32(label_startTime.Text), Convert.ToInt32(label_endTime.Text), Convert.ToInt32(comboBox_day.Text), Convert.ToInt32(comboBox_month.Text), Convert.ToInt32(comboBox_year.Text), lectureID); DateTime day = new DateTime(Convert.ToInt32(comboBox_year.Items[comboBox_year.SelectedIndex]), Convert.ToInt32(comboBox_month.Items[comboBox_month.SelectedIndex]), Convert.ToInt32(comboBox_day.Items[comboBox_day.SelectedIndex])); month = comboBox_month.Items[comboBox_month.SelectedIndex].ToString(); if ((Convert.ToInt32(comboBox_day.Items[comboBox_day.SelectedIndex])) < 10) { dayForConstraints = "0" + comboBox_day.Items[comboBox_day.SelectedIndex].ToString(); } else { dayForConstraints = comboBox_day.Items[comboBox_day.SelectedIndex].ToString(); } if ((Convert.ToInt32(comboBox_month.Items[comboBox_day.SelectedIndex])) < 10) { month = "0" + month; } if (day > (new DateTime(Convert.ToInt32(day.Year), 03, 05)) && day < (new DateTime(Convert.ToInt32(day.Year), 6, 15))) { SQLFunctions.addConstraint(SQLFunctions.getLecturerIDByLecturerName(SQLFunctions.findLecturerNameByLectureID(lectureID)), day.DayOfWeek.ToString(), (label_startTime.Text + ":00").ToString(), (label_endTime.Text + ":00").ToString(), textBox_description.Text.ToString(), SQLFunctions.findLecturerNameByLectureID(lectureID), (dayForConstraints + "/" + month + "/" + comboBox_year.Items[comboBox_year.SelectedIndex].ToString()), "B", (SQLFunctions.covertLectureIDtoLectureName(lectureIDS[comboBox_Lectures.SelectedIndex])).ToString()); } else if (day > new DateTime(Convert.ToInt32(day.Year), 10, 30) && day < new DateTime(Convert.ToInt32(day.Year), 2, 4)) { SQLFunctions.addConstraint(SQLFunctions.getLecturerIDByLecturerName(SQLFunctions.findLecturerNameByLectureID(lectureID)), day.DayOfWeek.ToString(), (label_startTime.Text + ":00").ToString(), (label_endTime.Text + ":00").ToString(), textBox_description.Text.ToString(), SQLFunctions.findLecturerNameByLectureID(lectureID), (dayForConstraints + "/" + month + "/" + comboBox_year.Items[comboBox_year.SelectedIndex].ToString()), "A", (SQLFunctions.covertLectureIDtoLectureName(lectureIDS[comboBox_Lectures.SelectedIndex])).ToString()); } MessageBox.Show("Lesson was successfuly removed"); } else if (comboBox_AddRemove.SelectedIndex == 2) { if (verify_details() == true) { DateTime day = new DateTime(Convert.ToInt32(comboBox_year.Items[comboBox_year.SelectedIndex]), Convert.ToInt32(textBox_month.Text), Convert.ToInt32(textBox_day.Text)); month = textBox_month.Text.ToString(); dayForConstraints = textBox_day.Text.ToString(); if (Convert.ToInt32(textBox_day.Text) < 10) { if (!textBox_day.Text.Contains('0')) { dayForConstraints = "0" + textBox_day.Text; } } if (Convert.ToInt32(textBox_month.Text) < 10) { if (!textBox_month.Text.Contains('0')) { month = "0" + textBox_month.Text; } } SQLFunctions.addChange(textBox_title.Text, textBox_description.Text, Convert.ToInt32(textBox_StartTime.Text), Convert.ToInt32(textBox_EndTime.Text), Convert.ToInt32(textBox_day.Text), Convert.ToInt32(textBox_month.Text), Convert.ToInt32(comboBox_year.Text), 0); if (day > new DateTime(Convert.ToInt32(day.Year), 3, 5) && day < new DateTime(Convert.ToInt32(day.Year), 6, 15)) { SQLFunctions.addConstraint("0", day.DayOfWeek.ToString(), (textBox_StartTime.Text + ":00").ToString(), (textBox_EndTime.Text + ":00").ToString(), textBox_description.Text.ToString(), "", (dayForConstraints + "/" + month + "/" + comboBox_year.Items[comboBox_year.SelectedIndex].ToString()), "B", "General"); } else if (day > new DateTime(Convert.ToInt32(day.Year), 10, 30) && day < new DateTime(Convert.ToInt32(day.Year), 2, 4)) { SQLFunctions.addConstraint("0", day.DayOfWeek.ToString(), (textBox_StartTime.Text + ":00").ToString(), (textBox_EndTime.Text + ":00").ToString(), textBox_description.Text.ToString(), "", (dayForConstraints + "/" + month + "/" + comboBox_year.Items[comboBox_year.SelectedIndex].ToString()), "A", "General"); } MessageBox.Show("Event was successfuly Added"); } } foreach (Control c in this.Controls) { if ((c.GetType() == typeof(TextBox)) || (c.GetType() == typeof(ComboBox))) { c.Text = ""; } } }