Example #1
0
        private void txtPasswordLogin_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                if (e.KeyChar == (int)Keys.Enter)
                {
                    if (txtUserLogin.Text.Trim() == "")
                    {
                        MessageBox.Show("Ingrese el Usuario", "Mensaje al Usuario", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        txtUserLogin.Focus();
                    }

                    else if (txtPasswordLogin.Text.Trim() == "")
                    {
                        MessageBox.Show("Ingrese la Contraseña", "Mensaje al Usuario", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        txtPasswordLogin.Focus();
                    }
                    else
                    {
                        //Verificar Login//
                        SolicitudDAO soliDao    = new SolicitudDAO();
                        var          userAccess = soliDao.ValidarAccesoUser(txtUserLogin.Text, txtPasswordLogin.Text);
                        if (userAccess != null)
                        {
                            VarGlobal.userAccesLogueado = userAccess;
                            if (userAccess.TipoAcceso.Equals("A"))
                            {
                                /*FrmRegistroDocs open = new FrmRegistroDocs();
                                 * open.Show();
                                 * this.Hide();*/
                                /*  MenuAdmin openMenuAdmin = new MenuAdmin();
                                 * openMenuAdmin.Show();
                                 * this.Hide();*/
                            }
                            else if (userAccess.TipoAcceso.Equals("U"))
                            {
                                /*FrmMisTareas openMisTareas = new FrmMisTareas();
                                 * openMisTareas.Show();
                                 * this.Hide();*/
                                MenuUser openMenuUser = new MenuUser();
                                openMenuUser.Show();
                                this.Hide();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Usuario o Clave incorrecta", "Mensaje al Usuario", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error:" + ex.Message, "Mensaje al Usuario", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string name     = SingInLogin.Text;
            string password = SingInPassword.Text;

            if (string.IsNullOrWhiteSpace(SingInLogin.Text) || string.IsNullOrWhiteSpace(SingInPassword.Text))
            {
                if (string.IsNullOrWhiteSpace(SingInLogin.Text))
                {
                    SingInLogin.BackColor = Color.MediumSeaGreen;
                }
                if (string.IsNullOrWhiteSpace(SingInPassword.Text))
                {
                    SingInPassword.BackColor = Color.MediumSeaGreen;
                }
                MessageBox.Show("Fill in the blank space, please");
                SingInLogin.BackColor    = Color.White;
                SingInPassword.BackColor = Color.White;
            }
            else if (SingInLogin.Text.Length <= 4 || SingInLogin.Text.Length >= 10)
            {
                SingInLogin.BackColor = Color.MediumSeaGreen;
                MessageBox.Show("Name has inappropriate length, try again");
                SingInLogin.BackColor = Color.White;
                SingInLogin.Text      = string.Empty;
            }
            else if (SingInPassword.Text.Length < 2 || SingInPassword.Text.Length >= 10)

            {
                SingInPassword.BackColor = Color.MediumSeaGreen;
                MessageBox.Show("Password has inappropriate length, try again");
                SingInPassword.BackColor = Color.White;
                SingInPassword.Text      = string.Empty;
            }
            else
            {
                string nickname;
                int    number;
                int    pass;
                bool   isInt     = int.TryParse(SingInPassword.Text, out number);
                bool   isIntName = int.TryParse(SingInLogin.Text, out number);
                // Данные с полей
                if (isIntName == true || isInt == false)
                {
                    if (isIntName == true)
                    {
                        SingInLogin.BackColor = Color.MediumSeaGreen;
                        MessageBox.Show("Name consists only of numbers, try again");
                        SingInLogin.Text      = string.Empty;
                        SingInLogin.BackColor = Color.White;
                    }
                    else
                    {
                        nickname = SingInLogin.Text;
                    }
                    if (isInt == false)
                    {
                        SingInPassword.BackColor = Color.MediumSeaGreen;
                        MessageBox.Show("Password consists not only of numbers, try again");
                        SingInPassword.Text      = string.Empty;
                        SingInPassword.BackColor = Color.White;
                    }
                    else
                    {
                        pass = Convert.ToInt32(SingInPassword.Text);
                    }
                }
                else
                {
                    nickname = SingInLogin.Text;
                    if (store.users.FirstOrDefault(u => u.Login == name && u.Password == password) != null)
                    {
                        MessageBox.Show($"Hello, {name}!");
                        Form Menu = new MenuUser(ref store);
                        Menu.Left = this.Left;
                        Menu.Top  = this.Top;
                        Menu.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Sorry, such User doesn`t exist...Try again or sign up !");
                    }
                }
            }
        }