Ejemplo n.º 1
0
        public JsonResult eliminarFolio(int IdArchivo, int IdFolio, int IdCarpeta)
        {
            var             archivoman  = new ArchivoManager();
            string          RutaCopiado = System.Configuration.ConfigurationManager.AppSettings["rutaCopiado"].ToString();
            List <Carpetas> _carpeta    = archivoman.obtenerCarpetas();
            Carpetas        _x          = _carpeta.Where(c => c.IdCarpeta == IdCarpeta).FirstOrDefault();
            string          _archivo    = archivoman.obtenerNombreArchivos(IdArchivo);

            if (_archivo != "")
            {
                var      physicalPath2 = Path.Combine(RutaCopiado + _x.RutaCarpeta + @"\" + IdFolio, _archivo);
                FileInfo _info         = new FileInfo(physicalPath2);
                if (_info.Exists)
                {
                    _info.Delete();
                }
            }
            return(Json(new
            {
                Success = "OK",
                Result = archivoman.eliminarArchivo(
                    IdArchivo, (long)HttpContext.Session["IdSesion"]
                    )
            }));
        }
Ejemplo n.º 2
0
        public JsonResult obtenerArchivos(int IdFolio)
        {
            var seguridad = new ArchivoManager();


            return(Json(seguridad.pintarHtml(IdFolio), JsonRequestBehavior.AllowGet));
        }
 private void ConstruirElArchivo(ArchivoManager archivoManager)
 {
     try
     {
         string nombreNuevoArchivo = archivoManager.CrearArchivo(rutaPorDefecto);
         MessageBox.Show($"El archivo {nombreNuevoArchivo} se creo de manera correcta", "Excelente!", MessageBoxButtons.OK);
     }
     catch (Exception exception)
     {
         MessageBox.Show($"Se ha presentado el siguiente inconveniente al crear el archivo: {exception.Message}", "Atención", MessageBoxButtons.OK);
     }
 }
        private void CargarInformacion(ArchivoManager archivoManager)
        {
            for (int rowIndex = 0; rowIndex < ChequesDataGridView.Rows.Count; rowIndex++)
            {
                string descripcionEncriptada = Encriptacion.EncriptarString(ChequesDataGridView.Rows[rowIndex].Cells[3].Value.ToString(), userPassword);

                archivoManager.ChequesList.Add(new Cheque
                {
                    Nombre      = ChequesDataGridView.Rows[rowIndex].Cells[0].Value.ToString(),
                    Numero      = ChequesDataGridView.Rows[rowIndex].Cells[1].Value.ToString(),
                    Monto       = Convert.ToDouble(ChequesDataGridView.Rows[rowIndex].Cells[2].Value.ToString()),
                    Descripcion = descripcionEncriptada,
                });
            }
        }
Ejemplo n.º 5
0
        public ActionResult Save(IEnumerable <HttpPostedFileBase> files, int idFolio, int tipo, int carpeta, int evento, int orden)
        {
            if (idFolio > 0)
            {
                string _resultado  = "";
                string _directorio = "Importar";
                string RutaCopiado = System.Configuration.ConfigurationManager.AppSettings["rutaCopiado"].ToString();
                foreach (var file in files)
                {
                    var fileName = Path.GetFileName(file.FileName);

                    var physicalPath = Path.Combine(Server.MapPath("~/App_Data/" + _directorio), fileName);


                    var _dir = new DirectoryInfo(Server.MapPath("~/App_Data/" + _directorio));
                    if (!_dir.Exists)
                    {
                        _dir.Create();
                    }
                    file.SaveAs(physicalPath);
                    var      seguridad  = new FolioManager();
                    var      archivoman = new ArchivoManager();
                    FileInfo _info      = new FileInfo(physicalPath);
                    _resultado = seguridad.LigarArchivos(idFolio, tipo, carpeta, fileName, _info.Extension, (long)HttpContext.Session["IdSesion"], evento, orden);

                    //MOVER A C
                    List <Carpetas> _carpeta = archivoman.obtenerCarpetas();
                    Carpetas        _x       = _carpeta.Where(c => c.IdCarpeta == carpeta).FirstOrDefault();
                    _dir = new DirectoryInfo(RutaCopiado + _x.RutaCarpeta + @"\" + idFolio);
                    if (!_dir.Exists)
                    {
                        _dir.Create();
                    }
                    var physicalPath2 = Path.Combine(RutaCopiado + _x.RutaCarpeta + @"\" + idFolio, fileName);
                    this.EliminarArchivos(physicalPath2);
                    System.IO.File.Copy(physicalPath, physicalPath2, true);
                    //MOVER A C
                    this.EliminarArchivos(physicalPath);
                    return(Json(new { Archivo = fileName, Evento = (_resultado == "OK" ? "OK" : "Error"), status = _resultado, Folio = idFolio }, "text/plain"));
                }
            }
            return(Json(new { Filas = 0, Archivo = "", Evento = "", status = "", Folio = idFolio }, "text/plain"));
        }
        private void CrearArchivoButton_Click(object sender, EventArgs e)
        {
            if (HayInformacionEnLaGrid())
            {
                LimpiarErrorProviders();

                ArchivoManager archivoManager = new ArchivoManager();

                CargarInformacion(archivoManager);

                ConstruirElArchivo(archivoManager);

                ChequesDataGridView.Rows.Clear();
            }
            else
            {
                ErrorProvider.SetError(ChequesDataGridView, "No hay información para crear el archivo");
                InformationProvider.SetError(CrearArchivoButton, "Primero agregue información para crear el archivo");
            }
        }
Ejemplo n.º 7
0
        public ActionResult Registrar()
        {
            StringBuilder    _html      = new StringBuilder();
            SeguridadManager _seguridad = new SeguridadManager();
            PerfilManager    _perfilMan = new PerfilManager();

            PersonaManager      _perMan  = new PersonaManager();
            ProveedorManager    _provMan = new ProveedorManager();
            DepartamentoManager _depMan  = new DepartamentoManager();
            ArchivoManager      _arMan   = new ArchivoManager();

            ServicioManager _serMan = new ServicioManager();
            UnidadManager   _uMan   = new UnidadManager();
            FormatoManager  _fMan   = new FormatoManager();


            string _nombre = string.Empty, _correo = string.Empty;

            if (User.Identity.Name == string.Empty)
            {
                return(RedirectToAction("LogIn", "Usuario"));
            }

            _seguridad.getDataUsuario(User.Identity.Name, ref _nombre, ref _correo);
            ViewBag.NombreUsuario = _nombre;
            ViewBag.Correo        = _correo;
            ViewBag.Menu          = _seguridad.getMenu(User.Identity.Name, "Folios", "Folios");
            if (HttpContext.Session["IdSesion"] == null || string.IsNullOrEmpty(HttpContext.Session["IdSesion"].ToString()))
            {
                return(RedirectToAction("LogIn", "Usuario"));
            }
            ViewBag.Sesion = HttpContext.Session["IdSesion"].ToString();
            List <SelectListItem> myNivel         = new List <SelectListItem>();
            List <Perfiles>       _perfiles       = _perfilMan.obtenerPerfiles();

            List <vwPersonas>    _lsTecnicos      = _perMan.obtenerPersonasPorCargo(PersonaManager.enumCargos.Tecnico);
            List <vwPersonas>    _lsSupervisores  = _perMan.obtenerPersonasPorCargo(PersonaManager.enumCargos.Supervisor);
            List <vwPersonas>    _lsDespachadores = _perMan.obtenerPersonasPorCargo(PersonaManager.enumCargos.Atiende);
            List <vwProveedores> _lsProveedores   = _provMan.obtenerProveedoresValidos();
            List <vwFormatos>    _lsFormatos      = _fMan.obtenerFormatosValidos();



            List <SelectListItem> _tecnicos       = new List <SelectListItem>();
            List <SelectListItem> _supervisores   = new List <SelectListItem>();
            List <SelectListItem> _despachadores  = new List <SelectListItem>();
            List <SelectListItem> _proveedores    = new List <SelectListItem>();
            List <SelectListItem> _formatos       = new List <SelectListItem>();

            List <SelectListItem>  myDepto        = new List <SelectListItem>();
            List <vwDepartamentos> _departamentos = _depMan.obtenerDepartamentos();

            List <SelectListItem> myTipos         = new List <SelectListItem>();
            List <TipoArchivo>    _tipos          = _arMan.obtenerTiposArchivos();

            List <SelectListItem> myCarpetas      = new List <SelectListItem>();
            List <Carpetas>       _carpetas       = _arMan.obtenerCarpetas();

            List <SelectListItem> myUnidades      = new List <SelectListItem>();
            List <vwUnidades>     _unidades       = _uMan.obtenerUnidades();
            List <SelectListItem> myClaves        = new List <SelectListItem>();
            List <vwServicios>    _claves         = _serMan.obtenerServicios();



            foreach (Perfiles nivel in _perfiles)
            {
                if (nivel.Perfil == "Administrador")
                {
                    myNivel.Add(new SelectListItem()
                    {
                        Text = nivel.Perfil, Value = nivel.IdPerfil.ToString(), Selected = true
                    });
                }
                else
                {
                    myNivel.Add(new SelectListItem()
                    {
                        Text = nivel.Perfil, Value = nivel.IdPerfil.ToString()
                    });
                }
            }

            foreach (vwPersonas nivel in _lsTecnicos)
            {
                _tecnicos.Add(new SelectListItem()
                {
                    Text = nivel.Paterno + " " + nivel.Materno + " " + nivel.Nombre, Value = nivel.IdPersona.ToString()
                });
            }

            foreach (vwPersonas nivel in _lsSupervisores)
            {
                _supervisores.Add(new SelectListItem()
                {
                    Text = nivel.Paterno + " " + nivel.Materno + " " + nivel.Nombre, Value = nivel.IdPersona.ToString()
                });
            }

            foreach (vwPersonas nivel in _lsDespachadores)
            {
                _despachadores.Add(new SelectListItem()
                {
                    Text = nivel.Paterno + " " + nivel.Materno + " " + nivel.Nombre, Value = nivel.IdPersona.ToString()
                });
            }

            foreach (vwProveedores nivel in _lsProveedores)
            {
                _proveedores.Add(new SelectListItem()
                {
                    Text = nivel.Proveedor, Value = nivel.IdProveedor.ToString()
                });
            }
            int _conta = 0;

            foreach (vwDepartamentos nivel in _departamentos)
            {
                if (_conta == 0)
                {
                    myDepto.Add(new SelectListItem()
                    {
                        Text = nivel.Departamento, Value = nivel.IdDepartamento.ToString(), Selected = true
                    });
                }
                else
                {
                    myDepto.Add(new SelectListItem()
                    {
                        Text = nivel.Departamento, Value = nivel.IdDepartamento.ToString()
                    });
                }
                ++_conta;
            }
            _conta = 0;
            foreach (TipoArchivo nivel in _tipos)
            {
                if (_conta == 0)
                {
                    myTipos.Add(new SelectListItem()
                    {
                        Text = nivel.TipoArchivo1, Value = nivel.IdTipoArchivo.ToString(), Selected = true
                    });
                }
                else
                {
                    myTipos.Add(new SelectListItem()
                    {
                        Text = nivel.TipoArchivo1, Value = nivel.IdTipoArchivo.ToString()
                    });
                }
                ++_conta;
            }
            _conta = 0;
            foreach (Carpetas nivel in _carpetas)
            {
                if (_conta == 0)
                {
                    myCarpetas.Add(new SelectListItem()
                    {
                        Text = nivel.RutaCarpeta, Value = nivel.IdCarpeta.ToString(), Selected = true
                    });
                }
                else
                {
                    myCarpetas.Add(new SelectListItem()
                    {
                        Text = nivel.RutaCarpeta, Value = nivel.IdCarpeta.ToString()
                    });
                }
                ++_conta;
            }
            _conta = 0;
            foreach (vwUnidades unidad in _unidades)
            {
                if (_conta == 0)
                {
                    myUnidades.Add(new SelectListItem()
                    {
                        Text = unidad.Unidad, Value = unidad.IdUnidad.ToString(), Selected = true
                    });
                }
                else
                {
                    myUnidades.Add(new SelectListItem()
                    {
                        Text = unidad.Unidad, Value = unidad.IdUnidad.ToString()
                    });
                }
                ++_conta;
            }
            _conta = 0;
            foreach (vwServicios servicio in _claves)
            {
                if (_conta == 0)
                {
                    myClaves.Add(new SelectListItem()
                    {
                        Text = servicio.Clave, Value = servicio.IdServicio.ToString(), Selected = true
                    });
                }
                else
                {
                    myClaves.Add(new SelectListItem()
                    {
                        Text = servicio.Clave, Value = servicio.IdServicio.ToString()
                    });
                }
                ++_conta;
            }
            _conta = 0;
            foreach (vwFormatos servicio in _lsFormatos)
            {
                if (_conta == 0)
                {
                    _formatos.Add(new SelectListItem()
                    {
                        Text = servicio.Formato, Value = servicio.IdFormato.ToString(), Selected = true
                    });
                }
                else
                {
                    _formatos.Add(new SelectListItem()
                    {
                        Text = servicio.Formato, Value = servicio.IdFormato.ToString()
                    });
                }
                ++_conta;
            }



            ViewBag.Niveles       = myNivel;
            ViewBag.Tecnicos      = _tecnicos;
            ViewBag.Supervisores  = _supervisores;
            ViewBag.Despachos     = _despachadores;
            ViewBag.Proveedores   = _proveedores;
            ViewBag.Departamentos = myDepto;
            ViewBag.Tipos         = myTipos;
            ViewBag.Carpetas      = myCarpetas;
            ViewBag.Claves        = myClaves;
            ViewBag.Unidades      = myUnidades;
            ViewBag.Formatos      = _formatos;
            return(View());
        }