I need some more help

My friend needs some more help with her project to be able to graduate. I'd like to say thank you to all those that helped before.

So this time she is looking to display something that is currently displayed in a text (pic one) to be displayed something in a nicer format (picture 2)

Here are the examples: http://ift.tt/1NjRx5x

Here is the code. Thank you in advance to those that offer their help.

public void addToOutput() {

 InitializeListBox(); if (recvDt != null && recvDt != "") { processData = recvDt.Split(','); processID = processData[0]; machineName = processData[1]; fileName = processData[2]; exeFile = processData[3]; filePath = processData[4]; dataGridView1.Rows.Add(processID, machineName, fileName, exeFile, filePath); output.Text += "\n Received Data : " + recvDt; recvDt = null; string inputfile = fileName; int index = inputfile.LastIndexOf(" -"); if (index > 0) { inputfile = inputfile.Substring(0, index); } if (inputfile == inputopenedfile) { listBox1.Items.Add( machineName + new MyListBoxItem(Color.DarkGray," has opened the right file.")); } else { string constring = "Database=chtbuster;Data Source=localhost;User Id=root;Password='';"; string count1 = "SELECT COUNT(*) FROM chtbuster.hostnametable; "; using (MySqlConnection conDataBase = new MySqlConnection(constring)) { MySqlCommand cmd1Database = new MySqlCommand(count1, conDataBase); conDataBase.Open(); long count = (long)cmd1Database.ExecuteScalar(); if (count == 0) { string insert_ht = "INSERT INTO chtbuster.hostnametable(hostName) VALUES(@machineName);"; MySqlCommand cmd5Database = new MySqlCommand(insert_ht, conDataBase); cmd5Database.Parameters.AddWithValue("@machineName", machineName); cmd5Database.ExecuteNonQuery(); output.Text += "\n Empty " + count; conDataBase.Close(); uint newhostname_id; string gethostname_id = "SELECT hostName_id FROM hostnametable WHERE (hostName=@machineName)"; MySqlCommand cmd2Database = new MySqlCommand(gethostname_id, conDataBase); conDataBase.Open(); cmd2Database.Parameters.AddWithValue("@machineName", machineName); MySqlDataReader reader = cmd2Database.ExecuteReader(); while (reader.Read()) { newhostname_id = reader.GetUInt32(0); conDataBase.Close(); conDataBase.Open(); string insert_pt = "INSERT INTO chtbuster.processtable(processID,processFileName,processName,processPath,hostName_id) VALUES (@processID, @fileName, @exeFile, @filePath, " + newhostname_id + " );"; MySqlCommand cmd3Database = new MySqlCommand(insert_pt, conDataBase); cmd3Database.Parameters.AddWithValue("@processID", processID); cmd3Database.Parameters.AddWithValue("@machineName", machineName); cmd3Database.Parameters.AddWithValue("@filename", fileName); cmd3Database.Parameters.AddWithValue("@exeFile", exeFile); cmd3Database.Parameters.AddWithValue("@filePath", filePath); cmd3Database.Parameters.AddWithValue("@newhostname_id", newhostname_id); cmd3Database.ExecuteNonQuery(); break; } } else { conDataBase.Close(); uint newhostname_id; string gethostname_id = "SELECT hostName_id FROM hostnametable WHERE (hostName=@machineName)"; MySqlCommand cmd2Database = new MySqlCommand(gethostname_id, conDataBase); conDataBase.Open(); cmd2Database.Parameters.AddWithValue("@machineName", machineName); MySqlDataReader reader = cmd2Database.ExecuteReader(); while (reader.Read()) { newhostname_id = reader.GetUInt32(0); conDataBase.Close(); conDataBase.Open(); string insert_pt = "INSERT INTO chtbuster.processtable(processID,processFileName,processName,processPath,hostName_id) VALUES (@processID, @fileName, @exeFile, @filePath, " + newhostname_id + " );"; MySqlCommand cmd3Database = new MySqlCommand(insert_pt, conDataBase); cmd3Database.Parameters.AddWithValue("@processID", processID); cmd3Database.Parameters.AddWithValue("@machineName", machineName); cmd3Database.Parameters.AddWithValue("@filename", fileName); cmd3Database.Parameters.AddWithValue("@exeFile", exeFile); cmd3Database.Parameters.AddWithValue("@filePath", filePath); cmd3Database.Parameters.AddWithValue("@newhostname_id", newhostname_id); cmd3Database.ExecuteNonQuery(); conDataBase.Close(); break; } } } string newconstring = "Database=chtbuster;Data Source=localhost;User Id=root;Password='';"; string counter = "SELECT COUNT(p.hostName_id) AS 'COUNT' FROM hostnametable h JOIN processtable p ON h.hostName_id = p.hostname_id GROUP BY p.hostName_id ORDER BY p.hostname_id"; using (MySqlConnection conDataBase = new MySqlConnection(newconstring)) { MySqlCommand countID = new MySqlCommand(counter, conDataBase); conDataBase.Open(); MySqlDataReader reader = countID.ExecuteReader(); while (reader.Read()) { uint stringcount = reader.GetUInt32(0); if (stringcount == 1) { listBox1.Items.Add(new MyListBoxItem(Color.Gold,stringcount + "st warning" + machineName + " has opened " + fileName + " from path " + filePath)); } else if (stringcount == 2) { listBox1.Items.Add(new MyListBoxItem(Color.Orange,stringcount + "nd warning" + machineName + " has opened " + fileName + " from path " + filePath)); } else if (stringcount == 3) { listBox1.Items.Add(new MyListBoxItem(Color.Firebrick,stringcount + "rd warning" + machineName + " has opened " + fileName + " from path " + filePath)); } else { listBox1.Items.Add(new MyListBoxItem(Color.Gray,stringcount + "th warning" + machineName + " has opened " + inputfile + " from path " + filePath)); } } conDataBase.Close(); } } } }) 

by bitches_love_cake via /r/csharp

Leave a Reply