Exemple #1
0
        public ActionResult Agregar(Usuario entidad)
        {
            if (!ModelState.IsValid)
            {
                return(View("Error", new Error()
                {
                    Message = "Error in data"
                }));
            }

            if (this.IsAdminUserLoggedIn() == false)
            {
                return(View("AccesoDenegado"));
            }

            var Repo = new UsuarioBLL();

            Repo.Agregar(entidad);
            return(View("Usuarios"));
        }
        private async void btnagregarcli_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                UsuarioBLL useCli = new UsuarioBLL();
                useCli.nombreUsuario = txtusercl.Text;
                string pass   = txtContra.Password;
                var    rolCli = Rol.cli;
                useCli.Agregar(useCli.nombreUsuario, pass, rolCli);
                Console.WriteLine("Usuario agregado");
                int id = useCli.getIdUsuario(useCli.nombreUsuario);

                int number;
                cli.Rut       = txtrutcl.Text;
                cli.Nombre    = txtnombrescl.Text;
                cli.apellidos = txtapellidoscl.Text;
                cli.direccion = txtdirecl.Text;
                cli.correo    = txtcorreocl.Text;

                if (int.TryParse(txttelefonocl.Text, out number))
                {
                    cli.telefono = number;
                }
                else
                {
                    throw new Exception("numero no corresponde ");
                }
                cli.idusuario = id;
                cli.Agregar();
                CargarDatos();
                await this.ShowMessageAsync("Informacion", "Agregado");
            }
            catch (Exception ex)
            {
                await this.ShowMessageAsync("INFORMACION", "Ha ocurrido un error");

                Console.WriteLine("error :" + ex.Message);
            }

            Limpiar();
        }
        private async void btnagregaremp_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                UsuarioBLL useEmp = new UsuarioBLL();
                useEmp.nombreUsuario = txtuserem.Text;
                string pass   = txtPass.Password;
                var    rolEmp = Rol.emp;
                useEmp.Agregar(useEmp.nombreUsuario, pass, rolEmp);
                Console.WriteLine("Usuario agregado");
                int id = useEmp.getIdUsuario(useEmp.nombreUsuario);

                int number;
                empleado.RUT_EMPL       = txtrutem.Text;
                empleado.NOMBRE_EMPL    = txtnombem.Text;
                empleado.APELLIDO_EMPL  = txtapelem.Text;
                empleado.DIRECCION_EMPL = txtdirem.Text;
                empleado.CORREO_EMP     = txtcorem.Text;
                empleado.CARGO_EMPL     = (Cargos)cmbcargoem.SelectedItem;

                if (int.TryParse(txtelefem.Text, out number))
                {
                    empleado.TELEFONO_EMPL = number;
                }
                else
                {
                    throw new Exception("numero no corresponde ");
                }
                empleado.ID_USUARIO = id;
                empleado.Agregar();
                await this.ShowMessageAsync("informacion", "Agregado");
            }
            catch (Exception ex)
            {
                await this.ShowMessageAsync("INFORMACION", "Ha ocurrido un error");

                Console.WriteLine("error :" + ex.Message);
            }
        }
Exemple #4
0
 public ActionResult Create(USUARIO usuario)
 {
     UsuarioBLL.Agregar(usuario);
     return(View("~/Views/Usuario/Usuario.cshtml", usuario));
 }