private void button1_Click(object sender, EventArgs e) { MarkAdd tForm = new MarkAdd(); List <Student> students = db.Students.ToList(); List <Subject> subjects = db.Subjects.ToList(); tForm.comboBox1.DataSource = subjects; tForm.comboBox1.ValueMember = "Id"; tForm.comboBox1.DisplayMember = "Name"; tForm.comboBox2.DataSource = students; tForm.comboBox2.ValueMember = "Id"; tForm.comboBox2.DisplayMember = "Surname"; DialogResult result = tForm.ShowDialog(this); if (result == DialogResult.Cancel) { return; } Mark mark = new Mark(); mark.Smark = Convert.ToInt32(tForm.textBox1.Text); mark.Subject = (Subject)tForm.comboBox1.SelectedItem; mark.Student = (Student)tForm.comboBox2.SelectedItem; db.Marks.Add(mark); db.SaveChanges(); MessageBox.Show("Оценка добавлена"); update(); }
private void button1_Click(object sender, EventArgs e) { TeachAdd tForm = new TeachAdd(); List <Subject> subjects = db.Subjects.ToList(); tForm.comboBox1.DataSource = subjects; tForm.comboBox1.ValueMember = "Id"; tForm.comboBox1.DisplayMember = "Name"; DialogResult result = tForm.ShowDialog(this); if (result == DialogResult.Cancel) { return; } Teacher teacher = new Teacher(); teacher.Name = tForm.textBox1.Text; teacher.Surname = tForm.textBox2.Text; teacher.Salary = Convert.ToInt32(tForm.textBox3.Text); teacher.Subject = (Subject)tForm.comboBox1.SelectedItem; db.Teachers.Add(teacher); db.SaveChanges(); MessageBox.Show("Учитель добавлен"); update(); }
public bool Create(Group newGroup) { foreach (var group in Database.Groups) { if (group.Name == newGroup.Name) { return(false); } } Database.Groups.Add(newGroup); Database.SaveChanges(); return(true); }
private void button1_Click(object sender, EventArgs e) { SubjAdd tForm = new SubjAdd(); DialogResult result = tForm.ShowDialog(this); if (result == DialogResult.Cancel) { return; } Subject subject = new Subject(); subject.Name = tForm.textBox1.Text; db.Subjects.Add(subject); db.SaveChanges(); MessageBox.Show("Предмет добавлен"); update(); }
private void button1_Click(object sender, EventArgs e) { StudAdd tForm = new StudAdd(); DialogResult result = tForm.ShowDialog(this); if (result == DialogResult.Cancel) { return; } Student student = new Student(); student.Name = tForm.textBox1.Text; student.Surname = tForm.textBox2.Text; student.Course = Convert.ToInt32(tForm.textBox3.Text); db.Students.Add(student); db.SaveChanges(); MessageBox.Show("Студент добавлен"); update(); }
//上下文提交 public bool Commit() { return(_context.SaveChanges() > 0); }
public int SaveChanges() { return(Db.SaveChanges()); }
public void Add(TEntity T) { _dbSet.Add(T); _context.SaveChanges(); }
public int SaveChanges() { return(_dbContext.SaveChanges()); }
public int SaveChanges() { return(_studyContext.SaveChanges()); }
public void Save() { _context.SaveChanges(); }