Beispiel #1
0
        private void LoadProcedure(List <MachinesStops> lstStops)
        {
            var ds  = new DataSet();
            var cmd = new System.Data.SqlClient.SqlCommand()
            {
                CommandText    = "get_OEE_rep_data",
                Connection     = MainWnd._sql_con,
                CommandType    = CommandType.StoredProcedure,
                CommandTimeout = 99999999
            };

            cmd.Parameters.Add("@from_date", SqlDbType.DateTime).Value = Get_Date_From();
            cmd.Parameters.Add("@to_date", SqlDbType.DateTime).Value   = Get_Date_To();
            cmd.Parameters.Add("@finesse", SqlDbType.VarChar).Value    = Get_Finezza_Array();
            MainWnd._sql_con.Open();
            var da = new SqlDataAdapter(cmd);

            da.Fill(ds);
            if (ds.Tables[0].Rows.Count >= 1)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    var newStop = new MachinesStops();

                    int.TryParse(dr[1].ToString(), out var month);
                    var m = string.Empty;
                    if (month < 10)
                    {
                        m = "0" + month.ToString();
                    }
                    else
                    {
                        m = month.ToString();
                    }
                    newStop.Date = dr[0].ToString() + "." + m;

                    double.TryParse(dr[2].ToString(), out var pettine);
                    double.TryParse(dr[3].ToString(), out var manuale);
                    double.TryParse(dr[4].ToString(), out var filato);
                    double.TryParse(dr[5].ToString(), out var aghi);
                    double.TryParse(dr[6].ToString(), out var urto);
                    double.TryParse(dr[7].ToString(), out var principale);
                    double.TryParse(dr[8].ToString(), out var altro);
                    double.TryParse(dr[9].ToString(), out var change_style);
                    double.TryParse(dr[10].ToString(), out var change_color);
                    double.TryParse(dr[11].ToString(), out var mc_breakdown);
                    double.TryParse(dr[12].ToString(), out var yarn_delay);
                    double.TryParse(dr[13].ToString(), out var yarn_quality);
                    double.TryParse(dr[14].ToString(), out var technique);
                    double.TryParse(dr[15].ToString(), out var maintance);
                    double.TryParse(dr[16].ToString(), out var cambio_taglia);
                    double.TryParse(dr[17].ToString(), out var preproduzione);
                    double.TryParse(dr[18].ToString(), out var svilu_potaglie);
                    double.TryParse(dr[19].ToString(), out var prototipo);
                    double.TryParse(dr[20].ToString(), out var campionario);
                    double.TryParse(dr[21].ToString(), out var riparazioni);
                    double.TryParse(dr[22].ToString(), out var cambio_art);
                    double.TryParse(dr[23].ToString(), out var pulizia_ord);
                    double.TryParse(dr[24].ToString(), out var pulizia_fron);
                    double.TryParse(dr[25].ToString(), out var cambio_aghi);
                    double.TryParse(dr[26].ToString(), out var teli);

                    newStop.CambiOre           = change_style + cambio_art + change_color + pettine + cambio_taglia;
                    newStop.PuliziaOre         = pulizia_ord;
                    newStop.CampionarioOre     = svilu_potaglie + prototipo + campionario + preproduzione;
                    newStop.CambioAghiOre      = cambio_aghi;
                    newStop.QualitaFilatoOre   = yarn_quality;
                    newStop.MaintanceOre       = maintance + yarn_delay;
                    newStop.RotturaFilatoOre   = filato;
                    newStop.PuliziaFrontureOre = pulizia_fron;
                    newStop.MeccaniciOre       = manuale + mc_breakdown + riparazioni + urto + principale;
                    newStop.VarieTOre          = technique + altro;
                    newStop.Teli = teli;
                    lstStops.Add(newStop);
                }
            }
            //calculate scarti rammendi
            if (ds.Tables[1].Rows.Count >= 1)
            {
                DateTime.TryParse(ds.Tables[1].Rows[0][0].ToString(), out var startDate);
                var startShift = ds.Tables[1].Rows[0][1].ToString();
                int.TryParse(ds.Tables[1].Rows[0][2].ToString(), out var startOperatorCode);
                int.TryParse(ds.Tables[1].Rows[0][3].ToString(), out var startMachine);
                var startOrder   = ds.Tables[1].Rows[0][4].ToString();
                var startArticle = ds.Tables[1].Rows[0][5].ToString();
                int.TryParse(ds.Tables[1].Rows[0][6].ToString(), out var startTrash);
                int.TryParse(ds.Tables[1].Rows[0][7].ToString(), out var startRepair);
                var sumTrash  = 0;
                var sumRepair = 0;
                foreach (DataRow row in ds.Tables[1].Rows)
                {
                    DateTime.TryParse(row[0].ToString(), out var date);
                    var shift = row[1].ToString();
                    int.TryParse(row[2].ToString(), out var operatorCode);
                    int.TryParse(row[3].ToString(), out var machine);
                    var order   = row[4].ToString();
                    var article = row[5].ToString();
                    int.TryParse(row[6].ToString(), out var trash);
                    int.TryParse(row[7].ToString(), out var repair);
                    if (date.Month != startDate.Month)
                    {
                        sumTrash  += startTrash;
                        sumRepair += startRepair;
                        var m     = string.Empty;
                        var month = startDate.Month;
                        if (month < 10)
                        {
                            m = "0" + month.ToString();
                        }
                        else
                        {
                            m = month.ToString();
                        }
                        var dt = startDate.Year.ToString() + "." + m;

                        var component = (from c in lstStops
                                         where c.Date == dt
                                         select c).SingleOrDefault();
                        if (component != null)
                        {
                            double.TryParse(sumTrash.ToString(), out var t);
                            double.TryParse(sumRepair.ToString(), out var r);
                            component.TeliScarti   = t;
                            component.TeliRammendi = r;
                        }
                        sumTrash  = 0;
                        sumRepair = 0;
                        startDate = date;
                    }
                    if (machine != startMachine || shift != startShift || operatorCode != startOperatorCode ||
                        order != startOrder || article != startArticle || date.Day != startDate.Day)
                    {
                        sumTrash  += startTrash;
                        sumRepair += startRepair;
                    }
                    startDate         = date;
                    startShift        = shift;
                    startOperatorCode = operatorCode;
                    startMachine      = machine;
                    startOrder        = order;
                    startArticle      = article;
                    startTrash        = trash;
                    startRepair       = repair;
                }
                //last record
                sumTrash  += startTrash;
                sumRepair += startRepair;
                var mo       = string.Empty;
                var tmpMonth = startDate.Month;
                if (tmpMonth < 10)
                {
                    mo = "0" + tmpMonth.ToString();
                }
                else
                {
                    mo = tmpMonth.ToString();
                }
                var tmpDate = startDate.Year.ToString() + "." + mo;
                var cmp     = (from c in lstStops
                               where c.Date == tmpDate
                               select c).SingleOrDefault();
                if (cmp != null)
                {
                    double.TryParse(sumTrash.ToString(), out var t);
                    double.TryParse(sumRepair.ToString(), out var r);
                    cmp.TeliScarti   = t;
                    cmp.TeliRammendi = r;
                }
            }

            MainWnd._sql_con.Close();
            da.Dispose();
            cmd = null;
        }
Beispiel #2
0
        private void LoadProcedure(List <MachinesStops> lstStops)
        {
            var cmd = new System.Data.SqlClient.SqlCommand()
            {
                CommandText    = "get_OEE_chart_data",
                Connection     = MainWnd._sql_con,
                CommandType    = CommandType.StoredProcedure,
                CommandTimeout = 99999999
            };

            cmd.Parameters.Add("@from_date", SqlDbType.DateTime).Value = Get_Date_From();
            cmd.Parameters.Add("@to_date", SqlDbType.DateTime).Value   = Get_Date_To();
            cmd.Parameters.Add("@finesse", SqlDbType.VarChar).Value    = Get_finezza_array();
            MainWnd._sql_con.Open();
            var dr = cmd.ExecuteReader();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    var newStop = new MachinesStops();

                    int.TryParse(dr[1].ToString(), out var month);
                    var m = string.Empty;
                    if (month < 10)
                    {
                        m = "0" + month.ToString();
                    }
                    else
                    {
                        m = month.ToString();
                    }
                    newStop.Date = dr[0].ToString() + "." + m;

                    double.TryParse(dr[2].ToString(), out var pettine);
                    double.TryParse(dr[3].ToString(), out var manuale);
                    double.TryParse(dr[4].ToString(), out var filato);
                    double.TryParse(dr[5].ToString(), out var aghi);
                    double.TryParse(dr[6].ToString(), out var urto);
                    double.TryParse(dr[7].ToString(), out var principale);
                    double.TryParse(dr[8].ToString(), out var altro);
                    double.TryParse(dr[9].ToString(), out var change_style);
                    double.TryParse(dr[10].ToString(), out var change_color);
                    double.TryParse(dr[11].ToString(), out var mc_breakdown);
                    double.TryParse(dr[12].ToString(), out var yarn_delay);
                    double.TryParse(dr[13].ToString(), out var yarn_quality);
                    double.TryParse(dr[14].ToString(), out var technique);
                    double.TryParse(dr[15].ToString(), out var maintance);
                    double.TryParse(dr[16].ToString(), out var cambio_taglia);
                    double.TryParse(dr[17].ToString(), out var preproduzione);
                    double.TryParse(dr[18].ToString(), out var svilu_potaglie);
                    double.TryParse(dr[19].ToString(), out var prototipo);
                    double.TryParse(dr[20].ToString(), out var campionario);
                    double.TryParse(dr[21].ToString(), out var riparazioni);
                    double.TryParse(dr[22].ToString(), out var cambio_art);
                    double.TryParse(dr[23].ToString(), out var pulizia_ord);
                    double.TryParse(dr[24].ToString(), out var pulizia_fron);
                    double.TryParse(dr[25].ToString(), out var cambio_aghi);

                    newStop.CambiOre           = change_style + cambio_art + change_color + pettine + cambio_taglia;
                    newStop.PuliziaOre         = pulizia_ord;
                    newStop.CampionarioOre     = svilu_potaglie + prototipo + campionario + preproduzione;
                    newStop.CambioAghiOre      = cambio_aghi;
                    newStop.QualitaFilatoOre   = yarn_quality;
                    newStop.MaintanceOre       = maintance + yarn_delay;
                    newStop.RotturaFilatoOre   = filato;
                    newStop.PuliziaFrontureOre = pulizia_fron;
                    newStop.MeccaniciOre       = manuale + mc_breakdown + riparazioni + urto + principale;
                    newStop.VarieTOre          = technique + altro;
                    lstStops.Add(newStop);
                }
            }

            MainWnd._sql_con.Close();
            dr.Close();
            cmd = null;
        }