private void button22_Click(object sender, EventArgs e) { WheelForm wf = new WheelForm(MyVal); this.Hide(); wf.ShowDialog(); }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { this.Hide(); WheelForm wf = new WheelForm(MyVal); wf.ShowDialog(); }
private void button1_Click(object sender, EventArgs e) { if (comboBox1.Text == "User") { data = usernameTextBox.Text.ToString(); ActThreePacman pac = new ActThreePacman(data); ActThree act3 = new ActThree(data); Form2 f2 = new Form2(data); WheelForm wh = new WheelForm(data); Form5 f5 = new Form5(data); ActFourMatchTheCards mat = new ActFourMatchTheCards(data); MySqlConnection sqlcon = new MySqlConnection(@"server=localhost;user id=root;database=seproject;password=rootpassword"); try { sqlcon.Open(); String username = usernameTextBox.Text; String password = passwordTextBox.Text; DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT * FROM seproject.user WHERE username = '******' and password = '******'", sqlcon); adapter.Fill(table); //check if the username exists or not if (table.Rows.Count > 0) { if (checkBox1.Checked == true) { MessageBox.Show("Successfully logged in!"); this.Hide(); Form2 f22 = new Form2(data); f22.ShowDialog(); } else { MessageBox.Show("Incorrect captcha!"); } } else { MessageBox.Show("Incorrect username/password"); usernameTextBox.Text = ""; passwordTextBox.Text = ""; } sqlcon.Close(); } catch (Exception ex) { MessageBox.Show("Connection error"); } } else if (comboBox1.Text == "Moderator") { MySqlConnection sqlcon = new MySqlConnection(@"server=localhost;user id=root;database=seproject;password=rootpassword"); try { sqlcon.Open(); String username = usernameTextBox.Text; String password = passwordTextBox.Text; DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT * FROM seproject.moderator WHERE username = '******' and password = '******'", sqlcon); adapter.Fill(table); //check if the username exists or not if (table.Rows.Count > 0) { if (checkBox1.Checked == true) { MessageBox.Show("Admin successfully logged in!"); this.Hide(); Moderator md = new Moderator(); md.ShowDialog(); } else { MessageBox.Show("Incorrect captcha!"); } } else { MessageBox.Show("Incorrect username/password"); usernameTextBox.Text = ""; passwordTextBox.Text = ""; } sqlcon.Close(); } catch (Exception ex) { MessageBox.Show("Connection error"); } } }
private void button1_Click(object sender, EventArgs e) { MySqlConnection sqlcon = new MySqlConnection(@"server=localhost;user id=root;database=seproject;password=rootpassword"); MySqlCommand cmd = null; MySqlDataReader reader = null; try { string sql = "SELECT inGameCurrency FROM seproject.user WHERE username = '******';"; //sqlcon = new MySqlConnection(Properties.Settings.Default.ConnectionString); cmd = new MySqlCommand(sql, sqlcon); sqlcon.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { val1 = reader.GetInt32("inGameCurrency"); //lblContinent.Text = reader.GetInt32("continent"); //lblRegion.Text = reader.GetString("region"); //lblSurfaceArea.Text = string.Format("{0:0.00}", reader.GetFloat("surfacearea")); } Console.WriteLine(val1); } catch (Exception ex) { MessageBox.Show(string.Format("An error occurred {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (reader != null) { reader.Close(); } if (sqlcon != null) { sqlcon.Close(); } } try { string sql = "SELECT realCurrency FROM seproject.user WHERE username = '******';"; //sqlcon = new MySqlConnection(Properties.Settings.Default.ConnectionString); cmd = new MySqlCommand(sql, sqlcon); sqlcon.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { val2 = reader.GetInt32("realCurrency"); //lblContinent.Text = reader.GetInt32("continent"); //lblRegion.Text = reader.GetString("region"); //lblSurfaceArea.Text = string.Format("{0:0.00}", reader.GetFloat("surfacearea")); } Console.WriteLine(val2); } catch (Exception ex) { MessageBox.Show(string.Format("An error occurred {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (reader != null) { reader.Close(); } if (sqlcon != null) { sqlcon.Close(); } } MessageBox.Show("Your coins: " + coins.ToString()); sum1 = val1 + coins; sum2 = val2 + tokens; try { sqlcon.Open(); string Query1 = "update seproject.user set inGameCurrency = " + "'" + coins + "' where (username = '******');"; MySqlCommand cmdInsert = new MySqlCommand(Query1, sqlcon); MySqlDataReader reader1 = cmdInsert.ExecuteReader(); MessageBox.Show("Saved"); while (reader1.Read()) { } //sqlcon.Close(); } catch (Exception ex) { MessageBox.Show("Insertion failed"); } finally { sqlcon.Close(); } MessageBox.Show("Your tokens: " + tokens.ToString()); try { sqlcon.Open(); string Query2 = "update seproject.user set realCurrency = " + "'" + tokens + "' where (username = '******');"; MySqlCommand cmdInsert1 = new MySqlCommand(Query2, sqlcon); MySqlDataReader reader2 = cmdInsert1.ExecuteReader(); MessageBox.Show("Saved"); while (reader2.Read()) { } sqlcon.Close(); } catch (Exception ex) { MessageBox.Show("Insertion failed"); } finally { sqlcon.Close(); } this.Hide(); WheelForm wf = new WheelForm(MyVal); wf.ShowDialog(); }