private void btnMainMenu_Click(object sender, EventArgs e) { MainMenu mainMenu = new MainMenu(); this.Hide(); mainMenu.ShowDialog(); }
private void btnLogin_Click(object sender, EventArgs e) { var dbConnectionStatus = false; var server = "78.189.60.108"; var database = "ef"; var uid = "remoteuser"; var password = "******"; string connectionString = "SERVER=" + server + "; PORT = 8001 ;" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD="******";SslMode=none"; var mycon = new MySqlConnection(connectionString); // "SERVER=78.189.60.108; PORT = 8001 ;DATABASE=ef; UID=remoteuser; PASSWORD=abcdefG1-1;SslMode=none"; try { mycon.Open(); dbConnectionStatus = true; } catch (Exception erro) { MessageBox.Show("Database Connection Failed!"); mycon.Close(); } if (dbConnectionStatus) { // lblUserName.Text = "Connected" + mycon.Database; var UserNameInput = txtbUserName.Text; var UserPasswordInput = txtbPassword.Text; MySqlCommand cmd = mycon.CreateCommand(); cmd.CommandText = "SELECT * from users WHERE UCODE ='" + UserNameInput + "' AND UPASS='******'"; MessageBox.Show(cmd.CommandText); MySqlDataReader reader = cmd.ExecuteReader(); // reader.Read(); if (reader.Read()) { // MessageBox.Show(reader.GetString(0) + reader.GetString(1) + reader.GetString(2) + reader.GetString(3) + reader.GetString(4) + reader.GetString(5)); Globals.userFullName = reader["UNAME"].ToString(); Globals.userName = reader["UCODE"].ToString(); Globals.userPass = reader["UPASS"].ToString(); Globals.userType = reader["TYPE"].ToString(); Globals.userRegion = Convert.ToInt32(reader["UREGION"]); Globals.userId = Convert.ToInt32(reader["UID"]); MainMenu frm2 = new MainMenu(); this.Hide(); //Hide the main form before showing the secondary frm2.ShowDialog(); //Show secondary form, code execution stop until frm2 is closed this.Show(); } else { MessageBox.Show("USERNAME or PASSWORD is invalid!"); mycon.Close(); } } }
/// <summary> /// Кнопка главного меню /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mainmenu_Click(object sender, EventArgs e) { this.Hide(); this.Dispose(); this.Close(); MainMenu mainmenu = new MainMenu(); game.Hide(); game.Dispose(); game.Close(); mainmenu.ShowDialog(); return; }
private void btnLogin_Click(object sender, EventArgs e) { sqlconn.Open(); sqlcmd.Connection = sqlconn; sqlcmd.CommandText = "select * from Login"; SqlDataReader sqlDataReader = sqlcmd.ExecuteReader(); if (sqlDataReader.Read()) { if (txtUsername.Text.Equals(sqlDataReader["username"].ToString()) && txtPassword.Text.Equals(sqlDataReader["password"].ToString())) { // MessageBox.Show("Login Success", "Congrats", MessageBoxButtons.OK, MessageBoxIcon.Information); MainMenu menuForm = new MainMenu(); this.Hide(); menuForm.ShowDialog(); } else { MessageBox.Show("Login FAILED", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } sqlconn.Close(); }