Exemplo n.º 1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (CourcesDb == null)
            {
                CourcesDb = new List <CourseDTO>();
            }

            CourseDTO course = new CourseDTO
            {
                Name = textBoxName.Text,
                Code = textBoxCode.Text
            };

            CourseInfoDTO info = new CourseInfoDTO
            {
                LaboratoryHours = Int32.Parse(textBoxLaboratories.Text),
                LectureHours    = Int32.Parse(textBoxLectures.Text),
                PracticeHours   = Int32.Parse(textBoxPractices.Text)
            };

            StaffForm staffForm = new StaffForm();

            if (staffForm.ShowDialog(this) == DialogResult.OK)
            {
                course.Staff = staffForm.StaffDb;
            }

            GroupForm groupForm = new GroupForm();

            if (groupForm.ShowDialog(this) == DialogResult.OK)
            {
                info.Groups = groupForm.DbGroups;
            }

            course.Info = info;
            CourcesDb.Add(course);

            dataGridView.Rows.Add();
            DataGridViewRow row = dataGridView.Rows[CourcesDb.Count - 1];

            row.Cells[0].Value = course.Name;
            row.Cells[1].Value = course.Code;
            row.Cells[2].Value = course.Info.LectureHours;
            row.Cells[3].Value = course.Info.PracticeHours;
            row.Cells[4].Value = course.Info.LaboratoryHours;

            foreach (var it in course.Info.Groups)
            {
                ((DataGridViewComboBoxCell)row.Cells[5]).Items.Add(it);
            }

            buttonClean.Enabled = true;
        }
Exemplo n.º 2
0
        private void buttonReplace_Click(object sender, EventArgs e)
        {
            if (rowIndex == -1)
            {
                return;
            }

            Selected.Name = textBoxName.Text;
            Selected.Code = textBoxCode.Text;
            Selected.Info.LectureHours    = Int32.Parse(textBoxLectures.Text);
            Selected.Info.PracticeHours   = Int32.Parse(textBoxPractices.Text);
            Selected.Info.LaboratoryHours = Int32.Parse(textBoxLaboratories.Text);

            StaffForm staffForm = new StaffForm();

            staffForm.StaffDb = Selected.Staff;
            if (staffForm.ShowDialog(this) == DialogResult.OK)
            {
                Selected.Staff = staffForm.StaffDb;
            }

            GroupForm groupForm = new GroupForm();

            groupForm.DbGroups = Selected.Info.Groups;
            if (groupForm.ShowDialog(this) == DialogResult.OK)
            {
                Selected.Info.Groups = groupForm.DbGroups;
            }

            dataGridView.Rows.Clear();

            int index = 0;

            foreach (var it in CourcesDb)
            {
                dataGridView.Rows.Add();
                DataGridViewRow row = dataGridView.Rows[index];

                row.Cells[0].Value = it.Name;
                row.Cells[1].Value = it.Code;
                row.Cells[2].Value = it.Info.LectureHours;
                row.Cells[3].Value = it.Info.PracticeHours;
                row.Cells[4].Value = it.Info.LaboratoryHours;

                foreach (var item in it.Info.Groups)
                {
                    ((DataGridViewComboBoxCell)row.Cells[5]).Items.Add(item);
                }

                ++index;
            }
        }