Example #1
0
        /// <summary>
        /// Muestra el reporte en un mediante el visor de Crystal Reports o
        /// manda a imprimir el reporte directamente a la impresora configurada.
        /// </summary>
        /// <param name="report"> Documento .rpt </param>
        /// <param name="reportName"> Nombre del reporte. </param>
        /// <param name="isDialog"> Se mostrará en una ventana tipo Dialogo. </param>
        /// <param name="owner"> Ventana Principal que utiliza el visor. </param>
        /// <param name="isDirectPrint"> Bandera de impresion directa. </param>
        /// <history>
        /// [edgrodriguez] 16/Jul/2016 Created
        /// </history>
        public static void ShowReport(ReportDocument report, string reportName = "", bool isDialog = false, Window owner = null, EnumPrintDevice PrintDevice = EnumPrintDevice.pdScreen, bool IsInvitation = false, int numCopies = 1)
        {
            switch (PrintDevice)
            {
            case EnumPrintDevice.pdPrinter:
                var boPrintReportOptions = new PrintReportOptions();
                boPrintReportOptions.PrinterName = (IsInvitation) ? ConfigRegistryHelper.GetConfiguredPrinter("PrintInvit") : boPrintReportOptions.PrinterName;
                if (IsInvitation && string.IsNullOrEmpty(boPrintReportOptions.PrinterName))
                {
                    UIHelper.ShowMessage($"The printer is not configured, please configure your printer.");
                    return;
                }
                var boReportClientDocument  = report.ReportClientDocument;
                var boPrintOutputController = boReportClientDocument.PrintOutputController;

                boPrintReportOptions.JobTitle       = reportName;
                boPrintReportOptions.NumberOfCopies = numCopies;
                boPrintOutputController.PrintReport(boPrintReportOptions);
                break;

            case EnumPrintDevice.pdScreen:
                var crViewer = new frmViewer(report, reportName);
                crViewer.Owner = owner;
                if (isDialog)
                {
                    crViewer.ShowDialog();
                    break;
                }
                crViewer.Show();
                break;
            }
        }
Example #2
0
 /// <summary>
 /// Despliega el reporte
 /// </summary>
 /// <history>
 /// [aalcocer] 01/03/2016 Created
 /// </history>
 private void btnPreview_Click(object sender, RoutedEventArgs e)
 {
     if (!dtgDatos.Items.IsEmpty)
     {
         StaStart("Loading preview...");
         fillMailReport();
         var _frmViewer = new frmViewer(_rptMailOuts);
         _frmViewer.ShowDialog();
         StaEnd();
     }
     else
     {
         UIHelper.ShowMessage("There is no data.");
     }
 }
Example #3
0
 /// <summary>
 /// Muestra la vista previa del reporte que esta cargado en el richTextBox
 /// </summary>
 ///<history>
 ///[erosado]  08/04/2016  Created
 /// </history>
 private void imgPreview_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (UIRichTextBoxHelper.HasInfo(ref richTextBox))
     {
         StaStart("Loading preview...");
         fillMailReport();
         var _frmViewer = new frmViewer(_rptMailOuts);
         _frmViewer.ShowDialog();
         StaEnd();
     }
     else
     {
         UIHelper.ShowMessage("There is no info to show a preview view.", MessageBoxImage.Information, "Mail Outs Configuration");
     }
 }
Example #4
0
        /// <summary>
        ///Prepara el reporte de invitación para ser visualizado
        /// </summary>
        /// <history>
        /// [jorcanche] 16/04/2016 created
        /// [jorcanche] 12/05/2016 Se cambio de frmInvitaciona RptinvitationHelper
        /// </history>
        public static async void RptInvitation(int guest = 0, string peID = "USER", Window window = null)
        {
            //Traemos la informacion del store y la almacenamos en un procedimiento
            InvitationData invitationData = await BRInvitation.RptInvitationData(guest);

            //Le damos memoria al reporte de Invitacion
            var rptInvi = new rptInvitation();

            /************************************************************************************************************
             *                          Información Adiocional sobre el DataSource del Crystal
             *************************************************************************************************************
             * Para que el DataSource acepte una entidad primero se debe de converir a lista
             * 1.- ObjectHelper.ObjectToList(invitationData.Invitation)
             * Pero sí al convertirlo hay propiedades nulas, el DataSource no lo aceptara y marcara error; para evitar esto
             * se debera convertir a DateTable para que no tenga nulos.
             * 2.- TableHelper.GetDataTableFromList(ObjectHelper.ObjectToList(invitationData.Invitation))
             *************************************************************************************************************/

            //Le agregamos la informacion
            rptInvi.SetDataSource(TableHelper.GetDataTableFromList(ObjectHelper.ObjectToList(new IM.Base.Classes.RptInvitationIM(invitationData.Invitation))));
            //Cargamos los subreportes
            rptInvi.Subreports["rptInvitationGuests.rpt"].SetDataSource(TableHelper.GetDataTableFromList(invitationData.InvitationGuest?.Select(c => new IM.Base.Classes.RptInvitationGuestsIM(c)).ToList() ?? new List <Classes.RptInvitationGuestsIM>()));
            rptInvi.Subreports["rptInvitationDeposits.rpt"].SetDataSource(invitationData.InvitationDeposit?.Select(c => new IM.Base.Classes.RptInvitationDepositsIM(c)).ToList() ?? new List <Classes.RptInvitationDepositsIM>());
            rptInvi.Subreports["rptInvitationGifts.rpt"].SetDataSource(TableHelper.GetDataTableFromList(invitationData.InvitationGift?.Select(c => new IM.Base.Classes.RptInvitationGiftsIM(c)).ToList() ?? new List <Classes.RptInvitationGiftsIM>()));

            //Cambiamos el lenguaje de las etiquetas.
            CrystalReportHelper.SetLanguage(rptInvi, invitationData.Invitation.gula);

            //Fecha y hora
            rptInvi.SetParameterValue("lblDateTime", BRHelpers.GetServerDateTime());

            //Cambiado por
            rptInvi.SetParameterValue("lblChangedBy", peID);

            //Cargamos el Viewer
            var frmViewer = new frmViewer(rptInvi)
            {
                Owner = window
            };

            frmViewer.ShowDialog();
        }
Example #5
0
        /// <summary>
        /// Obtiene un reporte de Equity
        /// </summary>
        /// <param name="membershipNum">numero de membresia</param>
        /// <param name="company">compania</param>
        /// <param name="clubAgency">agencia</param>
        /// <param name="clubGuest">club</param>
        /// <param name="owner">Ventana padre</param>
        /// <history>
        /// [ecanul] 06/04/2016 Created
        /// [ecanul] 07/04/2016 Modificated Agregado Validaciones y "show" del reporte
        /// [ecanul] 20/04/2016 Modificated Metodo Movido de frmInhouse a EquityHelpers
        /// [ecanul] 06/07/2016 Modified. Agregue subreporte RptEquityMembershipsPrevious
        /// [ecanul] 08/09/2016 Modified. Agregado nombre del web service y Club en el titulo del mensaje que genero un error.
        /// [wtorres] 06/09/2016 Modified. Agregue el parametro owner
        /// </history>
        public static void EquityReport(string membershipNum, Decimal company, int?clubAgency, int?clubGuest,
                                        Window owner)
        {
            EnumClub club;

            // si tiene membrecia
            if (membershipNum != null && membershipNum != "")
            {//si tiene permiso para el reporte de equity
                if (Context.User.HasPermission(EnumPermission.Equity, EnumPermisionLevel.ReadOnly))
                {
                    // // // ShowReport
                    // determinamos el club
                    if (clubAgency != null && clubAgency != 0)
                    {
                        club = (EnumClub)clubAgency;
                    }
                    else if (clubGuest != null && clubGuest != 0)
                    {
                        club = (EnumClub)clubGuest;
                    }
                    else
                    {
                        //Si no se encuentra un club en la tabla de agencies o en la tabla del guest se manda un error diciendo esto y se sale del metodo
                        UIHelper.ShowMessage("Agency Not Found", MessageBoxImage.Error, "Equity Report");
                        return;
                    }

                    Services.ClubesService.RptEquity rptClubes = null;

                    var clubesTitle     = $"Equity Report - Clubes - {EnumToListHelper.GetEnumDescription(club)}";
                    var callCenterTitle = $"Equity Report - Credito y Cobranza - {EnumToListHelper.GetEnumDescription(club)}";
                    try
                    {
                        //obtenemos los datos del reporte del servicio de Clubes
                        rptClubes = ClubesHelper.GetRptEquity(membershipNum, Convert.ToInt32(company), club);
                    }
                    catch (Exception ex)
                    {
                        UIHelper.ShowMessage(ex, clubesTitle);
                        return;
                    }


                    //si no se pudo generenar el reporte en clubes y nos salimos
                    if (rptClubes == null)
                    {
                        UIHelper.ShowMessage("This report did not return data", MessageBoxImage.Exclamation, clubesTitle);
                        return;
                    }
                    //si no encontramos la membrecia en clubles, nos salimos
                    if (rptClubes.Membership == null)
                    {
                        UIHelper.ShowMessage("Membership not found", MessageBoxImage.Exclamation, clubesTitle);
                        return;
                    }
                    Services.CallCenterService.RptEquity rptCallCenter = null;
                    try
                    {
                        //Obtenemos la membrecia en el servicio de Call Center
                        rptCallCenter = CallCenterHelper.GetRptEquity(membershipNum, Convert.ToInt32(company), club);
                    }
                    catch (Exception ex)
                    {
                        UIHelper.ShowMessage(ex, callCenterTitle);
                        return;
                    }

                    // si no se pudo generar reporte en Call Center nos salimos
                    if (rptCallCenter == null)
                    {
                        UIHelper.ShowMessage("This report did not return data", MessageBoxImage.Exclamation, callCenterTitle);
                        return;
                    }

                    // si no encontramos la membresia en Credito y Cobranza Reserva, nos salimos
                    if (rptCallCenter.Membership == null)
                    {
                        UIHelper.ShowMessage("Membership not found", MessageBoxImage.Exclamation, callCenterTitle);
                        return;
                    }

                    // indicamos que ciertas listas del reporte no tienen registros
                    RptEquityHeader header = new RptEquityHeader();
                    header.HasGolfFields = rptClubes.GolfFieldsDetail.Length > 0;
                    header.IsElite       = (club == EnumClub.PalaceElite);

                    var equity = new rptEquity();
                    //datos generales de equity
                    equity.Database.Tables["Membership"].SetDataSource(ObjectHelper.ObjectToList(rptClubes.Membership));
                    equity.Database.Tables["Member"].SetDataSource(ObjectHelper.ObjectToList(rptCallCenter.Membership));
                    //Si no tiene un Salesman  con OPC no se envia nada
                    Services.ClubesService.RptEquitySalesman[] salesmanOPC = rptClubes.Salesmen.Where(sm => sm.Title.Trim() == "OPC").ToArray();
                    if (salesmanOPC.Length > 0)
                    {
                        equity.Database.Tables["SalesmanOPC"].SetDataSource(salesmanOPC);
                    }
                    equity.Database.Tables["Hotel"].SetDataSource(ObjectHelper.ObjectToList(rptClubes.Hotels));
                    equity.Database.Tables["GolfFieldsHeader"].SetDataSource(ObjectHelper.ObjectToList(rptClubes.GolfFieldsHeader));
                    if (rptClubes.Verification != null)
                    {
                        rptClubes.Verification.VOLUMENGOLF = rptCallCenter.Membership.Golf - (rptClubes.Verification.VOLUMENGOLF / EquityHelpers.GetIVAByOffice(rptClubes.Membership.OFFICE));
                    }
                    equity.Database.Tables["Verification"].SetDataSource(ObjectHelper.ObjectToList(rptClubes.Verification));
                    //Subreportes
                    if (club == EnumClub.PalaceElite)
                    {
                        header.HasMembershipsPrevious = rptClubes.MembershipsPrevious.Length > 0;
                        if (header.HasMembershipsPrevious)
                        {
                            equity.Subreports["rptEquityMembershipsPrevious.rpt"].SetDataSource(rptClubes.MembershipsPrevious);
                        }
                    }
                    equity.Subreports["rptEquitySalesman.rpt"].SetDataSource(rptClubes.Salesmen);
                    equity.Subreports["rptEquityCoOwners.rpt"].SetDataSource(rptClubes.CoOwners);

                    equity.Subreports["rptEquityBeneficiaries.rpt"].Database.Tables["Reporte"].SetDataSource(rptClubes.Beneficiaries);
                    equity.Subreports["rptEquityBeneficiaries.rpt"].Database.Tables["Membership"].SetDataSource(ObjectHelper.ObjectToList(rptCallCenter.Membership));

                    equity.Subreports["rptEquityGolfFields.rpt"].SetDataSource(rptClubes.GolfFieldsDetail);
                    equity.Subreports["rptEquityRoomTypes.rpt"].SetDataSource(rptClubes.RoomTypes);

                    RptEquityProvision[] provisionsSNORM = rptCallCenter.Provisions.Where(p => p.IsSNORM == true).ToArray();
                    header.HasSNORM = provisionsSNORM.Length > 0;
                    if (header.HasSNORM)
                    {
                        equity.Subreports["rptEquityProvisionsSNORM.rpt"].SetDataSource(provisionsSNORM);
                    }

                    RptEquityProvision[] provisionsSAIRF = rptCallCenter.Provisions.Where(p => p.IsSAIRF == true).ToArray();
                    header.HasSAIRF = provisionsSAIRF.Length > 0;
                    equity.Subreports["rptEquityProvisionsSAIRF.rpt"].SetDataSource(provisionsSAIRF);

                    RptEquityProvision[] provisionsSRCI = rptCallCenter.Provisions.Where(p => p.IsSRCI == true).ToArray();
                    header.HasSRCI = provisionsSRCI.Length > 0;
                    equity.Subreports["rptEquityProvisionsSRCI.rpt"].SetDataSource(provisionsSRCI);

                    RptEquityProvision[] provisionsSCOMP = rptCallCenter.Provisions.Where(p => p.IsSCOMP == true).ToArray();
                    header.HasSCOMP = provisionsSCOMP.Length > 0;
                    equity.Subreports["rptEquityProvisionsSCOMP.rpt"].SetDataSource(provisionsSCOMP);

                    RptEquityProvision[] provisionsSCRG = rptCallCenter.Provisions.Where(p => p.IsSCRG == true).ToArray();
                    header.HasSCRG = provisionsSCRG.Length > 0;
                    equity.Subreports["rptEquityProvisionsSCRG.rpt"].SetDataSource(provisionsSCRG);

                    RptEquityProvision[] provisionsSIGR = rptCallCenter.Provisions.Where(p => p.IsSIGR == true).ToArray();
                    header.HasSIGR = provisionsSIGR.Length > 0;
                    equity.Subreports["rptEquityProvisionsSIGR.rpt"].SetDataSource(provisionsSIGR);

                    RptEquityProvision[] provisionsSVEC = rptCallCenter.Provisions.Where(p => p.IsSVEC == true).ToArray();
                    header.HasSVEC = provisionsSVEC.Length > 0;
                    equity.Subreports["rptEquityProvisionsSVEC.rpt"].SetDataSource(provisionsSVEC);

                    RptEquityProvision[] provisionsSREF = rptCallCenter.Provisions.Where(p => p.IsSREF == true).ToArray();
                    header.HasSREF = provisionsSREF.Length > 0;
                    equity.Subreports["rptEquityProvisionsSREF.rpt"].SetDataSource(provisionsSREF);

                    equity.Database.Tables["Header"].SetDataSource(ObjectHelper.ObjectToList(header));
                    if (rptCallCenter.Reservations.Length != 0)
                    {
                        equity.Subreports["rptEquityReservations.rpt"].SetDataSource(rptCallCenter.Reservations);
                    }

                    if (rptClubes.BalanceElectronicPurseHeaders.Length == 0)
                    {
                        equity.Subreports["rptEquityBalanceElectronicPurse.rpt"].ReportDefinition.Sections["GroupHeaderSection1"].SectionFormat.EnableSuppress = true;
                    }
                    equity.Subreports["rptEquityBalanceElectronicPurse.rpt"].Database.Tables["EquityBalanceElectronicPurseDetail"].SetDataSource(rptClubes.BalanceElectronicPurseDetails);
                    equity.Subreports["rptEquityBalanceElectronicPurse.rpt"].Database.Tables["BalanceElectronicPurseHeader"].SetDataSource(rptClubes.BalanceElectronicPurseHeaders);
                    var sum = rptCallCenter.Membership.Down - rptCallCenter.Membership.Down_escrow - rptCallCenter.Membership.Down_bal;
                    if (sum > 1)
                    {
                        equity.Subreports["rptEquityPaymentPromises.rpt"].SetDataSource(rptClubes.PaymentPromises);
                    }
                    if (club == EnumClub.PalaceElite)
                    {
                        equity.Subreports["rptEquityWeeksNights.rpt"].Database.Tables["WeeksNightsDetail"].SetDataSource(rptClubes.WeeksNightsDetails);
                        equity.Subreports["rptEquityWeeksNights.rpt"].Database.Tables["WeeksNightsHeader"].SetDataSource(rptClubes.WeeksNightsHeaders);
                    }
                    if (club == EnumClub.PalaceElite)
                    {
                        equity.Subreports["rptEquityGolfRCI.rpt"].SetDataSource(rptClubes.GolfRCI);
                    }
                    else
                    {
                        equity.ReportDefinition.ReportObjects["srptGolfRCI"].ObjectFormat.EnableSuppress = true;
                    }
                    if (club == EnumClub.PalaceElite)
                    {
                        equity.Subreports["rptEquityPromotions.rpt"].SetDataSource(rptClubes.Promotions);
                    }

                    if (club == EnumClub.PalaceElite)
                    {
                        if (rptClubes.MemberExtension != null)
                        {
                            if (rptClubes.MemberExtension.WHOLESALER)
                            {
                                equity.ReportDefinition.Sections["Section2"].SectionFormat.EnableSuppress = false;
                            }
                        }
                    }

                    var frm = new frmViewer(equity);
                    frm.Owner = owner;
                    frm.ShowDialog();
                }
                else
                {
                    UIHelper.ShowMessage("Access denied");
                }
            }
        }