Beispiel #1
0
        private void buttonSubjectSubmit_Click(object sender, EventArgs e)
        {
            //ToDo check teacher teaching two subjects in a semester
            if (!SubjectValidation())
            {
                return;
            }

            if (subjectName != textBoxSubjectName.Text)
            {
                if (subject.CheckForSubjectName(Convert.ToInt32(comboBoxSemesterName.SelectedValue), textBoxSubjectName.Text, userAccount.ua_department_id))
                {
                    MessageBox.Show(textBoxSubjectName.Text + " is already added.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }

            if ((this.Owner is View.View.ViewSubjectForm))
            {
                if (subject.UpdateSubject(userAccount.ua_department_id, Convert.ToInt32(comboBoxSemesterName.SelectedValue), textBoxSubjectName.Text, Convert.ToInt32(comboBoxTeacherName.SelectedValue)))
                {
                    MessageBox.Show("Updated Successfully.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Dispose();
                }
            }
            if (this.Owner is HomeForm)
            {
                if (subject.AddNewSubject(userAccount.ua_department_id, Convert.ToInt32(comboBoxSemesterName.SelectedValue), textBoxSubjectName.Text, Convert.ToInt32(comboBoxTeacherName.SelectedValue)))
                {
                    MessageBox.Show("Inserted Successfully.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Dispose();
                }
            }
        }