private void button6_Click(object sender, EventArgs e) { 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()); DeleteStud editSt = new DeleteStud(item); editSt.Owner = this; editSt.Show(); } }
private void button1_Click(object sender, EventArgs e) { var query = (from g in db.groups where g.name_group == comboBox1.SelectedItem.ToString() select g.code_group).ToList(); int number_of_student = db.students.Max(n => n.code_stud) + 1; students new_student = new students { code_stud = number_of_student, surname = textBox1.Text, name = textBox2.Text, code_group = query[0] }; db.students.Add(new_student); db.SaveChanges(); this.Close(); }
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]; }
public void button2_Click(object sender, EventArgs e) { 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 editSt = new FormEditStudent(item); editSt.Owner = this; editSt.Show(); } else { Application.OpenForms[0].Focus(); } } }
private void button2_Click(object sender, EventArgs e) { List <students> query = (from stud in db.students select stud).ToList(); if (dataGridView1.SelectedCells.Count == 1) { if (Application.OpenForms.Count == 2) { students item = query.First(w => w.code_stud.ToString() == dataGridView1.SelectedCells[0] .OwningRow.Cells[0].Value.ToString()); EditProgress editSt = new EditProgress(item); editSt.Owner = this; editSt.Show(); } else { MessageBox.Show("Ацтой"); } //Application.OpenForms[0].Focus(); } }
public DeleteStud(students stud) { InitializeComponent(); item = stud; label2.Text = item.surname + " " + item.name; }