private void LoginButton_Click(object sender, EventArgs e) { if (EmailLoginTextbox.Text.Equals("") || PasswordLoginTextbox.Text.Equals("")) { toolTip.Active = true; toolTip.SetToolTip(this.LoginButton, "Missing Inputs!"); return; } if (!IsValidEmail(EmailLoginTextbox.Text)) { toolTip.Active = true; toolTip.SetToolTip(this.LoginButton, "Invalid email format!"); return; } dt = dbconn.Select("SELECT `users`.`name` AS name, `users`.`surname` AS surname, `users`.`email` AS email, `users`.`password` AS password FROM `bookstore_schema`.`users` WHERE email = '" + EmailLoginTextbox.Text + "' AND password = '******';"); if (dt.Rows.Count == 0) { toolTip.Active = true; toolTip.SetToolTip(this.LoginButton, "Wrong credentials!"); return; } entryForm = new EntryForm(dt.Rows[0]["name"].ToString(), dt.Rows[0]["surname"].ToString(), dt.Rows[0]["email"].ToString()); this.Hide(); entryForm.Show(); }
private void SignUpButton_Click(object sender, EventArgs e) { foreach (TextBox c in SignUpPanel.Controls.OfType <TextBox>()) { if (c.Text.Equals("")) { toolTip.Active = true; toolTip.SetToolTip(this.SignUpButton, "Missing Inputs!"); return; } } if (!IsValidEmail(emailSignUpTextBox.Text)) { toolTip.Active = true; toolTip.SetToolTip(this.SignUpButton, "Invalid email format!"); return; } dt = dbconn.Select("SELECT `users`.`email` AS email FROM `bookstore_schema`.`users` WHERE email = '" + EmailLoginTextbox.Text + "';"); if (dt.Rows.Count != 0) { toolTip.Active = true; toolTip.SetToolTip(this.SignUpButton, "Email already exists!"); return; } if (!passwordSignUpTextBox.Text.Equals(passwordConfirmSignUpTextbox.Text)) { toolTip.Active = true; toolTip.SetToolTip(this.SignUpButton, "Wrong password confirmation!"); return; } message = dbconn.ExecuteNonQuery("INSERT INTO `bookstore_schema`.`users` (`name`, `surname`, `password`, `email`, `type`) VALUES ('" + nameSignUpTextBox.Text + "', '" + surnameSignUpTextBox.Text + "', '" + passwordSignUpTextBox.Text + "', '" + emailSignUpTextBox.Text + "', 'user');"); if (!message.Equals("OK")) { MessageBox.Show("Email already exists!", "Duplicate Entry", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } entryForm = new EntryForm(nameSignUpTextBox.Text, surnameSignUpTextBox.Text, emailSignUpTextBox.Text); this.Hide(); entryForm.Show(); }