Example #1
0
        /// <summary>
        /// 加载默认的工作计划表
        /// </summary>
        /// <param name="date">The start date.</param>
        /// <returns></returns>
        private static AppointmentList CreateDefualtAppointments(DateTime date)
        {
            List <Brush> brushes = new List <Brush>();

            brushes.Add(Brushes.LimeGreen);
            brushes.Add(Brushes.PowderBlue);
            brushes.Add(Brushes.DarkGreen);
            brushes.Add(Brushes.Green);
            brushes.Add(Brushes.DimGray);
            brushes.Add(Brushes.Red);
            brushes.Add(Brushes.Yellow);
            brushes.Add(Brushes.Aquamarine);
            brushes.Add(Brushes.Plum);
            brushes.Add(Brushes.Orange);
            brushes.Add(Brushes.Pink);



            //create 7am of last monday
            DateTime timeStart = new DateTime(date.Year, date.Month, date.Day, 8, 30, 0);
            //while (timeStart.DayOfWeek != DayOfWeek.Monday)
            //{
            //    timeStart = timeStart.AddDays(-1);
            //}

            AppointmentList appts = new AppointmentList();

            int hoursToAdd = 1;

            for (int i = 0; i < 12; i++)
            {
                BrakePlanAppointments app = new BrakePlanAppointments();

                app.Subject         = "无型号";
                app.ColorBlockBrush = Brushes.LimeGreen;
                app.DateStart       = timeStart.AddHours(i * hoursToAdd);
                app.DateEnd         = app.DateStart.AddMinutes(60);
                appts.Add(app);
            }


            appts.SortAppointments();

            return(appts);
        }
Example #2
0
        /// <summary>
        /// 获取产线点
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        private AppointmentList GetPlanPoints(DataTable table)
        {
            try
            {
                AppointmentList list = new AppointmentList();

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

                int hoursToAdd  = 1;
                int minuteToAdd = 60;

                List <TimeRange> rangs = new List <TimeRange>();

                //获取小时
                for (int i = 0; i < 12; i++)
                {
                    timeStart = timeStart.AddHours(hoursToAdd);

                    timeEnd = timeStart.AddMinutes(minuteToAdd);

                    TimeRange rang = new TimeRange();
                    rang.StartTime = timeStart;
                    rang.EndTime   = timeEnd;
                    rangs.Add(rang);
                }


                foreach (DataRow itemRow in table.Rows)
                {
                    foreach (TimeRange item in rangs)
                    {
                        DateTime ptime1 = Convert.ToDateTime(itemRow["start_time"].ToString());
                        DateTime ptime2 = Convert.ToDateTime(itemRow["end_time"]);

                        if (item.IsInFullRange(ptime1, ptime2))
                        {
                            ProductionPlanMDL mdl = new ProductionPlanMDL();
                            mdl.Prase(itemRow);

                            BrakePlanAppointments app = new BrakePlanAppointments();

                            app.Subject = string.Format("型号:{0} 预计产量:{1}实际产量:{2}",
                                                        mdl.BreakeID.ToString(), mdl.PlanNum.ToString(), mdl.Actual_num.ToString());
                            app.ColorBlockBrush = Brushes.OrangeRed;
                            app.DateStart       = ptime1;
                            app.DateEnd         = ptime2;
                            app.MDL             = mdl;
                            list.Add(app);
                            break;
                        }

                        if (item.IsInRange(ptime1))
                        {
                            ProductionPlanMDL mdl = new ProductionPlanMDL();
                            mdl.Prase(itemRow);

                            BrakePlanAppointments app = new BrakePlanAppointments();

                            app.Subject = string.Format("型号:{0} 预计产量:{1}/r/n实际产量:{2}",
                                                        mdl.BreakeID.ToString(), mdl.PlanID.ToString(), mdl.Actual_num.ToString());
                            app.ColorBlockBrush = Brushes.OrangeRed;
                            app.DateStart       = ptime1;
                            app.DateEnd         = ptime2;
                            app.MDL             = mdl;
                            list.Add(app);
                            break;
                        }
                    }
                }


                return(list);
            }
            catch (Exception ex)
            {
                CLog.WriteErrLogInTrace(ex.StackTrace);
                return(null);
            }
        }