// GET: Personal_agregarVM/Create
        public IActionResult Create()
        {
            Personal_agregarVM pc = new Personal_agregarVM();

            pc.Dia_1 = true;
            pc.Dia_2 = true;
            pc.Dia_3 = true;
            pc.Dia_4 = true;
            pc.Dia_5 = true;
            string   dateInput  = "Jan 1, 9999";
            DateTime parsedDate = DateTime.Parse(dateInput);

            pc.EndDa = parsedDate;
            pc.BegDa = DateTime.Now;
            // pc.Bukrs = "0";
            dateInput       = "Mar 1,1975";
            parsedDate      = DateTime.Parse(dateInput);
            pc.GbDat        = parsedDate;
            ViewBag.GpoCiaG = HttpContext.Session.GetString(SessionGpoCia);
            pc.Gbukrs       = ViewBag.GpoCiaG;
            List <Divis> divislist = new List <Divis>();

            divislist = (from divis2 in _context.Divis
                         select divis2).ToList();
            //agregando los items a la lista
            divislist.Insert(0, new Divis {
                Id = 0, Descrip = "Select"
            });
            //asignar category list to viewbag
            ViewBag.ListofCategory        = divislist;
            ViewBag.ListofTitles          = _bukrs.GetTitle();
            ViewBag.ListofClasedeContrato = _bukrs.GetClasedeContrato();
            ViewBag.ListofClavedeSexo     = _bukrs.GetClavedeSexo();
            ViewBag.ListofRegion1         = _bukrs.GetRegion1();
            ViewBag.ListofEstado          = _bukrs.GetRegion1();
            ViewBag.ListofTipoPago        = _bukrs.GetTipoPago();
            ViewBag.ListofPerPru          = _bukrs.GetPeriodoPrueba();

            if (ViewBag.GpoCiaG == null)
            {
                HttpContext.Session.SetString(SessionRegresa, "Create:Personal_agregarVM");
                return(RedirectToAction("Index", "GpoCiaGlobal"));
                //return Redirect("GpoCiaGlobal/Index");
            }
            else
            {
                HttpContext.Session.SetString(SessionRegresa, "");
            }
            var items = new List <SelectListItem>();

            items = _bukrs.DaBukrs2(ViewBag.GpoCiaG);

            //items = DaBukrs(ViewBag.GpoCiaG);
            ViewBag.DaBukrs = items.ToList();



            return(View(pc));
        }
Beispiel #2
0
        // GET: IT0_1/Create
        public async Task <IActionResult> Crear(int?IdPer)
        {
            if (IdPer == null)
            {
                return(NotFound());
            }
            IT16 it0p     = new IT16();
            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 lastIt16 = await _context.IT16s.LastOrDefaultAsync(m => m.PersonalId == IdPer);

            if (lastIt16 == null)
            {
                it0p.BegDa = DateTime.Now;
            }
            else
            {
                it0p.BegDa = lastIt16.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;
            ViewBag.ListofClasedeContrato = _bukrs.GetClasedeContrato();
            ViewBag.ListofPerPru          = _bukrs.GetPeriodoPrueba();

            return(View(it0p));
        }