IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VC++ .NET Discussion :

comment passer des paramètres d'un fichier crystalreport à partir de c++.net?


Sujet :

VC++ .NET

  1. #1
    Nouveau membre du Club
    Inscrit en
    Novembre 2006
    Messages
    43
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 43
    Points : 32
    Points
    32
    Par défaut comment passer des paramètres d'un fichier crystalreport à partir de c++.net?
    Salut
    j'ai creé un fichier crystalraport "test1.rpt" qui contient deux paramètres;
    l'une est une date d1 et l'autre chaine C1,je veus passer deux valeurs au paramètres précedent a partir de programme c++.net(2005) pour qu'il affiche les donneés celon ces 2 valeurs passé
    comment puisse je le faire ?
    merci

  2. #2
    Nouveau membre du Club
    Inscrit en
    Novembre 2006
    Messages
    43
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 43
    Points : 32
    Points
    32
    Par défaut Resolu
    voici tout le code

    #pragma once

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System:ata;
    using namespace System:rawing;
    using namespace CrystalDecisions::Shared;
    using namespace System::Collections;
    using namespace CrystalDecisions::CrystalReports::Engine;
    using namespace CrystalDecisions::Windows::Forms;

    namespace Test2 {

    /// <summary>
    /// Summary for form3
    ///
    /// WARNING: If you change the name of this class, you will need to change the
    /// 'Resource File Name' property for the managed resource compiler tool
    /// associated with all .resx files this class depends on. Otherwise,
    /// the designers will not be able to interact properly with localized
    /// resources associated with this form.
    /// </summary>
    public ref class form3 : public System::Windows::Forms::Form
    {

    public:
    form3(void)
    {

    InitializeComponent();
    //
    //TODO: Add the constructor code here
    //
    }

    protected:
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    ~form3()
    {
    if (components)
    {
    delete components;
    }
    }



    private: System::Windows::Forms::Button^ button1;
    private: CrystalDecisions::Windows::Forms::CrystalReportViewer^ crystalReportViewer1;
    protected:


    private:
    /// <summary>
    /// Required designer variable.
    /// </summary>

    System::ComponentModel::Container ^components;

    #pragma region Windows Form Designer generated code

    private:
    ReportDocument^ crReportDocument;
    ParameterFieldDefinitions^ crParameterFieldDefinitions;
    ParameterFieldDefinition^ crParameterFieldDefinition;
    ParameterFieldDefinition^ f2;
    ParameterValues^ crParameterValues;
    ParameterValues^ v2;
    ParameterDiscreteValue^ crParameterDiscreteValue;
    ParameterDiscreteValue^ p1;
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    void InitializeComponent(void)
    {
    this->button1 = (gcnew System::Windows::Forms::Button());
    this->crystalReportViewer1 = (gcnew CrystalDecisions::Windows::Forms::CrystalReportViewer());
    this->SuspendLayout();
    //
    // button1
    //
    this->button1->Location = System:rawing:oint(94, 32);
    this->button1->Name = L"button1";
    this->button1->Size = System:rawing::Size(113, 25);
    this->button1->TabIndex = 2;
    this->button1->Text = L"Affiche Raport";
    this->button1->UseVisualStyleBackColor = true;
    this->button1->Click += gcnew System::EventHandler(this, &form3::button1_Click);
    //
    // crystalReportViewer1
    //
    this->crystalReportViewer1->ActiveViewIndex = -1;
    this->crystalReportViewer1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
    this->crystalReportViewer1->Location = System:rawing:oint(24, 97);
    this->crystalReportViewer1->Name = L"crystalReportViewer1";
    this->crystalReportViewer1->SelectionFormula = L"";
    this->crystalReportViewer1->Size = System:rawing::Size(875, 410);
    this->crystalReportViewer1->TabIndex = 3;
    this->crystalReportViewer1->ViewTimeSelectionFormula = L"";
    //
    // form3
    //
    this->AutoScaleDimensions = System:rawing::SizeF(6, 13);
    this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    this->ClientSize = System:rawing::Size(911, 542);
    this->Controls->Add(this->crystalReportViewer1);
    this->Controls->Add(this->button1);
    this->Name = L"form3";
    this->Text = L"form3";
    this->ResumeLayout(false);

    }
    #pragma endregion




    private: System::Void crystalReportViewer1_Load(System::Object^ sender, System::EventArgs^ e) {


    }
    private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {



    String^ crParamVal;
    String^ crParamVal1;
    //Instantiate the report and load the report.
    crReportDocument = gcnew ReportDocument ();
    //crReportDocument->Load ("C:\\Crystal\\crnet\\cppnet_win_paramengine\\CRParams.rpt");
    //C:\\Documents and Settings\\sif\\Mes documents\\Visual Studio 2005\\Projects\\Test2\\Test2
    crReportDocument->Load ("C:\\Documents and Settings\\sif\\Mes documents\\Visual Studio 2005\\Projects\\Test2\\Test2\\test1.rpt");
    //Get the collection of parameters from the report
    crParameterFieldDefinitions = crReportDocument->DataDefinition->ParameterFields;

    //Access the specified parameter from the collection
    crParameterFieldDefinition = crParameterFieldDefinitions["d1"];
    f2=crParameterFieldDefinitions["d2"];
    //Get the current values from the parameter field. At this point
    //there are zero values set.
    crParameterValues = crParameterFieldDefinition->CurrentValues;
    v2 = f2->CurrentValues;
    //Set the current values for the parameter field
    crParamVal = "10/01/2008";

    crParameterDiscreteValue = gcnew ParameterDiscreteValue();
    crParameterDiscreteValue->Value = crParamVal; //1st current value

    crParamVal1 = "01/02/2008";
    p1 = gcnew ParameterDiscreteValue();
    p1->Value = crParamVal1;

    //Add the first current value for the parameter field
    crParameterValues->Add(crParameterDiscreteValue);
    v2->Add(p1);

    //Since this parameter allows multiple values, the discrete value
    //object needs to be reset. Destroy the previous instance and create
    //a new instance.
    //crParameterDiscreteValue = 0;


    //Add the second current value for the parameter field



    //All current parameter values must be applied for the parameter field.
    crParameterFieldDefinition->ApplyCurrentValues(crParameterValues);
    f2->ApplyCurrentValues(v2);

    //Set the viewer to the report object to be previewed.
    crystalReportViewer1->ReportSource = crReportDocument;


    }
    };
    }

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 0
    Dernier message: 15/10/2014, 01h13
  2. Réponses: 1
    Dernier message: 09/08/2007, 15h42
  3. [WebForms]Comment passer des paramètres à un UserControl ?
    Par cmoiscrat dans le forum Général Dotnet
    Réponses: 2
    Dernier message: 03/08/2006, 15h03
  4. Comment passer des paramètre a OpenRecordset
    Par molarisapa dans le forum Access
    Réponses: 2
    Dernier message: 09/03/2006, 17h14
  5. Réponses: 7
    Dernier message: 30/12/2004, 12h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo