コード例 #1
0
ファイル: Form1.cs プロジェクト: user20112/MachineManager
        public void refresh()
        {
            Machines = new List <Machine>();
            StringBuilder sqlStringBuilder = new StringBuilder();

            sqlStringBuilder.Append(" USE [" + ConfigurationManager.AppSettings["ENGDBDatabase"] + "] "); //select database
            sqlStringBuilder.Append("select * from MachineInfoTable");                                    //start loading the command into the string
            string SQLString = sqlStringBuilder.ToString();                                               //Convert Builder to string

            using (SqlCommand command = new SqlCommand(SQLString, ENGDBConnection))
            {                                                                           //Comand Time!
                using (IDataReader dr = command.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        Machine machine = new Machine(dr[5].ToString(), dr[1].ToString(), dr[6].ToString(), Convert.ToInt32(dr[4]), Convert.ToInt32(dr[3]), dr[2].ToString(), new List <String>(), Convert.ToInt32(dr[0]));
                        Machines.Add(machine);
                    }
                }
            }
            foreach (Machine machine in Machines)
            {
                sqlStringBuilder = new StringBuilder();
                sqlStringBuilder.Append(" USE [EngDb-" + machine.Line + "] ");                                                                          //select database
                sqlStringBuilder.Append("SELECT * FROM sys.columns WHERE object_id = OBJECT_ID('dbo." + machine.MachineName + "ShortTimeStatistics')"); //start loading the command into the string
                SQLString = sqlStringBuilder.ToString();                                                                                                //Convert Builder to string
                using (SqlCommand command = new SqlCommand(SQLString, ENGDBConnection))
                {                                                                                                                                       //Comand Time!
                    using (IDataReader dr = command.ExecuteReader())
                    {
                        int x = 0;
                        while (dr.Read())
                        {
                            if (x >= 9)
                            {
                                machine.StartingErrors.Add(dr[1].ToString());
                            }
                            x++;
                        }
                    }
                }
            }
            DisplayListView.Clear();
            DisplayListView.Columns.Add("MachineName", -2);
            DisplayListView.Columns.Add("Line", -2);
            DisplayListView.Columns.Add("Plant", -2);
            DisplayListView.Columns.Add("Engineer", -2);
            DisplayListView.Columns.Add("Theo", -2);
            DisplayListView.Columns.Add("SNPID", -2);
            DisplayListView.Columns.Add("Errors", -2);
            foreach (Machine machine in Machines)
            {
                string errorstring = "";
                try
                {
                    foreach (string error in machine.StartingErrors)
                    {
                        errorstring += error + ",";
                    }
                    errorstring = errorstring.Substring(0, errorstring.Length - 1);
                }
                catch
                {
                    errorstring = "";
                }
                DisplayListView.Items.Add(new ListViewItem(new string[7] {
                    machine.MachineName, machine.Line, machine.Plant, machine.Engineer, machine.Theoretical.ToString(), machine.SNPID.ToString(), errorstring
                }));
            }
            DisplayListView.View                  = View.Details;
            DisplayListView.ContextMenuStrip      = contextMenuStrip1;
            DisplayListView.FullRowSelect         = true;
            DisplayListView.MultiSelect           = false;
            DisplayListView.ItemSelectionChanged += new ListViewItemSelectionChangedEventHandler(SelectionChanged);
            DisplayListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
コード例 #2
0
 public StepPrompt(CommpanyInfo commpanyInfo, DisplayListView displayListView)
 {
     _commpanyInfor   = commpanyInfo;
     _displayListView = displayListView;
     InitializeComponent();
 }