예제 #1
0
        public static void FillOutStencilTable(DataGridView grid, Dictionary <string, MesModels> mesModels)
        {
            DataTable smtRecords = SQLoperations.GetStencilSmtRecords();
            Dictionary <string, stencilStruct> stencilDict = new Dictionary <string, stencilStruct>();

            foreach (DataRow row in smtRecords.Rows)
            {
                string   stencilID = row["StencilQR"].ToString();
                string   model     = row["Model"].ToString();
                DateTime date      = DateTime.Parse(row["DataCzasKoniec"].ToString());

                MesModels modelInfo;
                if (!mesModels.TryGetValue(model, out modelInfo))
                {
                    continue;
                }
                if (stencilID.Trim() == "")
                {
                    continue;
                }
                int qty = 0;
                int.TryParse(row["IloscWykonana"].ToString(), out qty);

                if (qty > 0)
                {
                    if (!stencilDict.ContainsKey(stencilID))
                    {
                        stencilDict.Add(stencilID, new stencilStruct());
                        stencilDict[stencilID].dateEnd   = new DateTime(1700, 01, 01);
                        stencilDict[stencilID].dateStart = DateTime.Now;
                    }
                    stencilDict[stencilID].cycleCOunt += qty / modelInfo.PcbsOnCarrier;

                    if (date < stencilDict[stencilID].dateStart)
                    {
                        stencilDict[stencilID].dateStart = date;
                    }

                    if (date > stencilDict[stencilID].dateEnd)
                    {
                        stencilDict[stencilID].dateEnd = date;
                    }
                }
            }

            grid.Columns.Clear();
            grid.Columns.Add("StencilID", "StencilID");
            grid.Columns.Add("Ilosc", "Ilość cykli");
            grid.Columns.Add("Okres", "Okres dni");
            grid.Columns.Add("Avg", "Średnio na dzień");

            foreach (var stencilEntry in stencilDict)
            {
                grid.Rows.Add(stencilEntry.Key, stencilEntry.Value.cycleCOunt, Math.Round((DateTime.Now - stencilEntry.Value.dateStart).TotalDays, 0, MidpointRounding.AwayFromZero), Math.Round(stencilEntry.Value.cycleCOunt / Math.Round((DateTime.Now - stencilEntry.Value.dateStart).TotalDays, 0, MidpointRounding.AwayFromZero), 1));
            }

            dgvTools.ColumnsAutoSize(grid, DataGridViewAutoSizeColumnMode.AllCells);
        }
        public static List <string> FillOutTestummaryReturnPcbOK(DataGridView grid, string lot)
        {
            Dictionary <string, Dictionary <string, DataTable> > testTable = SQLoperations.GetTestMeasurementsForLot(lot);
            DataTable table = new DataTable();

            table.Columns.Add("Start");
            table.Columns.Add("End");
            table.Columns.Add("Tester");
            table.Columns.Add("Tested");
            table.Columns.Add("OK");
            table.Columns.Add("NG");
            List <string> pcbOKList = new List <string>();

            foreach (var testerEntry in testTable)
            {
                int      total = 0;
                int      good  = 0;
                int      ng    = 0;
                DateTime start = DateTime.Now;
                DateTime end   = new DateTime(2000, 01, 01);
                List <Tuple <string, string> > ngList = new List <Tuple <string, string> >();


                foreach (var pcbEntry in testerEntry.Value)
                {
                    DateTime time = DateTime.Parse(pcbEntry.Value.Rows[0]["inspection_time"].ToString());

                    if (time > end)
                    {
                        end = time;
                    }
                    if (time < start)
                    {
                        start = time;
                    }

                    string result = pcbEntry.Value.Rows[0]["result"].ToString();
                    if (result == "OK")
                    {
                        pcbOKList.Add(pcbEntry.Key);
                        good++;
                    }
                    else
                    {
                        ng++;
                        ngList.Add(new Tuple <string, string>(pcbEntry.Key, result));
                    }
                    total++;
                }

                table.Rows.Add(start, end, testerEntry.Key, total, good, ng);
            }

            FillOutGrid(grid, table, false);
            return(pcbOKList);
        }
        public static void FilloutBoxingSummary(DataGridView grid, List <string> pcbs)
        {
            if (pcbs.Count > 0)
            {
                Dictionary <string, List <string> > boxes = SQLoperations.GetBoxingInfo(pcbs);

                grid.Columns.Clear();
                grid.Columns.Add("Pole", "");
                grid.Columns.Add("Wartość", "");

                foreach (var boxEntry in boxes)
                {
                    grid.Rows.Add(boxEntry.Key, boxEntry.Value.Count + "szt.");
                }

                SMTOperations.autoSizeGridColumns(grid);
            }
        }
        public static void FillOutViSummary(DataGridView grid, string lot)
        {
            DataTable viTable = SQLoperations.GetVisInspForLotL(lot);

            FillOutGrid(grid, viTable, true);
        }
        public static void FillOutSmtSummary(DataGridView grid, string lot)
        {
            DataTable smtTable = SQLoperations.GetSmtRecordsForLot(lot);

            FillOutGrid(grid, smtTable, false);
        }
        public static void FillOutKitting(DataGridView grid, string lot)
        {
            DataTable kitTable = SQLoperations.GetKittingInfoForLot(lot);

            FillOutGrid(grid, kitTable, false);
        }
        public static void ReLoadViTab(
            ref Dictionary <string, string> lotModelDictionary,
            ref List <WasteDataStructure> inspectionData,
            ref List <excelOperations.order12NC> mstOrders,
            ComboBox comboBoxViOperatorsCapa,
            ComboBox comboBoxModel,
            ComboBox comboBoxViModelAnalFamily,
            ComboBox comboBoxViModelAnalModel,

            CheckedListBox checkedListBoxViWasteLevelSmtLines,
            CheckedListBox checkedListBoxViReasons,
            CheckedListBox cBListViReasonAnalysesSmtLines,
            CheckedListBox cBListViModelAnalysesSmtLines,
            CheckedListBox cBListViReasonList,

            DateTimePicker dateTimePickerPrzyczynyOdpaduOd,
            DateTimePicker dateTimePickerWasteLevelBegin,
            DataGridView dataGridViewDuplikaty,
            DataGridView dataGridViewPomylkiIlosc,
            DataGridView dataGridViewPowyzej50,
            DataGridView dataGridViewBledyNrZlec,
            DataGridView dataGridViewMstOrders,
            DataGridView dataGridViewViOperatorsTotal,
            DataGridView gridLatestLots,
            DateTimePicker dateTimePickerViOperatorEfiiciencyStart,
            DateTimePicker dateTimePickerViOperatorEfiiciencyEnd,
            NumericUpDown numericUpDownMoreThan50Scrap,
            NumericUpDown numericUpDownMoreThan50Ng,
            Dictionary <string, string> lotToOrderedQty,

            //rework
            DataGridView dataGridViewReworkDailyReport,
            DataGridView dataGridViewReworkByOperator,
            DataGridView dataGridViewServiceVsNg,
            Chart chartServiceVsNg,
            bool chartDaily
            )
        {
            mstOrders = excelOperations.loadExcel(ref lotModelDictionary);

            if (masterVITable.Rows.Count < 1)
            {
                masterVITable = SQLoperations.DownloadVisInspFromSQL(120);
            }

            //textBox1.Text += "SQL table: " + masterVITable.Rows.Count + " rows" + Environment.NewLine;
            comboBoxViOperatorsCapa.Items.AddRange(CreateOperatorsList(masterVITable).ToArray());
            lotToSmtLine   = SQLoperations.lotToSmtLine(80); // to remove???
            inspectionData = ViDataLoader.LoadData(masterVITable, lotToSmtLine, lotModelDictionary);

            string[] smtLines = lotToSmtLine.Select(l => l.Value).Distinct().OrderBy(o => o).ToArray();

            foreach (var smtLine in smtLines)
            {
                checkedListBoxViWasteLevelSmtLines.Items.Add(smtLine, true);

                checkedListBoxViReasons.Items.Add(smtLine, true);
                cBListViReasonAnalysesSmtLines.Items.Add(smtLine, true);
                cBListViModelAnalysesSmtLines.Items.Add(smtLine, true);
            }

            comboBoxModel.Items.AddRange(lotModelDictionary.Select(m => m.Value.Replace("LLFML", "")).Distinct().OrderBy(o => o).ToArray());

            dateTimePickerPrzyczynyOdpaduOd.Value = DateTime.Now.AddDays(-30);
            dateTimePickerWasteLevelBegin.Value   = DateTime.Now.AddDays(-30);
            comboBoxViOperatorsCapa.SelectedIndex = comboBoxViOperatorsCapa.Items.IndexOf("Wszyscy");

            dataGridViewDuplikaty.DataSource = SzukajDuplikatow(inspectionData);
            dgvTools.ColumnsAutoSize(dataGridViewDuplikaty, DataGridViewAutoSizeColumnMode.AllCells);
            dataGridViewDuplikaty.Sort(dataGridViewDuplikaty.Columns[0], ListSortDirection.Descending);
            dgvTools.ColumnsAutoSize(dataGridViewDuplikaty, DataGridViewAutoSizeColumnMode.AllCells);

            dataGridViewPomylkiIlosc.DataSource = PomylkiIlosci(lotToOrderedQty, inspectionData);
            dgvTools.ColumnsAutoSize(dataGridViewPomylkiIlosc, DataGridViewAutoSizeColumnMode.AllCellsExceptHeader);

            dataGridViewPowyzej50.DataSource = MoreThan50(numericUpDownMoreThan50Scrap, numericUpDownMoreThan50Ng, lotModelDictionary, inspectionData);
            dgvTools.ColumnsAutoSize(dataGridViewPowyzej50, DataGridViewAutoSizeColumnMode.AllCells);
            dataGridViewPowyzej50.Sort(dataGridViewPowyzej50.Columns["Ile"], ListSortDirection.Descending);


            HashSet <string> wasteReasonList = new HashSet <string>();

            foreach (var wasteReason in inspectionData)
            {
                foreach (var r in wasteReason.WastePerReason)
                {
                    wasteReasonList.Add(r.Key.Replace("ng", "").Replace("scrap", ""));
                }
                break;
            }

            cBListViReasonList.Items.AddRange(wasteReasonList.ToArray());



            comboBoxViModelAnalFamily.Items.AddRange(modelFamilyList(inspectionData, lotModelDictionary));
            comboBoxViModelAnalModel.Items.AddRange(uniqueModelsList(inspectionData, lotModelDictionary));

            dataGridViewBledyNrZlec.DataSource = UnknownOrderNumberTable(lotModelDictionary, inspectionData);

            VIOperations.ngRatePerOperator(inspectionData, dateTimePickerViOperatorEfiiciencyStart.Value, dateTimePickerViOperatorEfiiciencyEnd.Value, dataGridViewViOperatorsTotal);

            SMTOperations.autoSizeGridColumns(dataGridViewViOperatorsTotal);

            dataGridViewMstOrders.DataSource = VIOperations.checkMstViIfDone(mstOrders, inspectionData);

            Rework.FillOutGridDailyProdReport(dataGridViewReworkDailyReport, dataGridViewReworkByOperator, SQLoperations.GetLedRework());
            RefreshReworkChart(inspectionData, chartServiceVsNg, chartDaily, dataGridViewServiceVsNg);

            FillOutGridLatestLots(gridLatestLots, inspectionData);
        }
예제 #8
0
        public static void FillOutGridTraceability(string[] ledIds, DataGridView grid)
        {
            DataTable sqlSmtTable = SQLoperations.GetSmtLedTraceability();
            DataTable sourceTable = new DataTable();

            sourceTable.Columns.Add("Dioda");
            sourceTable.Columns.Add("LOT");
            sourceTable.Columns.Add("SMT");
            sourceTable.Columns.Add("Box");
            sourceTable.Columns.Add("Końc.");
            List <string[]> rowsList     = new List <string[]>();
            List <string[]> notFoundList = new List <string[]>();

            foreach (DataRow row in sqlSmtTable.Rows)
            {
                //DataCzasKoniec,LiniaSMT,NrZlecenia,Model
                //  94MWS59R80JZ3E-137099    :83|137100:94MWS59R80JZ3E:81#137105:94MWS59R80JZ3E:82|137106:94MWS59R80JZ3E:75

                string        lot          = row["NrZlecenia"].ToString();
                string        smtLine      = row["LiniaSMT"].ToString();
                string        model        = row["Model"].ToString();
                string        date         = row["DataCzasKoniec"].ToString();
                string        ledLeftovers = row["KoncowkiLED"].ToString();
                string[]      splitByheads = ledLeftovers.Split('#');
                List <string> ledIdList    = new List <string>();
                List <string> lotsList     = new List <string>();
                //94MWS59R80JZ3E-139693


                foreach (var head in splitByheads)
                {
                    string[] leds = head.Split('|');
                    foreach (var led in leds)
                    {
                        var props = led.Split(':');
                        var pair  = props[1] + "-" + props[0];
                        var left  = props[2];
                        if (!ledIds.Contains(pair))
                        {
                            break;
                        }
                        rowsList.Add(new string[] { pair, lot, model, smtLine, left });
                    }
                }
            }
            foreach (var id in ledIds)
            {
                if (id.Trim() == "")
                {
                    continue;
                }
                bool idFound = false;
                foreach (var item in rowsList)
                {
                    if (id == item[0])
                    {
                        sourceTable.Rows.Add(item);
                        idFound = true;
                    }
                }
                if (!idFound)
                {
                    notFoundList.Add(id.Split('-'));
                    sourceTable.Rows.Add(id, "Nieznane", "Brak", "Danych", "SMT");
                }
            }

            var notFoundLots = SQLoperations.GetZlecenieString(notFoundList);

            foreach (DataRow row in sourceTable.Rows)
            {
                if (row["LOT"].ToString() == "Nieznane")
                {
                    string nc12Id = row["Dioda"].ToString();
                    foreach (var item in notFoundLots)
                    {
                        if (nc12Id == item[0] + "-" + item[1])
                        {
                            row["LOT"] = item[2];
                        }
                    }
                }
            }

            //foreach (DataRow gridRow in sourceTable.Rows)
            //{
            //    string lotNo = gridRow["LOT"].ToString();
            //    if (lotsList.Contains(lotNo) || lotNo == "") continue;
            //    List<string> serials = SQLoperations.lotToPcbSerialNo(lotNo);
            //    gridRow["Box"] = string.Join("|", SQLoperations.GetBoxPalletIdFromPcb(serials).ToArray());
            //    lotsList.Add(lotNo);

            //}

            grid.DataSource = sourceTable;
        }