예제 #1
0
        public static void FillGridWorkReport(DataTable lotTable, DataGridView grid)
        {
            DataTable dt = lotTable.Copy();

            dt.Columns.Remove("LiniaProdukcyjna");
            SortedDictionary <DateTime, SortedDictionary <int, DataTable> > tablesPerDayPerShift = SMTOperations.sortTableByDayAndShift(dt, "DataCzasWydruku");


            System.Drawing.Color rowColor = System.Drawing.Color.LightBlue;

            grid.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

            foreach (var dayEntry in tablesPerDayPerShift)
            {
                if (rowColor == System.Drawing.Color.LightBlue)
                {
                    rowColor = System.Drawing.Color.White;
                }
                else
                {
                    rowColor = System.Drawing.Color.LightBlue;
                }
                var week = dateTools.GetIso8601WeekOfYear(dayEntry.Key);

                foreach (var shiftEntry in dayEntry.Value)
                {
                    double qty = 0;
                    foreach (DataRow row in shiftEntry.Value.Rows)
                    {
                        qty += double.Parse(row["Ilosc_wyrobu_zlecona"].ToString());
                    }

                    grid.Rows.Add(dayEntry.Key.ToShortDateString(), week, shiftEntry.Key.ToString(), qty);
                    foreach (DataGridViewCell cell in grid.Rows[grid.Rows.Count - 1].Cells)
                    {
                        cell.Style.BackColor = rowColor;
                        if (cell.OwningColumn.HeaderText == "Ilość")
                        {
                            cell.Tag = shiftEntry.Value;
                        }
                    }
                }
            }
            grid.FirstDisplayedScrollingRowIndex = grid.RowCount - 1;
            SMTOperations.autoSizeGridColumns(grid);
        }
예제 #2
0
        public static void ReLoadSmtTab(
            DataGridView dataGridViewSmtProduction,
            DataGridView dataGridViewChangeOvers,
            DataGridView dataGridViewSmtLedDropped,
            DataGridView dataGridViewSmtLedWasteByModel,
            DataGridView dataGridViewSmtWasteTotal,
            DataGridView dataGridViewSmtLedWasteTotalPerLine,
            DataGridView dataGridViewSmtStencilUsage,
            DataTable smtRecords,
            ref Dictionary <string, Dictionary <string, List <durationQuantity> > > smtModelLineQuantity,
            RadioButton radioButtonSmtShowAllModels,
            Dictionary <string, MesModels> mesModels,
            ComboBox comboBoxSmtModels,
            ComboBox comboBoxSmtLedWasteLine,
            ComboBox comboBoxSmtLewWasteFreq,
            ComboBox comboBoxSmtLedWasteLines,
            Dictionary <string, Color> lineColors,
            Chart chartLedWasteChart,
            Panel panelSmtLedWasteCheckContainer)
        {
            SortedDictionary <DateTime, SortedDictionary <int, DataTable> > sortedTableByDayAndShift = SMTOperations.sortTableByDayAndShift(smtRecords, "DataCzasKoniec");

            SMTOperations.shiftSummaryDataSource(sortedTableByDayAndShift, dataGridViewSmtProduction);

            smtModelLineQuantity = SMTOperations.smtQtyPerModelPerLine(smtRecords, radioButtonSmtShowAllModels.Checked, mesModels);
            comboBoxSmtModels.Items.AddRange(smtModelLineQuantity.Select(m => m.Key).OrderBy(m => m).ToArray());

            ChangeOverTools.BuildSmtChangeOverGrid(ChangeOverTools.BuildDateShiftLineDictionary(smtRecords), dataGridViewChangeOvers);

            ledWasteDictionary = LedWasteDictionary(sortedTableByDayAndShift, mesModels);
            SMTOperations.FillOutDailyLedWaste(ledWasteDictionary, dataGridViewSmtLedDropped);
            SMTOperations.FillOutLedWasteByModel(ledWasteDictionary, dataGridViewSmtLedWasteByModel, comboBoxSmtLedWasteLine.Text);
            SMTOperations.FillOutLedWasteTotalWeekly(ledWasteDictionary, dataGridViewSmtWasteTotal);
            Dictionary <string, bool> lineOptions = new Dictionary <string, bool>();

            lineColors = new Dictionary <string, Color>();

            foreach (Control c in panelSmtLedWasteCheckContainer.Controls)
            {
                if ((c is CheckBox))
                {
                    lineOptions.Add(c.Text.Trim(), ((CheckBox)c).Checked);
                    lineColors.Add(c.Text.Trim(), c.BackColor);
                }
            }

            Charting.DrawLedWasteChart(ledWasteDictionary, chartLedWasteChart, comboBoxSmtLewWasteFreq.Text, lineOptions, lineColors);

            comboBoxSmtLedWasteLine.Items.Add("Wszystkie");
            comboBoxSmtLedWasteLine.Items.AddRange(smtModelLineQuantity.SelectMany(m => m.Value).Select(l => l.Key).Distinct().OrderBy(l => l).ToArray());
            comboBoxSmtLedWasteLine.Text = "Wszystkie";
            comboBoxSmtLedWasteLines.Items.AddRange(ledWasteDictionary.SelectMany(date => date.Value).SelectMany(shift => shift.Value).Select(l => l.model).Distinct().OrderBy(l => l).ToArray());
            comboBoxSmtLedWasteLines.Items.Insert(0, "Wszystkie");
            comboBoxSmtLedWasteLines.Text = "Wszystkie";
            SMTOperations.FillOutLedWasteTotalByLine(ledWasteDictionary, dataGridViewSmtLedWasteTotalPerLine, comboBoxSmtLedWasteLines.Text);
            FillOutStencilTable(dataGridViewSmtStencilUsage, mesModels);
        }