Пример #1
0
        /// <summary>
        /// 初始化数据列表
        /// </summary>
        //private void LoadDataGrid2()
        //{
        //    if (index >= 4)
        //        index = 0;

        //    ArrayList list = new ArrayList();

        //    list.Add("MGU Lin1");
        //    list.Add("PN");
        //    list.Add("PLAN");
        //    list.Add("ACTUAL");
        //    list.Add("OEE");

        //    PlineInfo info = (PlineInfo)plinelist[index];

        //    int rowHeight = (int)((double)this.dataGridView1.Height / 5) - 6;
        //    //if (pItems == null)
        //    //    return;

        //    Random ran = new Random();
        //    int RandKey = ran.Next(100, 999);

        //    DataGridViewRow row = new DataGridViewRow();


        //    for (int i = 0; i < 5; i++)
        //    {
        //        DataGridViewTextBoxCell contentCell = new DataGridViewTextBoxCell();
        //        if (i > 0)
        //        {
        //                contentCell.Value = list[i].ToString();
        //        }
        //        else
        //            contentCell.Value = "";


        //        contentCell.Style.ForeColor = Color.White;
        //        row.Cells.Add(contentCell);
        //    }


        //    row.Height = rowHeight;
        //    row.DefaultCellStyle.Font = new Font("黑体", 9, FontStyle.Bold);

        //    row.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
        //    row.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
        //    this.dataGridView1.Rows.Add(row);


        //    for (int c = 0; c < 4; c++)
        //    {
        //        row = new DataGridViewRow();

        //        double oee = 0.0;
        //        int plan = 0;
        //        for (int i = 0; i < 5; i++)
        //        {
        //            DataGridViewTextBoxCell contentCell = new DataGridViewTextBoxCell();



        //            switch (i)
        //            {
        //                case 0:

        //                    //contentCell.Value = "MGU Lin1";
        //                    contentCell.Value=info.PLineID;
        //                    break;
        //                case 1:
        //                    //contentCell.Value = string.Empty;
        //                    contentCell.Value=info.PN[c];
        //                    break;
        //                case 2:
        //                    //RandKey = ran.Next(500, 800);
        //                    //contentCell.Value = (RandKey ).ToString();
        //                   // contentCell.Value = string.Empty;
        //                     plan = (int)CommUitls.GetRandomNumber(info.PLAN[c] - 10, info.PLAN[c] + 50, 2);
        //                      contentCell.Value = plan.ToString();
        //                    break;
        //                case 3:

        //                    //contentCell.Value = (RandKey - 40).ToString();
        //                   // contentCell.Value = string.Empty;

        //                     oee = (int)CommUitls.GetRandomNumber(info.OEE[c] - 4, info.OEE[c] + 3, 2);

        //                     double changeVal = oee / 100;
        //                   // int actual = (int)CommUitls.GetRandomNumber(info.Actual[c] - 10, info.Actual[c] + 50, 2);
        //                     int actual = (int)(plan * changeVal);

        //                     contentCell.Value = actual.ToString();
        //                    //contentCell.Value = info.Actual[i].ToString();
        //                    break;
        //                case 4:
        //                    //RandKey = ran.Next(88, 95);
        //                    //contentCell.Value = RandKey.ToString() + "%";
        //                   // contentCell.Value = string.Empty;

        //                   // int oee = (int)CommUitls.GetRandomNumber(info.OEE[c] - 4, info.OEE[c] + 3, 2);
        //                 //   int oee = GetRandomValue(info.PLineID, 2);
        //                    contentCell.Value = ((int)oee).ToString() + "%";
        //                    //contentCell.Value = info.OEE[i].ToString() + "%";
        //                    break;

        //                default:
        //                    break;

        //            }

        //            contentCell.Style.ForeColor = Color.White;
        //            row.Cells.Add(contentCell);
        //        }
        //        row.Height = rowHeight;
        //        row.DefaultCellStyle.Font = new Font("黑体", 9, FontStyle.Bold);

        //        row.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
        //        row.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
        //        this.dataGridView1.Rows.Add(row);
        //    }

        //    index++;

        //}


        private int  GetRandomValue(int lineID, int oee)
        {
            try
            {
                int ret = 80;

                switch (lineID)
                {
                case 0:

                    ret = (int)CommUitls.GetRandomNumber(85, 87, 2);

                    break;

                case 1:
                    ret = (int)CommUitls.GetRandomNumber(86, 90, 2);

                    break;

                case 2:
                    ret = (int)CommUitls.GetRandomNumber(90, 92, 2);

                    break;

                case 3:
                    ret = (int)CommUitls.GetRandomNumber(90, 94, 2);

                    break;

                default:
                    break;
                }

                return(ret);
            }
            catch
            {
                return(0);
            }
        }
Пример #2
0
        /// <summary>
        /// 初始化数据列表
        /// </summary>
        private void LoadTotalGridDataGrid()
        {
            ///LoadColumnHeader();

            ArrayList list = new ArrayList();

            //list.Add("型 号");
            //list.Add("计划量");
            //list.Add("实际\r\n产量");
            //list.Add("OEE");
            //list.Add("备注");

            list.Add("PLine");
            list.Add("Produc\r\ttivity");
            list.Add("C/O");
            //  list.Add("Down Time");
            list.Add("OEE");

            int rowHeight = (int)((double)this.dataGridView2.Height / 5) - 6;
            //if (pItems == null)
            //    return;

            Random ran     = new Random();
            int    RandKey = ran.Next(100, 999);

            DataGridViewRow row = new DataGridViewRow();


            int fontSize = 15;

            if (this.Width > 1000)
            {
                fontSize = fontSize * 2;
            }

            //  for (int i = 0; i < 5; i++)
            for (int i = 0; i < 4; i++)
            {
                DataGridViewTextBoxCell contentCell = new DataGridViewTextBoxCell();
                contentCell.Value = list[i].ToString();

                contentCell.Style.ForeColor = Color.White;
                // contentCell.Style.Font= new Font("黑体", 15, FontStyle.Bold);
                row.Cells.Add(contentCell);
            }
            row.Height = rowHeight;
            row.DefaultCellStyle.Font = new Font("黑体", fontSize, FontStyle.Bold);

            row.DefaultCellStyle.WrapMode  = DataGridViewTriState.True;
            row.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dataGridView2.Rows.Add(row);


            for (int c = 0; c < 4; c++)
            {
                row = new DataGridViewRow();

                for (int i = 0; i < 4; i++)
                //  for (int i = 0; i < 5; i++)
                {
                    DataGridViewTextBoxCell contentCell = new DataGridViewTextBoxCell();
                    switch (i)
                    {
                    case 0:    //编号
                        if (c > 2)
                        {
                            contentCell.Value = "MGU Line";
                        }
                        else
                        {
                            contentCell.Value = "Line" + (c + 1).ToString();
                        }
                        break;

                    case 1:    //生产效率
                        // RandKey = ran.Next(8, 9.6);
                        //double productivity = CommUitls.GetRandomNumber(8.0, 9.6, 1);
                        //contentCell.Value = productivity.ToString(); //+ "%";

                        if ((c % 2) == 0)
                        {
                            double productivity = CommUitls.GetRandomNumber(8.2, 9.4, 1);
                            contentCell.Value = productivity.ToString();
                        }
                        else
                        {
                            double productivity = CommUitls.GetRandomNumber(8.0, 9.0 + c * 0.5, 1);
                            contentCell.Value = productivity.ToString();
                        }

                        break;

                    case 2:    //换型时间

                        if ((c % 2) == 0)
                        {
                            double change = CommUitls.GetRandomNumber(0.07, 0.21 + c * 0.05, 2);
                            contentCell.Value = change.ToString() + "h";
                        }
                        else
                        {
                            double change = CommUitls.GetRandomNumber(0.05, 0.22 + c * 0.02, 2);
                            contentCell.Value = change.ToString() + "h";
                        }

                        break;
                    //case 3://故障时间
                    //    //RandKey = ran.Next(88, 95);
                    //    //contentCell.Value =RandKey.ToString()+"%";

                    //    if ((c % 2) == 0)
                    //    {
                    //        double change = CommUitls.GetRandomNumber(0.02,c*0.10, 2);
                    //        contentCell.Value = change.ToString() + "h";
                    //    }
                    //    else
                    //    {
                    //        double change = CommUitls.GetRandomNumber(0.01, 0.10, 2);
                    //        contentCell.Value = change.ToString() + "h";
                    //    }
                    //    break;
                    // case 4:
                    case 3:
                        // RandKey = ran.Next(90, 97);
                        //contentCell.Value =RandKey.ToString()+"%";

                        int oee = GetRandomValue(c, 2);
                        contentCell.Value = oee.ToString() + "%";
                        break;

                    default:
                        break;
                    }

                    contentCell.Style.ForeColor = Color.White;
                    row.Cells.Add(contentCell);
                }
                row.Height = rowHeight;
                row.DefaultCellStyle.Font = new Font("黑体", fontSize, FontStyle.Bold);

                row.DefaultCellStyle.WrapMode  = DataGridViewTriState.True;
                row.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                this.dataGridView2.Rows.Add(row);
            }

            ////Cloumn
            //for (int i = 0; i < 4; i++)
            //{
            //    DataGridViewRow row = new DataGridViewRow();


            //    //row
            //    for (int j = 0; j < 5; j++)
            //    {
            //        DataGridViewTextBoxCell contentCell = new DataGridViewTextBoxCell();

            //        switch (j)
            //        {
            //            case 0:
            //                contentCell.Value = list[i];
            //                break;
            //            case 1:
            //                contentCell.Value = "Line"+(i+1).ToString();
            //                break;
            //            case 2:
            //                contentCell.Value = string.Empty; ;
            //                break;
            //            case 3:
            //                contentCell.Value = string.Empty;

            //                break;

            //            default:
            //                break;

            //        }
            //        contentCell.Style.ForeColor = Color.White;
            //        row.Cells.Add(contentCell);
            //    }

            //    row.Height = rowHeight;
            //    row.DefaultCellStyle.Font = new Font("黑体", 12, FontStyle.Bold);

            //    row.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            //    row.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            //    this.dataGridView2.Rows.Add(row);


            //}
        }
Пример #3
0
        /// <summary>
        /// 初始化数据列表
        /// </summary>
        private void LoadDataGrid2()
        {
            if (index >= 4)
            {
                index = 0;
            }

            ArrayList list = new ArrayList();

            list.Add("MGU Lin1");
            list.Add("PN");
            list.Add("PLAN");
            list.Add("ACTUAL");
            list.Add("OEE");

            PlineInfo info = (PlineInfo)plinelist[index];

            int rowHeight = (int)((double)this.dataGridView1.Height / 5) - 6;
            //if (pItems == null)
            //    return;

            Random ran     = new Random();
            int    RandKey = ran.Next(100, 999);

            DataGridViewRow row = new DataGridViewRow();


            for (int i = 0; i < 5; i++)
            {
                DataGridViewTextBoxCell contentCell = new DataGridViewTextBoxCell();
                if (i > 0)
                {
                    contentCell.Value = list[i].ToString();
                }
                else
                {
                    contentCell.Value = "";
                }


                contentCell.Style.ForeColor = Color.White;
                row.Cells.Add(contentCell);
            }


            row.Height = rowHeight;
            row.DefaultCellStyle.Font = new Font("黑体", 9, FontStyle.Bold);

            row.DefaultCellStyle.WrapMode  = DataGridViewTriState.True;
            row.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dataGridView1.Rows.Add(row);


            for (int c = 0; c < 4; c++)
            {
                row = new DataGridViewRow();

                double oee  = 0.0;
                int    plan = 0;
                for (int i = 0; i < 5; i++)
                {
                    DataGridViewTextBoxCell contentCell = new DataGridViewTextBoxCell();



                    switch (i)
                    {
                    case 0:

                        //contentCell.Value = "MGU Lin1";
                        contentCell.Value = info.PLineID;
                        break;

                    case 1:
                        //contentCell.Value = string.Empty;
                        contentCell.Value = info.PN[c];
                        break;

                    case 2:
                        //RandKey = ran.Next(500, 800);
                        //contentCell.Value = (RandKey ).ToString();
                        // contentCell.Value = string.Empty;
                        plan = (int)CommUitls.GetRandomNumber(info.PLAN[c] - 10, info.PLAN[c] + 50, 2);
                        contentCell.Value = plan.ToString();
                        break;

                    case 3:

                        //contentCell.Value = (RandKey - 40).ToString();
                        // contentCell.Value = string.Empty;

                        oee = (int)CommUitls.GetRandomNumber(info.OEE[c] - 4, info.OEE[c] + 3, 2);

                        double changeVal = oee / 100;
                        // int actual = (int)CommUitls.GetRandomNumber(info.Actual[c] - 10, info.Actual[c] + 50, 2);
                        int actual = (int)(plan * changeVal);

                        contentCell.Value = actual.ToString();
                        //contentCell.Value = info.Actual[i].ToString();
                        break;

                    case 4:
                        //RandKey = ran.Next(88, 95);
                        //contentCell.Value = RandKey.ToString() + "%";
                        // contentCell.Value = string.Empty;

                        // int oee = (int)CommUitls.GetRandomNumber(info.OEE[c] - 4, info.OEE[c] + 3, 2);
                        //   int oee = GetRandomValue(info.PLineID, 2);
                        contentCell.Value = ((int)oee).ToString() + "%";
                        //contentCell.Value = info.OEE[i].ToString() + "%";
                        break;

                    default:
                        break;
                    }

                    contentCell.Style.ForeColor = Color.White;
                    row.Cells.Add(contentCell);
                }
                row.Height = rowHeight;
                row.DefaultCellStyle.Font = new Font("黑体", 9, FontStyle.Bold);

                row.DefaultCellStyle.WrapMode  = DataGridViewTriState.True;
                row.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                this.dataGridView1.Rows.Add(row);
            }

            index++;
        }