示例#1
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("Ошибка изменения данных");
                    }
                }
            }
        }
示例#2
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();
                    }
                }
            }
        }
示例#3
0
        public FormEditStudent(students stud)
        {
            item = stud;
            InitializeComponent();

            var groups_for_list = (from g in db.groups
                                   select g.name_group).Distinct();

            foreach (string it in groups_for_list)
            {
                comboBox1.Items.Add(it);
            }

            textBox1.Text = item.surname.ToString();
            textBox2.Text = item.name.ToString();

            var query = (from g in db.groups
                         where g.code_group == item.code_group
                         select g.name_group).ToList();

            comboBox1.SelectedItem = query[0];
        }