Ejemplo n.º 1
0
        private void CmdAddUser_OnClick(object sender, RoutedEventArgs e)
        {
            // check exist user if update
            TemplateMyUsersDataBase u = MainWindow.SqliteSource.GetUserEdit(TxtUser.Text);

            // existe usuario update
            if (TxtUser.Text != string.Empty && TxtPw.Password != string.Empty &&
                MainWindow.SqliteSource.CheckUserExist(TxtUser.Text))
            {
                if (TxtUser.Text != u.User || TxtPw.Password != u.Password || TxtOwner.Text != u.Owner)
                {
                    // update algum valor alterado
                    MainWindow.SqliteSource.UpdateUserIn(TxtUser.Text, TxtPw.Password, TxtOwner.Text, u.User);
                }
            }

            // cria novo usuario
            if (TxtUser.Text != string.Empty && TxtPw.Password != string.Empty && !MainWindow.SqliteSource.CheckUserExist(TxtUser.Text))
            {
                MainWindow.SqliteSource.CreatUser(TxtUser.Text, TxtPw.Password, TxtOwner.Text);
                this.ShowMessageAsync(@"Sucess", @"User created");
            }

            // refresh list user
            ListUserInDataBase();

            // clear txt
            TxtUser.Text   = string.Empty;
            TxtPw.Password = string.Empty;
            TxtOwner.Text  = string.Empty;

            TxtUser.Focus();
        }
Ejemplo n.º 2
0
        private void CmdRemoveUser_OnClick(object sender, RoutedEventArgs e)
        {
            TemplateMyUsersDataBase u = MainWindow.SqliteSource.GetUserEdit(TxtUser.Text);

            if (u == null)
            {
                return;
            }
            // check password
            if (TxtPw.Password != u.Password || TxtUser.Text != u.User || TxtOwner.Text != u.Owner && MainWindow.SqliteSource.CheckUserExist(TxtUser.Text))
            {
                return;
            }

            MainWindow.SqliteSource.DeleteUser(TxtUser.Text);
            // refresh list user
            ListUserInDataBase();

            // clear txt
            TxtUser.Text   = string.Empty;
            TxtPw.Password = string.Empty;
            TxtOwner.Text  = string.Empty;

            TxtUser.Focus();
            this.ShowMessageAsync(@"Sucess", @"User deleted");
        }
Ejemplo n.º 3
0
 private void BtnAceptar_Click(object sender, EventArgs e)
 {
     if (TxtUser.Text.IsNullOrEmpty() || TxtPWD.Text.IsNullOrEmpty())
     {
         MessageBox.Show(@"Error, favor de capturar el usuario y/o contraseña");
         TxtUser.Focus();
     }
     else if (ValidaUsuario(TxtUser.Text, TxtPWD.Text))
     {
         Hide();
     }
 }
Ejemplo n.º 4
0
 private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (TxtUser.Text == "" || TxtUser.Text == "User ID")
     {
         MessageBox.Show("Enter your User ID then Press Enter Key!", "MESSAGE BOX", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtUser.Focus();
     }
     else
     {
         PasswordHint();
     }
     panelHint.Visible = true;
 }
Ejemplo n.º 5
0
        private void MnuItemClearAll_OnClick(object sender, RoutedEventArgs e)
        {
            MainWindow.SqliteSource.DeleteAllUsers();
            // refresh list user
            ListUserInDataBase();

            // clear txt
            TxtUser.Text   = string.Empty;
            TxtPw.Password = string.Empty;
            TxtOwner.Text  = string.Empty;

            TxtUser.Focus();
            this.ShowMessageAsync(@"Sucess", @"deleted all");
        }
Ejemplo n.º 6
0
        private void BtnIngresar_Click(object sender, EventArgs e)
        {
            try
            {
                string  Ingreso = string.Format("Select * FROM analista WHERE usuariored='{0}' AND contraseña='{1}'", TxtUser.Text.Trim(), TxtPass.Text.Trim());
                DataSet dataSet = Utilidades.EjecutarBd(Ingreso);

                string cuenta = dataSet.Tables[0].Rows[0]["usuariored"].ToString().Trim();
                usuarioRed = cuenta;
                string password = dataSet.Tables[0].Rows[0]["contraseña"].ToString().Trim();
                contraseñaUsuario = password;
                string usercode = dataSet.Tables[0].Rows[0]["id"].ToString().Trim();
                idusuario = usercode;
                string nombre = dataSet.Tables[0].Rows[0]["nombre"].ToString().Trim();
                nombreUsuario = nombre;
                string apellido = dataSet.Tables[0].Rows[0]["apellido"].ToString().Trim();
                apellidoUsuario = apellido;

                if (cuenta == "admin" && TxtPass.Text == password)
                {
                    this.Hide();
                    administrador NuevaVentana = new administrador();
                    NuevaVentana.Show();
                }
                else if (TxtUser.Text == cuenta && TxtPass.Text == password)
                {
                    this.Hide();
                    ConfigUsuario configuracionUser = new ConfigUsuario();
                    configuracionUser.Show();
                }
            }
            catch
            {
                MessageBox.Show("No puedes ingresar, datos incorrectos");
                TxtUser.Text = "";
                TxtPass.Text = "";
                TxtUser.Focus();
            }
        }
Ejemplo n.º 7
0
 //VALIDACION DE ACCESSO
 private void BtnLogin_Click(object sender, EventArgs e)
 {
     if (TxtUser.Text != "Username")
     {
         if (TxtUser.Text != "Username" && TxtUser.TextLength > 2)
         {
             if (TxtPass.Text != "Password")
             {
                 var valirpass = TxtPass.Text;
                 var valiruser = TxtUser.Text;
                 if (valirpass == "admin" && valiruser == "lobo")
                 {
                     this.Hide();
                     Bienvenida welcome = new Bienvenida();
                     welcome.ShowDialog();
                     Menu abrir = new Menu();
                     abrir.Show();
                     abrir.FormClosed += Logout;
                 }
                 else
                 {
                     msgError("Incorrect username or password entered. \n   Please try again.");
                     TxtPass.Text = "Password";
                     TxtPass.UseSystemPasswordChar = false;
                     TxtUser.Focus();
                 }
             }
             else
             {
                 msgError("Please enter password.");
             }
         }
         else
         {
             msgError("Please enter username.");
         }
     }
 }
 private void BtnLogin_Click(object sender, EventArgs e)
 {
     if (TxtUser.Text.Equals("Usuario") || TxtPassword.Text.Equals("Contraseña") || TxtUser.Text.Equals("") || TxtPassword.Text.Equals(""))
     {
         MessageBox.Show("Ingrese los Datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         TxtUser.Focus();
     }
     else
     {
         var usr = userService.ValidateUser(TxtUser.Text, TxtPassword.Text);
         if (usr != null)
         {
             MessageBox.Show("Usuario Logeado!", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information);
             FrmPrincipal principal = new FrmPrincipal(usr);
             principal.Show();
             this.Hide();
         }
         else
         {
             MessageBox.Show("Ingrese los Datos correctos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             TxtUser.Focus();
         }
     }
 }
Ejemplo n.º 9
0
        private void CmdLogin_Click(object sender, EventArgs e)
        {
            if (TxtUser.Text != "" && TxtPW.Text != "")
            {
                con.Open();
                OleDbCommand cmd1 = new OleDbCommand("select * from UserDetails where UserID='" + TxtUser.Text.Trim() + "' ", con);
                cmd1.Connection = con;
                rdr             = cmd1.ExecuteReader();
                bool temp = false;
                while (rdr.Read())
                {
                    lblPW.Text     = rdr["Password1"].ToString();
                    lblUser.Text   = rdr["UserName"].ToString();
                    lblULevel.Text = rdr["UserLevel"].ToString();
                    lblPWHint.Text = rdr["PWHint"].ToString();
                    lblColor.Text  = rdr["BGColor"].ToString();
                    temp           = true;
                }
                con.Close();
                if (temp == false)
                {
                    MessageBox.Show("Please Enter the correct User ID, or Sign Up your details!", "MESSAGE BOX", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TxtUser.Text = "";
                    TxtPW.Text   = "";
                    TxtUser.Focus();
                    return;
                }
                else
                {
                    if (TxtPW.Text == lblPW.Text)
                    {
                        FrmLoad FLoad = new FrmLoad();

                        Control[] ctrlsID = FLoad.Controls.Find("lblUser", false);
                        Label     lbl1    = (Label)ctrlsID[0];
                        lbl1.Text = lblUser.Text;

                        Control[] ctrlsUL = FLoad.Controls.Find("lblULevel", false);
                        Label     lbl2    = (Label)ctrlsUL[0];
                        lbl2.Text = lblULevel.Text;

                        Control[] ctrlsIDD = FLoad.Controls.Find("lblID", false);
                        Label     lbl3     = (Label)ctrlsIDD[0];
                        lbl3.Text = TxtUser.Text;

                        Control[] ctrlsPW = FLoad.Controls.Find("lblPW", false);
                        Label     lbl4    = (Label)ctrlsPW[0];
                        lbl4.Text = TxtPW.Text;

                        Control[] ctrlsPWh = FLoad.Controls.Find("lblPWHint", false);
                        Label     lbl5     = (Label)ctrlsPWh[0];
                        lbl5.Text = lblPWHint.Text;

                        Control[] ctrlsClr = FLoad.Controls.Find("lblColor", false);
                        Label     lbl6     = (Label)ctrlsClr[0];
                        lbl6.Text = lblColor.Text;

                        this.Visible = false;
                        FLoad.Show();
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Please Enter the Valied Password!", "Invalied Data!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        TxtPW.Text = "";
                        TxtPW.Focus();
                        return;
                    }
                }
            }
            else
            {
                MessageBox.Show("Please Enter the Valied User ID and Password!", "Invalied Data!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtUser.Text = "";
                TxtPW.Text   = "";
                TxtUser.Focus();
                return;
            }
        }