Exemplo n.º 1
0
 public FormEditProg(progress prog)
 {
     InitializeComponent();
     item                 = prog;
     textBox1.Text        = item.estimate.ToString();
     numericUpDown1.Value = item.date_exam.Day;
     numericUpDown2.Value = item.date_exam.Month;
     numericUpDown3.Value = item.date_exam.Year;
 }
Exemplo n.º 2
0
        private void button6_Click(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show("Вы уверены?", "Внимание!", MessageBoxButtons.YesNo);

            if (res == DialogResult.Yes)
            {
                if (radioButton1.Checked)
                {
                    try
                    {
                        List <students> query = (from stud in db.students
                                                 select stud).ToList();
                        if (dataGridView1.SelectedCells.Count == 1)
                        {
                            students item = query.First(w => w.code_stud.ToString() == dataGridView1.SelectedCells[0].OwningRow.Cells[0].Value.ToString());
                            db.students.Remove(item);
                            db.SaveChanges();
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Ошибка изменения данных");
                    }
                }
                else if (radioButton2.Checked)
                {
                    try
                    {
                        List <progress> query = (from prog in db.progress
                                                 select prog).ToList();
                        if (dataGridView1.SelectedCells.Count == 1)
                        {
                            progress item = query.First(w => w.code_stud.ToString() == dataGridView1.SelectedCells[0].OwningRow.Cells[0].Value.ToString() && w.code_subject.ToString() == dataGridView1.SelectedCells[0].OwningRow.Cells[7].Value.ToString());
                            db.progress.Remove(item);
                            db.SaveChanges();
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Ошибка изменения данных");
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                List <students> query = (from stud in db.students
                                         select stud).ToList();
                if (dataGridView1.SelectedCells.Count == 1)
                {
                    if (Application.OpenForms.Count == 1)
                    {
                        students item = query.First(w => w.code_stud.ToString() == dataGridView1.SelectedCells[0].OwningRow.Cells[0].Value.ToString());

                        FormEditStudent edtSt = new FormEditStudent(item);
                        edtSt.Owner = this;
                        edtSt.Show();
                    }
                    else
                    {
                        Application.OpenForms[0].Focus();
                    }
                }
            }
            else if (radioButton2.Checked)
            {
                List <progress> query = (from prog in db.progress

                                         select prog).ToList();
                if (dataGridView1.SelectedCells.Count == 1)
                {
                    if (Application.OpenForms.Count == 1)
                    {
                        progress item = query.First(w => w.code_stud.ToString() == dataGridView1.SelectedCells[0].OwningRow.Cells[0].Value.ToString() && w.code_subject.ToString() == dataGridView1.SelectedCells[0].OwningRow.Cells[7].Value.ToString());

                        FormEditProg edtPr = new FormEditProg(item);
                        edtPr.Owner = this;
                        edtPr.Show();
                    }
                    else
                    {
                        Application.OpenForms[0].Focus();
                    }
                }
            }
        }
Exemplo n.º 4
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         DateTime dt   = new DateTime((int)numericUpDown3.Value, (int)numericUpDown2.Value, (int)numericUpDown1.Value);
         progress prog = new progress
         {
             code_stud    = (int)numericUpDown1.Value,
             code_subject = (int)numericUpDown3.Value,
             code_lector  = (int)numericUpDown2.Value,
             estimate     = (int)numericUpDown4.Value,
             date_exam    = dt
         };
         db.progress.Add(prog);
         db.SaveChanges();
         this.Close();
     }
     catch
     {
         MessageBox.Show("Ошибка внесения данных");
     }
 }