public InformeCarteraClientesRpt GetCarteraClientesReport(ClienteInfo cliente, SerieInfo serie, FormatConfCarteraClientesReport conf)
        {
            InformeCarteraClientesRpt   doc        = new InformeCarteraClientesRpt();
            List <CarteraClientesPrint> pList      = new List <CarteraClientesPrint>();
            List <CobroFacturaPrint>    pCobroList = new List <CobroFacturaPrint>();

            QueryConditions conditions = new QueryConditions
            {
                Cliente  = cliente,
                Serie    = serie,
                FechaIni = conf.inicio,
                FechaFin = conf.final
            };

            GetFacturas(cliente, conditions, conf, pList, pCobroList);

            doc.SetDataSource(pList);
            if (pCobroList.Count != 0)
            {
                doc.Subreports["CobroFacturasRpt"].SetDataSource(pCobroList);
            }
            else
            {
                conf.verCobros = false;
            }

            doc.SetParameterValue("VerCobros", conf.verCobros);

            FormatReport(doc, conf);
            FormatHeader(doc);

            return(doc);
        }
        private void FormatReport(InformeCarteraClientesRpt rpt, FormatConfCarteraClientesReport conf)
        {
            switch (conf.campo_ordenacion)
            {
            case "Nombre":
            {
                rpt.GHNumeroCliente.SectionFormat.EnableSuppress = true;
                rpt.GFNumero.SectionFormat.EnableSuppress        = true;
                rpt.GHNombre.SectionFormat.EnableSuppress        = false;
                rpt.GFNombre.SectionFormat.EnableSuppress        = false;
                FieldDefinition fdes = rpt.Database.Tables[0].Fields["Nombre"];
                rpt.DataDefinition.SortFields[0].Field         = fdes;
                rpt.DataDefinition.SortFields[0].SortDirection =
                    conf.orden_ascendente ? CrystalDecisions.Shared.SortDirection.AscendingOrder : CrystalDecisions.Shared.SortDirection.DescendingOrder;
            }
            break;

            case "Numero de Cliente":
            {
                rpt.GHNumeroCliente.SectionFormat.EnableSuppress = false;
                rpt.GFNumero.SectionFormat.EnableSuppress        = false;
                rpt.GHNombre.SectionFormat.EnableSuppress        = true;
                rpt.GFNombre.SectionFormat.EnableSuppress        = true;
                FieldDefinition fdes = rpt.Database.Tables[0].Fields["Codigo"];
                rpt.DataDefinition.SortFields[0].Field         = fdes;
                rpt.DataDefinition.SortFields[0].SortDirection = conf.orden_ascendente ?
                                                                 CrystalDecisions.Shared.SortDirection.AscendingOrder :
                                                                 CrystalDecisions.Shared.SortDirection.DescendingOrder;
            }
            break;
            }

            rpt.Detalles.SectionFormat.EnableSuppress = conf.resumido;
        }
        public InformeCarteraClientesRpt GetCarteraClientesReport(ClienteList lista, SerieInfo serie, FormatConfCarteraClientesReport conf)
        {
            if (lista == null || lista.Count == 0)
            {
                return(null);
            }

            InformeCarteraClientesRpt   doc        = new InformeCarteraClientesRpt();
            List <CarteraClientesPrint> pList      = new List <CarteraClientesPrint>();
            List <CobroFacturaPrint>    pCobroList = new List <CobroFacturaPrint>();

            QueryConditions conditions = new QueryConditions
            {
                Serie    = serie,
                FechaIni = conf.inicio,
                FechaFin = conf.final
            };

            foreach (ClienteInfo item in lista)
            {
                conditions.Cliente = item;

                GetFacturas(item, conditions, conf, pList, pCobroList);
            }

            doc.SetDataSource(pList);
            if (pCobroList.Count != 0)
            {
                doc.Subreports["CobroFacturasRpt"].SetDataSource(pCobroList);
            }
            else
            {
                conf.verCobros = false;
            }

            doc.SetParameterValue("VerCobros", conf.verCobros);

            FormatReport(doc, conf);
            FormatHeader(doc);

            return(doc);
        }
        protected override void PrintAction()
        {
            PgMng.Reset(4, 1, Face.Resources.Messages.RETRIEVING_DATA, this);
            ClienteInfo cliente = TodosCliente_CkB.Checked ? null : _cliente;
            SerieInfo   serie   = TodosSerie_CkB.Checked ? null : _serie;

            FormatConfCarteraClientesReport conf = new FormatConfCarteraClientesReport();

            conf.tipo             = (ETipoFacturas)(long)TipoFactura_CB.SelectedValue;
            conf.orden_ascendente = Ascendente_RB.Checked;
            conf.resumido         = Resumido_RB.Checked;
            conf.verCobros        = Detallado_RB.Checked;
            conf.campo_ordenacion = Ordenar_CB.SelectedItem.ToString();

            if (FInicial_DTP.Checked)
            {
                conf.inicio = FInicial_DTP.Value;
            }
            else
            {
                conf.inicio = DateTime.MinValue;
            }

            if (FFinal_DTP.Checked)
            {
                conf.final = FFinal_DTP.Value;
            }
            else
            {
                conf.final = DateTime.MaxValue;
            }

            string filtro = GetFilterValues();

            PgMng.Grow();

            ClienteList clientes = ClienteList.GetList(false);

            //Quitamos el cliente CONSUMO PROPIO por peticion del Balaños
            ClienteInfo cp = clientes.GetItemByProperty("Nombre", "CONSUMO PROPIO");

            if (cp != null)
            {
                clientes.RemoveItem(cp.Oid);
            }

            PgMng.Grow(Face.Resources.Messages.BUILDING_REPORT);

            ClienteReportMng reportMng = new ClienteReportMng(AppContext.ActiveSchema, this.Text, filtro);

            if (!TodosCliente_CkB.Checked)
            {
                InformeCarteraClientesRpt rpt = reportMng.GetCarteraClientesReport(_cliente, _serie, conf);

                PgMng.FillUp();
                ShowReport(rpt);
            }
            else
            {
                InformeCarteraClientesRpt rpt = reportMng.GetCarteraClientesReport(clientes, _serie, conf);

                PgMng.FillUp();
                ShowReport(rpt);
            }

            _action_result = DialogResult.Ignore;
        }