Exemple #1
0
        private void LoadData()
        {
            _dataTable = new DataTable();

            int.TryParse(MainWnd._mouseOverMachineNumber, out var machine);
            if (machine <= 0 || machine > 210)
            {
                MessageBox.Show("Invalid machine number.", "Sinotico", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            using (var con = new SqlConnection(MainWnd.conString))
            {
                var cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "[getcleanersonmachine]";
                cmd.Connection  = con;

                cmd.Parameters.Add("@startdate", SqlDbType.DateTime).Value   = MainWnd.Get_from_date();
                cmd.Parameters.Add("@enddate", SqlDbType.DateTime).Value     = MainWnd.Get_to_date();
                cmd.Parameters.Add("@machine", SqlDbType.Int).Value          = machine;
                cmd.Parameters.Add("@shiftArray", SqlDbType.NVarChar).Value  = MainWnd.Get_shift_array().ToString();
                cmd.Parameters.Add("@puliziaType", SqlDbType.NVarChar).Value = _puliziaType;

                con.Open();
                var dr = cmd.ExecuteReader();
                _dataTable.Load(dr);
                con.Close();
                dr.Close();
            }

            dgvReport.DataSource = _dataTable;

            dgvReport.Columns[0].Visible = false;
        }
 private void LoadProcedure(DataTable dt, int idm)
 {
     using (var con = new SqlConnection(MainWnd.conString))
     {
         var cmd = new SqlCommand();
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Connection  = con;
         cmd.CommandText = "[getscartirammendireportdata]";
         cmd.Parameters.Add("@machine", SqlDbType.Int).Value       = idm;
         cmd.Parameters.Add("@fromDate", SqlDbType.DateTime).Value = MainWnd.Get_from_date();
         cmd.Parameters.Add("@toDate", SqlDbType.DateTime).Value   = MainWnd.Get_to_date();
         cmd.Parameters.Add("@shift", SqlDbType.NVarChar).Value    = MainWnd.Get_shift_array().ToString();
         con.Open();
         var dr = cmd.ExecuteReader();
         dt.Load(dr);
         con.Close();
         dr.Close();
     }
 }
        public void PopulateChartData()
        {
            var global      = new Globals();
            var chart_data  = new DataTable();
            var table_data  = new DataTable();
            var cbArray     = new CheckBox[] { MainWnd._sqOne, MainWnd._sqTwo, MainWnd._sqThree };
            var currentCb   = 0;
            var processedCb = 0;
            var checks      = 0;
            var checksDone  = 0;
            var gridIndex   = 0;

            foreach (var cb in cbArray)
            {
                if (cb.Checked)
                {
                    checks++;
                }
            }

            foreach (var chart in new System.Windows.Forms.DataVisualization.Charting.Chart[] { chart1, chart2, chart3 })
            {
                table_data = new DataTable();

                var machinesArray = string.Empty;

                if (processedCb >= 3 || checks <= checksDone)
                {
                    return;
                }

                while (processedCb < 3)
                {
                    if (cbArray[processedCb].Checked)
                    {
                        currentCb = processedCb;
                        processedCb++;
                        break;
                    }
                    processedCb++;
                }

                if (currentCb == 0)
                {
                    machinesArray = string.Empty;
                    machinesArray = ",1,2,3,4,5,6,7,8,9,10,11,12,13,14" +
                                    ",15,16,17,18,19,20,21,22,23,24,25,26,27,28" +
                                    ",29,30,31,32,33,34,35,36,37,38,39,40,41,42" +
                                    ",43,44,45,46,47,48,49,50,51,52,53,54,55,56" +
                                    ",57,58,59,60,61,62,63,64,65,66,67,68,69,70,";
                    checksDone++;
                }
                else if (currentCb == 1)
                {
                    machinesArray = string.Empty;
                    machinesArray = ",71,72,73,74,75,76,77,78,79,80,81,82,83,84" +
                                    ",85,86,87,88,89,90,91,92,93,94,95,96,97,98" +
                                    ",99,100,101,102,103,104,105,106,107,108,109,110,111,112" +
                                    ",113,114,115,116,117,118,119,120,121,122,123,124,125,126" +
                                    ",127,128,129,130,131,132,133,134,135,136,137,138,139,140,";
                    checksDone++;
                }
                else if (currentCb == 2)
                {
                    machinesArray = string.Empty;
                    machinesArray = ",141,142,143,144,145,146,147,148,149,150,151,152,153,154" +
                                    ",155,156,157,158,159,160,161,162,163,164,165,166,167,168" +
                                    ",169,170,171,172,173,174,175,176,177,178,179,180,181,182" +
                                    ",183,184,185,186,187,188,189,190,191,192,193,194,195,196" +
                                    ",197,198,199,200,201,202,203,204,205,206,207,208,209,210,";
                    checksDone++;
                }
                else
                {
                    continue;
                }

                chart.Visible = true;
                _dgvTables[gridIndex].Visible = true;

                using (var con = new SqlConnection(MainWnd.conString))
                {
                    var cmd = new SqlCommand("get_data_in_hold_per_hour", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@from_date", SqlDbType.DateTime).Value = MainWnd.Get_to_date();
                    cmd.Parameters.Add("@to_date", SqlDbType.DateTime).Value   = MainWnd.Get_to_date();
                    cmd.Parameters.Add("@machine", SqlDbType.VarChar).Value    = machinesArray;

                    chart_data = new DataTable();

                    con.Open();
                    var dr = cmd.ExecuteReader();
                    chart_data.Load(dr);
                    con.Close();
                    dr.Close();
                    cmd = null;

                    cmd             = new SqlCommand("get_data_in_hold_per_shift", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@from_date", SqlDbType.DateTime).Value = MainWnd.Get_from_date();
                    cmd.Parameters.Add("@to_date", SqlDbType.DateTime).Value   = MainWnd.Get_to_date();
                    cmd.Parameters.Add("@shift", SqlDbType.VarChar).Value      = MainWnd.Get_shift_array().ToString();
                    cmd.Parameters.Add("@machine", SqlDbType.VarChar).Value    = machinesArray;

                    con.Open();
                    dr = cmd.ExecuteReader();
                    table_data.Load(dr);
                    con.Close();
                    dr.Close();
                    cmd = null;
                }

                chart.ChartAreas.Clear();
                chart.Series.Clear();

                chart.ChartAreas.Add("hold");
                chart.ChartAreas[0].AxisX.MajorGrid.LineColor      = SystemColors.Control;
                chart.ChartAreas[0].AxisY.MajorGrid.LineColor      = SystemColors.Control;
                chart.ChartAreas[0].AxisX.MajorGrid.IntervalOffset = 20;
                chart.ChartAreas[0].BackColor = SystemColors.Control;
                chart.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.Gray;
                chart.ChartAreas[0].AxisY.LineColor            = Color.FromArgb(158, 158, 158);
                chart.ChartAreas[0].AxisX.LineColor            = Color.FromArgb(158, 158, 158);
                chart.ChartAreas[0].AxisY.LabelStyle.ForeColor = Color.Gray;
                chart.ChartAreas[0].AxisY.Maximum = 30000;

                chart.Series.Add("knitt");
                chart.Series.Add("manual");
                chart.Series.Add("yarn");
                chart.Series.Add("generic");

                chart.Series["knitt"].Color   = Color.FromArgb(0, 191, 254);
                chart.Series["manual"].Color  = Color.FromArgb(255, 2, 0);
                chart.Series["yarn"].Color    = Color.FromArgb(131, 0, 125);
                chart.Series["generic"].Color = Color.Gold;

                for (var i = 0; i <= chart.Series.Count - 1; i++)
                {
                    chart.Series[i].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedColumn;
                }

                List <int> shiftHours = new List <int>();
                int[]      legendValues = new int[4];
                int        _knitt = 0, _manual = 0, _yarn = 0, _generics = 0;
                foreach (var shift in MainWnd.ListOfSelectedShifts)
                {
                    shiftHours.Clear();

                    if (shift == "cbMorning")
                    {
                        for (int i = 7; i <= 14; i++)
                        {
                            shiftHours.Add(i);
                        }
                    }
                    else if (shift == "cbAfternoon")
                    {
                        for (int i = 15; i <= 22; i++)
                        {
                            shiftHours.Add(i);
                        }
                    }
                    else if (shift == "cbNight")
                    {
                        for (int i = 0; i <= 6; i++)
                        {
                            shiftHours.Add(i);
                        }
                        shiftHours.Add(23);
                    }

                    legendValues[3] += _generics;
                    legendValues[2] += _yarn;
                    legendValues[1] += _manual;
                    legendValues[0] += _knitt;

                    _knitt    = 0;
                    _manual   = 0;
                    _yarn     = 0;
                    _generics = 0;

                    foreach (DataRow row in chart_data.Rows)
                    {
                        var hour = Convert.ToInt32(row[0]);

                        int knit, comb, manual, yarn, needle, shock, roller, other;

                        if (shiftHours.Contains(hour))
                        {
                            knit   = Convert.ToInt32(row[1]) > 0 ? Convert.ToInt32(row[1]) : knit = 0;
                            comb   = Convert.ToInt32(row[3]) > 0 ? Convert.ToInt32(row[3]) : comb = 0;
                            manual = Convert.ToInt32(row[4]) > 0 ? Convert.ToInt32(row[4]) : manual = 0;
                            yarn   = Convert.ToInt32(row[5]) > 0 ? Convert.ToInt32(row[5]) : yarn = 0;
                            needle = Convert.ToInt32(row[6]) > 0 ? Convert.ToInt32(row[6]) : needle = 0;
                            shock  = Convert.ToInt32(row[7]) > 0 ? Convert.ToInt32(row[7]) : shock = 0;
                            roller = Convert.ToInt32(row[8]) > 0 ? Convert.ToInt32(row[8]) : roller = 0;
                            other  = Convert.ToInt32(row[9]) > 0 ? Convert.ToInt32(row[9]) : other = 0;

                            _knitt    += knit;
                            _manual   += manual;
                            _yarn     += yarn;
                            _generics += comb + needle + shock + roller + other;
                        }
                    }
                    chart.Series["knitt"].Points.AddXY(shift.Remove(0, 2), _knitt.ToString());
                    chart.Series["manual"].Points.AddXY(shift.Remove(0, 2), _manual.ToString());
                    chart.Series["yarn"].Points.AddXY(shift.Remove(0, 2), _yarn.ToString());
                    chart.Series["generic"].Points.AddXY(shift.Remove(0, 2), _generics.ToString());

                    chart.Titles[chart.Name + "Title"].Visible = true;
                    chart.Titles[chart.Name + "Title"].Text    = "SQUADRA " + (currentCb + 1).ToString() + ":";

                    int position = 0;
                    foreach (var serie in chart.Series)
                    {
                        serie.IsVisibleInLegend = true;
                        serie.LegendText        = " = " + legendValues[position];
                        position++;
                    }
                    position = 0;
                }

                var conv_table_data = new DataTable();

                double stopTime    = 0;
                double total       = 0;
                double genericStop = 0;
                double allStops    = 0;

                foreach (DataColumn dc in table_data.Columns)
                {
                    if (dc.ColumnName == "stop_time" || dc.ColumnName == "Color" || dc.ColumnName == "Size" ||
                        dc.ColumnName == "Component")
                    {
                        continue;
                    }

                    conv_table_data.Columns.Add(dc.ColumnName); //copies datacolumns
                }

                conv_table_data.Columns.Add("Generic Stops");
                conv_table_data.Columns.Add("TOTAL");

                var newRow       = conv_table_data.NewRow();
                var grid_col_idx = 5;

                TimeSpan formatedTs = new TimeSpan();

                for (var col_idx = 8; col_idx < 16; col_idx++)
                {
                    double current_cell_value = 0;
                    for (var row_idx = 0; row_idx < table_data.Rows.Count; row_idx++)
                    {
                        current_cell_value += Convert.ToDouble(table_data.Rows[row_idx][col_idx]);
                    }

                    formatedTs = TimeSpan.FromSeconds(current_cell_value);
                    string time = string.Format("{0}:{1}",
                                                (int)formatedTs.TotalHours < 10 ?
                                                "0" + ((int)formatedTs.TotalHours).ToString() :
                                                ((int)formatedTs.TotalHours).ToString(),
                                                (int)formatedTs.Minutes < 10 ?
                                                "0" + ((int)formatedTs.Minutes).ToString() :
                                                ((int)formatedTs.Minutes).ToString());
                    newRow[grid_col_idx] = time;
                    grid_col_idx++;
                    total += current_cell_value;

                    if (col_idx == 8)
                    {
                        continue;
                    }
                    else
                    {
                        allStops += current_cell_value;
                    }
                }

                for (var row_idx = 0; row_idx < table_data.Rows.Count; row_idx++)
                {
                    stopTime += Convert.ToInt32(table_data.Rows[row_idx][16]);
                }

                genericStop = stopTime - allStops;

                if (genericStop < 0)
                {
                    genericStop = 0;
                }
                total += genericStop;

                formatedTs = TimeSpan.FromSeconds(genericStop);
                string generic_time = string.Format("{0}:{1}",
                                                    (int)formatedTs.TotalHours < 10 ?
                                                    "0" + ((int)formatedTs.TotalHours).ToString() :
                                                    ((int)formatedTs.TotalHours).ToString(),
                                                    (int)formatedTs.Minutes < 10 ?
                                                    "0" + ((int)formatedTs.Minutes).ToString() :
                                                    ((int)formatedTs.Minutes).ToString());
                newRow[13] = generic_time;
                formatedTs = TimeSpan.FromSeconds(total);
                string total_time = string.Format("{0}:{1}",
                                                  (int)formatedTs.TotalHours < 10 ?
                                                  "0" + ((int)formatedTs.TotalHours).ToString() :
                                                  ((int)formatedTs.TotalHours).ToString(),
                                                  (int)formatedTs.Minutes < 10 ?
                                                  "0" + ((int)formatedTs.Minutes).ToString() :
                                                  ((int)formatedTs.Minutes).ToString());
                newRow[14] = total_time;
                conv_table_data.Rows.Add(newRow);

                StyleGridView(_dgvTables[gridIndex]);
                _dgvTables[gridIndex].DataSource = conv_table_data;

                gridIndex++;
            }
        }
        private void CreateMachinesReport()
        {
            LoadingInfo.InfoText = "Loading chart...";
            LoadingInfo.ShowLoading();

            /*
             **Create controls based on shifts selection
             */

            var global = new Globals();

            var chart_data = new DataTable();
            var table_data = new DataTable();

            // Loads charts data

            using (var con = new SqlConnection(MainWnd.conString))
            {
                var cmd = new SqlCommand("get_data_in_hold_per_hour", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@from_date", SqlDbType.DateTime).Value = MainWnd.Get_to_date();
                cmd.Parameters.Add("@to_date", SqlDbType.DateTime).Value   = MainWnd.Get_to_date();
                cmd.Parameters.Add("@machine", SqlDbType.VarChar).Value    = _machines_array.ToString();

                con.Open();
                var dr = cmd.ExecuteReader();
                chart_data.Load(dr);
                con.Close();
                dr.Close();
                cmd = null;

                // Loads table data

                cmd             = new SqlCommand("get_data_in_hold_per_shift", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@from_date", SqlDbType.DateTime).Value = MainWnd.Get_from_date();
                cmd.Parameters.Add("@to_date", SqlDbType.DateTime).Value   = MainWnd.Get_to_date();
                cmd.Parameters.Add("@shift", SqlDbType.VarChar).Value      = MainWnd.Get_shift_array().ToString();
                cmd.Parameters.Add("@machine", SqlDbType.VarChar).Value    = _machines_array.ToString();

                con.Open();
                dr = cmd.ExecuteReader();
                table_data.Load(dr);
                con.Close();
                dr.Close();
                cmd = null;
            }

            // Creates controls with data structure

            var topObjLocation  = 20;
            var leftObjLocation = 17;
            var objW            = Width - 50;

            _panel_shift            = new Panel();
            _panel_shift.Dock       = DockStyle.Fill;
            _panel_shift.AutoScroll = true;
            Controls.Add(_panel_shift);
            _panel_shift.BringToFront();

            foreach (var shift in MainWnd.ListOfSelectedShifts)
            {
                // Add shift title

                _lbl_shfit           = new Label();
                _lbl_shfit.AutoSize  = true;
                _lbl_shfit.Font      = new Font("Microsoft Sans Serif", 15);
                _lbl_shfit.ForeColor = Color.Black;

                var shf     = "";
                var upShift = string.Empty;

                if (shift.Remove(0, 2) == "Night")
                {
                    shf     = "Turno 1";
                    upShift = "NIGHT";
                }
                else if (shift.Remove(0, 2) == "Morning")
                {
                    shf     = "Turno 2";
                    upShift = "MORNING";
                }
                else if (shift.Remove(0, 2) == "Afternoon")
                {
                    shf     = "Turno 3";
                    upShift = "AFTERNOON";
                }

                _lbl_shfit.Text = shf;

                var lblW = _lbl_shfit.Width;
                var locX = (Width / 2 - lblW / 2);

                _lbl_shfit.Location = new Point(locX - 20, topObjLocation + 10);

                _panel_shift.Controls.Add(_lbl_shfit);

                topObjLocation += _lbl_shfit.Height;

                // Convert table data
                var conv_table_data = new DataTable();

                foreach (DataColumn dc in table_data.Columns)
                {
                    if (dc.ColumnName == "stop_time")
                    {
                        continue;
                    }

                    conv_table_data.Columns.Add(dc.ColumnName); //copies datacolumns
                }

                conv_table_data.Columns.Add("Generic Stops");
                conv_table_data.Columns.Add("TOTAL");

                foreach (DataRow row in table_data.Rows)
                {
                    var newRow = conv_table_data.NewRow();

                    if (row[1].ToString() != upShift)
                    {
                        continue;
                    }

                    var knitTime = Convert.ToInt32(row[8]);
                    var stopTime = Convert.ToInt32(row[16]);

                    var total = 0;

                    for (var i = 0; i <= 7; i++)
                    {
                        if (i == 0)
                        {
                            newRow[i] = Convert.ToDateTime(row[i]).ToShortDateString();
                        }
                        else
                        {
                            newRow[i] = row[i].ToString();
                        }
                    }

                    for (var i = 8; i <= 15; i++)
                    {
                        newRow[i] = ConvertSecondsToHHmm(Convert.ToInt32(row[i]));

                        total += Convert.ToInt32(row[i]);
                    }

                    var genericStop = 0;
                    var allStops    = 0;

                    for (var i = 9; i <= 15; i++)
                    {
                        allStops += Convert.ToInt32(row[i]);
                    }

                    genericStop = stopTime - allStops;

                    if (genericStop < 0)
                    {
                        genericStop = 0;
                    }
                    total += genericStop;

                    newRow[16] = ConvertSecondsToHHmm(genericStop);
                    newRow[17] = ConvertSecondsToHHmm(total);
                    conv_table_data.Rows.Add(newRow);
                }

                //Add chart

                _chart           = new System.Windows.Forms.DataVisualization.Charting.Chart();
                _chart.Size      = new Size(objW, 400);
                _chart.Location  = new Point(leftObjLocation, topObjLocation + 20);
                _chart.BackColor = Color.WhiteSmoke;
                topObjLocation  += _chart.Height;

                _chart.ChartAreas.Clear();
                _chart.Series.Clear();

                _chart.ChartAreas.Add("hold");

                _chart.ChartAreas[0].AxisX.MajorGrid.LineColor      = Color.Gainsboro;
                _chart.ChartAreas[0].AxisY.MajorGrid.LineColor      = Color.Gainsboro;
                _chart.ChartAreas[0].AxisX.MajorGrid.IntervalOffset = 20;
                _chart.ChartAreas[0].BackColor                  = Color.WhiteSmoke;
                _chart.ChartAreas[0].AxisX.LineColor            = Color.WhiteSmoke;
                _chart.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.Gray;
                _chart.ChartAreas[0].AxisY.LineColor            = Color.Silver;
                _chart.ChartAreas[0].AxisY.LabelStyle.ForeColor = Color.Gray;
                _chart.ChartAreas[0].AxisY.Maximum              = 60;
                //_chart.ChartAreas[0].AxisX.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Hours;
                //_chart.ChartAreas[0].AxisX.LabelAutoFitMinFontSize = 15;

                _chart.Series.Add("knitt");
                _chart.Series.Add("comb");
                _chart.Series.Add("manual");
                _chart.Series.Add("yarn");
                _chart.Series.Add("needle");
                _chart.Series.Add("shock");
                _chart.Series.Add("roller");
                _chart.Series.Add("other");
                _chart.Series.Add("generic");

                _chart.Legends.Clear();

                _chart.Series["knitt"].Color  = global.GetStopColors()[0];
                _chart.Series["comb"].Color   = global.GetStopColors()[1];
                _chart.Series["manual"].Color = global.GetStopColors()[2];
                _chart.Series["yarn"].Color   = global.GetStopColors()[3];
                _chart.Series["needle"].Color = global.GetStopColors()[4];
                _chart.Series["shock"].Color  = global.GetStopColors()[5];
                _chart.Series["roller"].Color = global.GetStopColors()[6];
                _chart.Series["other"].Color  = global.GetStopColors()[7];

                _chart.Series["generic"].Color = Color.Gold;

                foreach (DataRow row in chart_data.Rows)
                {
                    var hour = Convert.ToInt32(row[0]);

                    int knit   = Convert.ToInt32(row[1]) > 0 ? Convert.ToInt32(row[1]) : knit = 0;
                    int comb   = Convert.ToInt32(row[3]) > 0 ? Convert.ToInt32(row[3]) : comb = 0;
                    int manual = Convert.ToInt32(row[4]) > 0 ? Convert.ToInt32(row[4]) : manual = 0;
                    int yarn   = Convert.ToInt32(row[5]) > 0 ? Convert.ToInt32(row[5]) : yarn = 0;
                    int needle = Convert.ToInt32(row[6]) > 0 ? Convert.ToInt32(row[6]) : needle = 0;
                    int shock  = Convert.ToInt32(row[7]) > 0 ? Convert.ToInt32(row[7]) : shock = 0;
                    int roller = Convert.ToInt32(row[8]) > 0 ? Convert.ToInt32(row[8]) : roller = 0;
                    int other  = Convert.ToInt32(row[9]) > 0 ? Convert.ToInt32(row[9]) : other = 0;

                    if (knit > 60)
                    {
                        knit = 60;
                    }

                    if (shift == "cbNight" && hour == 23)
                    {
                        _chart.Series["knitt"].Points.AddXY(hour.ToString(), knit);
                        _chart.Series["comb"].Points.AddXY(hour.ToString(), comb);
                        _chart.Series["manual"].Points.AddXY(hour.ToString(), manual);
                        _chart.Series["yarn"].Points.AddXY(hour.ToString(), yarn);
                        _chart.Series["needle"].Points.AddXY(hour.ToString(), needle);
                        _chart.Series["shock"].Points.AddXY(hour.ToString(), shock);
                        _chart.Series["roller"].Points.AddXY(hour.ToString(), roller);
                        _chart.Series["other"].Points.AddXY(hour.ToString(), other);

                        var stopTime  = Convert.ToInt32(row[2]);
                        var otherTime = 0;

                        for (var i = 3; i <= chart_data.Columns.Count - 9; i++)
                        {
                            otherTime += Convert.ToInt32(row[i]);
                        }

                        var unknow = stopTime - otherTime;

                        if (unknow > 60)
                        {
                            unknow = 60;
                        }
                        else if (unknow < 0)
                        {
                            unknow = 0;
                        }

                        if ((knit + unknow) > 60)
                        {
                            unknow = 60 - knit;
                        }

                        _chart.Series["generic"].Points.AddXY(hour.ToString(), unknow);
                    }

                    if (shift == "cbNight" && hour >= 0 && hour <= 6 || shift == "cbMorning" && hour >= 7 && hour <= 14 ||
                        shift == "cbAfternoon" && hour >= 15 && hour <= 22)
                    {
                        _chart.Series["knitt"].Points.AddXY(hour.ToString(), knit);
                        _chart.Series["comb"].Points.AddXY(hour.ToString(), comb);
                        _chart.Series["manual"].Points.AddXY(hour.ToString(), manual);
                        _chart.Series["yarn"].Points.AddXY(hour.ToString(), yarn);
                        _chart.Series["needle"].Points.AddXY(hour.ToString(), needle);
                        _chart.Series["shock"].Points.AddXY(hour.ToString(), shock);
                        _chart.Series["roller"].Points.AddXY(hour.ToString(), roller);
                        _chart.Series["other"].Points.AddXY(hour.ToString(), other);

                        var stopTime  = Convert.ToInt32(row[2]);
                        var otherTime = 0;

                        for (var i = 3; i <= 9; i++)
                        {
                            otherTime += Convert.ToInt32(row[i]);
                        }

                        var unknow = stopTime - otherTime;

                        if (unknow > 60)
                        {
                            unknow = 60;
                        }
                        else if (unknow < 0)
                        {
                            unknow = 0;
                        }

                        if ((knit + unknow) > 60)
                        {
                            unknow = 60 - knit;
                        }

                        _chart.Series["generic"].Points.AddXY(hour.ToString(), unknow);
                    }
                }

                foreach (var s in _chart.Series)
                {
                    s.ChartType           = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedColumn;
                    s.Font                = new Font("Tahoma", 8, FontStyle.Bold);
                    s.LabelForeColor      = Color.Black;
                    s.IsValueShownAsLabel = true;

                    foreach (var d in s.Points)
                    {
                        if (d.YValues[0] < 1)
                        {
                            d.IsValueShownAsLabel = false;
                        }
                    }
                }

                _panel_shift.Controls.Add(_chart);

                _dgv          = new DataGridView();
                _dgv.Size     = new Size(objW, 150);
                _dgv.Location = new Point(leftObjLocation, topObjLocation + 20);

                topObjLocation += _dgv.Height + 20;

                _dgv.EnableHeadersVisualStyles = false;
                _dgv.DoubleBufferedDataGridView(true);

                _dgv.AllowUserToAddRows          = false;
                _dgv.AllowUserToDeleteRows       = false;
                _dgv.AllowUserToResizeColumns    = false;
                _dgv.AllowUserToResizeRows       = false;
                _dgv.AllowUserToOrderColumns     = false;
                _dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
                _dgv.ReadOnly        = true;
                _dgv.BackgroundColor = Color.WhiteSmoke;
                _dgv.BorderStyle     = BorderStyle.None;
                _dgv.MultiSelect     = false;
                _dgv.SelectionMode   = DataGridViewSelectionMode.CellSelect;
                _dgv.Font            = new Font("Microsoft Sans Serif", 9);
                _dgv.ForeColor       = Color.FromArgb(60, 60, 60);
                _dgv.CellBorderStyle = DataGridViewCellBorderStyle.None;

                _dgv.DataSource = conv_table_data;

                _dgv.DataBindingComplete += delegate
                {
                    _dgv.Columns[1].Visible = false;

                    for (var c = 8; c <= _dgv.Columns.Count - 3; c++)
                    {
                        _dgv.Columns[c].HeaderCell.Style.BackColor = global.GetStopColors()[c - 8];

                        _dgv.Columns[c].HeaderCell.Style.ForeColor = Color.White;
                        _dgv.Columns[c].HeaderCell.Style.Font      = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);

                        _dgv.Columns[c].HeaderText = global.StopReasonsIt[c - 8];
                    }

                    _dgv.Columns["Generic Stops"].HeaderCell.Style.BackColor = Color.Gold;
                    _dgv.Columns["Generic Stops"].HeaderCell.Style.ForeColor = Color.White;
                    _dgv.Columns["Generic Stops"].HeaderCell.Style.Font      = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);

                    foreach (DataGridViewColumn c in _dgv.Columns)
                    {
                        _dgv.AutoResizeColumn(c.DisplayIndex);
                    }
                };

                _panel_shift.Controls.Add(_dgv);
            }

            LoadingInfo.CloseLoading();
        }