Example #1
0
        public static bool setDocumentoAcreditacion(ContactoArchivosAnexo doc, bool esnuevo, bool esparcial)
        {
            bool operacionOk = true;

            try
            {
                using (Datos.FonadeDBDataContext db = new Datos.FonadeDBDataContext(cadenaConexion))
                {
                    if (esnuevo)
                    {
                        db.ContactoArchivosAnexos1.InsertOnSubmit(doc);
                    }
                    else
                    {
                        var reg = (from datos in db.ContactoArchivosAnexos1
                                   where datos.Id_ContactoArchivosAnexos == doc.Id_ContactoArchivosAnexos
                                   select datos).SingleOrDefault();

                        if (reg != null)
                        {
                            reg.Descripcion = doc.Descripcion;
                            reg.Observacion = doc.Observacion;

                            if (!esparcial)
                            {
                                if (doc.ruta != "")
                                {
                                    reg.ruta = doc.ruta;
                                }
                            }
                        }
                    }

                    db.SubmitChanges();
                }
            }
            catch
            {
                operacionOk = false;
            }

            return(operacionOk);
        }
Example #2
0
        public static bool updBorradoDocumentoAcreditacion(int idDocumento)
        {
            bool operacionOk = true;

            try
            {
                using (Datos.FonadeDBDataContext db = new Datos.FonadeDBDataContext(cadenaConexion))
                {
                    ContactoArchivosAnexo docUpd = db.ContactoArchivosAnexos1.Where(reg => reg.Id_ContactoArchivosAnexos == idDocumento).FirstOrDefault();

                    if (docUpd != null)
                    {
                        db.ContactoArchivosAnexos1.DeleteOnSubmit(docUpd);
                        db.SubmitChanges();
                    }
                }
            }
            catch
            {
                operacionOk = false;
            }

            return(operacionOk);
        }
Example #3
0
        protected void btnCrearDocumentoAcreditacion_Click(object sender, EventArgs e)
        {
            try
            {
                if (btnCrearDocumentoAcreditacion.Text != "Actualizar")
                {
                    if (!flDocumentoAcreditacion.HasFile)
                    {
                        Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(146), this, "Alert");
                    }
                    else
                    {
                        if (hdIdDocAcreditacion.Value == "")
                        {
                            string txtFormato      = "Link";
                            string codFormato      = String.Empty;
                            string NomFormato      = String.Empty;
                            string RutaHttpDestino = String.Empty;
                            string RutaDestino     = String.Empty;
                            int    CodCarpeta      = 0;

                            if (txtFormato.ToLower() == ".asp" || txtFormato.ToLower() == "php" || txtFormato.ToLower() == "xml" || txtFormato.ToLower() == "aspx" || txtFormato.ToLower() == "exe")
                            {
                                Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(154), this, "Alert");
                            }

                            string[] extension = flDocumentoAcreditacion.PostedFile.FileName.ToString().Trim().Split('.');
                            txtFormato = "." + extension[extension.Length - 1];

                            var query = Negocio.PlanDeNegocioV2.Formulacion.Anexos.Anexos.getDocumentoFormato(txtFormato);

                            if (query == null)
                            {
                                DocumentoFormato datos = new DocumentoFormato();
                                datos.NomDocumentoFormato = "Archivo " + txtFormato;
                                datos.Extension           = txtFormato;
                                datos.Icono = "IcoDocNormal.gif";

                                if (Negocio.PlanDeNegocioV2.Formulacion.Anexos.Anexos.insDocumentoFormato(datos))
                                {
                                    var consulta = Negocio.PlanDeNegocioV2.Formulacion.Anexos.Anexos.getDocumentoFormato(txtFormato);

                                    codFormato = consulta.Id_DocumentoFormato.ToString();
                                    NomFormato = consulta.NomDocumentoFormato;
                                }
                            }
                            else
                            {
                                codFormato = query.Id_DocumentoFormato.ToString();
                                NomFormato = query.NomDocumentoFormato;
                            }

                            CodCarpeta      = Convert.ToInt32(CodigoProyecto) / 2000;
                            RutaHttpDestino = ConfigurationManager.AppSettings.Get("DirVirtual") + "contactoAnexos\\" + CodCarpeta + "\\ContactoAnexo_" + usuario.IdContacto + "\\";
                            RutaDestino     = "contactoAnexos\\" + CodCarpeta + "\\ContactoAnexo_" + usuario.IdContacto + "\\";
                            var rutaFull = ConfigurationManager.AppSettings.Get("RutaIP") + RutaHttpDestino;

                            if (System.IO.File.Exists(rutaFull + flDocumentoAcreditacion.FileName))
                            {
                                Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(155), this, "Alert");
                            }
                            else
                            {
                                if (!System.IO.Directory.Exists(rutaFull))
                                {
                                    System.IO.Directory.CreateDirectory(rutaFull);
                                }

                                flDocumentoAcreditacion.SaveAs(rutaFull + flDocumentoAcreditacion.FileName);
                                RutaHttpDestino = RutaHttpDestino + Archivo.FileName;

                                ContactoArchivosAnexo nuevoDocAcreditacion = new ContactoArchivosAnexo()
                                {
                                    CodContacto        = usuario.IdContacto,
                                    CodContactoEstudio = null,
                                    ruta          = RutaDestino + flDocumentoAcreditacion.FileName,
                                    NombreArchivo = flDocumentoAcreditacion.FileName,
                                    TipoArchivo   = "DocumentoAcreditacion",
                                    CodProyecto   = CodigoProyecto,
                                    Bloqueado     = false,
                                    Descripcion   = txtNombreDocAcreditacion.Text.Trim(),
                                    Observacion   = txtObservacionDocAcreditacion.Text.Trim()
                                };

                                if (Negocio.PlanDeNegocioV2.Formulacion.Anexos.Anexos.setDocumentoAcreditacion(nuevoDocAcreditacion, true, false))
                                {
                                    Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(148), this, "Alert");
                                }
                                else
                                {
                                    Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(149), this, "Alert");
                                }
                            }
                        }
                        else
                        {
                            ContactoArchivosAnexo actualdoc = new ContactoArchivosAnexo()
                            {
                                CodContacto        = usuario.IdContacto,
                                CodContactoEstudio = null,
                                NombreArchivo      = Archivo.FileName,
                                TipoArchivo        = "DocumentoAcreditacion",
                                CodProyecto        = CodigoProyecto,
                                Bloqueado          = false,
                                Descripcion        = txtNombreDocumento.Text.Trim(),
                                Observacion        = txtObservacionDocAcreditacion.Text.Trim()
                            };

                            if (Negocio.PlanDeNegocioV2.Formulacion.Anexos.Anexos.setDocumentoAcreditacion(actualdoc, false, false))
                            {
                                Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(148), this, "Alert");
                            }
                            else
                            {
                                Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(149), this, "Alert");
                            }

                            hddIdDocumento.Value = string.Empty;
                        }

                        CargarGridDocumentosAcreditacion();
                        pnlPrincipal.Visible = true;
                        pnlDocumentosAcreditacion.Visible = false;
                    }
                }
                else
                {
                    var documento = Negocio.PlanDeNegocioV2.Formulacion.Anexos.Anexos.getDocumentoNormalAcreditacion(Convert.ToInt32(ViewState["idDocumentoAcreditacion"].ToString()));

                    if (documento != null)
                    {
                        documento.Descripcion = txtNombreDocAcreditacion.Text.Trim();
                        documento.Observacion = txtObservacionDocAcreditacion.Text.Trim();

                        Negocio.PlanDeNegocioV2.Formulacion.Anexos.Anexos.setDocumentoAcreditacion(documento, false, true);

                        CargarGridDocumentosAcreditacion();
                        pnlPrincipal.Visible = true;
                        pnlDocumentosAcreditacion.Visible = false;
                        tdSubir2.Visible = true;
                    }
                    else
                    {
                        Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(154), this, "Alert");
                    }
                }
            }
            catch (Exception ex)
            {
                Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(7), this, "Alert");
            }
        }