Exemple #1
0
        /// <summary>
        /// Handles the AppointmentEdit event of the calendar control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Syd.ScheduleControls.Events.AppointmentEditEventArgs"/> instance containing the event data.</param>
        private void calendar_AppointmentEdit(object sender, AppointmentEditEventArgs e)
        {
            //show a dialog to edit the appointment
            using (PlaninfoItemForm dialog = new PlaninfoItemForm())
            {
                dialog.AppointmentDateStart = e.Appointment.DateStart;
                dialog.AppointmentDateEnd   = e.Appointment.DateEnd;
                dialog.LineID = this.cbPLine.SelectedIndex + 1;

                ProductionPlanDal dal = new ProductionPlanDal();

                ProductionPlanMDL mdl = dal.GetProductionPalnByID(((BrakePlanAppointments)e.Appointment).MDL.TID);

                if (mdl != null)
                {
                    dialog.IsUpdate       = true;
                    dialog.ProductionPlan = mdl;
                }
                else
                {
                    dialog.IsUpdate = false;
                }

                DialogResult result = dialog.ShowDialog();

                if (result == DialogResult.OK)
                {
                    int ret = -1;

                    if (dialog.IsUpdate)
                    {
                        ret = dal.UpdateProductionPlanItem(dialog.ProductionPlan);
                    }
                    else
                    {
                        ret = dal.InsertProductionPlanItem(dialog.ProductionPlan);
                    }

                    if (ret > 0)
                    {
                        LoadPlanGrid();
                        //    //if the user clicked 'save', update the appointment dates and title
                        //e.Appointment.DateStart = dialog.AppointmentDateStart;
                        //e.Appointment.DateEnd = dialog.AppointmentDateEnd;
                        //e.Appointment.Subject =dialog.ProductionPlan.BreakeID + ":" + dialog.ProductionPlan.PlanNum.ToString();
                        ////have to tell the controls to refresh appointment display

                        //dayView1.RefreshAppointments();


                        MessageBox.Show("修改数据成功!");

                        //dayView1.Invalidate();
                    }
                    else
                    {
                        MessageBox.Show("修改数据失败!");
                    }
                }
                else if (result == DialogResult.Abort)
                {
                    int ret = dal.DeleteProudctionPlanItem(dialog.ProductionPlan.TID);


                    if (ret > 0)
                    {
                        LoadPlanGrid();
                        //    //if the user clicked 'save', update the appointment dates and title
                        //e.Appointment.DateStart = dialog.AppointmentDateStart;
                        //e.Appointment.DateEnd = dialog.AppointmentDateEnd;
                        //e.Appointment.Subject =dialog.ProductionPlan.BreakeID + ":" + dialog.ProductionPlan.PlanNum.ToString();
                        ////have to tell the controls to refresh appointment display

                        //dayView1.RefreshAppointments();


                        MessageBox.Show("删除数据成功!");

                        //dayView1.Invalidate();
                    }
                    else
                    {
                        MessageBox.Show("删除数据失败!");
                    }
                }
            }
        }