예제 #1
0
 private void SubjectForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (NoSave)
     {
         DialogResult result = MessageBox.Show("Сохранить изменения?", "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
         if (result == DialogResult.Yes)
         {
             Subjects.Save();
         }
         else if (result == DialogResult.No)
         {
             Subjects.Load();
         }
         else
         {
             e.Cancel = true;
         }
     }
 }
예제 #2
0
파일: WelcomeForm.cs 프로젝트: groshik/curs
 public void LoadData()
 {
     LoadProgress.Text = "Загрузка данных о студентах...";
     LoadProgress.Refresh();
     Students.Load();
     LoadProgress.Text = "Загрузка данных о группах...";
     LoadProgress.Refresh();
     Application.EnableVisualStyles();
     Groups.Load();
     LoadProgress.Text = "Загрузка данных о предметах...";
     LoadProgress.Refresh();
     Application.EnableVisualStyles();
     Subjects.Load();
     LoadProgress.Text = "Загрузка пользователей...";
     LoadProgress.Refresh();
     Application.EnableVisualStyles();
     Users.Load();
     LoadProgress.Text = "Загрузка завершина...";
     LoadProgress.Refresh();
     Thread.Sleep(1500);
     DialogResult = DialogResult.OK;
 }
예제 #3
0
 private void CenselSubjectsButton_Click(object sender, EventArgs e)
 {
     Subjects.Load();
     NoSave = false;
     subjectGridView.DataSource = Subjects.Items.ToList();
 }
예제 #4
0
        public void UpdateTable()
        {
            Table.Rows.Clear();
            Table.Columns.Clear();
            Table.CellValueChanged -= UpdateData;
            List <int> removeSubjects = new List <int>();

            SubjectsList.ForEach(subject =>
            {
                Subject subjectInfo = Subjects.GetSubjectByID(subject);
                if (subjectInfo == null)
                {
                    removeSubjects.Add(subject);
                }
            });
            removeSubjects.ForEach(remove =>
            {
                RemoveSubject(remove, false);
            });
            SubjectsList.ForEach(subject => {
                Subject subjectInfo       = Subjects.GetSubjectByID(subject);
                DataGridViewColumn newCol = new DataGridViewColumn()
                {
                    Name         = subjectInfo.Id.ToString(),
                    HeaderText   = subjectInfo.Title,
                    SortMode     = DataGridViewColumnSortMode.NotSortable,
                    CellTemplate = new DataGridViewTextBoxCell()
                };
                Table.Columns.Add(newCol);
            });

            DataGridViewColumn averageAssessmentCol = new DataGridViewColumn
            {
                ReadOnly         = true,
                HeaderText       = "Средняя оценка",
                CellTemplate     = new DataGridViewTextBoxCell(),
                DefaultCellStyle = new DataGridViewCellStyle
                {
                    BackColor = System.Drawing.Color.FromArgb(200, 200, 200)
                }
            };

            Table.Columns.Add(averageAssessmentCol);
            DataGridViewColumn stipendCol = new DataGridViewColumn
            {
                ReadOnly     = true,
                HeaderText   = "Стипендия",
                CellTemplate = new DataGridViewTextBoxCell(),
            };

            Table.Columns.Add(stipendCol);
            List <int> removeStudents = new List <int>();

            StudentList.ForEach(student =>
            {
                Student studentInfo = Students.GetStudentByID(student.IdStudent);
                if (studentInfo == null)
                {
                    removeStudents.Add(student.IdStudent);
                }
            });
            removeStudents.ForEach(remove =>
            {
                RemoveStudent(remove, false);
            });
            StudentList.ForEach(student =>
            {
                Student studentInfo  = Students.GetStudentByID(student.IdStudent);
                DataGridViewRow row  = new DataGridViewRow();
                string studentName   = studentInfo.FullName + " (" + Groups.GetGroupByID(studentInfo.Id_Group).Number + ")";
                row.HeaderCell.Value = studentName;
                row.Tag = student;
                Table.Rows.Add(row);
                int RowHeaderWidth = 9 * studentName.Length;
                if (RowHeaderWidth > Table.RowHeadersWidth)
                {
                    Table.RowHeadersWidth = RowHeaderWidth;
                }
            });
            int i = 0, j = 0;

            StudentList.ForEach(stud =>
            {
                j = 0;
                double averageAssessment = 0;
                double assessmentCounr   = 0;
                SubjectsList.ForEach(subj =>
                {
                    int assessments    = stud.AssessmentsList[subj];
                    averageAssessment += assessments;
                    assessmentCounr++;
                    Table[j, i].Value = assessments;
                    j++;
                });
                averageAssessment /= assessmentCounr;
                Table[j, i].Value  = Math.Round(averageAssessment, 2);
                Student student    = Students.GetStudentByID(stud.IdStudent);
                double allowance   = 0;
                if (averageAssessment >= 9 && student.Active_Participation)
                {
                    allowance = 1.5;
                    Table[j + 1, i].Style.BackColor = System.Drawing.Color.FromArgb(28, 193, 243);
                }
                else if (averageAssessment >= 9)
                {
                    allowance = 1.25;
                    Table[j + 1, i].Style.BackColor = System.Drawing.Color.FromArgb(80, 216, 103);
                }
                else if (averageAssessment > 5)
                {
                    allowance = 1;
                }
                else
                {
                    Table[j + 1, i].Style.BackColor = System.Drawing.Color.FromArgb(253, 81, 81);
                }
                Double.TryParse(StipendBox.Text, out double stipend);
                stipend *= allowance;
                Table[j + 1, i].Value = Math.Round(stipend, 2);
                i++;
            });
            Table.CellValueChanged += UpdateData;
        }