partial void DeleteAppointment(Appointment instance);
partial void InsertAppointment(Appointment instance);
partial void UpdateAppointment(Appointment instance);
/// <summary> /// 保存约会 /// </summary> private void Save() { string subject = tbxSubject.Text; string location = tbxLocation.Text; DateTime start = dateTimeInputStart.Value; DateTime end = dateTimeInputEnd.Value; int labelId = (int)this.cbeLabel.SelectedValue; int displayId = (int)this.cbeDisplay.SelectedValue; string description = richTextBoxEx1.Text; int remindable = Convert.ToInt32(switchButton1.ValueTrue); Appointment appointment = new Appointment { Description = description, DisplayId = displayId, EndTime = end, LabelId = labelId, Location = location, Remindable = remindable, StartTime = start, Subject = subject }; int count = 0; using (var ctx = DbConfiguration.Items["Scheduler"].CreateDbContext()) { count = ctx.Set<Appointment>().Insert(appointment); } if (count == 1) { MessageBoxEx.Show(this, "添加成功", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { if (MessageBoxEx.Show(this, "添加失败,是否尝试重新保存", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Save(); } else { this.Close(); } } }