private void btn_Accept_Click(object sender, EventArgs e) { if (!Check_Syntax()) { MessageBox.Show("Enter valid data!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { TimetableDataContext context = new TimetableDataContext(); int Id = 1; if (context.ClassRooms.Count() != 0) { Id = context.ClassRooms.Max(p => p.ID) + 1; } ClassRoom cls = new ClassRoom(); cls.ID = Id; cls.Name = tbox_Name.Text; cls.Description = tbox_Description.Text; context.ClassRooms.InsertOnSubmit(cls); context.SubmitChanges(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
partial void DeleteClassRoom(ClassRoom instance);
partial void UpdateClassRoom(ClassRoom instance);
partial void InsertClassRoom(ClassRoom instance);