private void pictureBox2_Click(object sender, EventArgs e) { // Clear listview before refreshing, we don't want any duplicates. listView1.Items.Clear(); try { ListViewItem listviewitem = new ListViewItem(); AppDBFunctions appDB = new AppDBFunctions(); appDB.getApps(listView1, listviewitem, imageList1); } catch { MessageBox.Show(loc.EN_APPDB_REFRESH_FAIL, loc.EN_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void Main_Load(object sender, EventArgs e) { // Read userdata sqlFunctions sql = new sqlFunctions(); string appPath = Path.GetDirectoryName(Application.ExecutablePath); System.IO.StreamReader file = new System.IO.StreamReader(appPath + "/lastuser.txt"); string user; user = file.ReadLine(); file.Close(); MySqlConnection conn = new MySqlConnection("server=mysql05.citynetwork.se;userid=114794-xs71327;password=valvehelpedme;database=114794-nettest"); MySqlCommand getauth = new MySqlCommand("SELECT * FROM users WHERE username = '******';"); getauth.Parameters.AddWithValue("username", user); getauth.Connection = conn; conn.Open(); MySqlDataReader Reader = getauth.ExecuteReader(); this.Text = "Merriment CDS :: " + loc.EN_LOGGED_IN_AS + user; //label5.Text = "Merriment CDS :: " + loc.EN_LOGGED_IN_AS + user; while (Reader.Read()) { label1.Text = (sql.GetDBString("username", Reader)); label2.Text = (sql.GetDBString("usertitle", Reader)); pictureBox1.ImageLocation = (sql.GetDBString("avatar", Reader)); if (sql.GetDBString("isadmin", Reader) == "no") { label3.Text = string.Empty; } else { label3.Text = loc.EN_ADMIN; } } Reader.Close(); conn.Close(); // Fill listview with all applications which we will fetch from the database ListViewItem listviewitem = new ListViewItem(); AppDBFunctions appDB = new AppDBFunctions(); appDB.getApps(listView1, listviewitem, imageList1); }