Ejemplo n.º 1
0
 public void Update(StudentMark studentMark)
 {
     if (studentMark.Id == 0)
     {
         cathedraContext.StudentMarks.Add(studentMark);
     }
     cathedraContext.SaveChanges();
 }
Ejemplo n.º 2
0
 private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         StudentMark studentMark = dataGridView1.SelectedRows[0].DataBoundItem as StudentMark;
         DBController.Instance.Remove(studentMark);
         UpdateMarks();
     }
 }
Ejemplo n.º 3
0
        private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int course  = int.Parse(comboBox2.Text);
            int semestr = int.Parse(comboBox1.Text);

            if (dataGridView1.SelectedRows.Count > 0)
            {
                StudentMark studentMark = dataGridView1.SelectedRows[0].DataBoundItem as StudentMark;

                NewMarkForm form = new NewMarkForm(student, course, semestr, studentMark);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    UpdateMarks();
                }
            }
        }
Ejemplo n.º 4
0
        public NewMarkForm(Student student, int course, int semestr, StudentMark studentMark = null)
        {
            InitializeComponent();

            comboBox1.DataSource = DBController.Instance.Subjects;

            this.student = student;
            this.semestr = semestr;
            this.course  = course;

            if (studentMark != null)
            {
                comboBox1.SelectedItem = studentMark.Subject;
                numericUpDown1.Value   = studentMark.Mark;
                this.studentMark       = studentMark;
            }
        }
Ejemplo n.º 5
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            Subject subject = comboBox1.SelectedItem as Subject;

            if (studentMark == null)
            {
                if (student.Marks.Any(t => t.Subject == subject && t.Semestr == semestr && t.Course == course))
                {
                    MessageBox.Show("Такой предмет уже создан!");
                    return;
                }
                studentMark = new StudentMark();
            }

            studentMark.Subject = subject;
            studentMark.Mark    = (int)numericUpDown1.Value;
            studentMark.Student = student;
            studentMark.Semestr = semestr;
            studentMark.Course  = course;

            DBController.Instance.Update(studentMark);

            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 6
0
 public void Remove(StudentMark studentMark)
 {
     cathedraContext.StudentMarks.Remove(studentMark);
     cathedraContext.SaveChanges();
 }