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

Windows Presentation Foundation Discussion :

temps d'execution entre requète DB et affichage


Sujet :

Windows Presentation Foundation

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Août 2008
    Messages
    45
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Calvados (Basse Normandie)

    Informations forums :
    Inscription : Août 2008
    Messages : 45
    Par défaut temps d'execution entre requète DB et affichage
    Bonjours à tous,
    J'aurai aimer avoir une information sur le comportement de mon application.
    Voici un petit morceau du code qui me permet d'afficher des informations dans des textbox après avoir été rechercher celles ci dans la base de données SQL server.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    public nvFicheClient(string mode, decimal idClient)
            {
                InitializeComponent();
                this.DataContext = new Client();
                _mode = mode;
               
                    lbltitrefenetre.Content = "Modification de la fiche client";
                    this.Title = "Modification d'une fiche client";
                    //btn_cretationClient_step3_terminer.Click += new RoutedEventHandler(btn_modification_step3_terminer_Click);
                    Client cli = DBclient.AffichageClient(idClient);
                    MessageBox.Show(string.Format(""));                    txtbRaisonSociale.Text = cli.IdClient.ToString();
                        txtbNomContact.Text = cli.NomClient;
                        txtbPrenomContact.Text = cli.PrenomClient;
                        txtbAdresse.Text = cli.AdresseClient;
                        txtbCP.Text = cli.CpClient;
                        txtbVille.Text = cli.VilleClient;
                        txtbTelFixe.Text = cli.TelFixeClient;
                        txtbTelPort.Text = cli.TelPortableClient;
                        txtbFax.Text = cli.FaxClient;
                        txtbEmail.Text = cli.EmailClient;
                    
                
            }
    Ce qui est étrange c'est la ligne en rouge.
    Si je ne met pas celle ci entre les 2 (ou toutes autres opérations) mes textbox sont vides par contre si la ligne est présente mes inf s'affichant bien dans mes textbox.
    Y'a t'il un délai nécessaire entre la recupération de mes données dans la base et l'affichage ?
    Cela me parait bizard c'est la première fois que je vois ça et l'idée du délai entre les 2 aussi mais je n'arrive pas à comprendre.
    En vous remerciant par avance.
    Thomas D.

  2. #2
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Par défaut
    Tu peux nous montrer le code de ta méthode AffichageClient ? Car je ne vois pas ce qui pourrait provoquer ce comportement...

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Août 2008
    Messages
    45
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Calvados (Basse Normandie)

    Informations forums :
    Inscription : Août 2008
    Messages : 45
    Par défaut
    Oui, voici le code de AffichageClient dans DBClient
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
     
     public static Client AffichageClient(decimal idClient)
            {
                Client client = new Client();
                DbCommand cmd = DataConnection.CreateCommandPs("ps_afficherClient");
                DbParameter paramidClient = cmd.CreateParameter();
                paramidClient.ParameterName = "@IdClient";
                paramidClient.DbType = DbType.Decimal;
                paramidClient.Value = idClient;
                cmd.Parameters.Add(paramidClient);
                DbDataReader dr = DataConnection.CreateDateReader(cmd);
                if(dr.Read())
                {
                    if (!dr.IsDBNull(0))
                    {
                        client.IdClient = dr.GetDecimal(0);
                    }
                    if (!dr.IsDBNull(1))
                    {
                        client.RaisonSocialeClient = dr.GetString(3);
                    }
                    if (!dr.IsDBNull(2))
                    {
                        client.NomClient = dr.GetString(1);
                    }
                        if (!dr.IsDBNull(3))
                    {
                        client.PrenomClient =  dr.GetString(2);
                    }
                    if (!dr.IsDBNull(4))
                    {
                        client.AdresseClient = dr.GetString(4);
                    }
                    if (!dr.IsDBNull(5))
                    {
                        client.CpClient = dr.GetString(5);
                    }
                    if (!dr.IsDBNull(6))
                    {
                        client.VilleClient = dr.GetString(6);
                    }
                    if (!dr.IsDBNull(7))
                    {
                        client.TelFixeClient = dr.GetString(7);
                    }
                    if (!dr.IsDBNull(8))
                    {
                        client.TelPortableClient = dr.GetString(8);
                    }
                    if (!dr.IsDBNull(9))
                    {
                        client.FaxClient = dr.GetString(9);
                    }
                    if (!dr.IsDBNull(10))
                    {
                        client.EmailClient = dr.GetString(10);
                    }
                }
                return client;
            }
    et l'objet client
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
     
    public class Client
        {
            private decimal _idClient;
     
            public decimal IdClient
            {
                get { return _idClient; }
                set { _idClient = value; }
            }
            private string _nomClient;
     
            public string NomClient
            {
                get { return _nomClient; }
                set 
                { 
                    _nomClient = value;
                    if (String.IsNullOrEmpty(value))
                    {
                        throw new ApplicationException("Champs obligatoire.");
                    }
                }
            }
            private string _prenomClient;
     
            public string PrenomClient
            {
                get { return _prenomClient; }
                set 
                { 
                    _prenomClient = value;
                    if (String.IsNullOrEmpty(value))
                    {
                        throw new ApplicationException("Champs obligatoire.");
                    }
                }
            }
            private string _raisonSocialeClient;
     
            public string RaisonSocialeClient
            {
                get { return _raisonSocialeClient; }
                set 
                { 
                    _raisonSocialeClient = value;
                    if (String.IsNullOrEmpty(value))
                    {
                        throw new ApplicationException("Champs obligatoire.");
                    }
                }
            }
            private string _adresseClient;
     
            public string AdresseClient
            {
                get { return _adresseClient; }
                set { _adresseClient = value; }
            }
            private string _cpClient;
     
            public string CpClient
            {
                get { return _cpClient; }
                set
                { 
                    _cpClient = value;
                    if (!string.IsNullOrEmpty(value))
                    {
                        if (CpClient.Length != 5)
                        {
                            throw new ApplicationException("Le code postal doit comporter 5 chiffres. Ex : '14000'");
                        }
                    }
                    else
                    {
                        throw new ApplicationException("Ce champs ne peut pas être vide");
                    }
                }
            }
            private string _villeClient;
     
            public string VilleClient
            {
                get { return _villeClient; }
                set 
                { 
                    _villeClient = value;
                    if (String.IsNullOrEmpty(value))
                    {
                        throw new ApplicationException("Champs obligatoire.");
                    }
     
                }
            }
            private string _telFixeClient;
     
            public string TelFixeClient
            {
                get { return _telFixeClient; }
                set 
                { 
                    _telFixeClient = value;
                    if (!string.IsNullOrEmpty(value))
                    {
                        if (value.Length != 10)
                        {
                            throw new ApplicationException("Le numéro de téléphone doit être composé de 10 chiffres. Ex : 0678969696");
                        }
                        else
                        {
                            if (!char.Equals(value[0],'0'))
                            {
                                throw new ApplicationException("Le numéro de téléphone fixe doit commencer par 0.");
                            }
                            else
                            {
                                if (char.Equals(value[1], '6'))
                                {
                                    throw new ApplicationException("Le numéro de téléphone fixe ne doit pas commencer par 06.");
                                }
                            }
     
                        }
                    }
     
     
                }
            }
            private string _telPortableClient;
     
            public string TelPortableClient
            {
                get { return _telPortableClient; }
                set 
                { 
                    _telPortableClient = value;
                    if (!string.IsNullOrEmpty(value))
                    {
                        if (value.Length != 10 )
                        {
                            throw new ApplicationException(value[0].ToString());
                        }
                        else
                        {
                            if (!char.Equals(value[0], '0'))
                            {
                                throw new ApplicationException("Le numéro de téléphone portable doit commencer par 0.");
                            }
                            else
                            {
                                if (!char.Equals(value[1], '6'))
                                {
                                    throw new ApplicationException("Le numéro de téléphone portable doit commencer par 06.");
                                }
                            }
     
                        }
     
                    }
                }
            }
            private string _faxClient;
     
            public string FaxClient
            {
                get { return _faxClient; }
                set 
                { 
                    _faxClient = value;
                    if (!string.IsNullOrEmpty(value))
                    {
                        if (value.Length != 10)
                        {
                            throw new ApplicationException("Le numéro de téléphone doit être composé de 10 chiffres. Ex : 0678969696");
                        }
                        else
                        {
                            if (!char.Equals(value[0], '0'))
                            {
                                throw new ApplicationException("Le numéro de Fax doit commencer par 0.");
                            }
                            else
                            {
                                if (char.Equals(value[1], '6'))
                                {
                                    throw new ApplicationException("Le numéro de Fax ne doit pas commencer par 06.");
                                }
                            }
     
                        }
                    }
                }
            }
            private string _emailClient;
     
            public string EmailClient
            {
                get { return _emailClient; }
                set { _emailClient = value; }
            }
     
            //Constructeur de la classe métier CLIENT
            public Client()
            {
     
            }
     
            public Client(decimal idClient,string nom, string prenom)
            {   
                IdClient = idClient;
                NomClient = nom;
                PrenomClient = prenom;
     
            }
     
            public Client(string nomClient, string prenomClient, string raisonSocialeClient, string adresseClient, string cpClient, string villeClient, string telFixeClient, string telPortableClient, string faxClient, string emailclient)
            {
                NomClient = nomClient;
                PrenomClient = prenomClient;
                RaisonSocialeClient = raisonSocialeClient;
                AdresseClient = adresseClient;
                CpClient = cpClient;
                VilleClient = villeClient;
                TelFixeClient = telFixeClient;
                TelPortableClient = telPortableClient;
                FaxClient = faxClient;
                EmailClient = emailclient;
            }
     
            public Client(decimal idClient,string nomClient, string prenomClient, string raisonSocialeClient, string adresseClient, string cpClient, string villeClient, string telFixeClient, string telPortableClient, string faxClient, string emailclient)
            {
                IdClient = idClient;
                NomClient = nomClient;
                PrenomClient = prenomClient;
                RaisonSocialeClient = raisonSocialeClient;
                AdresseClient = adresseClient;
                CpClient = cpClient;
                VilleClient = villeClient;
                TelFixeClient = telFixeClient;
                TelPortableClient = telPortableClient;
                FaxClient = faxClient;
                EmailClient = emailclient;
            }
     
            //Override de toString()
            public override string ToString()
            {
                return string.Format("{0} {1}", NomClient, PrenomClient);
            }
        }
    Merci.
    Thomas D.

  4. #4
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Par défaut
    Essaye de remplacer:

    Par:


  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Août 2008
    Messages
    45
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Calvados (Basse Normandie)

    Informations forums :
    Inscription : Août 2008
    Messages : 45
    Par défaut
    ça passe toujours pas c'est bizard quand même car avant hier ça avait l'air de passer et là ce soir plus rien alors que je n'ai rien touché à part que je suis sur une autre machine.
    Après l'instanciation et la recupération de mon objet client :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Client cli = DBclient.AffichageClient(idClient);
    J'ai testé :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    MessageBox.show(string.Format("{0} {1} {2}", cli.idClient, cli.nomClient, cli.prenomClient);
    Et il m'affiche bien les info sur mon client dans ma messageBox et mes textbox sont bien remplies mais si je retire ce code alors là Bammmm j'ai bien la fenêtre mias plus rien dans les textbox.
    Autant d'habitude j'arrive toujours à régler ses petis soucis mais là je bloque.

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Août 2008
    Messages
    45
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Calvados (Basse Normandie)

    Informations forums :
    Inscription : Août 2008
    Messages : 45
    Par défaut
    Bon thomas j'ai testé quelque chose, j'ai fais un timer que j'ai réglé à 3 secondes pour voir si cela avait un impact sur l'application
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
     
      public partial class nvFicheClient : Window
        {
            private string _mode;
            private Client clientTest;
            private int compteur;
     
            public int Compteur
            {
                get { return compteur; }
                set { compteur = value; }
            }
     
            public Client ClientTest
            {
                get { return clientTest; }
                set { clientTest = value; }
            }
            public nvFicheClient(string mode)
            {
                InitializeComponent();
                this.DataContext = new Client();
                _mode = mode;
                if(mode == "ajout")
                {
                    lbltitrefenetre.Content = "Creation d'un nouveau client";
                    btn_cretationClient_step3_terminer.Click +=  new RoutedEventHandler(btn_cretationClient_step3_terminer_Click);
                }
     
            }
            public nvFicheClient(string mode, decimal idClient)
            {
                InitializeComponent();
                this.DataContext = new Client();
                _mode = mode;
     
                    lbltitrefenetre.Content = "Modification de la fiche client";
                    this.Title = "Modification d'une fiche client";
                    DispatcherTimer dpt = new DispatcherTimer();
                    TimeSpan ts = new TimeSpan(1000);
                    dpt.Interval = ts ;
                    //btn_cretationClient_step3_terminer.Click += new RoutedEventHandler(btn_modification_step3_terminer_Click);
                    Client cli = DBclient.AffichageClient(idClient);
                    ClientTest = cli;
                    dpt.IsEnabled = true;
                    Compteur = 0;
                    dpt.Tick += new EventHandler(dpt_Tick);
     
                        //txtbRaisonSociale.Text = cli.IdClient.ToString();
                        //txtbNomContact.Text = cli.NomClient;
                        //txtbPrenomContact.Text = cli.PrenomClient;
                        //txtbAdresse.Text = cli.AdresseClient;
                        //txtbCP.Text = cli.CpClient;
                        //txtbVille.Text = cli.VilleClient;
                        //txtbTelFixe.Text = cli.TelFixeClient;
                        //txtbTelPort.Text = cli.TelPortableClient;
                        //txtbFax.Text = cli.FaxClient;
                        //txtbEmail.Text = cli.EmailClient;
     
     
            }
     
            void dpt_Tick(object sender, EventArgs e)
            {
                Compteur++;
                if (Compteur == 3)
                {
                    ((DispatcherTimer)sender).IsEnabled = false;
                    txtbRaisonSociale.Text = ClientTest.RaisonSocialeClient;
     
                }
            }
    Avec ce décalage de 3 secondes par exemple ben ça passe ?
    Pense tu que ça puisse venir de ça mais c'est quand même bizard alors que ça fonctionné il y'a quelques jours ?
    Bonne nuit pour maintenant
    Thomas D.

Discussions similaires

  1. optimisation de temps d'execution de requête
    Par Smix007 dans le forum SQL
    Réponses: 7
    Dernier message: 21/06/2007, 17h49
  2. Temps d'execution de la requête
    Par lolafrite dans le forum Oracle
    Réponses: 8
    Dernier message: 26/01/2007, 17h52
  3. Affichage du temps d execution
    Par jean_bobi dans le forum C++
    Réponses: 3
    Dernier message: 16/05/2006, 13h44
  4. [MySQL] Afficher le temps mis pour executer une requête SQL
    Par micatmidog dans le forum PHP & Base de données
    Réponses: 6
    Dernier message: 28/09/2005, 11h23
  5. Temps d'execution d'une requête
    Par Maglight dans le forum Bases de données
    Réponses: 3
    Dernier message: 27/01/2005, 08h38

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