Beispiel #1
0
        public async Task <IActionResult> Crear(int?IdPer)
        {
            if (IdPer == null)
            {
                return(NotFound());
            }
            IT1 it0p     = new IT1();
            var personal = await _context.Personals
                           .SingleOrDefaultAsync(m => m.Id == IdPer);

            ViewBag.GpoCiaG = personal.Gbukrs;
            ViewBag.Nombre  = personal.Cname;
            ViewBag.Bukrs   = personal.Bukrs;
            ViewBag.NoPer   = personal.Pernr;
            var items = new List <SelectListItem>();

            items = _bukrs.DaClasedeMedida(personal.Gbukrs, personal.Bukrs);
            ViewBag.ListaClases = items.ToList();
            var esta1 = new List <Estatus_stat2>();

            esta1            = _bukrs.GetEstatus1(personal.Bukrs, personal.Gbukrs);
            ViewBag.ListaEst = esta1.ToList();
            var divis = new List <Divis>();

            divis = _bukrs.GetDivisions(personal.Bukrs, personal.Gbukrs);
            ViewBag.ListaDivis   = divis.ToList();
            ViewBag.ListaNomina  = _bukrs.GetNomina(personal.Bukrs, personal.Gbukrs).ToList();
            ViewBag.CentroCostos = _bukrs.GetCentrodeCostos(personal.Bukrs, personal.Gbukrs).ToList();
            var tipoper = new List <SelectListItem>();

            tipoper          = _bukrs.GetTipoPersonal(personal.Bukrs, personal.Gbukrs);
            ViewBag.TipoPers = tipoper.ToList();
            var lastIt0 = await _context.IT1s.LastOrDefaultAsync(m => m.PersonalId == IdPer);

            if (lastIt0 == null)
            {
                it0p.BegDa = DateTime.Now;
            }
            else
            {
                it0p.BegDa = lastIt0.BegDa.AddDays(1);
            }
            it0p.Gbukrs = personal.Gbukrs;
            it0p.Bukrs  = personal.Bukrs;
            string   dateInput  = "Jan 1, 9999";
            DateTime parsedDate = DateTime.Parse(dateInput);

            it0p.EndDa = parsedDate;
            var userNa = User.FindFirstValue(ClaimTypes.Name);

            it0p.Uname      = userNa;
            it0p.Pernr      = personal.Pernr;
            it0p.Aedtm      = DateTime.Now;
            it0p.PersonalId = personal.Id;

            return(View(it0p));
        }
        public JsonResult GetTipoPer(string bukrs)
        {
            //traer datos
            ViewBag.GpoCiaG = HttpContext.Session.GetString(SessionGpoCia);
            string x = ViewBag.GpoCiaG;
            //inserta datos

            var modifiedData = new List <SelectListItem>();

            modifiedData = _bukrs.GetTipoPersonal(bukrs, x);
            return(Json(modifiedData));
        }
Beispiel #3
0
        public async Task <IActionResult> Crear([Bind("Id,Gbukrs,Bukrs,Pernr,Subty,BegDa,EndDa,Seqnr,Aedtm,Uname,Dar01,Dat01,PersonalId")] IT41 iT41)
        {
            if (ModelState.IsValid)
            {
                // cambiar el anterior
                var lastIt0 = await _context.IT41s.LastOrDefaultAsync(m => m.PersonalId == iT41.PersonalId && m.Dar01 == iT41.Dar01);

                if (lastIt0 == null)
                {
                }
                else
                {
                    lastIt0.EndDa = iT41.BegDa.AddDays(-1);
                    _context.Update(lastIt0);
                    await _context.SaveChangesAsync();
                }
                // agregar el nuevo
                _context.Add(iT41);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                var x = iT41.PersonalId;
                return(RedirectToAction("Edit", "Personals", new { id = x }));
            }
            var personal = await _context.Personals
                           .SingleOrDefaultAsync(m => m.Id == iT41.PersonalId);

            ViewBag.GpoCiaG     = iT41.Gbukrs;
            ViewBag.Nombre      = personal.Cname;
            ViewBag.Bukrs       = iT41.Bukrs;
            ViewBag.NoPer       = iT41.Pernr;
            ViewBag.ClaseFechas = _bukrs.GetClasedeFecha();
            var items = new List <SelectListItem>();

            items = _bukrs.DaClasedeMedida(personal.Gbukrs, personal.Bukrs);
            ViewBag.ListaClases = items.ToList();
            var esta1 = new List <Estatus_stat2>();

            esta1            = _bukrs.GetEstatus1(personal.Bukrs, personal.Gbukrs);
            ViewBag.ListaEst = esta1.ToList();
            var divis = new List <Divis>();

            divis = _bukrs.GetDivisions(personal.Bukrs, personal.Gbukrs);
            ViewBag.ListaDivis   = divis.ToList();
            ViewBag.TipoPers     = _bukrs.GetTipoPersonal(personal.Bukrs, personal.Gbukrs).ToList();
            ViewBag.ListaNomina  = _bukrs.GetNomina(personal.Bukrs, personal.Gbukrs).ToList();
            ViewBag.CentroCostos = _bukrs.GetCentrodeCostos(personal.Bukrs, personal.Gbukrs).ToList();

            return(View(iT41));
        }