Esempio n. 1
0
        public ActionResult DeleteConfirmed(string id)
        {
            t_merit t_merit = db.t_merit.Find(id);

            db.t_merit.Remove(t_merit);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
 public ActionResult Edit([Bind(Include = "supervisor,axo,nombre,depto,budget_imp,budget_porc,budget_spen,estatus,notas,u_id,f_id,autoriza,ind_autoriza,f_autoriza,n_autoriza")] t_merit t_merit)
 {
     if (ModelState.IsValid)
     {
         db.Entry(t_merit).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.autoriza   = new SelectList(db.t_empleados, "empleado", "nombre", t_merit.autoriza);
     ViewBag.supervisor = new SelectList(db.t_empleados, "empleado", "nombre", t_merit.supervisor);
     return(View(t_merit));
 }
Esempio n. 3
0
        // GET: t_merit/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            t_merit t_merit = db.t_merit.Find(id);

            if (t_merit == null)
            {
                return(HttpNotFound());
            }
            return(View(t_merit));
        }
Esempio n. 4
0
        // GET: t_merit/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            t_merit t_merit = db.t_merit.Find(id);

            if (t_merit == null)
            {
                return(HttpNotFound());
            }
            ViewBag.autoriza   = new SelectList(db.t_empleados, "empleado", "nombre", t_merit.autoriza);
            ViewBag.supervisor = new SelectList(db.t_empleados, "empleado", "nombre", t_merit.supervisor);
            return(View(t_merit));
        }
Esempio n. 5
0
        public ActionResult AddComments(string supervisor, decimal axo, string comments)
        {
            if (!Login())
            {
                return(RedirectToAction("NoUser", "Home", null));
            }

            t_merit t_merit = db.t_merit.Find(supervisor, axo);

            t_merit.n_autoriza      = comments;
            t_merit.f_autoriza      = System.DateTime.Now;
            db.Entry(t_merit).State = EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("IndexModule4", "t_merit", new { empleado = t_merit.supervisor }));
        }
Esempio n. 6
0
        public ActionResult CreateAll(decimal sparamx)
        {
            //list of employees / local & tress store procedure query

            var     budgetAxo = db.t_budget_pta.Where(x => x.axo == sparamx).ToList();
            decimal dBudget   = 0;

            if (budgetAxo.Any())
            {
                if (!decimal.TryParse(budgetAxo[0].budget.ToString(), out dBudget))
                {
                    return(HttpNotFound());
                }
            }

            var spPlanners = db.sp_view_merit_planners().ToList();

            if (spPlanners.ToList().Count() > 0)
            {
                for (int x = 0; x < spPlanners.ToList().Count(); x++)
                {
                    var sSuper   = spPlanners[x].empleado.ToString();
                    var sName    = spPlanners[x].nombre.ToString();
                    var sDepto   = spPlanners[x].TB_ELEMENT.ToString();
                    var sManager = string.Empty;
                    if (spPlanners[x].gerente != null)
                    {
                        sManager = spPlanners[x].gerente.ToString();
                    }
                    else
                    {
                        sManager = null;
                    }
                    decimal dSalary       = 0;
                    decimal dSalaryBudget = 0;
                    if (!decimal.TryParse(spPlanners[x].salary.ToString(), out dSalary))
                    {
                        dSalary = 0;
                    }

                    if (dSalary > 0)
                    {
                        dSalaryBudget = dSalary * (dBudget / 100);
                    }
                    else
                    {
                        continue;
                    }

                    var spDirect = db.sp_view_merit_dreport(sSuper).ToList();
                    if (spPlanners.ToList().Count() > 0)
                    {
                        //saver t_merit
                        t_merit dbMerit = new t_merit();
                        dbMerit.supervisor  = sSuper;
                        dbMerit.axo         = sparamx;
                        dbMerit.nombre      = sName;
                        dbMerit.depto       = sDepto;
                        dbMerit.budget_imp  = dSalaryBudget;
                        dbMerit.budget_porc = dBudget;
                        dbMerit.budget_spen = 0;
                        dbMerit.autoriza    = sManager;
                        dbMerit.estatus     = "PE";
                        dbMerit.u_id        = Convert.ToString(Session["userAccount"]);
                        dbMerit.f_id        = System.DateTime.Now;

                        db.Entry(dbMerit).State = EntityState.Added;
                        if (db.SaveChanges() > 0)
                        {
                            //save t_meridet
                            for (int i = 0; i < spDirect.ToList().Count(); i++)
                            {
                                t_meridet dbMeridet = new t_meridet();
                                dbMeridet.supervisor = sSuper;
                                dbMeridet.axo        = sparamx;
                                dbMeridet.empleado   = spDirect[i].empleado.ToString();
                                dbMeridet.nombre     = spDirect[i].nombre.ToString();
                                dbMeridet.jobcode    = spDirect[i].jobcode.ToString();
                                decimal dMRP = 0;
                                if (!decimal.TryParse(spDirect[i].mrp.ToString(), out dMRP))
                                {
                                    dMRP = 0;
                                }
                                dbMeridet.market_mcr   = dMRP;
                                dbMeridet.puesto       = spDirect[i].PU_DESCRIP.ToString();
                                dbMeridet.calificacion = spDirect[i].califica.ToString();
                                decimal dSalaryD = 0;
                                if (!decimal.TryParse(spDirect[i].salary.ToString(), out dSalaryD))
                                {
                                    dSalaryD = 0;
                                }
                                dbMeridet.salario_axo   = dSalaryD;
                                dbMeridet.budget_porc   = dBudget;
                                dbMeridet.estatus       = "PE";
                                dbMeridet.sugerido_imp  = 0;
                                dbMeridet.sugerido_porc = 0;
                                dbMeridet.lump_imp      = 0;
                                dbMeridet.lump_porc     = 0;
                                dbMeridet.market_mcr    = 0;//get mrc from job
                                dbMeridet.out_guide     = "0";
                                dbMeridet.salario_nuevo = 0;
                                DateTime dtSalario = DateTime.Parse(spDirect[i].CB_FEC_ANT.ToString());
                                DateTime dtIngreso = DateTime.Parse(spDirect[i].CB_FEC_ING.ToString());
                                if (Elegible(dtSalario, dtSalario))
                                {
                                    dbMeridet.ind_elegible = "1";
                                }
                                else
                                {
                                    dbMeridet.ind_elegible = "0";
                                }
                                dbMeridet.u_id = Convert.ToString(Session["userAccount"]);
                                dbMeridet.f_id = DateTime.Now;

                                db.Entry(dbMeridet).State = EntityState.Added;
                                db.SaveChanges();
                            }
                        }
                    }
                }
            }

            return(RedirectToAction("Start", "t_merit", new { sparame = Session["userNo"], sparamx = sparamx }));
        }