} // end of sendButton /*************************** Login Button ************************************* * Takes the users name they typed in the username textbox and requests a connction * with the server, then logs in to the server enabling the create button, list * games button, and join button. */ private void LoginButton_Click_1(object sender, EventArgs e) { // handle a blank username and don't allow people to have names longer than 16 characters if (textBox3.Text.Trim() == "") { textBox1.Text = "Please enter a Username before logging in"; return; } if (textBox3.Text.Length > 16) { textBox1.Text = "You shall not enter names longer than 16 characters!"; return; } // Username is what was typed into the textbox clientNo = textBox3.Text; try { // Try to connect to the server clientSocket.Connect("18.216.181.228", 13000); // *** Loopback can be uncommented out for testing on local machine *** // just make sure you comment out the IP above //clientSocket.Connect("127.0.0.1", 13000); serverStream = clientSocket.GetStream(); // Send the user name to the server byte[] outStream = System.Text.Encoding.ASCII.GetBytes(textBox3.Text + "|"); serverStream.Write(outStream, 0, outStream.Length); serverStream.Flush(); // Create a new thread top handle the client Thread ctThread = new Thread(getMessage); ctThread.Start(); } catch (Exception ex) { textBox1.AppendText(ex.ToString()); } if (clientSocket.Connected) { // If the client connects successfully, enables button functions LoginButton.Hide(); CreateButton.Show(); ListGamesButton.Show(); JoinButton.Show(); SendButton.Show(); } } // end of LoginButton
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { CreateButton.Show(); DeleteButton.Show(); UpdateButton.Show(); string categoryName = listBox1.SelectedItem.ToString(); //Type returnType; switch (categoryName) { case "Curators": db.Curators.Load(); dataGridView1.DataSource = db.Curators.Local.ToBindingList(); break; case "Departments": db.Departments.Load(); dataGridView1.DataSource = db.Departments.Local.ToBindingList(); break; case "Faculties": db.Faculties.Load(); dataGridView1.DataSource = db.Faculties.Local.ToBindingList(); break; case "Groups": db.Groups.Load(); dataGridView1.DataSource = db.Groups.Local.ToBindingList(); break; case "GroupsCurators": db.GroupsCurators.Load(); dataGridView1.DataSource = db.GroupsCurators.Local.ToBindingList(); break; case "GroupsLectures": db.GroupsLectures.Load(); dataGridView1.DataSource = db.GroupsLectures.Local.ToBindingList(); break; case "Lectures": db.Lectures.Load(); dataGridView1.DataSource = db.Lectures.Local.ToBindingList(); break; case "Subjects": db.Subjects.Load(); dataGridView1.DataSource = db.Subjects.Local.ToBindingList(); break; case "Teachers": db.Teachers.Load(); dataGridView1.DataSource = db.Teachers.Local.ToBindingList(); break; } /* * db.Set(returnType); * dataGridView1.DataSource = db.GetTableType(categoryName).Local; * dataGridView1.DataSource = db.Curators.Local.ToBindingList(); * * var dt = new DataTable(); * var conn = db.Database.Connection; * var connectionState = conn.State; * if (connectionState != ConnectionState.Open) * conn.Open(); * using (var cmd = conn.CreateCommand()) * { * cmd.CommandText = $"SELECT * FROM {categoryName}"; * using (var reader = cmd.ExecuteReader()) * { * dt.Load(reader); * } * } * dataGridView1.DataSource = dt; * * * button2.Show(); * var dynamicTableType = Type.GetType(categoryName); * dataGridView1.DataSource = db.Set(dynamicTableType.GetType); * DbSet asd = new DbSet(); * db.Curators.Local.tob*/ }