private void btnLoginAsGuest_Click(object sender, EventArgs e) { //create instance of profile form Form_ConfirmProfile frmConfirmProfile = new Form_ConfirmProfile(txtUserName.Text); //display new form frmConfirmProfile.Show(); //hide current form this.Hide(); }
private void btnLogIn_Click(object sender, EventArgs e) { //defining a variable for Password string password; //checking for empty text if (txtUserName.Text == "" || txtPassword.Text == "") {// if so, show error message MessageBox.Show(NULL_VALUE_MSG, Program.APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information); txtUserName.Focus(); } else { password = tblUsersTableAdapter.LoginQuery(txtUserName.Text); //check to see if username and password match our records in the database if (txtPassword.Text != password) // HOW ABOUT FOR USERNAME???? { // if not, show relevant error message MessageBox.Show(INCORRECT_LOGIN_INFO, Program.APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information); txtPassword.Focus(); } // if everything looks good, then else { // cheking usertype to redirect different form on the basis of type int UserType = (int)tblUsersTableAdapter.GetUserType(txtUserName.Text, password); if (UserType == 1) { //create instance of profile form Form_ConfirmProfile frmConfirmProfile = new Form_ConfirmProfile(txtUserName.Text); //display new form frmConfirmProfile.Show(); //hide current form this.Hide(); } else if (UserType == 0) { // open admin amin Page adminHomeForm adminHomeForm = new adminHomeForm(); //display new form adminHomeForm.Show(); // hide the current page this.Hide(); } //clearing the textbox txtUserName.Text = ""; txtPassword.Text = ""; } } }