Пример #1
0
        private string cargar_Grilla()
        {
            string sError = "";

            DataTable dt = new DataTable();

            nPrensa unaPrensaN = new nPrensa();
            sError = unaPrensaN.Buscar_Todos(ref dt);
            grdPrensa.DataSource = dt;
            grdPrensa.DataBind();

            return sError;
        }
Пример #2
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            if (documento != "")
            {
                // Create a name for the file to store
                HttpPostedFile myFile = fuDocumento.PostedFile;

                if (!DocumentoExiste(documento))
                {
                    if (myFile.FileName != null & myFile.FileName != "")
                    {
                        int nFileLen = myFile.ContentLength;
                        // Allocate a buffer for reading of the file
                        // make sure the size of the file is > 0
                        if (nFileLen > 0)
                        {
                            byte[] myData = new byte[nFileLen];
                            myFile.InputStream.Read(myData, 0, nFileLen);

                            // Create a name for the file to store
                            string strFilename = "\\Prensa\\" + Path.GetFileName(myFile.FileName);

                            // Write data into a file
                            WriteToFile(Server.MapPath(strFilename), ref myData);

                        }
                    }

                    oPrensa unaPrensa = new oPrensa();
                    unaPrensa.titulo = txtTitulo.Text;
                    unaPrensa.adjunto = documento;

                    nPrensa nPrensa = new nPrensa();
                    nPrensa.Alta(ref unaPrensa);

                    string sError = cargar_Grilla();
                }
            }
            else
            {
                Response.Write("<script type='text/javascript' language='javascript'> alert('La entrada de prensa seleccionada ya se encuentra cargada.');</script>");
            }
        }
Пример #3
0
        protected void grdPrensa_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string sError = "";
            if (int.Parse(e.CommandArgument.ToString()) > 0)
            {
                try
                {
                    nPrensa unaPrensaN = new nPrensa();
                    oPrensa unaPrensaO = new oPrensa();
                    sError = unaPrensaN.Buscar_Uno(int.Parse(e.CommandArgument.ToString()), ref unaPrensaO);

                    System.Diagnostics.Process.Start(Server.MapPath(unaPrensaO.adjunto.Substring(1)));
                }
                catch (Exception ex)
                {
                    Response.Write("<script type='text/javascript' language='javascript'> alert('" + ex.Message + "');</script>");
                }
            }
        }
Пример #4
0
        protected void BtnModificar_Click(object sender, EventArgs e)
        {
            oPrensa unaPrensaModif = new oPrensa();
               if (documentoEditar != "")
            {
                // Create a name for the file to store
                if (!viodocumento)
                {
                    HttpPostedFile myFile = fuDocumentoEditar.PostedFile;

                    if (myFile.FileName != null & myFile.FileName != "")
                    {
                        int nFileLen = myFile.ContentLength;
                        // Allocate a buffer for reading of the file
                        // make sure the size of the file is > 0
                        if (nFileLen > 0)
                        {
                            byte[] myData = new byte[nFileLen];
                            myFile.InputStream.Read(myData, 0, nFileLen);

                            // Create a name for the file to store
                            string strFilename = "\\Prensa\\" + Path.GetFileName(myFile.FileName);

                            // Write data into a file
                            WriteToFile(Server.MapPath(strFilename), ref myData);
                            //documento = strFilename.Substring(strFilename.LastIndexOf("\\") + 1);

                            unaPrensaModif.adjunto = documentoEditar;
                        }
                    }
                }
                else
                {
                    unaPrensaModif.adjunto = documentoEditar;
                }
            }

            unaPrensaModif.id = int.Parse(hId.Value.ToString());
            unaPrensaModif.titulo = txtTituloEditar.Text;
            unaPrensaModif.adjunto = documentoEditar;

            nPrensa nPrensa = new nPrensa();
            nPrensa.Modificar(unaPrensaModif);

            string sError = cargar_Grilla();

            formModificar.Visible = false;
            viodocumento = false;
        }
Пример #5
0
 private bool DocumentoExiste(string adjunto)
 {
     nPrensa unaPrensaN = new nPrensa();
     return unaPrensaN.Buscar_Uno(adjunto);
 }
Пример #6
0
        protected void grdPrensa_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Editar")
            {
                string sError = "";
                try
                {
                    if (int.Parse(e.CommandArgument.ToString()) > 0)
                    {
                        nPrensa unaPrensaN = new nPrensa();
                        oPrensa unaPrensaO = new oPrensa();
                        sError = unaPrensaN.Buscar_Uno(int.Parse(e.CommandArgument.ToString()), ref unaPrensaO);

                        hId.Value = unaPrensaO.id.ToString();
                        txtTituloEditar.Text = unaPrensaO.titulo;
                        formModificar.Visible = true;

                    }
                }
                catch (Exception ex)
                {
                    Response.Write("<script type='text/javascript' language='javascript'> alert('" + sError + "');</script>");
                }
            }
            else
            {
                if (e.CommandName == "Ver")
                {
                    string sError = "";
                    if (int.Parse(e.CommandArgument.ToString()) > 0)
                    {
                        try
                        {
                            nPrensa unaPrensaN = new nPrensa();
                            oPrensa unaPrensaO = new oPrensa();
                            sError = unaPrensaN.Buscar_Uno(int.Parse(e.CommandArgument.ToString()), ref unaPrensaO);

                            System.Diagnostics.Process.Start(Server.MapPath(unaPrensaO.adjunto));
                        }
                        catch (Exception ex)
                        {
                            Response.Write("<script type='text/javascript' language='javascript'> alert('" + ex.Message + "');</script>");
                        }
                    }
                }
                else
                {
                    if (e.CommandName == "Eliminar")
                    {
                        string sError = "";
                        if (int.Parse(e.CommandArgument.ToString()) > 0)
                        {
                            try
                            {
                                nPrensa unaPrensaN = new nPrensa();
                                oPrensa unaPrensaO = new oPrensa();
                                sError = unaPrensaN.Eliminar(e.CommandArgument.ToString());
                                cargar_Grilla();
                            }
                            catch (Exception ex)
                            {
                                Response.Write("<script type='text/javascript' language='javascript'> alert('" + ex.Message + "');</script>");
                            }
                        }
                    }
                }
            }
        }