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

Accès aux données Discussion :

[C#]Conseil sur le rafraichissement des données


Sujet :

Accès aux données

  1. #1
    Membre expert
    Avatar de aityahia
    Homme Profil pro
    CIEPTAL CARS SPA
    Inscrit en
    Mars 2006
    Messages
    1 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Algérie

    Informations professionnelles :
    Activité : CIEPTAL CARS SPA
    Secteur : Transports

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 938
    Points : 3 329
    Points
    3 329
    Par défaut [C#]Conseil sur le rafraichissement des données
    salut
    je juste de me mettre au dotnet comme je viens d'entamer ma première application, je me demmande quelle est la meilleurs méthode pour synchronisé mes données sur les différente vue, je m'explique par l'exemple:

    j'ai une fiche ou j'ai une liste de mes client et j'ai un formulaire d'ajout et d'édition, dans chacune de mes fichier j'ai un Datasource, TableAdapter et un BindingSource alors lorsque j'ajoute un nouvel enregistrement je doit un Fill de ma fiche liste pour voir les nouvelle modification je pense que cette méthode n'est pas très pratique en terme de performance.

    je vous demande quel est le standard ou les bonne pratiques pour avoir une application base harmonieuse et performante.

    ps:j'ai pensé a mettre mes TableAdapter en public dans un seul endroit je préfère demandé votre avis avant:
    Salutation.

  2. #2
    Membre expert
    Avatar de aityahia
    Homme Profil pro
    CIEPTAL CARS SPA
    Inscrit en
    Mars 2006
    Messages
    1 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Algérie

    Informations professionnelles :
    Activité : CIEPTAL CARS SPA
    Secteur : Transports

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 938
    Points : 3 329
    Points
    3 329
    Par défaut
    je viens de trouvez un bout de fil que je n'arrive pas à reproduire, avec une application Winform.



    Citation Envoyé par l'aide de Visual Studio 2008
    Vous pouvez facilement partager des données entre des formulaires à l'aide du composant BindingSource. Par exemple, vous pouvez afficher un formulaire en lecture seule qui résume les données de la source de données et un autre formulaire modifiable qui contient des informations détaillées sur l'élément actuellement sélectionné dans la source de données. Cet exemple illustre ce scénario.

    L'exemple de code suivant montre comment partager un BindingSource et ses données liées entre des formulaires. Dans cet exemple, le BindingSource partagé est passé au constructeur du formulaire enfant. Le formulaire enfant permet à l'utilisateur de modifier les données pour l'élément actuellement sélectionné dans le formulaire principal

    Remarque :
    L'événement BindingComplete du composant BindingSource est géré dans l'exemple pour garantir que les deux formulaires restent synchronisés. Pour plus d'informations sur la raison de cette opération, consultez Comment : s'assurer que plusieurs contrôles liés à la même source de données restent synchronisés.


    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
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Data;
     
    namespace BindingSourceMultipleForms
    {
        public class MainForm : Form
        {
            public MainForm()
            {
                this.Load += new EventHandler(MainForm_Load);
            }
     
            private BindingSource bindingSource1;
            private Button button1;
     
            private void MainForm_Load(object sender, EventArgs e)
            {
                InitializeData();
            }
     
            private void InitializeData()
            {
                bindingSource1 = new System.Windows.Forms.BindingSource();
     
                // Handle the BindingComplete event to ensure the two forms
                // remain synchronized.
                bindingSource1.BindingComplete +=  
                    new BindingCompleteEventHandler(bindingSource1_BindingComplete);
                ClientSize = new System.Drawing.Size(292, 266);
                DataSet dataset1 = new DataSet();
     
                // Some xml data to populate the DataSet with.
                string musicXml =
                    "<?xml version='1.0' encoding='UTF-8'?>" +
                    "<music>" +
                     "<recording><artist>Dave Matthews</artist>" +
                     "<cd>Under the Table and Dreaming</cd>" + 
                     "<releaseDate>1994</releaseDate><rating>3.5</rating></recording>" +
                     "<recording><artist>Coldplay</artist><cd>X&amp;Y</cd>" + 
                     "<releaseDate>2005</releaseDate><rating>4</rating></recording>" +
                     "<recording><artist>Dave Matthews</artist>" + 
                     "<cd>Live at Red Rocks</cd>" + 
                     "<releaseDate>1997</releaseDate><rating>4</rating></recording>" +
                     "<recording><artist>U2</artist>" + 
                     "<cd>Joshua Tree</cd><releaseDate>1987</releaseDate>" + 
                     "<rating>5</rating></recording>" +
                     "<recording><artist>U2</artist>" +
                     "<cd>How to Dismantle an Atomic Bomb</cd>" + 
                     "<releaseDate>2004</releaseDate><rating>4.5</rating></recording>" +
                     "<recording><artist>Natalie Merchant</artist>" +
                     "<cd>Tigerlily</cd><releaseDate>1995</releaseDate>" +
                     "<rating>3.5</rating></recording>" +
                     "</music>";
     
                // Read the xml.
                System.IO.StringReader reader = new System.IO.StringReader(musicXml);
                dataset1.ReadXml(reader); 
     
                // Get a DataView of the table contained in the dataset.
                DataTableCollection tables = dataset1.Tables;
                DataView view1 = new DataView(tables[0]);
     
                // Create a DataGridView control and add it to the form.
                DataGridView datagridview1 = new DataGridView();
                datagridview1.ReadOnly = true;
                datagridview1.AutoGenerateColumns = true;
                datagridview1.Width = 300;
                this.Controls.Add(datagridview1);
                bindingSource1.DataSource = view1;
                datagridview1.DataSource = bindingSource1;
                datagridview1.Columns.Remove("artist");
                datagridview1.Columns.Remove("releaseDate");
     
                // Create and add a button to the form. 
                button1 = new Button();
                button1.AutoSize = true;
                button1.Text = "Show/Edit Details";
                this.Controls.Add(button1);
                button1.Location = new Point(50, 200);
                button1.Click += new EventHandler(button1_Click);
            }
     
            // Handle the BindingComplete event to ensure the two forms
            // remain synchronized.
            private void bindingSource1_BindingComplete(object sender, BindingCompleteEventArgs e)
            {
                if (e.BindingCompleteContext == BindingCompleteContext.DataSourceUpdate
                    && e.Exception == null)
                    e.Binding.BindingManagerBase.EndCurrentEdit();
            }
     
            // The detailed form will be shown when the button is clicked.
            private void button1_Click(object sender, EventArgs e)
            {
                DetailForm detailForm = new DetailForm(bindingSource1);
                detailForm.Show();
            }
     
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.Run(new MainForm());
            }
        }
     
        // The detail form class. 
        public class DetailForm : Form
        {
            private BindingSource formDataSource;
     
            // The constructor takes a BindingSource object.
            public DetailForm(BindingSource dataSource)
            {
                formDataSource = dataSource;
                this.ClientSize = new Size(240, 200);
                TextBox textBox1 = new TextBox();
                this.Text = "Selection Details";
                textBox1.Width = 220;
                TextBox textBox2 = new TextBox();
                TextBox textBox3 = new TextBox();
                TextBox textBox4 = new TextBox();
                textBox4.Width = 30;
                textBox3.Width = 50;
     
                // Associate each text box with a column from the data source.
                textBox1.DataBindings.Add("Text", formDataSource, "cd", true, DataSourceUpdateMode.OnPropertyChanged);
     
                textBox2.DataBindings.Add("Text", formDataSource, "artist", true);
                textBox3.DataBindings.Add("Text", formDataSource, "releaseDate", true);
                textBox4.DataBindings.Add("Text", formDataSource, "rating", true);
                textBox1.Location = new Point(10, 10);
                textBox2.Location = new Point(10, 40);
                textBox3.Location = new Point(10, 80);
                textBox4.Location = new Point(10, 120);
                this.Controls.AddRange(new Control[] { textBox1, textBox2, textBox3, textBox4 });
            }
     
        }
    }
    je viens de retrouvez le lien sur msdn
    j'ai testé l'exemple qui marche bien mais quand je tante de l'application winform standard impossible.
    si je touche au constructeur tous mes composant sur la fiche disparaissent.

  3. #3
    Membre expert
    Avatar de aityahia
    Homme Profil pro
    CIEPTAL CARS SPA
    Inscrit en
    Mars 2006
    Messages
    1 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Algérie

    Informations professionnelles :
    Activité : CIEPTAL CARS SPA
    Secteur : Transports

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 938
    Points : 3 329
    Points
    3 329
    Par défaut
    je viens de réglé mon problème, j'avais Créer par erreur un autres constructeur pour la fiche.
    a+

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

Discussions similaires

  1. [PHP 5.3] Conseil sur la manipulation des données en MVC
    Par grinder59 dans le forum Langage
    Réponses: 3
    Dernier message: 01/09/2014, 15h14
  2. [AJAX] Rafraichissement des données sur la page
    Par TreizeSegments dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 17/05/2006, 18h32
  3. question sur le rafraichissement des données dans la base
    Par vbcasimir dans le forum Bases de données
    Réponses: 8
    Dernier message: 06/06/2005, 12h44
  4. Conseil sur choix base de donnée "individuelle"
    Par Rica dans le forum Décisions SGBD
    Réponses: 5
    Dernier message: 12/05/2005, 13h16
  5. Quiz : testez vos connaissances sur le cryptage des données
    Par SheikYerbouti dans le forum Oracle
    Réponses: 0
    Dernier message: 08/10/2004, 10h06

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