Example #1
0
 //Metodo que carga el perfil del usuario
 private void cargarPefil()
 {
     try
     {
         //Carga Usuario
         Negocio.UsuarioN  un = new Negocio.UsuarioN();
         Entidades.Usuario u  = new Entidades.Usuario();
         u = un.cargarUsuario(this.rut);
         //Carga Comuna
         Entidades.Comuna c  = new Entidades.Comuna();
         Negocio.ComunaN  cn = new Negocio.ComunaN();
         if (u != null)
         {
             //Prepara los datos para mostralos por label
             lblRut.Content       = u.rutUsuario;
             lblNombres.Content   = u.nombres;
             lblApellidos.Content = u.apellidoPaterno + " " + u.apellidoMaterno;
             lblFecha.Content     = u.fechaNacimiento.ToString("dd DE MMMM DEL yyyy", CultureInfo.CreateSpecificCulture("es-MX")).ToLower();
             lblEmail.Content     = u.email;
             lblCel.Content       = "+" + u.cel;
             lblDireccion.Content = u.direccion;
             c = cn.cargarComuna(u.comunaId);
             lblComuna.Content = c.nombre;
             lblMsjP.Content   = "";
         }
         else
         {
             lblMsjP.Content = "Error, al cargar perfil";
         }
     }
     catch (Exception)
     {
         lblMsjP.Content = "Error, ComunĂ­quese a soporte";
     }
 }
Example #2
0
 private void btnGuarda_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Negocio.UsuarioN    un = new Negocio.UsuarioN();
         Entidades.Usuario   u  = new Entidades.Usuario();
         Negocio.Validadores v  = new Negocio.Validadores();
         u = un.cargarUsuario(this.rut);
         if (u != null)
         {
             if (txtEmail.Visibility == Visibility.Visible && txtCel.Visibility == Visibility.Visible)
             {
                 if (txtEmail.Text.Trim() != "" && txtCel.Text.Trim() != "")
                 {
                     if (v.validarEmail(txtEmail.Text) == true)
                     {
                         u.email = txtEmail.Text;
                         string  num  = lblCod.Content + txtCel.Text;
                         decimal num2 = Convert.ToDecimal(num.Replace("+", ""));
                         u.cel           = num2;
                         lblMsjP.Content = "";
                         un.modificarusuario(u);
                         //Limpia y refresca
                         txtEmail.Text          = "";
                         txtCel.Text            = "";
                         txtEmail.Visibility    = Visibility.Collapsed;
                         lblCod.Visibility      = Visibility.Collapsed;
                         txtCel.Visibility      = Visibility.Collapsed;
                         btnCancelar.Visibility = Visibility.Collapsed;
                         btnGuarda.Visibility   = Visibility.Collapsed;
                         lblEmail.Visibility    = Visibility.Visible;
                         lblCel.Visibility      = Visibility.Visible;
                         cargarPefil();
                     }
                     else
                     {
                         lblMsjP.Content = "Email no valido";
                     }
                 }
                 else
                 {
                     lblMsjP.Content = "No puede tener campos vacios el momento de cambiar";
                 }
             }
             else if (txtEmail.Visibility == Visibility.Visible)
             {
                 if (txtEmail.Text.Trim() != "")
                 {
                     if (v.validarEmail(txtEmail.Text) == true)
                     {
                         u.email         = txtEmail.Text;
                         lblMsjP.Content = "";
                         un.modificarusuario(u);
                         //Limpia y refresca
                         txtEmail.Text          = "";
                         txtCel.Text            = "";
                         txtEmail.Visibility    = Visibility.Collapsed;
                         lblCod.Visibility      = Visibility.Collapsed;
                         txtCel.Visibility      = Visibility.Collapsed;
                         btnCancelar.Visibility = Visibility.Collapsed;
                         btnGuarda.Visibility   = Visibility.Collapsed;
                         lblEmail.Visibility    = Visibility.Visible;
                         lblCel.Visibility      = Visibility.Visible;
                         cargarPefil();
                     }
                     else
                     {
                         lblMsjP.Content = "Email no valido";
                     }
                 }
                 else
                 {
                     lblMsjP.Content = "No puede tener campos vacios el momento de cambiar";
                 }
             }
             else
             {
                 if (txtCel.Text.Trim() != "")
                 {
                     string  num  = lblCod.Content + txtCel.Text;
                     decimal num2 = Convert.ToDecimal(num.Replace("+", ""));
                     u.cel           = num2;
                     lblMsjP.Content = "";
                     un.modificarusuario(u);
                     //Limpia y refresca
                     txtEmail.Text          = "";
                     txtCel.Text            = "";
                     txtEmail.Visibility    = Visibility.Collapsed;
                     lblCod.Visibility      = Visibility.Collapsed;
                     txtCel.Visibility      = Visibility.Collapsed;
                     btnCancelar.Visibility = Visibility.Collapsed;
                     btnGuarda.Visibility   = Visibility.Collapsed;
                     lblEmail.Visibility    = Visibility.Visible;
                     lblCel.Visibility      = Visibility.Visible;
                     cargarPefil();
                 }
                 else
                 {
                     lblMsjP.Content = "No puede tener campos vacios el momento de cambiar";
                 }
             }
         }
         else
         {
             lblMsjP.Content = "Error al guardar, Contacte soporte";
         }
     }
     catch (Exception)
     {
         lblMsjP.Content = "Error desconocido, Contacte a soporte";
     }
 }