Ejemplo n.º 1
0
        private void LoadDataERPMQCToShow()
        {
            //Load data from m_ERPMQC
            LoadDataMQC dataMQC = new LoadDataMQC();

            dept        = "B01";
            process     = "MQC";
            ListMQCshow = dataMQC.listMQCItemsOfDept(dateTimeFrom, dateTimeTo, dept, process);
            int topCount = CountColumn * CountRow;

            ListMQCTake = ListMQCshow.Take(topCount).ToList();
            layoutMain.Controls.Clear();

            if (ListMQCTake.Count <= topCount)
            {
                int countList = 0;
                for (int i = 0; i < CountRow; i++)
                {
                    for (int j = 0; j < CountColumn; j++)
                    {
                        if (countList < ListMQCTake.Count)
                        {
                            //   line.Dispose();
                            if (this.WindowState == FormWindowState.Normal)
                            {
                                line = new LineUI(ListMQCTake[countList], cb_Department.Text, 20);
                            }
                            else if (this.WindowState == FormWindowState.Maximized)
                            {
                                line = new LineUI(ListMQCTake[countList], cb_Department.Text, 25);
                            }
                            line.Name = ListMQCTake[countList].product;

                            line.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                                 | System.Windows.Forms.AnchorStyles.Left)
                                                                                | System.Windows.Forms.AnchorStyles.Right)));

                            layoutMain.Controls.Add(line, j, i);
                            countList++;
                        }
                    }
                }
            }


            lb_Clock.Text = DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss");
        }
        //private void ScaleFont(Label lab)
        //{
        //    SizeF extent = TextRenderer.MeasureText(lab.Text, lab.Font);

        //    float hRatio = lab.Height / extent.Height;
        //    float wRatio = lab.Width / extent.Width;
        //    float ratio = (hRatio < wRatio) ? hRatio : wRatio;

        //    float newSize = lab.Font.Size * ratio;

        //    lab.Font = new Font(lab.Font.FontFamily, newSize, lab.Font.Style);
        //}
        private void LoadDataERPMQCToShow()
        {
            //Load data from m_ERPMQC
            LoadDataMQC dataMQC = new LoadDataMQC();

            dept        = "B01";
            process     = "MQC";
            ListMQCshow = dataMQC.listMQCItemsOfDept(dateTimeFrom, dateTimeTo, dept, process);
            var listshowline = ListMQCshow
                               .OrderBy(u => u.line)
                               .GroupBy(u => u.line)
                               .Select(grp => grp.ToList())
                               .ToList();
            List <MQCItem1> ListShowbyLine = new List <MQCItem1>();

            foreach (var LineData in listshowline)
            {
                MQCItem1 mQC     = new MQCItem1();
                DateTime maxDate = LineData.Select(d => d.DateRun).Max();
                mQC = LineData.Where(d => d.DateRun == maxDate).ToList()[0];

                ListShowbyLine.Add(mQC);
            }

            int topCount = CountColumn * CountRow;

            //ListMQCTake = ListMQCshow.Take(topCount).ToList();
            layoutMain.Controls.Clear();

            if (ListShowbyLine.Count <= topCount)
            {
                int countList = 0;
                for (int i = 0; i < CountRow; i++)
                {
                    for (int j = 0; j < CountColumn; j++)
                    {
                        if (countList < ListShowbyLine.Count)
                        {
                            //   line.Dispose();
                            if (this.WindowState == FormWindowState.Normal)
                            {
                                line = new LineUI(ListShowbyLine[countList], cb_Department.Text, 20);
                            }
                            else if (this.WindowState == FormWindowState.Maximized)
                            {
                                line = new LineUI(ListShowbyLine[countList], cb_Department.Text, 25);
                            }
                            line.Name = ListShowbyLine[countList].line;

                            line.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                                 | System.Windows.Forms.AnchorStyles.Left)
                                                                                | System.Windows.Forms.AnchorStyles.Right)));

                            layoutMain.Controls.Add(line, j, i);
                            countList++;
                        }
                    }
                }
            }


            lb_Clock.Text = DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss");
        }