Exemple #1
0
        protected Lazaro.Pres.Spreadsheet.Row FormatArt(Lazaro.Pres.Spreadsheet.Sheet sheet, Lbl.Comprobantes.DetalleArticulo useField)
        {
            Lazaro.Pres.Spreadsheet.Row Reng = new Lazaro.Pres.Spreadsheet.Row(sheet);

            int id_articulo = useField.Articulo == null ? 0 : useField.Articulo.Id;

            Lazaro.Pres.Spreadsheet.Cell NewCell = Reng.Cells.Add();
            ExcelReg e = excReg.Find(t => t.name == "id_articulo");

            NewCell = GetContent(NewCell, e, id_articulo);

            string nombre = useField.Nombre;

            NewCell = Reng.Cells.Add();
            e       = excReg.Find(t => t.name == "nombre");
            NewCell = GetContent(NewCell, e, nombre);

            string descripcion = useField.Descripcion;

            NewCell = Reng.Cells.Add();
            e       = excReg.Find(t => t.name == "descripcion");
            NewCell = GetContent(NewCell, e, descripcion);

            decimal cantidad = useField.Cantidad;

            NewCell = Reng.Cells.Add();
            e       = excReg.Find(t => t.name == "cantidad");
            NewCell = GetContent(NewCell, e, cantidad);

            decimal costo = useField.Costo;

            NewCell = Reng.Cells.Add();
            e       = excReg.Find(t => t.name == "costo");
            NewCell = GetContent(NewCell, e, costo);

            decimal precio = useField.ImporteUnitario;

            NewCell = Reng.Cells.Add();
            e       = excReg.Find(t => t.name == "precio");
            NewCell = GetContent(NewCell, e, precio);

            decimal importe = useField.ImporteUnitarioFinal;

            NewCell = Reng.Cells.Add();
            e       = excReg.Find(t => t.name == "importe");
            NewCell = GetContent(NewCell, e, importe);

            decimal recargo = useField.Recargo;

            NewCell = Reng.Cells.Add();
            e       = excReg.Find(t => t.name == "recargo");
            NewCell = GetContent(NewCell, e, recargo);

            decimal total = useField.ImporteAImprimir;

            NewCell = Reng.Cells.Add();
            e       = excReg.Find(t => t.name == "total");
            NewCell = GetContent(NewCell, e, total);

            return(Reng);
        }
Exemple #2
0
        protected Lazaro.Pres.Spreadsheet.Cell GetContent(Lazaro.Pres.Spreadsheet.Cell NewCell, ExcelReg e, object campo)
        {
            switch (e.fieldtype)
            {
            case Lfx.Data.InputFieldTypes.Integer:
            case Lfx.Data.InputFieldTypes.Serial:
                if (campo == null || campo is DBNull)
                {
                    NewCell.Content = null;
                }
                else if (e.format != "")
                {
                    NewCell.Content = System.Convert.ToInt32(campo.ToString()).ToString(e.format);
                }
                else
                {
                    NewCell.Content = campo.ToString();
                }
                break;

            case Lfx.Data.InputFieldTypes.Relation:
            case Lfx.Data.InputFieldTypes.Text:
            case Lfx.Data.InputFieldTypes.Memo:
                if (campo == null)
                {
                    NewCell.Content = null;
                }
                else if (campo is System.Byte[])
                {
                    NewCell.Content = System.Text.Encoding.Default.GetString(((System.Byte[])(campo)));
                }
                else
                {
                    NewCell.Content = campo.ToString();
                }
                break;

            case Lfx.Data.InputFieldTypes.Currency:
                double ValorCur = (campo == null || campo is DBNull) ? 0 : System.Convert.ToDouble(campo.ToString());
                NewCell.Content = ValorCur;
                break;

            case Lfx.Data.InputFieldTypes.Numeric:
                if (campo == null || campo is DBNull)
                {
                    NewCell.Content = null;
                }
                else
                {
                    NewCell.Content = System.Convert.ToDouble(campo.ToString());
                }
                break;

            case Lfx.Data.InputFieldTypes.Date:
                if (campo != null)
                {
                    NewCell.Content = campo.ToString();
                }
                break;

            case Lfx.Data.InputFieldTypes.DateTime:
                NewCell.Content = campo;
                break;

            case Lfx.Data.InputFieldTypes.Bool:
                if (System.Convert.ToBoolean(campo))
                {
                    NewCell.Content = "Sí";
                }
                else
                {
                    NewCell.Content = "No";
                }
                break;

            default:
                NewCell.Content = campo;
                break;
            }
            return(NewCell);
        }
Exemple #3
0
        public virtual Lazaro.Pres.Spreadsheet.Workbook ToWorkbookDetalle(int IDComprobante)
        {
            Lbl.Comprobantes.Factura selComprobante = new Lbl.Comprobantes.Factura(this.Connection, IDComprobante);

            Lazaro.Pres.Spreadsheet.Workbook Res   = new Lazaro.Pres.Spreadsheet.Workbook();
            Lazaro.Pres.Spreadsheet.Sheet    Sheet = new Lazaro.Pres.Spreadsheet.Sheet(this.Text + " Comprobante");
            Res.Sheets.Add(Sheet);


            int OrderColumn = -1;

            if (selComprobante != null)
            {
                for (int i = 0; i < 9; i++)
                {
                    ExcelReg nexc = new ExcelReg();
                    switch (i)
                    {
                    case 0:
                        nexc.name      = "id_articulo";
                        nexc.desc      = "Código";
                        nexc.alig      = Lfx.Types.StringAlignment.Near;
                        nexc.width     = 100;
                        nexc.fieldtype = Lfx.Data.InputFieldTypes.Integer;
                        break;

                    case 1:
                        nexc.name      = "nombre";
                        nexc.desc      = "Nombre";
                        nexc.alig      = Lfx.Types.StringAlignment.Near;
                        nexc.width     = 300;
                        nexc.fieldtype = Lfx.Data.InputFieldTypes.Text;
                        break;

                    case 2:
                        nexc.name      = "descripcion";
                        nexc.desc      = "Descripción";
                        nexc.alig      = Lfx.Types.StringAlignment.Near;
                        nexc.width     = 150;
                        nexc.fieldtype = Lfx.Data.InputFieldTypes.Text;
                        break;

                    case 3:
                        nexc.name      = "cantidad";
                        nexc.desc      = "Cantidad";
                        nexc.alig      = Lfx.Types.StringAlignment.Near;
                        nexc.width     = 80;
                        nexc.fieldtype = Lfx.Data.InputFieldTypes.Numeric;
                        break;

                    case 4:
                        nexc.name      = "costo";
                        nexc.desc      = "Costo";
                        nexc.alig      = Lfx.Types.StringAlignment.Near;
                        nexc.width     = 90;
                        nexc.fieldtype = Lfx.Data.InputFieldTypes.Currency;
                        break;

                    case 5:
                        nexc.name      = "precio";
                        nexc.desc      = "Precio Uni.";
                        nexc.alig      = Lfx.Types.StringAlignment.Near;
                        nexc.width     = 120;
                        nexc.fieldtype = Lfx.Data.InputFieldTypes.Currency;
                        break;

                    case 6:
                        nexc.name      = "importe";
                        nexc.desc      = "Importe";
                        nexc.alig      = Lfx.Types.StringAlignment.Near;
                        nexc.width     = 120;
                        nexc.fieldtype = Lfx.Data.InputFieldTypes.Currency;
                        break;

                    case 7:
                        nexc.name      = "recargo";
                        nexc.desc      = "Recargo";
                        nexc.alig      = Lfx.Types.StringAlignment.Near;
                        nexc.width     = 100;
                        nexc.fieldtype = Lfx.Data.InputFieldTypes.Currency;
                        break;

                    case 8:
                        nexc.name      = "total";
                        nexc.desc      = "Total";
                        nexc.alig      = Lfx.Types.StringAlignment.Near;
                        nexc.width     = 120;
                        nexc.fieldtype = Lfx.Data.InputFieldTypes.Currency;

                        break;
                    }
                    Lazaro.Pres.Spreadsheet.ColumnHeader ColHead = new Lazaro.Pres.Spreadsheet.ColumnHeader(nexc.desc, nexc.width);
                    ColHead.Name          = Lazaro.Orm.Data.ColumnValue.GetNameOnly(nexc.name);
                    ColHead.TextAlignment = nexc.alig; ColHead.DataType = nexc.fieldtype; ColHead.Format = nexc.format; ColHead.Printable = true;
                    if (i == 8)
                    {
                        ColHead.TotalFunction = Lazaro.Pres.Spreadsheet.QuickFunctions.Sum;
                    }
                    Sheet.ColumnHeaders.Add(ColHead);
                    excReg.Add(nexc);
                }
            }

            // Exporto los renglones
            Lbl.Comprobantes.ColeccionDetalleArticulos detArt = selComprobante.Articulos;
            foreach (Lbl.Comprobantes.DetalleArticulo DtRow in detArt)
            {
                Lazaro.Pres.Spreadsheet.Row Reng = this.FormatArt(Sheet, DtRow);
                Sheet.Rows.Add(Reng);
            }

            if (OrderColumn >= 0)
            {
                if (m_GroupingColumnName != null)
                {
                    Sheet.SortByGroupAndColumn(OrderColumn, true);
                }
                else
                {
                    if (OrderColumn >= 0)
                    {
                        Sheet.Sort(OrderColumn, true);
                    }
                }
            }

            return(Res);
        }