Ejemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            SomerenLogic.Login_Service loginService = new SomerenLogic.Login_Service();
            List <Login> loginList = loginService.GetLogin();
            string       email     = txtUserName.Text;

            bool Isadmin = false;
            bool Isright = false;

            foreach (var s in loginList)
            {
                if ((s.UserName == txtUserName.Text) && (s.Password == txtPassword.Text))
                {
                    this.Hide();
                    if (s.Type == "admin")
                    {
                        Isadmin = true;
                    }
                    SomerenUI someren = new SomerenUI(Isadmin, $"{email}");
                    someren.ShowDialog();
                    this.Close();
                    break;
                }
                else
                {
                    Isright = true;
                }
            }
            if (Isright = true)
            {
                MessageBox.Show("Invalid user name or password!!!");
            }
        }
        //login
        // string[] usernames = {  "*****@*****.**", "rita @ infhaarlem.nl" };
        //string[] passwords = {  "t78Dx4BfhqfEamxdnAkLCpbC", "qd6VqFfyzF5UgPRDNy9NSCb4" };
        private void Login_Click(object sender, EventArgs e)
        {
            Login_Service    loginService = new Login_Service();
            List <LoginData> loginDatas   = loginService.GetLoginDatas();

            foreach (var lg in loginDatas)
            {
                if (lg.Username == UsernameBox.Text && lg.Password == PasswordBox.Text)
                {
                    SomerenUI s = new SomerenUI();
                    s.ShowDialog();
                    this.Hide();
                }
            }
        }
Ejemplo n.º 3
0
        private void btn_RegisterConfirm_Click(object sender, EventArgs e)
        {
            //prep
            List <string> LicenceKey = new List <string>()
            {
                "XsZAb", "tgz3PsD", "qYh69un", "WQCEx"
            };
            bool      LicenceError = true;
            bool      PasswordsError = false;
            bool      EmptyError = false;
            bool      Isadmin = false;
            string    email, password = null, passwordchecker1, passwordchecker2, licence;
            Login_DAO login = new Login_DAO();

            //getting the email
            email = txt_RegisterEmailAddress.Text;

            //checking if everything is filled in
            if (string.IsNullOrWhiteSpace(txt_RegisterUsername.Text) | string.IsNullOrWhiteSpace(txt_RegisterPassword.Text) | string.IsNullOrWhiteSpace(txt_RegisterConfirmPassword.Text) | string.IsNullOrWhiteSpace(txt_RegisterLicenceKey.Text) | string.IsNullOrWhiteSpace(txt_RegisterEmailAddress.Text))
            {
                EmptyError = true;
            }

            //checking the licence
            licence = txt_RegisterLicenceKey.Text;
            foreach (var key in LicenceKey)
            {
                if (licence == key)
                {
                    LicenceError = false;
                    break;
                }
            }

            //checking the password
            passwordchecker1 = txt_RegisterPassword.Text;
            passwordchecker2 = txt_RegisterConfirmPassword.Text;
            if (passwordchecker1 != passwordchecker2)
            {
                PasswordsError = true;
            }
            else
            {
                password = passwordchecker1;
            }

            //confirming if everything is ok
            if (EmptyError == true)
            {
                lbl_RegisterError.Show();
                lbl_RegisterError.Text = "Error! Fill in all requirements";
            }
            else if (LicenceError == true && PasswordsError == true)
            {
                lbl_RegisterError.Show();
                lbl_RegisterError.Text = "Error! Invalid licence key and unsimilar passwords";
            }
            else if (LicenceError == true)
            {
                lbl_RegisterError.Show();
                lbl_RegisterError.Text = "Error! Invalid licence key";
            }
            else if (PasswordsError == true)
            {
                lbl_RegisterError.Show();
                lbl_RegisterError.Text = "Error! Passwords does not match";
            }
            else
            {
                //MessageBox.Show($"email= {email}\npassword= {password}");
                login.AddAccount($"{email}", $"{password}");
                this.Hide();
                SomerenUI someren = new SomerenUI(Isadmin, $"{email}");
                someren.ShowDialog();
                this.Close();
            }
        }