public SchedulePreview(int id) { InitializeComponent(); ctx = new ScheduleContext(); dataGridView1.AllowUserToAddRows = false; ctx.Schedules.Load(); s = ctx.Schedules.Find(id); }
private void button1_Click(object sender, EventArgs e) { using (var ctx = new ScheduleContext()) { if (textBox2.Text == "") { MessageBox.Show("Missing required input.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var schedule = new Schedule { Name = textBox2.Text.ToString(), }; ctx.Schedules.Add(schedule); ctx.SaveChanges(); this.Close(); } } }