public async Task <IActionResult> Edit(int id, [Bind("CargoId,NombreCargo")] CargoEmpleado cargoEmpleado)
        {
            if (id != cargoEmpleado.CargoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cargoEmpleado);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CargoEmpleadoExists(cargoEmpleado.CargoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cargoEmpleado));
        }
Exemple #2
0
 public async Task eliminarCargoEmpleado(CargoEmpleado cargoEmpleado)
 {
     if (cargoEmpleado != null)
     {
         _context.Remove(cargoEmpleado);
         await _context.SaveChangesAsync();
     }
 }
Exemple #3
0
 private void btnModificar_Click(object sender, EventArgs e)
 {
     try
     {
         Barrio barrio = new Barrio();
         barrio.ID          = Convert.ToInt32(cbxBarrio.SelectedValue);
         barrio.Descripcion = cbxBarrio.Text.ToString();
         Localidad localidad = new Localidad();
         localidad.ID          = Convert.ToInt32(cbxLocalidad.SelectedValue);
         localidad.Descripcion = cbxLocalidad.Text.ToString();
         Provincia provincia = new Provincia();
         provincia.ID          = Convert.ToInt32(cbxProvincia.SelectedValue);
         provincia.Descripcion = cbxProvincia.Text.ToString();
         TipoDireccion tipoDireccion = new TipoDireccion();
         tipoDireccion.ID          = Convert.ToInt32(cbxTDireccion.SelectedValue);
         tipoDireccion.Descripcion = cbxTDireccion.Text.ToString();
         Direccion direccion = new Direccion();
         direccion.Calle         = txtCalle.Text;
         direccion.Numero        = Convert.ToInt32(txtAltura.Text);
         direccion.Barrio        = barrio;
         direccion.Localidad     = localidad;
         direccion.Provincia     = provincia;
         direccion.TipoDireccion = tipoDireccion;
         CargoEmpleado cargo = new CargoEmpleado();
         cargo.ID          = Convert.ToInt32(cbxCargo.SelectedValue);
         cargo.Descripcion = cbxCargo.Text.ToString();
         TipoTelefono tipoTelefono = new TipoTelefono();
         tipoTelefono.ID          = Convert.ToInt32(cbxTTelefono.SelectedValue);
         tipoTelefono.Descripcion = cbxTTelefono.Text.ToString();
         Telefono telefono = new Telefono();
         telefono.Numero       = Convert.ToInt32(txtNumero.Text);
         telefono.TipoTelefono = tipoTelefono;
         Genero genero = new Genero();
         genero.ID          = Convert.ToInt32(cbxGenero.SelectedValue);
         genero.Descripcion = cbxGenero.Text.ToString();
         Oficina oficina = new Oficina();
         oficina.ID          = Convert.ToInt32(cbxOficina.SelectedValue);
         oficina.Descripcion = cbxOficina.Text.ToString();
         Personal nuevo = new Personal();
         nuevo.Nombre    = txtNombre.Text;
         nuevo.Apellido  = txtApellido.Text;
         nuevo.Email     = txtEmail.Text;
         nuevo.Genero    = genero;
         nuevo.Oficina   = oficina;
         nuevo.Cargo     = cargo;
         nuevo.Direccion = direccion;
         nuevo.Telefono  = telefono;
         nuevo.Superior  = Convert.ToInt32(txtLegajoSupervisor.Text);
         nuevo.Legajo    = legajo;
         nuevo.modificarPersonal();
         MessageBox.Show("Modificado Con Exito");
     }
     catch (Exception)
     {
         MessageBox.Show("Complete todos los campos con datos validos");
     }
 }
Exemple #4
0
        public async Task <IActionResult> CrearEditarCargo([Bind("IdCargo,Cargo")] CargoEmpleado cargoEmpleado)
        {
            if (ModelState.IsValid)
            {
                await _context.guardarCargoEmpleado(cargoEmpleado);

                return(RedirectToAction(nameof(Index)));
            }
            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Create([Bind("CargoId,NombreCargo")] CargoEmpleado cargoEmpleado)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cargoEmpleado);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cargoEmpleado));
        }
        public ActionResult Edit(CargoEmpleadoViewModels model)
        {
            if (ModelState.IsValid)
            {
                CargoEmpleado             = dbCtx.CargoEmpleado.FirstOrDefault(a => a.Id == model.Id);
                CargoEmpleado.NombreCargo = model.NombreCargo;
                CargoEmpleado.Sueldo      = model.Sueldo;
                dbCtx.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Exemple #7
0
 public async Task <IActionResult> CrearEditarCargo(int id = 0)
 {
     if (id == 0)
     {
         return(View(new CargoEmpleado()));
     }
     else
     {
         cargoEmpleado = await _context.obtenerCargoEmpleadoPorID(id);
     }
     return(View(cargoEmpleado));
 }
        public ActionResult Edit(int id)
        {
            ViewBag.Title = "Editar Cargo";

            CargoEmpleadoViewModels cargo = new CargoEmpleadoViewModels();

            CargoEmpleado     = dbCtx.CargoEmpleado.FirstOrDefault(a => a.Id == id);
            cargo.Id          = CargoEmpleado.Id;
            cargo.NombreCargo = CargoEmpleado.NombreCargo;
            cargo.Sueldo      = CargoEmpleado.Sueldo;

            return(View(cargo));
        }
Exemple #9
0
        public async Task guardarCargoEmpleado(CargoEmpleado cargoEmpleado)
        {
            if (cargoEmpleado.IdCargo == 0)
            {
                _context.Add(cargoEmpleado);
            }
            else
            {
                _context.Update(cargoEmpleado);
            }

            await _context.SaveChangesAsync();
        }
Exemple #10
0
        public string traerCargo(int idCargo)
        {
            CargoEmpleado cargo =
                (from miCargo in _context.CargoEmpleados
                 where (miCargo.IdCargo == idCargo)
                 select miCargo).FirstOrDefault();

            if (cargo == null)
            {
                return("Por Definir");
            }
            else
            {
                return(cargo.Cargo);
            }
        }
Exemple #11
0
        public async Task <IActionResult> CreareditarCargo([Bind("IdCargo,Cargo")] CargoEmpleado cargoEmpleado)
        {
            if (ModelState.IsValid)
            {
                if (cargoEmpleado.IdCargo == 0)
                {
                    _context.Add(cargoEmpleado);
                }
                else
                {
                    _context.Update(cargoEmpleado);
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cargoEmpleado));
        }
 public CargoEmpleadoController()
 {
     dbCtx         = new ApplicationDbContext();
     CargoEmpleado = new CargoEmpleado();
 }
Exemple #13
0
 private void btnRegistrar_Click(object sender, EventArgs e)
 {
     try
     {
         Barrio barrio = new Barrio();
         barrio.ID          = Convert.ToInt32(cbxBarrio.SelectedValue);
         barrio.Descripcion = cbxBarrio.Text.ToString();
         Localidad localidad = new Localidad();
         localidad.ID          = Convert.ToInt32(cbxLocalidad.SelectedValue);
         localidad.Descripcion = cbxLocalidad.Text.ToString();
         Provincia provincia = new Provincia();
         provincia.ID          = Convert.ToInt32(cbxProvincia.SelectedValue);
         provincia.Descripcion = cbxProvincia.Text.ToString();
         TipoDireccion tipoDireccion = new TipoDireccion();
         tipoDireccion.ID          = Convert.ToInt32(cbxTDireccion.SelectedValue);
         tipoDireccion.Descripcion = cbxTDireccion.Text.ToString();
         Direccion direccion = new Direccion();
         direccion.Calle         = txtCalle.Text;
         direccion.Numero        = Convert.ToInt32(txtAltura.Text);
         direccion.Barrio        = barrio;
         direccion.Localidad     = localidad;
         direccion.Provincia     = provincia;
         direccion.TipoDireccion = tipoDireccion;
         CargoEmpleado cargo = new CargoEmpleado();
         cargo.ID          = Convert.ToInt32(cbxCargo.SelectedValue);
         cargo.Descripcion = cbxCargo.Text.ToString();
         TipoTelefono tipoTelefono = new TipoTelefono();
         tipoTelefono.ID          = Convert.ToInt32(cbxTTelefono.SelectedValue);
         tipoTelefono.Descripcion = cbxTTelefono.Text.ToString();
         Telefono telefono = new Telefono();
         telefono.Numero       = Convert.ToInt32(txtNumero.Text);
         telefono.Empresa      = txtEmpresa.Text.ToString();
         telefono.TipoTelefono = tipoTelefono;
         Fecha fNac = new Fecha();
         fNac.Dia = Convert.ToInt32(txtNacDia.Text);
         fNac.Mes = Convert.ToInt32(txtNacMes.Text);
         fNac.Año = Convert.ToInt32(txtNacAño.Text);
         Fecha fIng = new Fecha();
         fIng.Dia = Convert.ToInt32(txtIngDia.Text);
         fIng.Mes = Convert.ToInt32(txtIngMes.Text);
         fIng.Año = Convert.ToInt32(txtIngAño.Text);
         Genero genero = new Genero();
         genero.ID          = Convert.ToInt32(cbxGenero.SelectedValue);
         genero.Descripcion = cbxGenero.Text.ToString();
         Oficina oficina = new Oficina();
         oficina.ID          = Convert.ToInt32(cbxOficina.SelectedValue);
         oficina.Descripcion = cbxOficina.Text.ToString();
         Personal nuevo = new Personal();
         nuevo.Nombre          = txtNombre.Text;
         nuevo.Apellido        = txtApellido.Text;
         nuevo.Email           = txtEmail.Text;
         nuevo.Genero          = genero;
         nuevo.Oficina         = oficina;
         nuevo.Cargo           = cargo;
         nuevo.Direccion       = direccion;
         nuevo.Telefono        = telefono;
         nuevo.FechaNacimiento = fNac;
         nuevo.FechaIngreso    = fIng;
         nuevo.Superior        = Convert.ToInt32(txtLegajoSupervisor.Text);
         nuevo.Contraseña      = txtContraseña.Text.ToString();
         nuevo.altaPersonal();
         MessageBox.Show("Agregado Con Exito");
     }
     catch (Exception)
     {
         MessageBox.Show("Complete todos los campos con datos validos");
     }
 }