/// <summary> /// Fires the appointment new. /// </summary> /// <param name="newApptDate">The new appt date.</param> protected void FireAppointmentNew(DateTime newApptDate) { EventHandler <AppointmentCreateEventArgs> handler = AppointmentCreate; if (handler != null) { AppointmentCreateEventArgs args = new AppointmentCreateEventArgs(newApptDate, this); handler(this, args); } }
/// <summary> /// Handles the AppointmentAdd event of the calendar control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Syd.ScheduleControls.Events.AppointmentCreateEventArgs"/> instance containing the event data.</param> private void calendar_AppointmentAdd(object sender, AppointmentCreateEventArgs e) { //show a dialog to add an appointment using (PlaninfoItemForm dialog = new PlaninfoItemForm()) { //dialog.LineID = this.cbPLine.SelectedIndex + 1; dialog.LineID = this.lineID; if (e.Date != null) { dialog.AppointmentDateStart = e.Date.Value; dialog.AppointmentDateEnd = e.Date.Value.AddMinutes(30); } DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { ProductionPlanSQLiteDal dal = new ProductionPlanSQLiteDal(); //ProductionPlanDal dal = new ProductionPlanDal(); if (dal.InsertProductionPlanItem(dialog.ProductionPlan) > 0) { //if the user clicked 'save', save the new appointment ////string title = dialog.AppointmentTitle; //DateTime dateStart = dialog.AppointmentDateStart; //DateTime dateEnd = dialog.AppointmentDateEnd; //e.Control.Appointments.Add(new BrakePlanAppointments() //{ // Subject = dialog.ProductionPlan.BreakeID + ":" + dialog.ProductionPlan.PlanNum.ToString(), // DateStart = dateStart, // DateEnd = dateEnd //}); ////have to tell the controls to refresh appointment display // dayView1.RefreshAppointments(); // dayView2.RefreshAppointments(); //get the controls to repaint LoadPlanGrid(); MessageBox.Show("添加数据成功!"); //dayView1.Invalidate(); } else { MessageBox.Show("添加数据失败!"); } } } }