Beispiel #1
0
        /// <summary>
        /// Inserta un nuevo formato de documento
        /// </summary>
        /// <param name="nuevoformato">Nuevo Formato</param>
        /// <returns>Verdadero si la operación fue exitosa falso en otro escenario</returns>
        public static bool insDocumentoFormato(DocumentoFormato nuevoformato)
        {
            bool operacionOk = true;

            try
            {
                using (Datos.FonadeDBDataContext db = new Datos.FonadeDBDataContext(cadenaConexion))
                {
                    db.DocumentoFormatos.InsertOnSubmit(nuevoformato);
                    db.SubmitChanges();
                }
            }
            catch
            {
                operacionOk = false;
            }

            return(operacionOk);
        }
Beispiel #2
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");
            }
        }
Beispiel #3
0
        protected void btnCrearAnexo_Click(object sender, EventArgs e)
        {
            try
            {
                if (btnCrearAnexo.Text != "Actualizar")
                {
                    if (!Archivo.HasFile)
                    {
                        Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(146), this, "Alert");
                    }
                    else
                    {
                        if (hddIdDocumento.Value == "")
                        {
                            string txtFormato      = "Link";
                            string codFormato      = String.Empty;
                            string NomFormato      = String.Empty;
                            string RutaHttpDestino = 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 = Archivo.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;
                            }

                            string nomtab = Negocio.PlanDeNegocioV2.Utilidad.General.getNombreTab(CodigoTab);

                            CodCarpeta      = Convert.ToInt32(CodigoProyecto) / 2000;
                            RutaHttpDestino = ConfigurationManager.AppSettings.Get("DirVirtual") + "FonadeDocumentos\\Anexos\\Usuario" + usuario.IdContacto + "\\" + nomtab + "\\";
                            var rutaFull = ConfigurationManager.AppSettings.Get("RutaIP") + RutaHttpDestino;

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

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


                                Documento nuevodoc = new Documento()
                                {
                                    NomDocumento        = txtNombreDocumento.Text.Trim(),
                                    URL                 = RutaHttpDestino,
                                    Fecha               = DateTime.Now,
                                    CodProyecto         = CodigoProyecto,
                                    CodDocumentoFormato = byte.Parse(codFormato),
                                    CodContacto         = usuario.IdContacto,
                                    Comentario          = txtComentario.Text.Trim(),
                                    CodTab              = (short)CodigoTab,
                                    CodEstado           = (byte)EstadoProyecto
                                };

                                if (Negocio.PlanDeNegocioV2.Formulacion.Anexos.Anexos.setDocumento(nuevodoc, true, false))
                                {
                                    Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(148), this, "Alert");
                                }
                                else
                                {
                                    Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(149), this, "Alert");
                                }
                            }
                        }
                        else
                        {
                            Documento actualdoc = new Documento()
                            {
                                NomDocumento = txtNombreDocumento.Text.Trim(),
                                URL          = "",
                                Comentario   = txtComentario.Text.Trim(),
                                CodTab       = (short)CodigoTab,
                                Id_Documento = int.Parse(hddIdDocumento.Value)
                            };

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

                            hddIdDocumento.Value = string.Empty;
                        }

                        CargarGridAnexos(Constantes.CONST_Inscripcion);
                        pnlPrincipal.Visible      = true;
                        pnlCrearDocumento.Visible = false;
                    }
                }
                else
                {
                    var documento = Negocio.PlanDeNegocioV2.Formulacion.Anexos.Anexos.getDocumentoNormal(Convert.ToInt32(ViewState["idDocumento2"].ToString()));

                    if (documento != null)
                    {
                        documento.NomDocumento = txtNombreDocumento.Text.Trim();
                        documento.Comentario   = txtComentario.Text.Trim();

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

                        CargarGridAnexos(Constantes.CONST_Inscripcion);
                        pnlPrincipal.Visible      = true;
                        pnlCrearDocumento.Visible = false;
                        tdSubir.Visible           = true;
                    }
                    else
                    {
                        Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(154), this, "Alert");
                    }
                }
            }
            catch (Exception ex)
            {
                Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(7), this, "Alert");
            }
        }
Beispiel #4
0
        /// <summary>
        /// Mauricio Arias Olave.
        /// 28/05/2014.
        /// Limitado por tamaño la carga de archivos.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnCrearAnexo_Click(object sender, EventArgs e)
        {
            //Inicializar variables.
            ClientScriptManager cm = this.ClientScript;

            if (btnCrearAnexo.Text != "Actualizar")
            {
                if (!Archivo.HasFile)
                {
                    cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('No ha subido ningún archivo.');</script>");
                    return;
                }
                else
                {
                    if (Archivo.PostedFile.ContentLength > 10485760) // = 10MB
                    {
                        cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('El tamaño del archivo debe ser menor a 10 Mb.');</script>");
                        return;
                    }
                    else
                    {
                        #region Procesar la información adjunta al archivo seleccionado.
                        if (hddIdDocumento.Value == "")
                        {
                            string txtFormato      = "Link";
                            string codFormato      = String.Empty;
                            string NomFormato      = String.Empty;
                            string RutaHttpDestino = String.Empty;
                            String Filename        = String.Empty;
                            int    CodCarpeta      = 0;

                            if (txtLink.Text == "")
                            {
                                string[] extencion = Archivo.PostedFile.FileName.ToString().Trim().Split('.');
                                txtFormato = "." + extencion[extencion.Length - 1];
                            }
                            if (txtFormato.ToLower() == ".asp" || txtFormato.ToLower() == "php" || txtFormato.ToLower() == "xml" || txtFormato.ToLower() == "aspx" || txtFormato.ToLower() == "exe")
                            {
                                lblMensajeError.Text = "El Archivo que intenta adjuntar no es permitido";
                            }

                            try
                            {
                                var query = (from df in consultas.Db.DocumentoFormatos
                                             where df.Extension == txtFormato
                                             select new { df.Id_DocumentoFormato, df.NomDocumentoFormato }).FirstOrDefault();

                                codFormato = query.Id_DocumentoFormato.ToString();;
                                NomFormato = query.NomDocumentoFormato;
                            }
                            catch
                            {
                                DocumentoFormato datos = new DocumentoFormato();
                                datos.NomDocumentoFormato = "Archivo " + txtFormato;
                                datos.Extension           = txtFormato;
                                datos.Icono = "IcoDocNormal.gif";

                                consultas.Db.DocumentoFormatos.InsertOnSubmit(datos);
                                consultas.Db.SubmitChanges();

                                var query = (from df in consultas.Db.DocumentoFormatos
                                             where df.Extension == txtFormato
                                             select new { df.Id_DocumentoFormato, df.NomDocumentoFormato }).FirstOrDefault();

                                codFormato = query.Id_DocumentoFormato.ToString();;
                                NomFormato = query.NomDocumentoFormato;
                            }
                            if (txtLink.Text == "")
                            {
                                CodCarpeta      = Convert.ToInt32(codProyecto) / 2000;
                                RutaHttpDestino = ConfigurationManager.AppSettings.Get("DirVirtual") + "FonadeDocumentos\\Anexos\\Usuario" + usuario.IdContacto + "\\Anexos\\";
                                var rutaFull = ConfigurationManager.AppSettings.Get("RutaIP") + RutaHttpDestino;

                                if (!System.IO.Directory.Exists(rutaFull))
                                {
                                    System.IO.Directory.CreateDirectory(rutaFull);
                                }

                                Filename = System.IO.Path.GetFileName(Archivo.FileName);
                                //RutaHttpDestino = RutaHttpDestino + Filename;

                                // yo --> 17 08 2016
                                //if (!CargarArchivoServidor(Archivo, RutaHttpDestino, Archivo.FileName.Substring(0, Archivo.FileName.ToString().IndexOf('.')).cleanSpecialChars(true), txtFormato.Substring(1), ConfigurationManager.AppSettings.Get("RutaDocumentosTEMP")))
                                //{
                                //    lblMensajeError.Text = respuesta.Mensaje;
                                //    return;
                                //}

                                Archivo.SaveAs(rutaFull + Session["NombreArchivo"].ToString());

                                //Archivo.SaveAs
                                //Cambiar la forma de hacerlo
                                //RutaHttpDestino = ConfigurationManager.AppSettings.Get("DirVirtual2")+"Proyecto/" + Math.Abs(Convert.ToInt32(codProyecto) / 2000) + "/" + @"Proyecto_" + codProyecto + @"/" + Archivo.FileName.ToString();
                                RutaHttpDestino = RutaHttpDestino + Session["NombreArchivo"].ToString();
                            }
                            else
                            {
                                if (txtLink.Text.Contains("http://") == false)
                                {
                                    txtLink.Text = "http://" + txtLink.Text;
                                }
                                RutaHttpDestino = txtLink.Text;
                            }

                            string txtSQL = "INSERT INTO Documento(NomDocumento,URL,Fecha,CodProyecto,CodDocumentoFormato,CodContacto,Comentario,Borrado,CodTab,CodEstado)" +
                                            "VALUES('" + txtNombreDocumento.Text.htmlEncode() + "','" + RutaHttpDestino + "',getDate()," + codProyecto + ",'" + codFormato + "'," + usuario.IdContacto + ",'" + txtComentario.Text + "',0,'" + txtTab + "'," + CodigoEstado.ToString() + ")";
                            RutaHttpDestino = null;
                            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
                            try
                            {
                                //NEW RESULTS:

                                SqlCommand Cmd = new SqlCommand(txtSQL, con);

                                if (con != null)
                                {
                                    if (con.State != ConnectionState.Open)
                                    {
                                        con.Open();
                                    }
                                }
                                Cmd.CommandType = CommandType.Text;
                                Cmd.ExecuteNonQuery();
                                //con.Close();
                                //con.Dispose();
                                Cmd.Dispose();


                                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "alert('El Archivo fue guardado'); window.close();", true);
                                Response.Redirect(Request.RawUrl);
                                //return;
                            }
                            catch
                            {
                                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "alert('No se pudo generar el registro');", true);
                                return;
                            }
                            finally
                            {
                                con.Close();
                                con.Dispose();
                            }
                        }
                        else
                        {
                            SqlCommand cmd = new SqlCommand();

                            try
                            {
                                //Borrar la inversión
                                string txtSQL = " Update Documento set NomDocumento ='" + txtNombreDocumento.Text.htmlEncode() + "'," +
                                                " Comentario = '" + txtComentario.Text + "'," +
                                                " codTab = " + txtTab;

                                if (txtLink.Text != "")
                                {
                                    txtSQL = txtSQL + ", Url='" + txtLink.Text + "'";
                                }

                                txtSQL = txtSQL + " WHERE Id_Documento = " + hddIdDocumento.Value;
                                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
                                try
                                {
                                    //NEW RESULTS:

                                    cmd = new SqlCommand(txtSQL, con);

                                    if (con != null)
                                    {
                                        if (con.State != ConnectionState.Open)
                                        {
                                            con.Open();
                                        }
                                    }
                                    cmd.CommandType = CommandType.Text;
                                    cmd.ExecuteNonQuery();
                                    //con.Close();
                                    //con.Dispose();
                                    cmd.Dispose();
                                }
                                catch { }
                                finally
                                {
                                    con.Close();
                                    con.Dispose();
                                }
                            }
                            catch { }

                            hddIdDocumento.Value = string.Empty;
                        }
                        //consultas.Db.SubmitChanges();
                        CargarGridAnexos();

                        pnlPrincipal.Visible      = true;
                        pnlCrearDocumento.Visible = false;
                        #endregion
                    }
                }
            }
            else
            {
                var documento = (from d in consultas.Db.Documentos
                                 where d.Id_Documento == Convert.ToInt32(Session["idDocumento2"].ToString())
                                 select d).FirstOrDefault();
                documento.NomDocumento = txtNombreDocumento.Text.Trim();
                documento.Comentario   = txtComentario.Text.Trim();
                consultas.Db.SubmitChanges();
                CargarGridAnexos();

                pnlPrincipal.Visible      = true;
                pnlCrearDocumento.Visible = false;
                tdSubir.Visible           = true;
            }
        }
Beispiel #5
0
        protected void btn_Accion_Click(object sender, EventArgs e)
        {
            try
            {
                //Si es un registro nuevo
                if (btn_Accion.Text != "Actualizar")
                {
                    //Si no se a seleccionado un archivo
                    if (!Archivo.HasFile)
                    {
                        Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(146), this, "Alert");
                    }
                    else
                    {
                        //Determina si es actualización o creación del anexo
                        if (hddIdDocumento.Value == "")
                        {
                            string txtFormato      = "Link";
                            string codFormato      = String.Empty;
                            string NomFormato      = String.Empty;
                            string RutaHttpDestino = String.Empty;
                            int    CodCarpeta      = 0;

                            //Valida que las siguientes extensiones no se suban
                            if (txtFormato.ToLower() == ".asp" || txtFormato.ToLower() == "php" || txtFormato.ToLower() == "xml" || txtFormato.ToLower() == "aspx" || txtFormato.ToLower() == "exe")
                            {
                                Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(154), this, "Alert");
                            }

                            //Se extrae la información de la extensión del archivo. Si no existe se crea su registro en la base de datos
                            string[] extension = Archivo.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;
                            }

                            //Se trae el nombre de la sección escogida para generar el directorio
                            string nomtab = Negocio.PlanDeNegocioV2.Utilidad.General.getNombreTab(CodigoTab);

                            CodCarpeta      = Convert.ToInt32(CodigoProyecto) / 2000;
                            RutaHttpDestino = ConfigurationManager.AppSettings.Get("DirVirtual") + "FonadeDocumentos\\Anexos\\Usuario" + usuario.IdContacto + "\\" + nomtab + "\\";
                            var rutaFull = ConfigurationManager.AppSettings.Get("RutaIP") + RutaHttpDestino;

                            //Si el archivo existe se descarta
                            if (System.IO.File.Exists(rutaFull + Archivo.FileName))
                            {
                                Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(155), this, "Alert");
                            }
                            else
                            {
                                if (!System.IO.Directory.Exists(rutaFull))
                                {
                                    System.IO.Directory.CreateDirectory(rutaFull);
                                }

                                //Se salva el archivo
                                Archivo.SaveAs(rutaFull + Archivo.FileName);
                                RutaHttpDestino = RutaHttpDestino + Archivo.FileName;

                                //Se genera el registro del documento
                                Documento nuevodoc = new Documento()
                                {
                                    NomDocumento        = NomDocumento.Text.Trim(),
                                    URL                 = RutaHttpDestino,
                                    Fecha               = DateTime.Now,
                                    CodProyecto         = CodigoProyecto,
                                    CodDocumentoFormato = byte.Parse(codFormato),
                                    CodContacto         = usuario.IdContacto,
                                    Comentario          = Comentario.Text.Trim(),
                                    CodTab              = (short)CodigoTab,
                                    CodEstado           = (byte)EstadoProyecto
                                };

                                if (Negocio.PlanDeNegocioV2.Formulacion.Anexos.Anexos.setDocumento(nuevodoc, true, false))
                                {
                                    Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(148), this, "Alert");
                                    Cerrar();
                                }
                                else
                                {
                                    Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(149), this, "Alert");
                                }
                            }
                        }
                        else
                        {
                            //Se crea el registro del documento
                            Documento actualdoc = new Documento()
                            {
                                NomDocumento = NomDocumento.Text.Trim(),
                                URL          = "",
                                Comentario   = Comentario.Text.Trim(),
                                CodTab       = (short)CodigoTab,
                                Id_Documento = int.Parse(hddIdDocumento.Value)
                            };

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

                            hddIdDocumento.Value = string.Empty;
                        }
                    }
                }
                //Se actualiza el documento existente
                else
                {
                    var documento = Negocio.PlanDeNegocioV2.Formulacion.Anexos.Anexos.getDocumentoNormal(Convert.ToInt32(ViewState["idDocumento2"].ToString()));

                    if (documento != null)
                    {
                        documento.NomDocumento = NomDocumento.Text.Trim();
                        documento.Comentario   = Comentario.Text.Trim();

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

                        Cerrar();
                    }
                    else
                    {
                        Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(154), this, "Alert");
                    }
                }
            }
            catch (Exception ex)
            {
                Utilidad.Utilidades.PresentarMsj(Mensajes.GetMensaje(7), this, "Alert");
            }
        }