コード例 #1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxCourses.SelectedItem == null)
     {
         MessageBox.Show("Alegeti cursul pe care doriti sa il adaugati profesorului.", "Atentie", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (comboBoxSet.SelectedItem == null)
     {
         MessageBox.Show("Alegeti seria la care doriti sa adaugati cursul.", "Atentie", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         DataGridViewRow row = gridTeachers.SelectedRows[0];
         BLAdmin         bl  = new BLAdmin();
         bl.AddTeacherCourse(Convert.ToInt32(row.Cells["TeacherId"].Value), Convert.ToInt32(comboBoxCourses.SelectedValue), comboBoxSet.GetItemText(comboBoxSet.SelectedItem));
         MessageBox.Show("Cursul a fost adaugat cu succes!", "Succes", MessageBoxButtons.OK, MessageBoxIcon.Information);
         gridCourses.DataSource = bl.GetCourses(Convert.ToInt32(row.Cells["TeacherId"].Value));
         DataTable tableCourses = bl.GetListOfCourses(Convert.ToInt32(row.Cells["TeacherId"].Value));
         comboBoxCourses.ValueMember   = "CourseId";
         comboBoxCourses.DisplayMember = "CourseName";
         comboBoxCourses.DataSource    = tableCourses;
         comboBoxCourses.SelectedItem  = null;
         comboBoxSet.SelectedItem      = null;
         lblCourse.Visible             = true;
         lblSet.Visible = true;
     }
 }
コード例 #2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (gridCourses.SelectedRows[0] == null)
     {
         MessageBox.Show("Alegeti materia pe care doriti sa o stergeti.", "Atentie", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         DataGridViewRow rowTeacher = gridTeachers.SelectedRows[0];
         DataGridViewRow rowCourse  = gridCourses.SelectedRows[0];
         DialogResult    result     = MessageBox.Show("Sunteti sigur ca doriti sa stergeti " + rowCourse.Cells["CourseName"].Value.ToString() + " din lista de materii predate de " + rowTeacher.Cells["TeacherName"].Value.ToString() + " " + rowTeacher.Cells["TeacherSurname"].Value.ToString() + "?", "Confirmare", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (result == DialogResult.Yes)
         {
             BLAdmin bl = new BLAdmin();
             bl.DeleteTeacherCourse(Convert.ToInt32(rowTeacher.Cells["TeacherId"].Value), Convert.ToInt32(rowCourse.Cells["CourseId"].Value));
             MessageBox.Show("Cursul a fost sters cu succes!", "Succes", MessageBoxButtons.OK, MessageBoxIcon.Information);
             gridCourses.DataSource = bl.GetCourses(Convert.ToInt32(rowTeacher.Cells["TeacherId"].Value));
             DataTable tableCourses = bl.GetListOfCourses(Convert.ToInt32(rowTeacher.Cells["TeacherId"].Value));
             comboBoxCourses.ValueMember   = "CourseId";
             comboBoxCourses.DisplayMember = "CourseName";
             comboBoxCourses.DataSource    = tableCourses;
             comboBoxCourses.SelectedItem  = null;
         }
         else
         {
             return;
         }
     }
 }
コード例 #3
0
        private void gridTeachers_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            DataGridViewRow row = gridTeachers.SelectedRows[0];
            BLAdmin         bl  = new BLAdmin();

            gridCourses.DataSource = bl.GetCourses(Convert.ToInt32(row.Cells["TeacherId"].Value));
            gridCourses.Columns["CourseId"].Visible      = false;
            gridCourses.Columns["CourseName"].HeaderText = "Materie";
            gridCourses.Columns["StudySet"].HeaderText   = "Serie";
            gridCourses.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

            DataTable tableCourses = bl.GetListOfCourses(Convert.ToInt32(row.Cells["TeacherId"].Value));

            comboBoxCourses.ValueMember   = "CourseId";
            comboBoxCourses.DisplayMember = "CourseName";
            comboBoxCourses.DataSource    = tableCourses;
            comboBoxCourses.SelectedItem  = null;

            lblCourse.Visible       = true;
            lblSet.Visible          = true;
            gridCourses.Visible     = true;
            btnAdd.Visible          = true;
            btnDelete.Visible       = true;
            comboBoxCourses.Visible = true;
            comboBoxSet.Visible     = true;
            lblInfo.Visible         = true;
            lblInfo.Text            = "Lista materiilor predate de " + row.Cells["TeacherName"].Value.ToString() + " " + row.Cells["TeacherSurname"].Value.ToString() + ".";
        }