コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            switch (cb_interval.SelectedIndex)
            {
            case 0:
            {
                MainWnd.SetTableSource("extendview");

                Properties.Settings.Default.TableSource = MainWnd.GetTableSource();
                Properties.Settings.Default.Save();
                MessageBox.Show("Saved!", "Data Interval");
            }
            break;

            case 1:
            {
                MainWnd.SetTableSource("currentyearview");

                Properties.Settings.Default.TableSource = MainWnd.GetTableSource();
                Properties.Settings.Default.Save();
                MessageBox.Show("Saved!", "Data Interval");
            }
            break;

            case 2:
            {
                MainWnd.SetTableSource("historyview");

                Properties.Settings.Default.TableSource = MainWnd.GetTableSource();
                Properties.Settings.Default.Save();
                MessageBox.Show("Saved!", "Data Interval");
            }
            break;
            }
        }
コード例 #2
0
ファイル: RepArticles.cs プロジェクト: AerreRomania/Sinotico
        private void LoadProcedure()
        {
            try
            {
                var cmd = new SqlCommand("[getarticlepartitionedqty]", MainWnd._sql_con)
                {
                    CommandType    = CommandType.StoredProcedure,
                    CommandTimeout = 500
                };

                cmd.Parameters.Add("@dateFrom", SqlDbType.DateTime).Value = Get_Date_From();
                cmd.Parameters.Add("@dateTo", SqlDbType.DateTime).Value   = Get_Date_To();
                cmd.Parameters.Add("@file", SqlDbType.VarChar).Value      = _fileName;
                cmd.Parameters.Add("@table", SqlDbType.VarChar).Value     = MainWnd.GetTableSource();

                var da = new SqlDataAdapter(cmd);
                var ds = new DataSet();
                da.Fill(_dataSet);
                da.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex, "Error.", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
        protected override void OnLoad(EventArgs e)
        {
            FrmHolidays.dc = new DataContext(MainWnd.conString);
            StyleDataGridView(dgvSettings);
            LoadData();

            cb_interval.SelectedIndex = GetInterval(MainWnd.GetTableSource());

            if (Properties.Settings.Default.UpdateSettings)
            {
                //update user settings from previous version
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpdateSettings = false;
                Properties.Settings.Default.Save();
            }
            AddClearFilterButton(txtDownloadSource, "btnAddPath");

            cbUpdateRuntime.Checked = Properties.Settings.Default.checkUpdates;
            txtDownloadSource.Text  = Properties.Settings.Default.downloadSource;
            Intensity_slider.Value  = currIntesity.Value;
            intensity_label.Text    = "Selected intesity: " + Intensity_slider.Value.ToString();

            //var pathMain = AppDomain.CurrentDomain.BaseDirectory;
            //var strAssembOld = "";
            //foreach (var file in Directory.GetFiles(pathMain))
            //{
            //    if (Path.GetExtension(file) != ".exe") continue;
            //    strAssembOld = Assembly.LoadFile(file).GetName().Version.ToString();
            //}
            //linkLabel1.Text = "Sinotico version: " + strAssembOld;
            //linkLabel1.Refresh();

            base.OnLoad(e);
        }
コード例 #4
0
        private void LoadProcedure(string shift, DataTable dt)
        {
            SqlDataReader dr;

            if (string.IsNullOrEmpty(cboLines.Text) && string.IsNullOrEmpty(cboLines.Text))
            {
                machinesNr = 210;
            }
            if (!string.IsNullOrEmpty(cboLines.Text))
            {
                machinesNr = 14;
            }
            if (!string.IsNullOrEmpty(cboBlocks.Text))
            {
                machinesNr = 70;
            }

            var cmd = new SqlCommand("getmergedproductioneffects", MainWnd._sql_con)
            {
                CommandType    = CommandType.StoredProcedure,
                CommandTimeout = 300
            };

            cmd.Parameters.Add("@from_date", SqlDbType.DateTime).Value = GetDateFrom;
            cmd.Parameters.Add("@to_date", SqlDbType.DateTime).Value   = GetDateTo;
            cmd.Parameters.Add("@shift", SqlDbType.VarChar).Value      = shift;
            cmd.Parameters.Add("@machine", SqlDbType.VarChar).Value    = _machines_array.ToString();
            cmd.Parameters.Add("@machinesNr", SqlDbType.Int).Value     = machinesNr;
            cmd.Parameters.Add("@table", SqlDbType.VarChar).Value      = MainWnd.GetTableSource();

            MainWnd._sql_con.Open();
            dr = cmd.ExecuteReader();
            dt.Load(dr);
            MainWnd._sql_con.Close();
            dr.Close();
            cmd = null;

            _daysRange = GetDateTo.Subtract(GetDateFrom).TotalDays;
            if (_daysRange == 0)
            {
                _daysRange = 1;
            }
            else
            {
                _daysRange += 1.0;
            }
        }
コード例 #5
0
        private void LoadChanges(string txt)
        {
            _tblChanges = new DataTable();

            var cmd = new SqlCommand(txt, MainWnd._sql_con)
            {
                CommandType    = CommandType.StoredProcedure,
                CommandTimeout = 1000
            };

            cmd.Parameters.Add("@year", SqlDbType.Int).Value      = Convert.ToInt32(_year);
            cmd.Parameters.Add("@table", SqlDbType.VarChar).Value = MainWnd.GetTableSource();

            MainWnd._sql_con.Open();
            var dr = cmd.ExecuteReader();

            _tblChanges.Load(dr);
            MainWnd._sql_con.Close();
            dr.Close();
            cmd = null;
        }
コード例 #6
0
        private void LoadProcedure(DataSet ds)
        {
            var cmd = new SqlCommand()
            {
                CommandText    = "get_capi_report_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("@table", SqlDbType.VarChar).Value      = MainWnd.GetTableSource();
            MainWnd._sql_con.Open();
            var da = new SqlDataAdapter(cmd);

            da.Fill(ds);
            MainWnd._sql_con.Close();
            da.Dispose();
            cmd = null;
        }
コード例 #7
0
ファイル: RepOEETEEP.cs プロジェクト: AerreRomania/Sinotico
        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();
            cmd.Parameters.Add("@table", SqlDbType.VarChar).Value      = MainWnd.GetTableSource();
            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;
        }