示例#1
0
        public bool grabarDB(rol_cargo_Info info, ref int IdCargo)
        {
            try
            {
                using (Entities_general entyti = new Entities_general())
                {
                    var selec = (from q in entyti.rol_cargo
                                 where
                                 q.rc_descripcion == info.rc_descripcion
                                 select q);

                    if (selec.Count() == 0)
                    {
                        rol_cargo addnewC = new rol_cargo();
                        addnewC.IdCargo        = GetId();
                        addnewC.rc_codigo      = info.rc_codigo;
                        addnewC.rc_descripcion = info.rc_descripcion;
                        addnewC.estado         = true;
                        entyti.rol_cargo.Add(addnewC);
                        entyti.SaveChanges();
                        IdCargo = addnewC.IdCargo;
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
 public ActionResult Modificar(int?IdCargo)
 {
     try
     {
         info_cargo = new rol_cargo_Info();
         return(View(cargo_data.GetInfo(IdCargo)));
     }
     catch (Exception)
     {
         throw;
     }
 }
 public ActionResult Anular(rol_cargo_Info item)
 {
     if (ModelState.IsValid)
     {
         try
         {
             cargo_data.anularDB(item);
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(RedirectToAction("Index", "Cargo"));
 }
示例#4
0
 public bool anularDB(rol_cargo_Info info)
 {
     try
     {
         using (Entities_general entyti = new Entities_general())
         {
             var addnewC = entyti.rol_cargo.Where(v => v.IdCargo == info.IdCargo).FirstOrDefault();
             if (addnewC != null)
             {
                 addnewC.estado = false;
                 entyti.SaveChanges();
             }
             return(true);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#5
0
 public bool modificarDB(rol_cargo_Info info)
 {
     try
     {
         using (Entities_general entyti = new Entities_general())
         {
             var addnewC = entyti.rol_cargo.Where(v => v.IdCargo == info.IdCargo).FirstOrDefault();
             if (addnewC != null)
             {
                 addnewC.rc_codigo      = info.rc_codigo;
                 addnewC.rc_descripcion = info.rc_descripcion;
                 entyti.SaveChanges();
             }
             return(true);
         }
     }
     catch (Exception e)
     {
         throw;
     }
 }
        public ActionResult Nuevo(rol_cargo_Info item)
        {
            var model = new object[0];

            if (ModelState.IsValid)
            {
                try
                {
                    int idcargo = 0;
                    cargo_data.grabarDB(item, ref idcargo);
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }

            return(RedirectToAction("Index", "Cargo"));
        }
示例#7
0
        public rol_cargo_Info GetInfo(string ca_descripcion)
        {
            rol_cargo_Info info = new rol_cargo_Info();

            try
            {
                using (Entities_general entyti = new Entities_general())
                {
                    var addnewC = entyti.rol_cargo.Where(v => v.rc_descripcion == ca_descripcion).FirstOrDefault();
                    if (addnewC != null)
                    {
                        info.IdCargo        = addnewC.IdCargo;
                        info.rc_codigo      = addnewC.rc_codigo;
                        info.rc_descripcion = addnewC.rc_descripcion;
                    }
                }
                return(info);
            }
            catch (Exception e)
            {
                return(new rol_cargo_Info());
            }
        }
 public ActionResult Nuevo()
 {
     info_cargo = new rol_cargo_Info();
     return(View(info_cargo));
 }
示例#9
0
        public ActionResult Importarempleados(HttpPostedFileBase uploadfile)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    int cont    = 0;
                    int IdCargo = 0;
                    List <rol_empleado_Info> listaemp      = new List <rol_empleado_Info>();
                    List <rol_cargo_Info>    listaCargo    = new List <rol_cargo_Info>();
                    rol_cargo_Data           caro_data     = new rol_cargo_Data();
                    rol_empleado_Data        empleado_data = new rol_empleado_Data();
                    if (uploadfile != null && uploadfile.ContentLength > 0)
                    {
                        Stream           stream = uploadfile.InputStream;
                        IExcelDataReader reader = null;
                        if (uploadfile.FileName.EndsWith(".xls"))
                        {
                            reader = ExcelReaderFactory.CreateBinaryReader(stream);
                        }
                        else if (uploadfile.FileName.EndsWith(".xlsx"))
                        {
                            reader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                        }
                        while (reader.Read())
                        {
                            if (!reader.IsDBNull(0))
                            {
                                if (cont != 0)
                                {
                                    // verificando cargo
                                    if (cargo_data.si_existe(reader.GetString(7)) == false)
                                    {
                                        rol_cargo_Info infoc = new rol_cargo_Info();
                                        infoc.rc_descripcion = reader.GetString(7);
                                        infoc.estado         = true;
                                        caro_data.grabarDB(infoc, ref IdCargo);
                                    }
                                    else
                                    {
                                        IdCargo = cargo_data.GetInfo(reader.GetString(7)).IdCargo;
                                    }


                                    try
                                    {
                                        rol_empleado_Info info = new rol_empleado_Info();
                                        info.re_codigo    = reader.GetString(0);
                                        info.re_apellidos = reader.GetString(1);
                                        info.re_nombres   = reader.GetString(2);
                                        info.re_cedula    = reader.GetString(3);
                                        info.re_correo    = reader.GetString(4);
                                        info.re_telefonos = reader.GetString(5);
                                        info.re_direccion = reader.GetString(6);
                                        info.IdCargo      = IdCargo;
                                        info.estado       = reader.GetString(8) == "A" ? true : false;
                                        listaemp.Add(info);
                                        if (emp_data.si_existe(info.re_cedula))
                                        {
                                            emp_data.modificarDB_x_cedula(info);
                                        }
                                        else
                                        {
                                            empleado_data.guardarDB(info);
                                        }
                                    }
                                    catch (Exception)
                                    {
                                    }
                                }
                                cont++;
                            }
                        }

                        return(RedirectToAction("Index", "Empleado"));
                    }
                }
                else
                {
                    ModelState.AddModelError("File", "Please upload your file");
                }
                return(View());
            }
            catch (Exception ex)
            {
                return(View());
            }
        }