Example #1
0
            public byte[] Generado()
            {
                using (var XlsPack = new ExcelPackage())
                {
                    XlsPack.Workbook.Properties.Author = "Glasser";
                    XlsPack.Workbook.Properties.Title  = "Informe Pedidos " + DateTime.Today.ToShortDateString();
                    var hoja1 = XlsPack.Workbook.Worksheets.Add("Pedidos");
                    hoja1.Name = "Pedidos";
                    hoja1.PrinterSettings.PaperSize = ePaperSize.Letter;


                    hoja1.Column(2).Width       = 60;
                    hoja1.Column(3).Width       = 20;
                    hoja1.Column(4).Width       = 20;
                    hoja1.Column(5).Width       = 10;
                    hoja1.Column(6).Width       = 10;
                    hoja1.Column(7).Width       = 25;
                    hoja1.Column(8).Width       = 18;
                    hoja1.Column(9).Width       = 12;
                    hoja1.Row(6).Height         = 30;
                    hoja1.Row(6).Style.WrapText = true;
                    #region Header


                    int row  = 2;
                    int col1 = 1;

                    cell                           = hoja1.Cells[row, col1];
                    cell.Merge                     = true;
                    cell.Value                     = "Cliente: ";
                    cell.Style.Font.Bold           = true;
                    cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
                    border                         = cell.Style.Border;
                    border.Bottom.Style            = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.None;
                    col1++;

                    cell                           = hoja1.Cells[row, col1];
                    cell.Merge                     = true;
                    cell.Value                     = _Cli.Nombre;
                    cell.Style.Font.Bold           = true;
                    cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
                    border                         = cell.Style.Border;
                    border.Bottom.Style            = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.None;
                    col1++;

                    row++;
                    col1                           = 1;
                    cell                           = hoja1.Cells[row, col1];
                    cell.Merge                     = true;
                    cell.Value                     = "Rut: ";
                    cell.Style.Font.Bold           = true;
                    cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
                    border                         = cell.Style.Border;
                    border.Bottom.Style            = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.None;
                    col1++;

                    cell                           = hoja1.Cells[row, col1];
                    cell.Merge                     = true;
                    cell.Value                     = _Cli.Rut;
                    cell.Style.Font.Bold           = true;
                    cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
                    border                         = cell.Style.Border;
                    border.Bottom.Style            = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.None;
                    col1++;


                    /*--Item--*/
                    row                            = 6;
                    col1                           = 1;
                    cell                           = hoja1.Cells[row, col1];
                    cell.Merge                     = true;
                    cell.Value                     = "Item";
                    cell.Style.Font.Bold           = true;
                    cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                    border                         = cell.Style.Border;
                    border.Bottom.Style            = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin;
                    col1++;

                    /*--nombre--*/
                    cell                           = hoja1.Cells[row, col1];
                    cell.Merge                     = true;
                    cell.Value                     = "Pedido";
                    cell.Style.Font.Bold           = true;
                    cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                    border                         = cell.Style.Border;
                    border.Bottom.Style            = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin;
                    col1++;

                    /*--Nro--*/
                    cell                           = hoja1.Cells[row, col1];
                    cell.Merge                     = true;
                    cell.Value                     = "Números de Pedido";
                    cell.Style.Font.Bold           = true;
                    cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                    border                         = cell.Style.Border;
                    border.Bottom.Style            = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin;
                    col1++;

                    /*--Tipo--*/
                    cell                           = hoja1.Cells[row, col1];
                    cell.Merge                     = true;
                    cell.Value                     = "Tipo";
                    cell.Style.Font.Bold           = true;
                    cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                    border                         = cell.Style.Border;
                    border.Bottom.Style            = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin;
                    col1++;

                    /*--Cantidad--*/
                    cell                           = hoja1.Cells[row, col1];
                    cell.Merge                     = true;
                    cell.Value                     = "Cantidad";
                    cell.Style.Font.Bold           = true;
                    cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                    border                         = cell.Style.Border;
                    border.Bottom.Style            = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin;
                    col1++;

                    /*--Total--*/
                    cell                           = hoja1.Cells[row, col1];
                    cell.Merge                     = true;
                    cell.Value                     = "Neto";
                    cell.Style.Font.Bold           = true;
                    cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                    border                         = cell.Style.Border;
                    border.Bottom.Style            = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin;
                    col1++;

                    /*--Ingresado por--*/
                    cell                           = hoja1.Cells[row, col1];
                    cell.Merge                     = true;
                    cell.Value                     = "Ingresado por";
                    cell.Style.Font.Bold           = true;
                    cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                    border                         = cell.Style.Border;
                    border.Bottom.Style            = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin;
                    col1++;

                    /*--fentre--*/
                    cell                           = hoja1.Cells[row, col1];
                    cell.Merge                     = true;
                    cell.Value                     = "Fecha Entrega";
                    cell.Style.Font.Bold           = true;
                    cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                    border                         = cell.Style.Border;
                    border.Bottom.Style            = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin;
                    col1++;

                    /*--Estado--*/
                    cell                           = hoja1.Cells[row, col1];
                    cell.Merge                     = true;
                    cell.Value                     = "Estado";
                    cell.Style.Font.Bold           = true;
                    cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                    border                         = cell.Style.Border;
                    border.Bottom.Style            = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin;
                    col1++;
                    #endregion

                    row++;
                    int cont = 1;

                    foreach (PedidoEcom item in Items)
                    {
                        int col = 1;
                        /*item*/
                        cell       = hoja1.Cells[row, col];
                        cell.Merge = true;
                        cell.Value = cont;
                        cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                        border = cell.Style.Border;
                        border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.None;
                        col++;

                        /*Nombre*/
                        cell       = hoja1.Cells[row, col];
                        cell.Merge = true;
                        cell.Value = item.Nombre;
                        cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
                        border = cell.Style.Border;
                        border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.None;
                        col++;

                        /*Nros*/
                        cell       = hoja1.Cells[row, col];
                        cell.Merge = true;
                        cell.Value = item.NroPedido;
                        cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                        border = cell.Style.Border;
                        border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.None;
                        col++;

                        /*Tipo*/
                        string Tipo = null;
                        if (item.OrderType == "TER")
                        {
                            Tipo = "Termopanel";
                        }
                        else if (item.OrderType == "TEM")
                        {
                            Tipo = "Templado";
                        }
                        cell       = hoja1.Cells[row, col];
                        cell.Merge = true;
                        cell.Value = Tipo;
                        cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                        border = cell.Style.Border;
                        border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.None;
                        col++;

                        /*Cant*/
                        cell       = hoja1.Cells[row, col];
                        cell.Merge = true;
                        cell.Value = item.CanTotal;
                        cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                        border = cell.Style.Border;
                        border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.None;
                        col++;

                        /*Neto*/
                        cell       = hoja1.Cells[row, col];
                        cell.Merge = true;
                        cell.Value = item.Neto;
                        cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                        border = cell.Style.Border;
                        border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.None;
                        col++;

                        /*Usuario*/
                        GlasserUser.GetInfo GGI = new GlasserUser.GetInfo(item.UserId);
                        string Usuario;
                        if (GGI.IsSuccess)
                        {
                            Usuario = GGI.Datos.Nombre + " " + GGI.Datos.Apellido;
                        }
                        else
                        {
                            Usuario = item.UserId;
                        }
                        /*Usuario*/
                        cell       = hoja1.Cells[row, col];
                        cell.Merge = true;
                        cell.Value = Usuario;
                        cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
                        border = cell.Style.Border;
                        border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.None;
                        col++;

                        /*Fentrega*/
                        cell       = hoja1.Cells[row, col];
                        cell.Merge = true;
                        cell.Value = item.F_Entrega;
                        cell.Style.Numberformat.Format = "dd-mm-yyyy";
                        cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                        border = cell.Style.Border;
                        border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.None;
                        col++;

                        string Estado;

                        if (item.Estado == "BOR")
                        {
                            Estado = " Borrador";
                        }
                        else if (item.Estado == "DES")
                        {
                            Estado = " Entregado";
                        }
                        else if (item.Estado == "ING")
                        {
                            Estado = " Ingresado";
                        }
                        else if (item.Estado == "PRG")
                        {
                            Estado = " En Fabricación";
                        }
                        else if (item.Estado == "DIS")
                        {
                            Estado = " Bodega";
                        }
                        else
                        {
                            Estado = "";
                        }

                        /*Estado*/
                        cell       = hoja1.Cells[row, col];
                        cell.Merge = true;
                        cell.Value = Estado;
                        cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                        border = cell.Style.Border;
                        border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin;
                        col++;

                        cont++;
                        row++;
                    }


                    return(XlsPack.GetAsByteArray());
                }
            }
Example #2
0
    protected void FillTabla(List <PedidoEcom> Items)
    {
        HtmlGenericControl table;

        table = new HtmlGenericControl("table")
        {
            ID = "OrdersTable",
        };
        table.Attributes.Add("class", "table card-border-lila");

        /*Header*/
        HtmlGenericControl thead  = new HtmlGenericControl("thead");
        HtmlGenericControl strong = new HtmlGenericControl("strong");
        HtmlGenericControl trhead = new HtmlGenericControl("tr");
        HtmlGenericControl tbody  = new HtmlGenericControl("tbody");

        trhead.Attributes.Add("class", "CsCabecera");
        HtmlGenericControl th;
        HtmlGenericControl tr;
        HtmlGenericControl td;

        /*Nombre*/
        th = new HtmlGenericControl("th")
        {
            InnerHtml = "Pedido"
        };
        trhead.Controls.Add(th);

        /*Número*/
        th = new HtmlGenericControl("th")
        {
            InnerHtml = "Nro de Pedido"
        };
        trhead.Controls.Add(th);

        /*Tipo*/
        th = new HtmlGenericControl("th")
        {
            InnerHtml = "Tipo"
        };
        trhead.Controls.Add(th);

        /*Cantidad*/
        th = new HtmlGenericControl("th")
        {
            InnerHtml = "Cantidad"
        };
        trhead.Controls.Add(th);

        /*Total*/
        th = new HtmlGenericControl("th")
        {
            InnerHtml = "Total"
        };
        th.Attributes.Add("style", "min-width:150px;");
        trhead.Controls.Add(th);

        /*Ingresado por*/
        th = new HtmlGenericControl("th")
        {
            InnerHtml = "Ingresado por"
        };
        trhead.Controls.Add(th);

        /*Fecha de Entrega*/
        th = new HtmlGenericControl("th")
        {
            InnerHtml = "Fecha de entrega"
        };
        trhead.Controls.Add(th);

        /*Estado del pedido*/
        th = new HtmlGenericControl("th")
        {
            InnerHtml = "Estado"
        };
        trhead.Controls.Add(th);

        trhead.Controls.Add(th);
        thead.Controls.Add(trhead);
        strong.Controls.Add(thead);

        //agregar la cabecera a la tabla
        table.Controls.Add(strong);

        var items = Items.OrderByDescending(iterator => iterator.F_Ingreso).Take(CantItems);

        foreach (PedidoEcom item in items)
        {
            tr = new HtmlGenericControl("tr");
            tr.Attributes.Add("class", "pedido");
            /*Nombre*/
            td = new HtmlGenericControl("td")
            {
                InnerHtml = item.Nombre
            };
            tr.Controls.Add(td);

            /*Nombre*/
            td = new HtmlGenericControl("td")
            {
                InnerHtml = item.NroPedido
            };
            tr.Controls.Add(td);

            /*Tipo*/
            string Tipo;
            if (item.OrderType == "TER")
            {
                Tipo = "Termopanel";
            }
            else
            {
                Tipo = "";
            }
            td = new HtmlGenericControl("td")
            {
                InnerHtml = Tipo
            };
            td.Attributes.Add("style", "vertical-align: middle;");
            tr.Controls.Add(td);


            /*Cantidad*/
            td = new HtmlGenericControl("td")
            {
                InnerHtml = item.CanTotal.ToString()
            };
            td.Attributes.Add("style", "vertical-align: middle; text-align:center;");
            tr.Controls.Add(td);

            /*Total*/
            td = new HtmlGenericControl("td")
            {
                InnerHtml = item.Bruto.ToString("C0", CultureInfo.CurrentCulture)
            };
            td.Attributes.Add("style", "vertical-align: middle; text-align:center;");
            tr.Controls.Add(td);

            GlasserUser.GetInfo GGI = new GlasserUser.GetInfo(item.UserId);
            string Usuario;
            if (GGI.IsSuccess)
            {
                Usuario = GGI.Datos.Nombre + " " + GGI.Datos.Apellido;
            }
            else
            {
                Usuario = item.UserId;
            }
            /*Usuario*/

            td = new HtmlGenericControl("td")
            {
                InnerHtml = Usuario
            };
            tr.Controls.Add(td);

            string FechaE;
            if (item.F_Entrega < DateTime.Today.AddDays(-10000))
            {
                FechaE = "Sin Fecha";
            }
            else
            {
                FechaE = item.F_Entrega.ToShortDateString();
            }
            /*Fecha Entrega*/
            td = new HtmlGenericControl("td")
            {
                InnerHtml = FechaE
            };
            td.Attributes.Add("style", "vertical-align: middle; text-align:center;");
            tr.Controls.Add(td);

            /*Estado*/
            td = new HtmlGenericControl("td");

            string             Estado;
            HtmlGenericControl span = new HtmlGenericControl("span");
            HtmlGenericControl i    = new HtmlGenericControl("i");
            if (item.Estado == "BOR")
            {
                Estado = " Borrador";
                i.Attributes.Add("class", "fas fa-eraser");
                td.Attributes.Add("class", "text-mangotango");
            }
            else if (item.Estado == "DES")
            {
                Estado = " Entregado";
                i.Attributes.Add("class", "fas fa-thumbs-up");
                td.Attributes.Add("class", "text-success");
            }
            else if (item.Estado == "ING")
            {
                Estado = " Ingresado";
                i.Attributes.Add("class", "fas fa-clipboard-check");
                td.Attributes.Add("class", "text-primary");
            }
            else if (item.Estado == "PRG")
            {
                Estado = " En Fabricación";
                i.Attributes.Add("class", "fas fa-cogs");
                td.Attributes.Add("class", "text-lila");
            }
            else if (item.Estado == "DIS")
            {
                Estado = " Bodega";
                i.Attributes.Add("class", "fas fa-warehouse");
                td.Attributes.Add("class", "text-warning");
            }
            else
            {
                Estado = "";
            }

            span.InnerHtml = Estado;
            td.Controls.Add(i);
            td.Controls.Add(span);
            td.Attributes.Add("id", item.Estado);
            tr.Controls.Add(td);

            td = new HtmlGenericControl("td")
            {
                InnerHtml = item.ID
            };
            td.Attributes.Add("style", "display:none;");
            tr.Controls.Add(td);

            string ItemDetalle = "";
            if (item.OrderType == "TER")
            {
                ItemDetalle = "<p>Tipo de Orden: Termopanel.</p>";
            }
            else if (item.OrderType == "TEM")
            {
                ItemDetalle = "<p>Tipo de Orden: Templados.</p>";
            }

            if (!string.IsNullOrEmpty(item.NroPedido))
            {
                ItemDetalle += "<p>Números de pedidos: " + item.NroPedido + "</p>";
            }

            if (!string.IsNullOrWhiteSpace(item.Observa))
            {
                ItemDetalle += "<p>Observaciones: " + item.Observa + "</p>";
            }

            if (item.EsDespacho)
            {
                ItemDetalle += "<p>Despacho programado para el " + item.F_Entrega.ToLongDateString() + " en " + item.DirEntrega + "</p>";
            }
            else
            {
                ItemDetalle += "<p>Retiro programado para el " + item.F_Entrega.ToLongDateString() + "</p>";
            }

            ItemDetalle += "<div class='d-flex flex-row'>" +
                           "<div class='p-2'>Neto : </div><div class='p-2'>" + item.Neto.ToString("C0", CultureInfo.CurrentCulture) + "</div>" +
                           "</div>" +
                           "<div class='d-flex flex-row'>" +
                           "<div class='p-2'>IVA : </div><div class='p-2'>" + item.Iva.ToString("C0", CultureInfo.CurrentCulture) + "</div>" +
                           "</div>" +
                           "<div class='d-flex flex-row'>" +
                           "<div class='p-2'>Total : </div><div class='p-2'>" + item.Bruto.ToString("C0", CultureInfo.CurrentCulture) + "</div>" +
                           "</div>";


            td = new HtmlGenericControl("td")
            {
                InnerHtml = ItemDetalle
            };
            td.Attributes.Add("style", "display:none;");
            tr.Controls.Add(td);

            if (item.FileXLS == "OLD")
            {
                td = new HtmlGenericControl("td")
                {
                    InnerHtml = "OLD"
                };
            }
            else
            {
                td = new HtmlGenericControl("td")
                {
                    InnerHtml = ""
                };
            }
            td.Attributes.Add("style", "display:none;");
            tr.Controls.Add(td);

            td = new HtmlGenericControl("td")
            {
                InnerHtml = item.TokenId
            };
            td.Attributes.Add("style", "display:none;");
            tr.Controls.Add(td);

            tbody.Controls.Add(tr);
        }

        table.Controls.Add(tbody);
        DivTPedidos.Controls.Clear();
        DivTPedidos.Controls.Add(table);
    }