/// <summary> /// login and open the required panel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { string password; if (richPassword1.Visible) { password = richPassword1.Text; } else { password = richTextBox2.Text; } if (button1.Text.Equals("SIGN UP")) { User temp; try { temp = new User(); temp.ID = richTextBox1.Text; temp.Password = password; temp.Name = richTextBox3.Text; temp.Surname = richTextBox4.Text; temp.Age = richTextBox5.Text; } catch (ProjeException E) { E.notification = "LoginScreen ->> button1_Click(sıgn up event) Invalid user information"; Logger.writeExceptionLog(E.ToString()); AutoClosingMessageBox.Show("Invalid Argument!!!\nPlease Try Again", "Notification", 2000); richTextBox1.Text = ""; richPassword1.Text = ""; richTextBox3.Text = ""; richTextBox4.Text = ""; richTextBox5.Text = ""; temp = null; } if (temp != null) { if (!app.addUser(temp)) { AutoClosingMessageBox.Show("This username has already been taken", "Notification", 2300); richTextBox1.Text = ""; richPassword1.Text = ""; richTextBox3.Text = ""; richTextBox4.Text = ""; richTextBox5.Text = ""; } else { AutoClosingMessageBox.Show("You have successfully registered", "Notification", 1000); app.activeUserLocation = app.users.Count - 1; this.Hide(); new UserGUI().Show(); } } } else { //user login if (app.login(richTextBox1.Text, password)) { AutoClosingMessageBox.Show("The login process is successful", "Notification", 1500); this.Hide(); new UserGUI().Show(); } else if (app.admin.ID.Equals(richTextBox1.Text) && app.admin.Password.Equals(password)) //admin login { AutoClosingMessageBox.Show("The login process is successful", "Notification", 1500); this.Hide(); new AdminGUI().Show(); } else { AutoClosingMessageBox.Show("The login process fail", "Notification", 2000); } } }