private void buttonExportModule_Click(object sender, RoutedEventArgs e)
 {
     if (Etat != null && ListBoxDocument.SelectedItem != null)
     {
         string report = System.IO.Path.Combine(Core.Global.GetConfig().Folders.RootReport, "AEC_Invoice.rpt");
         Model.Sage.F_DOCENTETE_Light selected = (Model.Sage.F_DOCENTETE_Light)ListBoxDocument.SelectedItem;
         string temp_file = System.IO.Path.Combine(Core.Global.GetConfig().Folders.RootReport, selected.DO_Piece + ".pdf");
         Core.PrintCrystal.ExportPDF(report
                                     , new Model.Sage.Piece()
         {
             TotalAmountTaxExcl = 0, TotalTaxAmount = 0, DO_Date = selected.DO_Date, DO_Piece = selected.DO_Piece, cbMarq = 0
         }
                                     , 7
                                     , selected.DO_Tiers
                                     , temp_file);
     }
 }
        public void LoadViewer()
        {
            if (Etat != null && ListBoxDocument.SelectedItem != null)
            {
                Model.Sage.F_DOCENTETE_Light selected = (Model.Sage.F_DOCENTETE_Light)ListBoxDocument.SelectedItem;

                if (Etat.ParameterFields.Count == 0)
                {
                    Etat.RecordSelectionFormula = "{Commande.DO_Piece} = '" + selected.DO_Piece + "'";
                    Etat.Refresh();
                }
                else if (Etat.ParameterFields.Count > 0)
                {
                    Etat.SetParameterValue("piece", selected.DO_Piece);
                    //Etat.SetParameterValue("piecetaxes", selected.DO_Piece);
                    //Etat.SetParameterValue("piecetaxes", selected.DO_Piece, "Tableau_Taxes");
                }

                CRViewer.ViewerCore.ReportSource = Etat;

                /* pour fonction future
                 *
                 * if (Etat.ParameterFields.Count == 0 && parameters != null && parameters.Count(p => p.ParameterType == Model.Internal.CrystalReportParameters._Type.SelectionFormula) > 0)
                 *  Etat.RecordSelectionFormula = parameters.FirstOrDefault(p => p.ParameterType == Model.Internal.CrystalReportParameters._Type.SelectionFormula).ParameterValue;
                 *
                 * // fonctions avec application sur les sous-états
                 * Core.PrintCrystal.Logon(Etat, Core.Global.GetConnectionInfos().SageServer, Core.Global.GetConnectionInfos().SageIntegratedSecurity, Core.Global.GetConnectionInfos().SageDatabase, Core.Global.GetConnectionInfos().SageSQLUser, Core.Global.GetConnectionInfos().SageSQLPass);
                 *
                 * Etat.Refresh();
                 *
                 * if (Etat.ParameterFields.Count > 0 && parameters != null && parameters.Count(p => p.ParameterType == Model.Internal.CrystalReportParameters._Type.ParameterField) > 0)
                 * {
                 *  foreach (Model.Internal.CrystalReportParameters crparam in parameters.Where(p => p.ParameterType == Model.Internal.CrystalReportParameters._Type.ParameterField))
                 *  {
                 *      Etat.SetParameterValue(crparam.ParameterName, crparam.ParameterValue);
                 *  }
                 * }
                 */
            }
        }