public HomeForm(object sender,int loginUID, String uName) { login = (Form)sender; UID = loginUID; userName = uName; InitializeComponent(); self = this; killForm = true; home = pnlHome; }
public HomeForm(object sender, int loginUID, String uName) { login = (Form)sender; UID = loginUID; userName = uName; InitializeComponent(); self = this; killForm = true; home = pnlHome; }
private void btnLogin_Click(object sender, EventArgs e) { String givenUserName = Regex.Replace(txtboxUserName.Text, @"[\r\n\x00\x1a\\'""]", @"\$0"); String givenPassword = Regex.Replace(txtboxPassword.Text, @"[\r\n\x00\x1a\\'""]", @"\$0"); DBConnect connector = new DBConnect(); List <String>[] temp = connector.SelectUsers("SELECT * FROM Users WHERE name='" + givenUserName + "' AND pass='******'"); ValidateLogin(); if (temp[0].Count == 1) //Pass { userValid = true; passValid = true; } else //Fail because of wrong password { userValid = false; passValid = false; txtboxPassword.Text = ""; MessageBox.Show("Error: username/password do not match"); lblErrorMsg.Visible = true; } if (userValid && passValid) //txtboxUserName.Text.Equals("username") && txtboxPassword.Text.Equals("Password"); { //MessageBox.Show("UID:" + temp[0][0]); HomeForm main = new HomeForm(this, int.Parse(temp[0][0]), txtboxUserName.Text); main.Show(); this.Hide(); txtboxPassword.Text = ""; txtboxUserName.Text = ""; } else { lblErrorMsg.Visible = true; } }