Example #1
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(txtuser.Text) && !string.IsNullOrWhiteSpace(txtpass.Password))
                {
                    string password = HashClass.EncodePassword(string.Concat(txtuser.Text.ToLower(), txtpass.Password));

                    var obj = new tbUserEmpaque
                    {
                        nombreUsuario = txtuser.Text.ToLower(),
                        contraseƱa    = password
                    };

                    var resp = UsuarioNeg.GetUsuario(obj);

                    switch (resp.rol.Trim())
                    {
                    case "error":
                        MessageBox.Show(resp.nombreUsuario, "Ha ocurrido un error intente nuevamente");

                        break;

                    case "null":
                        MessageBox.Show("Icorrecto", "Las credenciales proporcionadas no son validas");
                        break;

                    case "Tickets":
                        App.Current.Properties["User"] = resp;
                        var form2 = new PricipalTickets();
                        this.Close();
                        form2.Show();
                        // stackPanelContenido.Children.Add(new TicktesScan());
                        break;

                    default:
                        App.Current.Properties["User"] = resp;
                        var form = new Principal();
                        this.Close();
                        form.Show();

                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }