Ejemplo n.º 1
0
        private void btNew_Click(object sender, EventArgs e)
        {
            PlaninfoItemForm dialog = new PlaninfoItemForm();

            DateTime timeStart = new DateTime(this.dateTimePicker1.Value.Year,
                                              this.dateTimePicker1.Value.Month,
                                              this.dateTimePicker1.Value.Day, 8, 30, 0);
            DateTime timeEnd = timeStart.AddMinutes(60);

            dialog.AppointmentDateStart = timeStart;
            dialog.AppointmentDateEnd   = timeEnd;
            //dialog.LineID = this.cbPLine.SelectedIndex + 1;
            dialog.LineID = this.lineID;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                ProductionPlanSQLiteDal dal = new ProductionPlanSQLiteDal();
                //ProductionPlanDal dal = new ProductionPlanDal();

                if (dal.InsertProductionPlanItem(dialog.ProductionPlan) > 0)
                {
                    LoadPlanGrid();

                    MessageBox.Show("添加数据成功!");
                    dayView1.Invalidate();
                }
                else
                {
                    MessageBox.Show("添加数据失败!");
                }
            }
        }
Ejemplo n.º 2
0
        /// <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("添加数据失败!");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 加载计划列表
        /// </summary>
        private void LoadPlanGrid()
        {
            try
            {
                this.dayView1.Appointments.Clear();

                this.dayView1.RefreshAppointments();
                DateTime weekstart = this.dateTimePicker1.Value;
                dayView1.Date = weekstart;

                //ProductionPlanDal dal = new ProductionPlanDal();

                ProductionPlanSQLiteDal dal = new ProductionPlanSQLiteDal();

                //int lineID = this.cbPLine.SelectedIndex+1;


                string planID = this.dateTimePicker1.Value.ToString("yyyyMMdd");

                planID = string.Format("{0}_{1}", planID, lineID);

                DataTable table = dal.GetProductionPalnByPlanID(planID);


                if (table == null || table.Rows.Count <= 0)
                {
                    this.dayView1.RefreshAppointments();

                    this.dayView1.Invalidate();
                    return;
                }
                else
                {
                    this.dayView1.Appointments = GetPlanPoints(table);

                    this.dayView1.RefreshAppointments();

                    this.dayView1.Invalidate();
                }
            }
            catch (Exception ex)
            {
                CLog.WriteErrLogInTrace(ex.Message.ToString());
            }
        }
Ejemplo n.º 4
0
        //private void InitalCombox()
        //{
        //    try
        //    {
        //        this.cbPLine.DataSource = Enum.GetValues(typeof(COM.LineType));
        //        this.cbPLine.SelectedIndex = 0;
        //    }
        //    catch(Exception ex)
        //    {
        //        CLog.WriteErrLogInTrace(ex.Message);
        //    }

        // }

        /// <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;
                dialog.LineID = this.lineID;


                ProductionPlanSQLiteDal dal = new ProductionPlanSQLiteDal();
                // 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("删除数据失败!");
                    }
                }
            }
        }