//private readonly UsurioAppServices _usuarioAppServices;
            // GET: /<controller>/

            public UsuarioController(ProyectoDataContext context /*, UsurioAppServices usuarioAppServices*/)
            {
                _baseDatos = context;
                //_usuarioAppServices = usuarioAppServices;

                if (_baseDatos.AplicacionTrabajos.Count() == 1)
                {
                    _baseDatos.AplicacionTrabajos.Add(new AplicacionTrabajo
                    {
                        IdUsuario            = 1,
                        IdPublicacionTrabajo = 1
                    });
                    _baseDatos.SaveChanges();
                }
            }
Пример #2
0
        // GET: /<controller>/

        public UsuarioController(ProyectoDataContext context, UsurioAppServices usuarioAppServices)
        {
            _baseDatos          = context;
            _usuarioAppServices = usuarioAppServices;

            if (_baseDatos.Usuarios.Count() == 1)
            {
                _baseDatos.Usuarios.Add(new Usuario {
                    PrimerNombre = "Jordan", PrimerApellido = "Ferrufino",
                    Cuidad       = "San Pedro Sula", Direccion = "Colonia Las Universidades", Telefono = 87741883,
                    Correo       = "*****@*****.**", Contrasenia = "Contrasenia"
                });
                _baseDatos.SaveChanges();
            }
        }
            //private readonly UsurioAppServices _usuarioAppServices;
            // GET: /<controller>/

            public UsuarioController(ProyectoDataContext context /*, UsurioAppServices usuarioAppServices*/)
            {
                _baseDatos = context;
                //_usuarioAppServices = usuarioAppServices;

                if (_baseDatos.PublicacionTrabajos.Count() == 1)
                {
                    _baseDatos.PublicacionTrabajos.Add(new PublicacionTrabajo
                    {
                        PuestoTrabajo = "Ingeniero en Redes",
                        Descripcion   = "Se Busca un ingeniero en redes que conosca sobre wan",
                        IdPropuesta   = 1
                    });
                    _baseDatos.SaveChanges();
                }
            }
Пример #4
0
        public void Execute(object parameter)
        {
            if (parameter.Equals("EmailProveedor"))
            {
                EmailProveedorView emailProveedor = new EmailProveedorView();
                emailProveedor.Show();
            }
            else if (parameter.Equals("TelefonoProveedor"))
            {
                TelefonoProveedorView telefonoProveedor = new TelefonoProveedorView();
                telefonoProveedor.Show();
            }
            else if (parameter.Equals("Add"))
            {
                this.IsReadOnlyNit               = false;
                this.IsReadOnlyRazonSocial       = false;
                this.IsReadOnlyDireccion         = false;
                this.IsReadOnlyPaginaWeb         = false;
                this.IsReadOnlyContactoPrincipal = false;
                this.accion            = ACCION.NUEVO;
                this.IsEnabledAdd      = false;
                this.IsEnabledCancel   = true;
                this.IsEnabledDelete   = false;
                this.IsEnabledSave     = true;
                this.IsEnabledUpdate   = false;
                this.nit               = "";
                this.razonSocial       = "";
                this.direccion         = "";
                this.paginaWeb         = "";
                this.contactoPrincipal = "";
            }
            else if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    Proveedores nuevo = new Proveedores();
                    nuevo.nit               = this.nit;
                    nuevo.razonSocial       = this.razonSocial;
                    nuevo.direccion         = this.direccion;
                    nuevo.paginaWeb         = this.paginaWeb;
                    nuevo.contactoPrincipal = this.contactoPrincipal;
                    db.Proveedores.Add(nuevo);
                    db.SaveChanges();
                    this.Proveedores.Add(nuevo);
                    MessageBox.Show("Registro almacenado correctamente");
                    this.IsReadOnlyNit               = true;
                    this.IsReadOnlyRazonSocial       = true;
                    this.IsReadOnlyDireccion         = true;
                    this.IsReadOnlyPaginaWeb         = true;
                    this.IsReadOnlyContactoPrincipal = true;
                    this.IsEnabledAdd      = true;
                    this.IsEnabledCancel   = true;
                    this.IsEnabledDelete   = true;
                    this.IsEnabledSave     = true;
                    this.IsEnabledUpdate   = true;
                    this.nit               = "";
                    this.razonSocial       = "";
                    this.direccion         = "";
                    this.paginaWeb         = "";
                    this.contactoPrincipal = "";
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion          = this.Proveedores.IndexOf(this.SelectProveedores);
                        var updateProveedores = this.db.Proveedores.Find(this.SelectProveedores.codigoProveedor);
                        updateProveedores.nit                  = this.nit;
                        updateProveedores.razonSocial          = this.razonSocial;
                        updateProveedores.direccion            = this.direccion;
                        updateProveedores.paginaWeb            = this.paginaWeb;
                        updateProveedores.contactoPrincipal    = this.contactoPrincipal;
                        this.db.Entry(updateProveedores).State = System.Data.Entity.EntityState.Modified;
                        this.db.SaveChanges();
                        this.Proveedores.RemoveAt(posicion);
                        this.Proveedores.Insert(posicion, updateProveedores);
                        MessageBox.Show("Registro actualizado");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SelectProveedores != null)
                {
                    var respuesta = MessageBox.Show("¿Está seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.Proveedores.Remove(this.SelectProveedores);
                            db.SaveChanges();
                            this.Proveedores.Remove(this.SelectProveedores);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else if (parameter.Equals("Update"))
            {
                this.accion                      = ACCION.ACTUALIZAR;
                this.IsReadOnlyNit               = false;
                this.IsReadOnlyRazonSocial       = false;
                this.IsReadOnlyDireccion         = false;
                this.IsReadOnlyPaginaWeb         = false;
                this.IsReadOnlyContactoPrincipal = false;
            }
            else if (parameter.Equals("Cancel"))
            {
                this.IsReadOnlyNit               = true;
                this.IsReadOnlyRazonSocial       = true;
                this.IsReadOnlyDireccion         = true;
                this.IsReadOnlyPaginaWeb         = true;
                this.IsReadOnlyContactoPrincipal = true;
                this.IsEnabledAdd      = true;
                this.IsEnabledCancel   = true;
                this.IsEnabledDelete   = true;
                this.IsEnabledSave     = true;
                this.IsEnabledUpdate   = true;
                this.nit               = "";
                this.razonSocial       = "";
                this.direccion         = "";
                this.paginaWeb         = "";
                this.contactoPrincipal = "";
            }
        }
        public void Execute(object parameter)
        {
            if (parameter.Equals("Add"))
            {
                this.IsReadOnlyEmail = false;
                this.IsReadOnlyNit   = false;
                this.accion          = ACCION.NUEVO;
                this.IsEnabledAdd    = false;
                this.IsEnabledCancel = true;
                this.IsEnabledDelete = false;
                this.IsEnabledSave   = true;
                this.IsEnabledUpdate = false;
                this.email           = "";
                this.nit             = "";
            }
            else if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    EmailCliente nuevo = new EmailCliente();
                    nuevo.email = this.email;
                    nuevo.nit   = this.nit;
                    db.EmailClientes.Add(nuevo);
                    db.SaveChanges();
                    this.EmailClientes.Add(nuevo);
                    MessageBox.Show("Registro almacenado correctamente");
                    this.IsReadOnlyEmail = true;
                    this.IsReadOnlyNit   = true;
                    this.IsEnabledAdd    = true;
                    this.IsEnabledCancel = true;
                    this.IsEnabledDelete = true;
                    this.IsEnabledSave   = true;
                    this.IsEnabledUpdate = true;
                    this.email           = "";
                    this.nit             = "";
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion    = this.EmailClientes.IndexOf(this.SelectEmailCliente);
                        var updateEmail = this.db.EmailClientes.Find(this.SelectEmailCliente.codigoEmail);
                        updateEmail.email = this.email;
                        updateEmail.nit   = this.nit;
                        this.db.Entry(updateEmail).State = System.Data.Entity.EntityState.Modified;
                        this.db.SaveChanges();
                        this.EmailClientes.RemoveAt(posicion);
                        this.EmailClientes.Insert(posicion, updateEmail);
                        MessageBox.Show("Registro actualizado");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SelectEmailCliente != null)
                {
                    var respuesta = MessageBox.Show("¿Está seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.EmailClientes.Remove(this.SelectEmailCliente);
                            db.SaveChanges();
                            this.EmailClientes.Remove(this.SelectEmailCliente);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else if (parameter.Equals("Update"))
            {
                this.accion          = ACCION.ACTUALIZAR;
                this.IsReadOnlyNit   = false;
                this.IsReadOnlyEmail = false;
            }
            else if (parameter.Equals("Cancel"))
            {
                this.IsReadOnlyNit   = true;
                this.IsReadOnlyEmail = true;
                this.IsEnabledAdd    = true;
                this.IsEnabledCancel = true;
                this.IsEnabledDelete = true;
                this.IsEnabledSave   = true;
                this.IsEnabledUpdate = true;
                this.nit             = "";
                this.email           = "";
            }
        }
Пример #6
0
        public void Execute(object parameter)
        {
            if (parameter.Equals("Add"))
            {
                this.IsReadOnlyCodigoCategoria = false;
                this.IsReadOnlyTipoEmpaque     = false;
                this.IsReadOnlyDescripcion     = false;
                this.IsReadOnlyExistencia      = false;
                this.IsReadOnlyImagen          = false;
                this.IsReadOnlyPrecioPorDocena = false;
                this.IsReadOnlyPrecioPorMayor  = false;
                this.IsReadOnlyPrecioUnitario  = false;
                this.accion          = ACCION.NUEVO;
                this.IsEnabledAdd    = false;
                this.IsEnabledCancel = true;
                this.IsEnabledDelete = false;
                this.IsEnabledSave   = true;
                this.IsEnabledUpdate = false;
                this.descripcion     = "";
                this.precioUnitario  = 0;
                this.precioPorMayor  = 0;
                this.precioPorDocena = 0;
                this.existencia      = 0;
                this.imagen          = "";
            }
            else if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    Productos nuevo = new Productos();
                    nuevo.codigoCategoria = this.codigoCategoria;
                    nuevo.codigoEmpaque   = this.codigoEmpaque;
                    nuevo.descripcion     = this.descripcion;
                    nuevo.precioUnitario  = this.precioUnitario;
                    nuevo.precioPorMayor  = this.precioPorMayor;
                    nuevo.precioPorDocena = this.precioPorDocena;
                    nuevo.existencia      = this.existencia;
                    nuevo.imagen          = this.imagen;
                    db.Productos.Add(nuevo);
                    db.SaveChanges();
                    this.Productos.Add(nuevo);
                    MessageBox.Show("Registro almacenado correctamente", "Exito", MessageBoxButton.OK, MessageBoxImage.None);
                    this.IsReadOnlyCodigoCategoria = true;
                    this.IsReadOnlyTipoEmpaque     = true;
                    this.IsReadOnlyPrecioUnitario  = true;
                    this.IsReadOnlyPrecioPorMayor  = true;
                    this.IsReadOnlyPrecioPorDocena = true;
                    this.IsReadOnlyDescripcion     = true;
                    this.IsReadOnlyExistencia      = true;
                    this.IsReadOnlyImagen          = true;
                    this.descripcion     = "";
                    this.imagen          = "";
                    this.precioPorDocena = 0;
                    this.precioPorMayor  = 0;
                    this.precioUnitario  = 0;
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion        = this.Productos.IndexOf(this.SelectProductos);
                        var updateProductos = this.db.Productos.Find(this.SelectProductos.codigoProducto);
                        updateProductos.codigoCategoria      = this.codigoCategoria;
                        updateProductos.codigoEmpaque        = this.codigoEmpaque;
                        updateProductos.descripcion          = this.descripcion;
                        updateProductos.precioPorDocena      = this.precioPorDocena;
                        updateProductos.precioPorMayor       = this.precioPorMayor;
                        updateProductos.precioUnitario       = this.precioUnitario;
                        updateProductos.existencia           = this.existencia;
                        updateProductos.imagen               = this.imagen;
                        this.db.Entry(updateProductos).State = System.Data.Entity.EntityState.Modified;
                        this.db.SaveChanges();
                        this.Productos.RemoveAt(posicion);
                        this.Productos.Insert(posicion, updateProductos);
                        MessageBox.Show("Registro actualizado correctamente");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SelectProductos != null)
                {
                    var respuesta = MessageBox.Show("¿Está seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.Productos.Remove(this.SelectProductos);
                            db.SaveChanges();
                            this.Productos.Remove(this.SelectProductos);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                }
            }
            else if (parameter.Equals("Update"))
            {
                this.accion = ACCION.ACTUALIZAR;
                this.IsReadOnlyCodigoCategoria = false;
                this.IsReadOnlyDescripcion     = false;
                this.IsReadOnlyExistencia      = false;
                this.IsReadOnlyImagen          = false;
                this.IsReadOnlyPrecioPorDocena = false;
                this.IsReadOnlyPrecioPorMayor  = false;
                this.IsReadOnlyPrecioUnitario  = false;
                this.IsReadOnlyTipoEmpaque     = false;
            }
            else if (parameter.Equals("Cancel"))
            {
                this.IsReadOnlyCodigoCategoria = true;
                this.IsReadOnlyDescripcion     = true;
                this.IsReadOnlyExistencia      = true;
                this.IsReadOnlyImagen          = true;
                this.IsReadOnlyPrecioPorDocena = true;
                this.IsReadOnlyPrecioPorMayor  = true;
                this.IsReadOnlyPrecioUnitario  = true;
                this.IsReadOnlyTipoEmpaque     = true;
            }
        }
Пример #7
0
        public void Execute(object parameter)
        {
            if (parameter.Equals("EmailClientes"))
            {
                EmailClientesView email = new EmailClientesView();
                email.Show();
            }
            else if (parameter.Equals("TelefonoClientes"))
            {
                TelefonoClientesView telefono = new TelefonoClientesView();
                telefono.Show();
            }
            else if (parameter.Equals("Add"))
            {
                this.IsReadOnlyNit       = false;
                this.IsReadOnlyDPI       = false;
                this.IsReadOnlyNombre    = false;
                this.IsReadOnlyDireccion = false;
                this.accion          = ACCION.NUEVO;
                this.IsEnabledAdd    = false;
                this.IsEnabledCancel = true;
                this.IsEnabledDelete = false;
                this.IsEnabledSave   = true;
                this.IsEnabledUpdate = false;
                this.nit             = "";
                this.dpi             = "";
                this.nombre          = "";
                this.direccion       = "";
            }
            else if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    Clientes nuevo = new Clientes();
                    nuevo.nit       = this.nit;
                    nuevo.DPI       = this.dpi;
                    nuevo.nombre    = this.nombre;
                    nuevo.direccion = this.direccion;
                    db.Clientes.Add(nuevo);
                    db.SaveChanges();
                    this.Clientes.Add(nuevo);
                    MessageBox.Show("Registro almacenado correctamente");
                    this.IsReadOnlyNit       = true;
                    this.IsReadOnlyDPI       = true;
                    this.IsReadOnlyNombre    = true;
                    this.IsReadOnlyDireccion = true;
                    this.IsEnabledAdd        = true;
                    this.IsEnabledCancel     = true;
                    this.IsEnabledDelete     = true;
                    this.IsEnabledSave       = true;
                    this.IsEnabledUpdate     = true;
                    this.nit       = "";
                    this.dpi       = "";
                    this.nombre    = "";
                    this.direccion = "";
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        if (SelectCliente != null)
                        {
                            int posicion       = this.Clientes.IndexOf(this.SelectCliente);
                            var updateClientes = this.db.Clientes.Find(this.SelectCliente.nit);
                            updateClientes.nit                  = this.nit;
                            updateClientes.DPI                  = this.dpi;
                            updateClientes.nombre               = this.nombre;
                            updateClientes.direccion            = this.direccion;
                            this.db.Entry(updateClientes).State = System.Data.Entity.EntityState.Modified;
                            this.db.SaveChanges();
                            this.Clientes.RemoveAt(posicion);
                            this.Clientes.Insert(posicion, updateClientes);
                            MessageBox.Show("Registro actualizado");
                        }
                        else
                        {
                            MessageBox.Show("Debe seleccionar un dato para poder actualizar");
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SelectCliente != null)
                {
                    var respuesta = MessageBox.Show("¿Está seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.Clientes.Remove(this.SelectCliente);
                            db.SaveChanges();
                            this.Clientes.Remove(this.SelectCliente);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else if (parameter.Equals("Update"))
            {
                this.accion              = ACCION.ACTUALIZAR;
                this.IsReadOnlyNit       = false;
                this.IsReadOnlyDPI       = false;
                this.IsReadOnlyNombre    = false;
                this.IsReadOnlyDireccion = false;
            }
            else if (parameter.Equals("Cancel"))
            {
                this.IsReadOnlyNit       = true;
                this.IsReadOnlyDPI       = true;
                this.IsReadOnlyNombre    = true;
                this.IsReadOnlyDireccion = true;
                this.IsEnabledAdd        = true;
                this.IsEnabledCancel     = true;
                this.IsEnabledDelete     = true;
                this.IsEnabledSave       = true;
                this.IsEnabledUpdate     = true;
                this.nit       = "";
                this.dpi       = "";
                this.nombre    = "";
                this.direccion = "";
            }
        }