Пример #1
0
        private Lazaro.Pres.Spreadsheet.Row FormatRowSum(Lazaro.Pres.Spreadsheet.Sheet sheet, Lazaro.Pres.FieldCollection useFields)
        {
            Lazaro.Pres.Spreadsheet.Row Reng = new Lazaro.Pres.Spreadsheet.Row(sheet);

            if (this.Definicion.KeyColumn != null && this.Definicion.KeyColumn.Printable)
            {
                Lazaro.Pres.Spreadsheet.Cell KeyCell = Reng.Cells.Add();
                KeyCell.Content = "-->";
            }

            for (int FieldNum = 0; FieldNum < useFields.Count; FieldNum++)
            {
                if (useFields[FieldNum].Printable)
                {
                    string FieldName = Lazaro.Orm.Data.ColumnValue.GetNameOnly(useFields[FieldNum].Name);

                    if (FieldNum >= 0)
                    {
                        Lazaro.Pres.Spreadsheet.Cell NewCell = Reng.Cells.Add();
                        if (FieldName == "total")
                        {
                            NewCell.Content = totalRenglon;
                        }
                        else
                        {
                            NewCell.Content = "";
                        }
                    }
                }
            }

            return(Reng);
        }
Пример #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);
        }
Пример #3
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);
        }
Пример #4
0
        protected override Lazaro.Pres.Spreadsheet.Row FormatRow(int itemId, Lfx.Data.Row row, Lazaro.Pres.Spreadsheet.Sheet sheet, Lazaro.Pres.FieldCollection useFields)
        {
            Lazaro.Pres.Spreadsheet.Row Reng = new Lazaro.Pres.Spreadsheet.Row(sheet);

            if (this.Definicion.KeyColumn != null && this.Definicion.KeyColumn.Printable)
            {
                Lazaro.Pres.Spreadsheet.Cell KeyCell = Reng.Cells.Add();
                KeyCell.Content = itemId;
            }

            for (int FieldNum = 0; FieldNum < useFields.Count; FieldNum++)
            {
                if (useFields[FieldNum].Printable)
                {
                    string FieldName = Lazaro.Orm.Data.ColumnValue.GetNameOnly(useFields[FieldNum].Name);

                    if (FieldNum >= 0)
                    {
                        Lazaro.Pres.Spreadsheet.Cell NewCell = Reng.Cells.Add();

                        switch (useFields[FieldNum].DataType)
                        {
                        case Lfx.Data.InputFieldTypes.Integer:
                        case Lfx.Data.InputFieldTypes.Serial:
                            if (row[FieldName] == null || row[FieldName] is DBNull)
                            {
                                NewCell.Content = null;
                            }
                            else if (useFields[FieldNum].Format != null)
                            {
                                NewCell.Content = System.Convert.ToInt32(row[FieldName]).ToString(useFields[FieldNum].Format);
                            }
                            else
                            {
                                NewCell.Content = row[FieldName].ToString();
                            }
                            break;

                        case Lfx.Data.InputFieldTypes.Relation:
                        case Lfx.Data.InputFieldTypes.Text:
                        case Lfx.Data.InputFieldTypes.Memo:
                            if (row[FieldName] == null)
                            {
                                NewCell.Content = null;
                            }
                            else if (FieldName == "comprob.id_formapago")
                            {
                                Lfx.Data.Row formPago = Lfx.Workspace.Master.Tables["formaspago"].FastRows[System.Convert.ToInt32(row[FieldName])];
                                if (formPago != null)
                                {
                                    NewCell.Content = formPago.Fields["nombre"].Value.ToString();
                                }
                                else
                                {
                                    NewCell.Content = row.Fields[FieldName].Value.ToString();
                                }
                            }
                            else if (row[FieldName] is System.Byte[])
                            {
                                NewCell.Content = System.Text.Encoding.Default.GetString(((System.Byte[])(row[FieldName])));
                            }
                            else
                            {
                                NewCell.Content = row.Fields[FieldName].Value.ToString();
                            }
                            break;

                        case Lfx.Data.InputFieldTypes.Currency:
                            double ValorCur = (row[FieldName] == null || row[FieldName] is DBNull) ? 0 : System.Convert.ToDouble(row[FieldName]);
                            NewCell.Content = ValorCur;
                            if (FieldName == "total")
                            {
                                totalRenglon += ValorCur;
                            }
                            break;

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

                        case Lfx.Data.InputFieldTypes.Date:
                            if (row.Fields[FieldName].Value != null)
                            {
                                NewCell.Content = row.Fields[FieldName].ValueDateTime;
                            }
                            break;

                        case Lfx.Data.InputFieldTypes.DateTime:
                            NewCell.Content = row[FieldName];
                            break;

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

                        case Lfx.Data.InputFieldTypes.Set:
                            int SetValue = System.Convert.ToInt32(row[FieldName]);
                            if (useFields[FieldNum] != null && useFields[FieldNum].SetValues != null & useFields[FieldNum].SetValues.ContainsKey(SetValue))
                            {
                                NewCell.Content = useFields[FieldNum].SetValues[SetValue];
                            }
                            else
                            {
                                NewCell.Content = "???";
                            }
                            break;

                        default:
                            NewCell.Content = row[FieldName];
                            break;
                        }
                    }
                }
            }

            return(Reng);
        }