Ejemplo n.º 1
0
    protected void chkPublicar_CheckedChanged(object sender, EventArgs e)
    {
        ConosudDataContext dc = new ConosudDataContext();

        CabeceraHojasDeRuta cab = (from C in dc.CabeceraHojasDeRutas
                                   where C.IdCabeceraHojasDeRuta == _idCabecera
                                   select C).Single <CabeceraHojasDeRuta>();

        cab.Publicar = chkPublicar.Checked;

        dc.SubmitChanges();
    }
Ejemplo n.º 2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (GridView1.Rows.Count > 0)
        {
            foreach (GridViewRow row in GridView1.Rows)
            {
                long IdCabecera = long.Parse((row.FindControl("lblId") as Label).Text);
                bool isCheck    = (row.FindControl("chkPublicar") as CheckBox).Checked;

                CabeceraHojasDeRuta Cabecera = (from C in db.CabeceraHojasDeRutas
                                                where C.IdCabeceraHojasDeRuta == IdCabecera
                                                select C).Single <CabeceraHojasDeRuta>();

                Cabecera.Publicar = isCheck;
            }

            db.SubmitChanges();

            GridView1.DataSource = null;
            GridView1.DataBind();
            TxPeriodo.Text = "";
        }
    }
    protected void btnBusquedaPrincipal_Click(object sender, ImageClickEventArgs e)
    {
        #region Codigo Anterior
        //bool CargoElementos = false;
        //lblEmpresa.Text = cboEmpresasAjax.SelectedItem.Text;
        //lblNroCont.Text = cboContratosAjax.SelectedItem.Text;
        //lblPeriodo.Text = cboPriodosAjax.SelectedItem.Text;


        //_nombreArchivo = @"ComentariosHoja.pdf";
        //_rutaArchivo = Server.MapPath(Request.ApplicationPath) + "\\Documentos\\";

        //imgReporte.Attributes["onClick"] = "AbrirDocumento('" + _nombreArchivo + "')";

        //Document document = new Document(PageSize.A4);

        //try
        //{
        //    Font font;

        //    PdfWriter.GetInstance(document, new FileStream(_rutaArchivo + _nombreArchivo, FileMode.Create));
        //    document.Open();

        //    string rutaImagen = Server.MapPath(Request.ApplicationPath) + @"\images\Encabezdo.png";
        //    iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance(rutaImagen);
        //    png.SetAbsolutePosition(20, 770);
        //    png.ScalePercent(20);
        //    document.Add(png);


        //    // PAGE 1
        //    Paragraph par = new Paragraph("Lujan de Cuyo");
        //    par.Alignment = 2;
        //    document.Add(par);


        //    par = new Paragraph(DateTime.Now.ToLongDateString());
        //    par.Alignment = 2;
        //    document.Add(par);


        //    string encabezado = "            A Continuación se detallan los comentarios para la hoja de ruta correspondiente al período " + cboPriodosAjax.SelectedItem.Text + ".";


        //    par = new Paragraph(encabezado);
        //    par.SpacingBefore= 15;
        //    par.SpacingAfter = 15;
        //    document.Add(par);


        //    List listInicial = new List(false, 20);


        //    List Empresaslist = new List(false, 20);
        //    Empresaslist.Add(new iTextSharp.text.ListItem("Empresa: " + cboEmpresasAjax.SelectedItem.Text));

        //    List ContratosList = new List(false, 20);
        //    ContratosList.Add(new iTextSharp.text.ListItem("Nro. Contrato:" + cboContratosAjax.SelectedItem.Text));


        //    List ContratistasList = new List(false, 20);
        //    ContratistasList.Add(new iTextSharp.text.ListItem("Contratista: " + cboContratistasAjax.SelectedItem.Text));


        //    DateTime Fecha = Convert.ToDateTime("01/" + cboPriodosAjax.SelectedItem.Text.Substring(5, 2) + "/" + cboPriodosAjax.SelectedItem.Text.Substring(0, 4));
        //    List ConObsList = new List(false, 50);
        //    font = new Font();
        //    font = FontFactory.GetFont("Verdana", 12, Font.UNDERLINE);
        //    font.Color = Color.BLUE;
        //    ConObsList.ListSymbol = new Chunk("");
        //    ConObsList.Add(new iTextSharp.text.ListItem(string.Format("COMENTARIOS {0:MMMM} del {0:yyyy}", Fecha).ToUpper(), font));



        //    GenerarMesesConComentarios(ConObsList, Convert.ToInt64(cboContratistasAjax.SelectedItem.Value), out CargoElementos);
        //    if (CargoElementos)
        //        ContratistasList.Add(ConObsList);



        //    listInicial.Add(Empresaslist);
        //    Empresaslist.Add(ContratosList);
        //    ContratosList.Add(ContratistasList);
        //    document.Add(listInicial);

        //}
        //catch (DocumentException de)
        //{
        //    Console.Error.WriteLine(de.Message);
        //}
        //catch (IOException ioe)
        //{
        //    Console.Error.WriteLine(ioe.Message);
        //}

        //// step 5: we close the document
        //document.Close();
        //tblDetalleResumen.Visible = true;
        #endregion


        ConosudDataContext  db  = new ConosudDataContext();
        CabeceraHojasDeRuta cab = (from C in db.CabeceraHojasDeRutas
                                   where C.IdCabeceraHojasDeRuta == int.Parse(cboPriodosAjax.SelectedItem.Value)
                                   select C).Single <CabeceraHojasDeRuta>();

        if (!cab.Publicar.Value && this.Session["TipoUsuario"] != null)
        {
            tblDetalleResumen.Visible     = false;
            tblDetalleEnAuditoria.Visible = true;
        }
        else
        {
            bool CargoElementos = false;
            lblEmpresa.Text = cboEmpresasAjax.SelectedItem.Text;
            lblNroCont.Text = cboContratosAjax.SelectedItem.Text;
            lblPeriodo.Text = cboPriodosAjax.SelectedItem.Text;


            _nombreArchivo = @"ComentariosHoja.pdf";
            _rutaArchivo   = Server.MapPath(Request.ApplicationPath) + "\\Documentos\\";

            imgReporte.Attributes["onClick"] = "AbrirDocumento('" + _nombreArchivo + "')";

            Document document = new Document(PageSize.A4);

            try
            {
                Font font;
                PdfWriter.GetInstance(document, new FileStream(_rutaArchivo + _nombreArchivo, FileMode.Create));
                document.Open();

                string rutaImagen         = Server.MapPath(Request.ApplicationPath) + @"\images\Encabezdo.png";
                iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance(rutaImagen);
                png.SetAbsolutePosition(20, 770);
                png.ScalePercent(20);
                document.Add(png);


                // PAGE 1
                Paragraph par = new Paragraph("Lujan de Cuyo");
                par.Alignment = 2;
                document.Add(par);


                par           = new Paragraph(DateTime.Now.ToLongDateString());
                par.Alignment = 2;
                document.Add(par);


                string encabezado = "            A Continuación se detallan los comentarios para la hoja de ruta correspondiente al período " + cboPriodosAjax.SelectedItem.Text + ".";


                par = new Paragraph(encabezado);
                par.SpacingBefore = 15;
                par.SpacingAfter  = 15;
                document.Add(par);


                List listInicial = new List(false, 20);

                List ContratosList = new List(false, 20);
                ContratosList.Add(new iTextSharp.text.ListItem("Contrato:" + cboContratosAjax.SelectedItem.Text));

                DateTime Fecha        = Convert.ToDateTime("01/" + cboPriodosAjax.SelectedItem.Text.Substring(5, 2) + "/" + cboPriodosAjax.SelectedItem.Text.Substring(0, 4));
                List     DetalleItems = new List(false, 20);
                DetalleItems = GenerarDetalleItem(out CargoElementos, Fecha);

                listInicial.Add(ContratosList);
                ContratosList.Add(DetalleItems);
                document.Add(listInicial);
            }
            catch (DocumentException de)
            {
                Console.Error.WriteLine(de.Message);
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.Message);
            }

            // step 5: we close the document
            document.Close();
            tblDetalleResumen.Visible     = true;
            tblDetalleEnAuditoria.Visible = false;
        }
    }
    protected void btnBusquedaPrincipal_Click(object sender, ImageClickEventArgs e)
    {
        //bool CargoElementos = false;
        //lblEmpresa.Text = cboEmpresasAjax.SelectedItem.Text;
        //lblNroCont.Text = cboContratosAjax.SelectedItem.Text;
        //lblPeriodo.Text = cboPriodosAjax.SelectedItem.Text;


        //_nombreArchivo = @"Resumen" + cboEmpresasAjax.SelectedItem.Text + cboContratosAjax.SelectedItem.Text + cboPriodosAjax.SelectedItem.Text.Replace("/", "") + ".pdf";
        //_nombreArchivo = _nombreArchivo.Replace("/", "-");
        //_rutaArchivo = Server.MapPath(Request.ApplicationPath) + "\\Documentos\\";

        //imgReporte.Attributes["onClick"] = "AbrirDocumento('" + _nombreArchivo + "')";

        //// step 1: creation of a document-object
        //Document document = new Document(PageSize.A4);

        //try
        //{
        //    Font font;
        //    Chunk chunk;


        //    // step 2: we create a writer that listens to the document
        //    PdfWriter.GetInstance(document, new FileStream(_rutaArchivo + _nombreArchivo, FileMode.Create));

        //    //// we Add a Footer that will show up on PAGE 1
        //    //HeaderFooter footer = new HeaderFooter(new Phrase("This is page: "), true);
        //    //footer.Border = Rectangle.NO_BORDER;
        //    //document.Footer = footer;

        //    //// we Add a Header that will show up on PAGE 2
        //    //HeaderFooter header = new HeaderFooter( new Phrase("This is a header"), false);
        //    //header.Alignment = 1;
        //    //document.Header = header;

        //    // step 3: we open the document
        //    document.Open();

        //    string rutaImagen = Server.MapPath(Request.ApplicationPath) + @"\images\Encabezdo.png";
        //    iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance(rutaImagen);
        //    png.SetAbsolutePosition(20, 770);
        //    png.ScalePercent(20);
        //    document.Add(png);

        //    // step 4: we Add content to the document

        //    // PAGE 1
        //    Paragraph par = new Paragraph("Lujan de Cuyo");
        //    par.Alignment = 2;
        //    document.Add(par);


        //    par = new Paragraph(DateTime.Now.ToLongDateString());
        //    par.Alignment = 2;
        //    document.Add(par);

        //    par = new Paragraph("Señor Jefe");
        //    par.Alignment = 0;
        //    document.Add(par);

        //    font = new Font();
        //    font = FontFactory.GetFont("Verdana", 12, Font.UNDERLINE);
        //    chunk = new Chunk("CONTRATOS Y.P.F.", font);
        //    par = new Paragraph(chunk);
        //    document.Add(par);



        //    string subcontratistas =", ";
        //    if (Helpers._SubContratistas.Count >1)
        //    {
        //        subcontratistas =", y subcontratistas: ";
        //        foreach (string emp in Helpers._SubContratistas.Keys)
        //        {
        //            if (emp != cboEmpresasAjax.SelectedItem.Text)
        //                subcontratistas += emp + ", ";
        //        }
        //    }

        //    string encabezado= "            Luego de recibida y controlada la documentación por el contrato " + cboContratosAjax.SelectedItem.Text + " de la empresa " + cboEmpresasAjax.SelectedItem.Text +
        //        subcontratistas + "por el período " + cboPriodosAjax.SelectedItem.Text + " (y meses anteriores, si corresponde), se informa a continuación los pendientes:";

        //    par = new Paragraph(encabezado);
        //    par.SpacingBefore= 15;
        //    par.SpacingAfter = 15;
        //    document.Add(par);



        //    List listInicial = new List(false, 20);


        //    List Empresaslist = new List(false, 20);
        //    Empresaslist.Add(new iTextSharp.text.ListItem("Empresa: " + cboEmpresasAjax.SelectedItem.Text));

        //    List ContratosList = new List(false, 20);
        //    ContratosList.Add(new iTextSharp.text.ListItem("Nro. Contrato:" + cboContratosAjax.SelectedItem.Text));



        //    List ContratistasList = new List(false, 20);
        //    ContratistasList.Add(new iTextSharp.text.ListItem("Contratista: " + cboContratistasAjax.SelectedItem.Text));


        //    List SinDocList = new List(false,50);
        //    font = new Font();
        //    font = FontFactory.GetFont("Verdana", 12, Font.UNDERLINE);
        //    font.Color = Color.RED;
        //    SinDocList.ListSymbol = new Chunk("");
        //    SinDocList.Add(new iTextSharp.text.ListItem("MESES SIN DOCUMENTACION PRESENTADA", font));

        //    List ConObsList = new List(false, 50);
        //    font = new Font();
        //    font = FontFactory.GetFont("Verdana", 12, Font.UNDERLINE);
        //    font.Color = Color.BLUE;
        //    ConObsList.ListSymbol = new Chunk("");
        //    ConObsList.Add(new iTextSharp.text.ListItem("MESES CON OBSERVACIONES", font));

        //    List EstimacionList = new List(false, 50);
        //    font = new Font();
        //    font = FontFactory.GetFont("Verdana", 12, Font.UNDERLINE);
        //    font.Color = new Color(System.Drawing.Color.DarkTurquoise);
        //    EstimacionList.ListSymbol = new Chunk("");
        //    EstimacionList.Add(new iTextSharp.text.ListItem("ESTIMACION", font));


        //    SinDocList = GenerarMeseSinDocumentacion(SinDocList, Convert.ToInt64(cboContratistasAjax.SelectedItem.Value), out CargoElementos);
        //    if (CargoElementos)
        //        ContratistasList.Add(SinDocList);

        //    GenerarMesesConComentarios(ConObsList, Convert.ToInt64(cboContratistasAjax.SelectedItem.Value), out CargoElementos);
        //    if (CargoElementos)
        //        ContratistasList.Add(ConObsList);

        //    ObtenerEstimacion(EstimacionList, Convert.ToInt64(cboPriodosAjax.SelectedItem.Value),out CargoElementos);
        //    if(CargoElementos)
        //        ContratistasList.Add(EstimacionList);

        //    foreach (DSConosud.ContratoEmpresasRow subContratistas in Helpers._SubContratistas.Values)
        //    {
        //        if (subContratistas["RazonSocial"].ToString() != cboEmpresasAjax.SelectedItem.Text)
        //        {
        //            ContratistasList.Add(new iTextSharp.text.ListItem("Subcontratista: " + subContratistas["RazonSocial"].ToString()));


        //            SinDocList = new List(false, 50);
        //            font = new Font();
        //            font = FontFactory.GetFont("Verdana", 12, Font.UNDERLINE);
        //            font.Color = Color.RED;
        //            SinDocList.ListSymbol = new Chunk("");
        //            SinDocList.Add(new iTextSharp.text.ListItem("MESES SIN DOCUMENTACION PRESENTADA", font));


        //            ConObsList = new List(false, 50);
        //            font = new Font();
        //            font = FontFactory.GetFont("Verdana", 12, Font.UNDERLINE);
        //            font.Color = Color.BLUE;
        //            ConObsList.ListSymbol = new Chunk("");
        //            ConObsList.Add(new iTextSharp.text.ListItem("MESES CON OBSERVACIONES", font));


        //            SinDocList = GenerarMeseSinDocumentacion(SinDocList, subContratistas.IdContratoEmpresas, out CargoElementos);
        //            if (CargoElementos)
        //                ContratistasList.Add(SinDocList);

        //            ConObsList = GenerarMesesConComentarios(ConObsList, subContratistas.IdContratoEmpresas, out CargoElementos);
        //            if (CargoElementos)
        //                ContratistasList.Add(ConObsList);

        //        }

        //    }


        //    listInicial.Add(Empresaslist);
        //    Empresaslist.Add(ContratosList);
        //    ContratosList.Add(ContratistasList);
        //    document.Add(listInicial);


        //}
        //catch (DocumentException de)
        //{
        //    Console.Error.WriteLine(de.Message);
        //}
        //catch (IOException ioe)
        //{
        //    Console.Error.WriteLine(ioe.Message);
        //}

        //// step 5: we close the document
        //document.Close();
        //tblDetalleResumen.Visible = true;


        ConosudDataContext  db  = new ConosudDataContext();
        CabeceraHojasDeRuta cab = (from C in db.CabeceraHojasDeRutas
                                   where C.IdCabeceraHojasDeRuta == int.Parse(cboPriodosAjax.SelectedItem.Value)
                                   select C).Single <CabeceraHojasDeRuta>();

        if (!cab.Publicar.Value && this.Session["TipoUsuario"] != null)
        {
            tblDetalleResumen.Visible     = false;
            tblDetalleEnAuditoria.Visible = true;
        }
        else
        {
            bool CargoElementos = false;
            lblEmpresa.Text = cboEmpresasAjax.SelectedItem.Text;
            lblNroCont.Text = cboContratosAjax.SelectedItem.Text;
            lblPeriodo.Text = cboPriodosAjax.SelectedItem.Text;


            _nombreArchivo = @"ComentariosHoja.pdf";
            _rutaArchivo   = Server.MapPath(Request.ApplicationPath) + "\\Documentos\\";

            imgReporte.Attributes["onClick"] = "AbrirDocumento('" + _nombreArchivo + "')";

            Document document = new Document(PageSize.A4);

            try
            {
                Font  font;
                Chunk chunk;


                // step 2: we create a writer that listens to the document
                PdfWriter.GetInstance(document, new FileStream(_rutaArchivo + _nombreArchivo, FileMode.Create));

                //// we Add a Footer that will show up on PAGE 1
                //HeaderFooter footer = new HeaderFooter(new Phrase("This is page: "), true);
                //footer.Border = Rectangle.NO_BORDER;
                //document.Footer = footer;

                //// we Add a Header that will show up on PAGE 2
                //HeaderFooter header = new HeaderFooter( new Phrase("This is a header"), false);
                //header.Alignment = 1;
                //document.Header = header;

                // step 3: we open the document
                document.Open();

                string rutaImagen         = Server.MapPath(Request.ApplicationPath) + @"\images\Encabezdo.png";
                iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance(rutaImagen);
                png.SetAbsolutePosition(20, 770);
                png.ScalePercent(20);
                document.Add(png);

                // step 4: we Add content to the document

                // PAGE 1
                Paragraph par = new Paragraph("Lujan de Cuyo");
                par.Alignment = 2;
                document.Add(par);


                par           = new Paragraph(DateTime.Now.ToLongDateString());
                par.Alignment = 2;
                document.Add(par);

                par           = new Paragraph("Señor Jefe");
                par.Alignment = 0;
                document.Add(par);

                font  = new Font();
                font  = FontFactory.GetFont("Verdana", 12, Font.UNDERLINE);
                chunk = new Chunk("CONTRATOS Y.P.F.", font);
                par   = new Paragraph(chunk);
                document.Add(par);



                string subcontratistas = ", ";
                if (Helpers._SubContratistas.Count > 1)
                {
                    subcontratistas = ", y subcontratistas: ";
                    foreach (string emp in Helpers._SubContratistas.Keys)
                    {
                        if (emp != cboEmpresasAjax.SelectedItem.Text)
                        {
                            subcontratistas += emp + ", ";
                        }
                    }
                }

                string encabezado = "            Luego de recibida y controlada la documentación por el contrato " + cboContratosAjax.SelectedItem.Text + " de la empresa " + cboEmpresasAjax.SelectedItem.Text +
                                    subcontratistas + "por el período " + cboPriodosAjax.SelectedItem.Text + " (y meses anteriores, si corresponde), se informa a continuación los pendientes:";

                par = new Paragraph(encabezado);
                par.SpacingBefore = 15;
                par.SpacingAfter  = 15;
                document.Add(par);


                List listInicial = new List(false, 20);

                List ContratosList = new List(false, 20);
                ContratosList.Add(new iTextSharp.text.ListItem("Contrato:" + cboContratosAjax.SelectedItem.Text));

                DateTime Fecha        = Convert.ToDateTime("01/" + cboPriodosAjax.SelectedItem.Text.Substring(5, 2) + "/" + cboPriodosAjax.SelectedItem.Text.Substring(0, 4));
                List     DetalleItems = new List(false, 20);
                DetalleItems = GenerarDetalleItem(out CargoElementos, Fecha);

                listInicial.Add(ContratosList);
                ContratosList.Add(DetalleItems);
                document.Add(listInicial);
            }
            catch (DocumentException de)
            {
                Console.Error.WriteLine(de.Message);
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.Message);
            }

            // step 5: we close the document
            document.Close();
            tblDetalleResumen.Visible     = true;
            tblDetalleEnAuditoria.Visible = false;
        }
    }