private void loginbutton_Click(object sender, EventArgs e) //next { if (firstname_click_check && lastname_click_check && phon_click_check && date) { string connectionString = "datasource=127.0.0.1;port=3306;username=root;password=;database=scorpio;"; string query = "UPDATE `user` SET `First_name`='" + usernameinput.Text + "',`last_name`='" + lastname.Text + "',`Phone_no`='" + phoneinput.Text + "' , `Birth_date`='" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "' WHERE User_name ='" + user_log_in.UserID + "'"; MySqlConnection databaseConnection = new MySqlConnection(connectionString); MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection); commandDatabase.CommandTimeout = 60; MySqlDataReader reader; try { databaseConnection.Open(); reader = commandDatabase.ExecuteReader(); databaseConnection.Close(); //MessageBox.Show(user_log_in.UserID); this.Hide(); var home = new homepage(); home.Closed += (s, args) => this.Close(); home.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void skip_Click(object sender, EventArgs e) { this.Hide(); var home = new homepage(); home.Closed += (s, args) => this.Close(); home.Show(); return; }
private void button1_Click(object sender, EventArgs e) //log in { usernameinput.ForeColor = Color.FromArgb(233, 233, 233); passwordinput.ForeColor = Color.FromArgb(233, 233, 233); panel1.BackColor = Color.FromArgb(233, 233, 233); panel2.BackColor = Color.FromArgb(233, 233, 233); pictureBox3.BackgroundImage = Properties.Resources.lock1; pictureBox2.BackgroundImage = Properties.Resources.user1; bool proced = true; if (string.IsNullOrEmpty(usernameinput.Text.ToString()) == true) { user_click_check = false; usernameinput.Text = "User Name"; } if (string.IsNullOrEmpty(passwordinput.Text.ToString()) == true) { pass_click_check = false; passwordinput.PasswordChar = '\0'; passwordinput.Text = "Password"; } if (user_click_check == false) { usernameinput.ForeColor = Color.FromArgb(100, 100, 100); panel1.BackColor = Color.FromArgb(190, 40, 40); proced = false; } if (pass_click_check == false) { passwordinput.ForeColor = Color.FromArgb(100, 100, 100); panel2.BackColor = Color.FromArgb(190, 40, 40); proced = false; } if (proced == true) { string connectionString = "datasource=127.0.0.1;port=3306;username=root;password=;database=scorpio;"; // Select all string query = "SELECT * FROM user"; MySqlConnection databaseConnection = new MySqlConnection(connectionString); MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection); commandDatabase.CommandTimeout = 60; MySqlDataReader reader; try { databaseConnection.Open(); reader = commandDatabase.ExecuteReader(); // Success, now list // If there are available rows if (reader.HasRows) { while (reader.Read()) { string userName = (string)reader["User_name"]; string pass = (string)reader["Password"]; if (string.Compare(userName, usernameinput.Text.ToString()) == 0 && string.Compare(pass, passwordinput.Text.ToString()) == 0) { // MessageBox.Show("you are loged in"); user_log_in.UserID = userName; databaseConnection.Close(); this.Hide(); var home = new homepage(); home.Closed += (s, args) => this.Close(); home.Show(); return; //MessageBox.Show("you are loged in"); } incorrectpanel.Visible = true; } } else { Console.WriteLine("No rows found."); } databaseConnection.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }