Exemplo n.º 1
0
        private void btnLogin_Click_2(object sender, EventArgs e)
        {
            if (LC.cekLogin(txtUser.Text, txtPass.Text) == true)
            {
                if (txtPass.Text.Length != 0 && txtUser.Text.Length != 0)
                {
                    if (txtPass.Text.Length >= 4)
                    {
                        DataTable        dt      = new DataTable();
                        MySqlDataAdapter adapter = LC.GetRole(txtUser.Text, txtPass.Text);
                        adapter.Fill(dt);

                        if (dt.Rows.Count > 0)
                        {
                            string role = dt.Rows[0]["NAMA_ROLE"].ToString();
                            if (role.ToLower() == "admin")
                            {
                                this.Hide();
                                FormAdmin A = new FormAdmin(role);
                                A.Show();
                            }
                            else if (role.ToLower() == "front office")
                            {
                                this.Hide();
                                FormFrontOffice FO = new FormFrontOffice(role);
                                FO.Show();
                            }
                            else if (role.ToLower() == "sales & marketing")
                            {
                                this.Hide();
                                FormSalesMarketing SM = new FormSalesMarketing(role);
                                SM.Show();
                            }
                            else if (role.ToLower() == "general manager" || role.ToLower() == "owner")
                            {
                                this.Hide();
                                FormOwnerGM OW = new FormOwnerGM();
                                OW.Show();
                            }
                            else
                            {
                                MessageBox.Show("tidak memiliki role");
                            }
                        }
                        else if (dt.Rows.Count == 0)
                        {
                            MessageBox.Show("Username atau Password salah", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else if (txtPass.Text.Length < 4 && txtPass.Text.Length >= 1)
                    {
                        MessageBox.Show("Password minimal 4 digit", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Username atau Password tidak boleh kosong", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Exemplo n.º 2
0
        public void OpenForm()
        {
            switch (User.levelAccess)
            {
            case LevelAccess.banned:
                break;

            case LevelAccess.user:
                FormUser formUser = new FormUser();
                formLogin.Hide();
                formUser.Show();
                break;

            case LevelAccess.seller:

                break;

            case LevelAccess.zavhoz:

                break;

            case LevelAccess.admin:
                FormAdmin formAdmin = new FormAdmin();
                formLogin.Hide();
                formAdmin.Show();
                break;
            }
        }
Exemplo n.º 3
0
        private void usersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //open user form
            FormAdmin admins = new FormAdmin();

            admins.Show();
        }
Exemplo n.º 4
0
        private void login_Click(object sender, EventArgs e)
        {
            this._loginVO = this._loginBUS.getUser(textUser.Text, textPassw.Text);

            if (this._loginVO.type == null)
            {
                MessageBox.Show("Incorrect username or password!", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else if (this._loginVO.type == "Customer")

            {
                //MessageBox.Show(_loginVO.idClient.ToString(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Hide();
                FormClient fc = new FormClient();
                fc.setId(this._loginVO.idClient);
                DataGridView dataGrid = fc.getGrid();
                fc.refreshGrid(this._loginVO.idClient);
                fc.Show();
            }
            else
            {
                this.Hide();
                FormAdmin fa = new FormAdmin();
                fa.refreshGrid();
                fa.Show();
            }
        }
Exemplo n.º 5
0
        private void btnAdmin_Click(object sender, EventArgs e)
        {
            FormAdmin fa = new FormAdmin();

            fa.Show();
            //this.Close();
        }
Exemplo n.º 6
0
        public override void ShowUserInterface(out DialogResult dialogResult)
        {
            FormAdmin formAdmin = new FormAdmin();

            formAdmin.ShowDialog();
            dialogResult = formAdmin.DialogResult;
        }
        private void buttonCancelar_Click(object sender, EventArgs e)
        {
            // Vuelve a la pantallita de formulario para el Administrador
            FormAdmin form_admin = new FormAdmin();

            form_admin.ShowDialog();
        }
Exemplo n.º 8
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("Ім'я або пароль введені неправлиьно");
                }
            }
        }
Exemplo n.º 10
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);
            }
        }
Exemplo n.º 11
0
 private void buttonLogIn_Click(object sender, EventArgs e)
 {
     if (service.LogIn(textBoxLogin.Text, textBoxPassword.Text, 3) &&
         textBoxKey.Text == "youshallnotpass")
     {
         FormAdmin window = new FormAdmin();
         formMain.Hide();
         window.ShowDialog();
         formMain.Close();
     }
     else
     {
         MessageBox.Show("Invalid data provided");
         textBoxLogin.Text    = "";
         textBoxPassword.Text = "";
         textBoxKey.Text      = "";
     }
 }
Exemplo n.º 12
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();
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Opens the Admin Form. If the administrator is true it allows access
        /// to the admin menu items on the form.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void loginToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Creates a Admin Form variable and opens the form.
            FormAdmin myFormAdmin = new FormAdmin();
            myFormAdmin.ShowDialog();

            // Checks if administrator flag has been changed to true.
            if (administrator)
            {
                // Enables admin Menu items on the Navigation Form (see below)
                adminForm();
            }
        }
Exemplo n.º 15
0
        private void login_button_Click(object sender, EventArgs e)
        {
            /*-----Controlamos que no halla textBoxs en blanco*/

            bool error = false;

            if (this.username_textbox.Text == "")
            {
                MessageBox.Show("Debe Ingresar username", "Acceso al Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                error = true;
            }

            if (this.passw_textbox.Text == "")
            {
                MessageBox.Show("Debe Ingresar password", "Acceso al Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                error = true;
            }

            if (error)
            {
                this.limpiar();
                return;
            }


            /*------------------------------------------------*/
            //el administrador ingreso usuario y contraseña
            connection conexion = new connection();


            DataTable administrador = conexion.execute_query("SELECT adm_username, adm_password, adm_cant_intentos, rol_estado FROM DATACENTER.Administrador  JOIN DATACENTER.Rol  ON (adm_rol_id=rol_id) WHERE adm_username= "******"'" + username_textbox.Text + "'");


            if (administrador.Rows.Count == 1)
            {
                //verificamos que el Rol administrador NO este inhabilitado
                if (administrador.Rows[0].ItemArray[3].ToString() != "H")
                {
                    MessageBox.Show("Rol Administrador Inhabilitado", "Acceso al Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //existe el usuario sino no me devolveria filas el select; entonces evaluamos la cant_intentos
                cant_fallidas = Convert.ToInt16(administrador.Rows[0].ItemArray[2].ToString());
                if (cant_fallidas == 3)
                {
                    MessageBox.Show("Superada la cantidad Máxima de intentos por loguearse, Usuario Inhabilitado ", "Acceso al Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.limpiar();
                    return;
                }

                //evaluamos si esta bien la contraseña

                funciones func = new funciones();
                if (func.get_hash(passw_textbox.Text) == administrador.Rows[0].ItemArray[1].ToString())
                {
                    //Row[n] siendo n nro de fila; itemArray[n] siendo n el nro de columna de la fila siendo n>=0

                    //limpiamos cant_intentos
                    cant_fallidas = 0;
                    procedure.update_cant_intentos_fallidos(username_textbox.Text, cant_fallidas);



                    //abrimos el formulario de administradores
                    FormAdmin form_admin = new FormAdmin();
                    form_admin.ShowDialog();
                }
                else
                {
                    cant_fallidas++;
                    //Se debe actualizar el campo adm_cant_intentos de la base de datos
                    procedure.update_cant_intentos_fallidos(username_textbox.Text, cant_fallidas);



                    MessageBox.Show("Password Incorrecto", "Acceso al Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            { //NO EXISTE EL USERNAME entonces NO podemos descontar cant_intentos_fallidos
                MessageBox.Show("Username Incorrecto", "Acceso al Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.username_textbox.Text = "";
            this.passw_textbox.Text    = "";
            return;
        }
Exemplo n.º 16
0
 /// <summary>
 /// Konstruktor
 /// </summary>
 /// <param name="formAdmin"></param>
 public FormAddress(FormAdmin formAdmin)
 {
     this.formAdmin = formAdmin;
     InitializeComponent();
 }
Exemplo n.º 17
0
 public ControllerFormAdmin(FormAdmin form)
 {
     this.form = form;
     dbManager = DbManager.GetInstance();
 }