Ejemplo n.º 1
0
        // on click function. Check if the access refericies are good and then give the access at the program. Otherwise show an error message
        private void loginNow(object sender, EventArgs e)
        {
            try
            {                                                                                             //take the data of the textBox
                UserManagerClient userManager = new UserManagerClient();                                  //initialize
                string            UserMail    = EmailBoxLogin.Text;
                string            PassHash    = EasyEncryption.MD5.ComputeMD5Hash(PasswordBoxLogin.Text); //encode the password

                //apply the funcition control on the referencies
                if (userManager.LoginChecker(UserMail, PassHash))
                {
                    loggingIn = true; //set the user logged

                    this.Hide();      //hide the control to the user
                    //verify if the user is an admin or not
                    if (userManager.IsAdmin(UserMail, PassHash))
                    {
                        AdminDashboard main = new AdminDashboard(UserMail, PassHash); //initialize a new admin form
                        main.Show();                                                  //send to the new form
                    }
                    else
                    {
                        UserDashboard main = new UserDashboard(UserMail, PassHash); //initialize a new user form
                        main.Show();
                    }
                    this.Close();// End of the control Hiding
                }
                else
                {
                    MessageBox.Show("Utente/Password errati.", "Non è così che si fa.", MessageBoxButtons.OK);//Error Message
                }
            }catch (Exception exc)
            {
                MessageBox.Show("Errore nella connessione al server.", "Proprio non riesco.", MessageBoxButtons.OK);
            }
        }