public List <chartdataPie> GetchartdataPies(MQCItem1 mQC)
        {
            List <chartdataPie> chartdatas       = new List <chartdataPie>();
            List <chartdataPie> chartdatasReturn = new List <chartdataPie>();

            for (int i = 0; i < mQC.listNGItems.Count; i++)
            {
                if (mQC.listNGItems[i].NGQuantity > 0)
                {
                    chartdatas.Add(new chartdataPie
                    {
                        Label   = mQC.listNGItems[i].NGName,
                        value   = mQC.listNGItems[i].NGQuantity,
                        Percent = (mQC.percentNG != 0) ? (mQC.listNGItems[i].NGQuantity / mQC.percentNG) : 0
                    });
                }
            }
            var group = chartdatas
                        .GroupBy(u => u.Label)
                        .Select(grp => grp.ToList())
                        .ToList();

            foreach (var item in group)
            {
                chartdataPie pie = new chartdataPie();
                pie         = item[0];
                pie.value   = item.Select(d => d.value).Sum();
                pie.Percent = (mQC.percentNG != 0) ? (pie.value / mQC.percentNG) : 0;
                chartdatasReturn.Add(pie);
            }
            return(chartdatasReturn);
        }
Esempio n. 2
0
 private void OnDispose(object sender, EventArgs e)
 {
     this.btn_chart.Click -= new System.EventHandler(this.Btn_chart_Click);
     this.lb_Lot.Click    -= new System.EventHandler(this.Lb_Lot_Click);
     mQCItem1              = null;
     // do stuff on dispose
 }
Esempio n. 3
0
        private void LoadDataERPMQCToShow()
        {
            //Load data from m_ERPMQC
            LoadDataMQC dataMQC = new LoadDataMQC();

            MQC = dataMQC.GetQCCItemOK(dateTimeFrom, dateTimeTo, MQC.product, MQC.PO, MQC.department, MQC.process);
        }
 public LineUI(MQCItem1 mQC, string dept, float sizeText)
 {
     InitializeComponent();
     mQCItem1 = mQC;
     Dept     = dept;
     SizeText = sizeText;
     UpdateUI(mQC);
     Disposed += OnDispose;
 }
Esempio n. 5
0
        private void LoadDataERPMQCToShow()
        {
            //Load data from m_ERPMQC

            LoadDataMQC dataMQC = new LoadDataMQC();

            dateTimeFrom = DateTime.Now.Date;
            dateTimeTo   = DateTime.Now.Date.AddDays(1);
            mQCItem      = dataMQC.GetQCCItemOK(dateTimeFrom, dateTimeTo, product, mQCItem.PO, dept, process);
        }
        private void LoadDataERPMQCToShow()
        {
            //Load data from m_ERPMQC

            LoadDataMQC dataMQC = new LoadDataMQC();

            //    DataTable dataLot = new DataTable();

            mQCItem = dataMQC.GetQCCItemLineLot(dateTimeFrom, dateTimeTo, Line, Model, Lot, process);
            //    }
        }
        public void UpdateUI(MQCItem1 mQC)
        {
            try
            {
                if (mQC != null && mQC.department != null)
                {
                    lb_model.Text = mQC.product;

                    lb_model.Font       = new  Font("Times New Roman", SizeText, FontStyle.Bold);
                    lb_Dept.Font        = new Font("Times New Roman", SizeText, FontStyle.Bold);
                    lb_Lot.Text         = mQC.PO;
                    lb_Lot.Font         = new Font("Times New Roman", SizeText, FontStyle.Bold);
                    lb_output.Font      = new Font("Times New Roman", SizeText + 5, FontStyle.Bold);
                    lb_targetvalue.Font = new Font("Times New Roman", SizeText + 5, FontStyle.Bold);
                    lb_defectValue.Font = new Font("Times New Roman", SizeText + 5, FontStyle.Bold);
                    if (Current != "")
                    {
                        lb_Dept.Text = mQC.line + "-" + Current;
                    }
                    else
                    {
                        lb_Dept.Text = mQC.line;
                    }
                    lb_output.Text = mQC.TotalOutput.ToString("N0");

                    lb_targetvalue.Text = mQC.TargetMQC.TargetOutput.ToString("N0");
                    lb_defectValue.Text = mQC.TotalNG.ToString("N0");

                    if (mQC.Status == ProductionStatus.ShortageMaterial.ToString())
                    {
                        pic_status.Image = null;

                        pic_status.Image = global::WindowsFormsApplication1.Properties.Resources.SHORTAGE_MATERIAL;
                    }
                    else if (mQC.Status == ProductionStatus.Normal.ToString())
                    {
                        pic_status.Image = null;

                        pic_status.Image = global::WindowsFormsApplication1.Properties.Resources.Normal_s;
                    }
                    else if (mQC.Status == ProductionStatus.HighDefect.ToString())
                    {
                        pic_status.Image = null;

                        pic_status.Image = global::WindowsFormsApplication1.Properties.Resources.High_Defect;
                    }
                }
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "UpdateUI(MQCItem1 mQC)", ex.Message);
            }
        }
        private void LoadDataERPMQCToShow()
        {
            //Load data from m_ERPMQC

            LoadDataMQC dataMQC = new LoadDataMQC();
            DataTable   dataLot = new DataTable();

            dataLot = dataMQC.GetMQCDataFromLine(mQCItem.line);
            if (dataLot != null && dataLot.Rows.Count == 1)
            {
                mQCItem = dataMQC.GetQCCItemOK(dateTimeFrom, dateTimeTo, dataLot.Rows[0][1].ToString(), dataLot.Rows[0][0].ToString(), dept, process);
            }
        }
        public MQCChart(MQCItem1 mQC, List <chartdatabyDate> chartdata, List <chartdatabyDate> chartdataDefect)
        {
            InitializeComponent();
            var scrProgram = Screen.FromControl(this);

            if (scrProgram.Primary)
            {
                // StartPosition was set to FormStartPosition.Manual in the properties window.
                Rectangle screen = Screen.PrimaryScreen.WorkingArea;
                int       w      = Width >= screen.Width ? screen.Width : (screen.Width + Width) / 2;
                int       h      = Height >= screen.Height ? screen.Height : (screen.Height + Height) / 2;
                // this.Location = new Point((screen.Width - w) / 2, (screen.Height - h) / 2);
                this.Location = new Point(0, 0);
                this.Size     = new Size(w, h);
            }
            else
            {
                Rectangle screen = scrProgram.WorkingArea;
                int       w      = Width >= screen.Width ? screen.Width : (screen.Width + Width) / 2;
                int       h      = Height >= screen.Height ? screen.Height : (screen.Height + Height) / 2;
                // this.Location = new Point((screen.Width - w) / 2, (screen.Height - h) / 2);
                this.Location = new Point(0, 0);
                this.Size     = new Size(w, h);
            }
            this.WindowState = FormWindowState.Maximized;
            MQC = mQC;
            chartdatabyDates     = chartdata;
            chartdatabyDates_old = chartdatabyDates;
            chartdatadefect      = chartdataDefect;
            chartdatadefect_old  = chartdatadefect;
            bgWorker             = new BackgroundWorker();

            // work happens in this method
            bgWorker.DoWork               += new DoWorkEventHandler(bg_DoWork);
            bgWorker.ProgressChanged      += BgWorker_ProgressChanged;
            bgWorker.RunWorkerCompleted   += new RunWorkerCompletedEventHandler(bg_RunWorkerCompleted);
            bgWorker.WorkerReportsProgress = true;
            //timer_update.Start();
            // this timer calls bgWorker again and again after regular intervals
            tmrCallBgWorker       = new System.Windows.Forms.Timer();//Timer for do task
            tmrCallBgWorker.Tick += new EventHandler(tmrCallBgWorker_Tick);
        }
        public MQCShowForm(MQCItem1 mQCItem1, string depttext)
        {
            InitializeComponent();
            var scrProgram = Screen.FromControl(this);

            if (scrProgram.Primary)
            {
                // StartPosition was set to FormStartPosition.Manual in the properties window.
                Rectangle screen = Screen.PrimaryScreen.WorkingArea;
                int       w      = Width >= screen.Width ? screen.Width : (screen.Width + Width) / 2;
                int       h      = Height >= screen.Height ? screen.Height : (screen.Height + Height) / 2;
                // this.Location = new Point((screen.Width - w) / 2, (screen.Height - h) / 2);
                this.Location = new Point(0, 0);
                this.Size     = new Size(w, h);
            }
            else
            {
                Rectangle screen = scrProgram.WorkingArea;
                int       w      = Width >= screen.Width ? screen.Width : (screen.Width + Width) / 2;
                int       h      = Height >= screen.Height ? screen.Height : (screen.Height + Height) / 2;
                // this.Location = new Point((screen.Width - w) / 2, (screen.Height - h) / 2);
                this.Location = new Point(0, 0);
                this.Size     = new Size(w, h);
            }
            mQCItem   = mQCItem1;
            deptFull  = depttext;
            IsStartup = false;
            // this is our worker
            bgWorker = new BackgroundWorker();

            // work happens in this method
            bgWorker.DoWork               += new DoWorkEventHandler(bg_DoWork);
            bgWorker.ProgressChanged      += BgWorker_ProgressChanged;
            bgWorker.RunWorkerCompleted   += new RunWorkerCompletedEventHandler(bg_RunWorkerCompleted);
            bgWorker.WorkerReportsProgress = true;
            //timer_update.Start();
            // this timer calls bgWorker again and again after regular intervals
            tmrCallBgWorker       = new System.Windows.Forms.Timer();//Timer for do task
            tmrCallBgWorker.Tick += new EventHandler(tmrCallBgWorker_Tick);
            // tmrCallBgWorker.Interval = 10000;
        }
Esempio n. 11
0
        public MQCShowForm(MQCItem1 mQCItem1, string depttext)
        {
            InitializeComponent();

            mQCItem   = mQCItem1;
            deptFull  = depttext;
            IsStartup = false;
            // this is our worker
            bgWorker = new BackgroundWorker();

            // work happens in this method
            bgWorker.DoWork               += new DoWorkEventHandler(bg_DoWork);
            bgWorker.ProgressChanged      += BgWorker_ProgressChanged;
            bgWorker.RunWorkerCompleted   += new RunWorkerCompletedEventHandler(bg_RunWorkerCompleted);
            bgWorker.WorkerReportsProgress = true;
            //timer_update.Start();
            // this timer calls bgWorker again and again after regular intervals
            tmrCallBgWorker       = new System.Windows.Forms.Timer();//Timer for do task
            tmrCallBgWorker.Tick += new EventHandler(tmrCallBgWorker_Tick);
            // tmrCallBgWorker.Interval = 10000;
        }
Esempio n. 12
0
        public MQCChart(MQCItem1 mQC, List <chartdatabyDate> chartdata, List <chartdatabyDate> chartdataDefect)
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Maximized;
            MQC = mQC;
            chartdatabyDates     = chartdata;
            chartdatabyDates_old = chartdatabyDates;
            chartdatadefect      = chartdataDefect;
            chartdatadefect_old  = chartdatadefect;
            bgWorker             = new BackgroundWorker();

            // work happens in this method
            bgWorker.DoWork               += new DoWorkEventHandler(bg_DoWork);
            bgWorker.ProgressChanged      += BgWorker_ProgressChanged;
            bgWorker.RunWorkerCompleted   += new RunWorkerCompletedEventHandler(bg_RunWorkerCompleted);
            bgWorker.WorkerReportsProgress = true;
            //timer_update.Start();
            // this timer calls bgWorker again and again after regular intervals
            tmrCallBgWorker       = new System.Windows.Forms.Timer();//Timer for do task
            tmrCallBgWorker.Tick += new EventHandler(tmrCallBgWorker_Tick);
        }
        //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");
        }
Esempio n. 14
0
        public MQCItem1 GetQCCItemOK(DateTime from, DateTime to, string model, string lot, string site, string process)
        {
            MQCItem1 mQCItem = new MQCItem1();

            try
            {
                LoadDefectMapping     defectMapping   = new LoadDefectMapping();
                List <NGItemsMapping> nGItemsMappings = defectMapping.listNGMapping("B01", "MQC");
                mQCItem.TargetMQC = new TargetMQC();
                LoadTargetProduction loadTarget = new LoadTargetProduction();
                mQCItem.TargetMQC = loadTarget.GetTargetMQC(model, DateTime.Now.Date.ToString("yyyyMMdd"));
                List <MQCDataItems> listMQC = new List <MQCDataItems>();
                listMQC = listMQCDataItems(from, to, model, lot, process);
                //Load MQCItem to show
                mQCItem.process    = process;
                mQCItem.department = site;
                mQCItem.product    = model;

                mQCItem.PO = (listMQC != null && listMQC.Count > 0) ?   listMQC[0].lot: "";
                var TotalOutputQty = listMQC
                                     .Where(d => d.remark == "OP")
                                     .Select((s => s.data))
                                     .ToList();
                mQCItem.TotalOutput = TotalOutputQty.Sum();
                var TotalNGQty = listMQC
                                 .Where(d => d.remark == "NG")
                                 .Select((s => s.data))
                                 .ToList();
                mQCItem.TotalNG = TotalNGQty.Sum();
                var TotalRework = listMQC
                                  .Where(d => d.remark == "RW")
                                  .Select((s => s.data))
                                  .ToList();
                mQCItem.TotalRework   = TotalRework.Sum();
                mQCItem.percentNG     = (mQCItem.TotalOutput + mQCItem.TotalNG + mQCItem.TotalRework) != 0 ? mQCItem.TotalNG / (mQCItem.TotalOutput + mQCItem.TotalNG + mQCItem.TotalRework) :0;
                mQCItem.percentRework = (mQCItem.TotalOutput + mQCItem.TotalNG + mQCItem.TotalRework) != 0 ? mQCItem.TotalRework / (mQCItem.TotalOutput + mQCItem.TotalNG + mQCItem.TotalRework) : 0;
                var listNGItem = listMQC
                                 .Where(d => d.remark == "NG")
                                 .Select((s => new { s.item, s.data }))
                                 .ToList();
                mQCItem.listNGItems = new List <NGItems>();
                foreach (var item in listNGItem)
                {
                    NGItems nGItems = new NGItems();
                    var     _NG_SFT = nGItemsMappings.Where(d => d.NGCode_Process == item.item).Select(s => s.NGCode_SFT).ToArray();
                    string  NG_SFT  = (_NG_SFT != null && _NG_SFT.Count() > 0) ?_NG_SFT[0] : "";
                    nGItems.NGType = NG_SFT;
                    var    _NGName_SFT = nGItemsMappings.Where(d => d.NGCode_Process == item.item).Select(s => s.NGCodeName_SFT).ToArray();
                    string NGName_SFT  = (_NGName_SFT != null && _NGName_SFT.Count() > 0) ? _NGName_SFT[0] : "";
                    nGItems.NGName = NGName_SFT;

                    nGItems.NGKey      = item.item;
                    nGItems.NGQuantity = item.data;
                    mQCItem.listNGItems.Add(nGItems);
                }
                var listRWItem = listMQC
                                 .Where(d => d.item.Contains("RW"))
                                 .Select((s => new { s.item, s.data }))
                                 .ToList();
                mQCItem.listRWItems = new List <NGItems>();
                foreach (var item in listRWItem)
                {
                    NGItems nGItems    = new NGItems();
                    string  strReplace = item.item.Replace("RW", "NG");
                    var     _NG_SFT    = nGItemsMappings.Where(d => d.NGCode_Process == strReplace).Select(s => s.NGCode_SFT).ToArray();
                    string  NG_SFT     = (_NG_SFT != null && _NG_SFT.Count() > 0) ? _NG_SFT[0] : "";
                    nGItems.NGType = NG_SFT;
                    var    _NGName_SFT = nGItemsMappings.Where(d => d.NGCode_Process == strReplace).Select(s => s.NGCodeName_SFT).ToArray();
                    string NGName_SFT  = (_NGName_SFT != null && _NGName_SFT.Count() > 0) ? _NGName_SFT[0] : "";
                    nGItems.NGName     = NGName_SFT;
                    nGItems.NGKey      = item.item;
                    nGItems.NGQuantity = item.data;
                    mQCItem.listRWItems.Add(nGItems);
                }
                List <MQCDataItems> listMQC_Error = new List <MQCDataItems>();
                listMQC_Error = listMQCData_ErrorItems(from, to, model, lot, process);
                mQCItem.InputMaterialNotYet = listMQC_Error.Where(w => w.remark == "OP" || w.remark == "NG").Select(d => d.data).ToArray().Sum();
                double targetDefect = 0;
                if (mQCItem.TargetMQC.TargetOutput != 0)
                {
                    targetDefect = (mQCItem.TargetMQC.TargetDefect / (mQCItem.TargetMQC.TargetDefect + mQCItem.TargetMQC.TargetOutput));
                }

                if (mQCItem.InputMaterialNotYet > 0)
                {
                    mQCItem.Status  = ProductionStatus.ShortageMaterial.ToString();
                    mQCItem.Measage = "Please supply material for production";
                }
                else if (mQCItem.percentNG > targetDefect && targetDefect > 0)
                {
                    mQCItem.Status  = ProductionStatus.HighDefect.ToString();
                    mQCItem.Measage = "Defect is too much";
                }
                else
                {
                    mQCItem.Status = ProductionStatus.Normal.ToString();
                }
                mQCItem.InputSFT = (mQCItem.TotalOutput + mQCItem.TotalNG) - mQCItem.InputMaterialNotYet;
            }
            catch (Exception ex)
            {
                Log.Logfile.Output(Log.StatusLog.Error, "GetQCCItemOK", ex.Message);
            }
            // sql.Append()
            return(mQCItem);
        }
Esempio n. 15
0
        public List <MQCItem1> listMQCItemsOfDept(DateTime from, DateTime to, string site, string process)
        {
            List <MQCItem1> listMQCReturn = new List <MQCItem1>();

            try
            {
                List <MQCDataItems> listMQC = new List <MQCDataItems>();
                listMQC = listMQCDataItemsbySite(from, to, site, process);
                var ListItems = listMQC
                                .GroupBy(u => u.lot)
                                .Select(grp => grp.ToList())
                                .ToList();

                foreach (var mQCDatas in ListItems)
                {
                    MQCItem1 mQCItem = new MQCItem1();

                    mQCItem.process    = process;
                    mQCItem.department = site;
                    mQCItem.product    = mQCDatas[0].model;
                    mQCItem.PO         = mQCDatas[0].lot;
                    mQCItem.TargetMQC  = new TargetMQC();
                    LoadTargetProduction loadTarget = new LoadTargetProduction();
                    mQCItem.TargetMQC = loadTarget.GetTargetMQC(mQCItem.product, DateTime.Now.Date.ToString("yyyyMMdd"));
                    var TotalOutputQty = mQCDatas
                                         .Where(d => d.remark == "OP")
                                         .Select((s => s.data))
                                         .ToList();
                    mQCItem.TotalOutput = TotalOutputQty.Sum();
                    var TotalNGQty = mQCDatas
                                     .Where(d => d.remark == "NG")
                                     .Select((s => s.data))
                                     .ToList();
                    mQCItem.TotalNG = TotalNGQty.Sum();
                    var TotalRework = mQCDatas
                                      .Where(d => d.remark == "RW")
                                      .Select((s => s.data))
                                      .ToList();
                    mQCItem.TotalRework   = TotalRework.Sum();
                    mQCItem.percentNG     = (mQCItem.TotalOutput + mQCItem.TotalNG + mQCItem.TotalRework) != 0 ? mQCItem.TotalNG / (mQCItem.TotalOutput + mQCItem.TotalNG + mQCItem.TotalRework) : 0;
                    mQCItem.percentRework = (mQCItem.TotalOutput + mQCItem.TotalNG + mQCItem.TotalRework) != 0 ? mQCItem.TotalRework / (mQCItem.TotalOutput + mQCItem.TotalNG + mQCItem.TotalRework) : 0;
                    List <MQCDataItems> listMQC_Error = new List <MQCDataItems>();
                    listMQC_Error = listMQCData_ErrorItems(from, to, mQCItem.product, mQCItem.PO, process);
                    mQCItem.InputMaterialNotYet = listMQC_Error.Where(w => w.remark == "OP" || w.remark == "NG").Select(d => d.data).ToArray().Sum();
                    double targetDefect = 0;
                    if (mQCItem.TargetMQC.TargetOutput != 0)
                    {
                        targetDefect = (mQCItem.TargetMQC.TargetDefect / (mQCItem.TargetMQC.TargetDefect + mQCItem.TargetMQC.TargetOutput));
                    }
                    if (mQCItem.InputMaterialNotYet > 0)
                    {
                        mQCItem.Status  = ProductionStatus.ShortageMaterial.ToString();
                        mQCItem.Measage = "Please supply material for production";
                    }
                    else if (mQCItem.percentNG > targetDefect && targetDefect > 0)
                    {
                        mQCItem.Status  = ProductionStatus.HighDefect.ToString();
                        mQCItem.Measage = "Defect is too much";
                    }
                    else
                    {
                        mQCItem.Status = ProductionStatus.Normal.ToString();
                    }
                    mQCItem.InputSFT = (mQCItem.TotalOutput + mQCItem.TotalNG) - mQCItem.InputMaterialNotYet;
                    listMQCReturn.Add(mQCItem);
                }
            }
            catch (Exception ex)
            {
                Log.Logfile.Output(Log.StatusLog.Error, "listMQCItemsOfDept()", ex.Message);
            }
            return(listMQCReturn);
        }