예제 #1
0
        private void btnAdmin_Click(object sender, EventArgs e)
        {
            FormAdmin fa = new FormAdmin();

            fa.Show();
            //this.Close();
        }
예제 #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (LC.cekLogin(txtUser.Text, txtPass.Text) == true)
            {
                MySqlDataAdapter adapter = LC.GetRole(txtUser.Text, txtPass.Text);
                adapter.Fill(dt);
                string role = dt.Rows[0]["NAMA_ROLE"].ToString();
                if (role.ToLower() == "admin")
                {
                    label3.Text = role;
                    this.Hide();
                    FormAdmin A = new FormAdmin(role);
                    A.Show();
                }
                else
                {
                    MessageBox.Show("tidak memiliki role");
                }
            }

            else
            {
                MessageBox.Show("Username atau password salah");
            }
        }
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            string typedLogin    = "";
            string typedPassword = "";

            if (textBoxLogin.Text == "" || textBoxPassword.Text == "")
            {
                MessageBox.Show("Заповніть всі поля");
                return;
            }
            else
            {
                typedLogin    = textBoxLogin.Text;
                typedPassword = textBoxPassword.Text;

                bool logedIn = false;
                foreach (var user in carshop_db.Instance.Users)
                {
                    if (typedLogin.Equals(user.name) && typedPassword.Equals(user.password))
                    {
                        if (user.userType == "admin")
                        {
                            Form admf = new FormAdmin();
                            admf.Show();
                            Hide();
                        }
                        if (user.userType == "secretary")
                        {
                            Form admf = new FormSecretary();
                            admf.Show();
                            Hide();
                        }
                        if (user.userType == "seller")
                        {
                            FormSales fs = new FormSales("seller");
                            fs.Show();
                            Hide();
                        }

                        logedIn = true;
                        break;
                    }
                }

                if (!logedIn)
                {
                    MessageBox.Show("Ім'я або пароль введені неправлиьно");
                }
            }
        }
예제 #4
0
        private void metroTextButtonLogin_Click(object sender, EventArgs e)
        {
            Login_ log = new Login_();

            try
            {
                log = DBcon.Login_s.SingleOrDefault(x => x.LoginUserName == metroTextBox1.Text && x.LoginPassword == metroTextBox2.Text);
                if (log != null)
                {
                    user = log.LoginUserName;
                    this.Hide();
                    metroTextBox1.Clear();
                    metroTextBox2.Clear();
                    var profile = log.Profile.ToString();
                    if (profile == "ADMIN")
                    {
                        var adminForm = new FormAdmin();
                        adminForm.Show();
                    }
                    else if (profile == "DOCTOR")
                    {
                        var doctorForm = new FormDoctor();
                        doctorForm.Show();
                    }
                    else if (profile == "ACCOUNTANT")
                    {
                        var accform = new FormAccountant();
                        accform.Show();
                    }
                    else if (profile == "RECEPTIONIST")
                    {
                        var recform = new FormReceptionist();
                        recform.Show();
                    }
                }
                else
                {
                    MetroMessageBox.Show(this, "Incorrect Login Details", "Login Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, ex.Message, "Critical Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
            }
        }
예제 #5
0
        /// <summary>
        /// Przycisk logujący
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            string login    = textBoxLogin.Text;
            string password = textBoxPassword.Text;

            if (usersRepository.IsLoginCorrect(login, password))
            {
                FormAdmin formAdmin = new FormAdmin();
                formAdmin.Show();
                Hide();
            }
            else
            {
                MessageBox.Show("Niepoprawny login lub hasło!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBoxLogin.Text    = "";
                textBoxPassword.Text = "";
            }
        }
        public void login(String username, String password)
        {
            //UsersDAL usersDAL = UsersDAL.getInstance();
            UserService userService = UserService.getInstance();
            String      passMD5     = getMd5Hash(password);

            UserDAO u = userService.getUser(username, passMD5);

            if (u != null)
            {
                if (u.getRole() == "user")
                {
                    FormUser formUser = new FormUser();
                    formUser.Show();
                }
                else if (u.getRole() == "admin")
                {
                    FormAdmin formAdmin = new FormAdmin();
                    formAdmin.Show();
                }
            }
        }