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

C# Discussion :

bindingsource utilité et manipulation


Sujet :

C#

  1. #1
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2012
    Messages
    238
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mars 2012
    Messages : 238
    Points : 77
    Points
    77
    Par défaut bindingsource utilité et manipulation
    salam


    je suis débutant et je vien de faie une recherche sur les utilité des bindingsource et vois bien son l’intérêt et je constate que c'est vraiment utile au lieu d'affecté a chaque fois des valeurs au label ou textbox on utilise un bindingsource et le tour est jouer . maintenant j'ai un problème :

    exp :je veut afficher dans un label une valeurs d'une cellule d'une table j'ai fais la liaison comme suite


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    bindingproduction_planifier.DataSource = datasetproduction;
                bindingproduction_planifier.DataMember = "production_planifier";
    editquantitéaparente.DataBindings.Add(new Binding("Text", datasetproduction, "production_planifier.qte_encours"));
    mon problème c'est que mon label m'affiche juste la cellule du premier row , moi je veut afficher la cellule du row que je veut et sans passé par un datagridview je veut le faire par code .
    j'ai trouver cette solution mais ça n’affecte pas l'affichage sur mon label :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    int itemFound = bindingproduction_planifier.Find("cleproduction", datasetproduction.Tables["op_momunclature_productionp"].Rows[0].Field<int>("cleproduction").ToString());
                bindingproduction_planifier.Position = itemFound;
    merci d'avance.
    Delphi XE8 Architect - Win 10

  2. #2
    Expert confirmé
    Inscrit en
    Avril 2008
    Messages
    2 564
    Détails du profil
    Informations personnelles :
    Âge : 64

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 564
    Points : 4 441
    Points
    4 441
    Par défaut
    bonjour adelcrb

    Ca revient à dropper un bindingnavigator sur le form....

    Mais si tu veux le faire par un code exemple:

    -personsDataSet1 est un dataset droppe sur le form pour ma bd Persons
    -personsTableAdapter1 idem...(aussi bien le dataset que l'adapter peuvent etre crees aussi par code et la table fille ,moyennant une connection ado.net sql server)...

    -on fille la table personsDataSet1.Persons....
    -dans bindings.add(), faire attention d'ajouter bindingproduction_planifier.DataSource car bindings.add un prametre de type datasource...

    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
     
     
    //dropper sur le form:
    //-01 dataset personnalise
    //-01 dataadapter personnalise  
    //- 04 buttons
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
     
    namespace WinDGVSearch
    {
        public partial class Form2 : Form
        {
            BindingSource bindingproduction_planifier = new BindingSource();
            public Form2()
            {
                InitializeComponent();
     
     
            }
     
     
            private void btnFillDataTable_Click(object sender, EventArgs e)
            {
                personsTableAdapter1.Fill(personsDataSet1.Persons);
                bindingproduction_planifier.DataSource = personsDataSet1;
                bindingproduction_planifier.DataMember = personsDataSet1.Persons.TableName;
     
                this.label1.DataBindings.Add(new Binding("Text", bindingproduction_planifier.DataSource , "Persons.Nom", true, DataSourceUpdateMode.OnPropertyChanged));
                this.label2.DataBindings.Add(new Binding("Text", bindingproduction_planifier.DataSource, "Persons.Prenom", true, DataSourceUpdateMode.OnPropertyChanged)); 
     
            }
     
            private void btnMoveNext_Click(object sender, EventArgs e)
            {
                bindingproduction_planifier.MoveNext();
                DataRowView drview = (DataRowView)bindingproduction_planifier.Current;
     
                this.label1.Text = drview.Row["Nom"].ToString();
                this.label2.Text = drview.Row["Prenom"].ToString();
                this.lblEnregNum.Text = "Current Record N° : " + bindingproduction_planifier.Position.ToString();
            }
     
            private void btnMovePrevious_Click(object sender, EventArgs e)
            {
                bindingproduction_planifier.MovePrevious();
                DataRowView drview = (DataRowView)bindingproduction_planifier.Current;
                this.label1.Text = drview.Row["Nom"].ToString();
                this.label2.Text = drview.Row["Prenom"].ToString();
     
                this.lblEnregNum.Text = "Current Record N° : " + bindingproduction_planifier.Position.ToString();
            }
     
            private void btnAddNew_Click(object sender, EventArgs e)
            {
                //se position sur le dernier record ....
                bindingproduction_planifier.MoveLast();
     
                //ajout nouveau record à la vue....
                bindingproduction_planifier.AddNew();
                DataRowView drview = (DataRowView)bindingproduction_planifier.Current;
                drview.Row["Nom"]="adel";
                drview.Row["Prenom"] = "moustansir";
     
                //se position sur le record ajoute....
                bindingproduction_planifier.MoveNext();
                this.label1.Text = drview.Row["Nom"].ToString();
                this.label2.Text = drview.Row["Prenom"].ToString();
                this.lblEnregNum.Text = "Current Record N° : " + bindingproduction_planifier.Position.ToString();
            }
        }
    }
    Maintenant le bindingnavigator t'as joue un tour....!!!
    bon code..

  3. #3
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2012
    Messages
    238
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mars 2012
    Messages : 238
    Points : 77
    Points
    77
    Par défaut
    merci l'ami
    voila j'ai ajouter ce bout de code et ça a marcher
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    DataRowView viewproduction_planifier = (DataRowView)bindingproduction_planifier.Current;
                editquantitéaparente.Text = viewproduction_planifier.Row["qte_encours"].ToString();
    je connais pas l'utilité du mot clé this c'est pour ça je lé pas mis mais bon ça marche ça m'évite de créer 10 datagridview pour manupuler ma table.mais je remarque quand même que c'est dirigé , je m’explique : il faut que j’affect a chaque fois ce que je doit mettre dans mon label ça ne se fait pas automatiquement .d’ailleurs j'ai suprimer le bout :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    editquantitéaparente.DataBindings.Add(new Binding("Text", datasetproduction, "production_planifier.qte_encours"));
    et ça a marcher comme même.
    c'est une solution c'est vrai mais elle ressemble a celle du datagridview .
    Delphi XE8 Architect - Win 10

  4. #4
    Expert confirmé
    Inscrit en
    Avril 2008
    Messages
    2 564
    Détails du profil
    Informations personnelles :
    Âge : 64

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 564
    Points : 4 441
    Points
    4 441
    Par défaut
    re
    Oups ya habibou...
    Il y a un petit bogus..dand le code ..c'est au niveau des DataBindings.Add()
    Voici le code modifie..tu dois garder les DataBindings :
    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
     
    //dropper sur le form:
    //-01 dataset personnalise
    //-01 dataadapter personnalise  
    //- 04 buttons
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
     
    namespace WinDGVSearch
    {
        public partial class Form2 : Form
        {
            BindingSource bindingproduction_planifier = new BindingSource();
            public Form2()
            {
                InitializeComponent();
     
     
            }
     
     
            private void btnFillDataTable_Click(object sender, EventArgs e)
            {
                personsTableAdapter1.Fill(personsDataSet1.Persons);
                bindingproduction_planifier.DataSource = personsDataSet1;
                bindingproduction_planifier.DataMember = personsDataSet1.Persons.TableName;
     
                this.label1.DataBindings.Add(new Binding("Text", bindingproduction_planifier, "Nom", true, DataSourceUpdateMode.OnPropertyChanged));
                this.label2.DataBindings.Add(new Binding("Text", bindingproduction_planifier, "Prenom", true, DataSourceUpdateMode.OnPropertyChanged));
            }
     
            private void btnMoveNext_Click(object sender, EventArgs e)
            {
                bindingproduction_planifier.MoveNext();
                this.lblEnregNum.Text = "Current Record N° : " + bindingproduction_planifier.Position.ToString();
            }
     
            private void btnMovePrevious_Click(object sender, EventArgs e)
            {
                bindingproduction_planifier.MovePrevious();
     
                this.lblEnregNum.Text = "Current Record N° : " + bindingproduction_planifier.Position.ToString();
            }
     
            private void btnAddNew_Click(object sender, EventArgs e)
            {
                //se position sur le dernier record ....
                bindingproduction_planifier.MoveLast();
     
                //ajout nouveau record à la vue....
                bindingproduction_planifier.AddNew();
                DataRowView drview = (DataRowView)bindingproduction_planifier.Current;
                drview.Row["Nom"]="adel";
                drview.Row["Prenom"] = "moustansir";
     
                //se position sur le record ajoute....
                bindingproduction_planifier.MoveNext();
     
                this.lblEnregNum.Text = "Current Record N° : " + bindingproduction_planifier.Position.ToString();
            }
     
        }
    }
    L'acces à DataRowView est necessaire si on veut ajouter un nouveau record...

    bon code.....

  5. #5
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2012
    Messages
    238
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mars 2012
    Messages : 238
    Points : 77
    Points
    77
    Par défaut
    merci hbibi ça marche impeccablement j'ai meme pas besoin du dataview , voila le code selon mes besoins (juste un affichage spécifique d'une valeur de cellule de ma table dans un label :

    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
     
    //racorder editquantite aparente avec qte en cours
    editquantitéaparente.DataBindings.Add(new Binding("Text", bindingproduction_planifier, "qte_encours", true, DataSourceUpdateMode.OnPropertyChanged));
    //tester si le poste est en production ensuite affecter la quantité en cour au label 
                if (datasetproduction.Tables["op_momunclature_productionp"].Rows.Count != 0)
                {
                    //ce positionner dans la ligne correspandante sur la table           production planifier
     int itemFound = bindingproduction_planifier.Find("cleproduction", datasetproduction.Tables["op_momunclature_productionp"].Rows[0].Field<int>("cleproduction").ToString());
    bindingproduction_planifier.Position = itemFound;
     
                }
                else
                {
                    editquantitéaparente.Text = "---------";
                }
    Delphi XE8 Architect - Win 10

  6. #6
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2012
    Messages
    238
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mars 2012
    Messages : 238
    Points : 77
    Points
    77
    Par défaut
    j'ai une dernière question avant de mettre résolu.

    es que je peut utilisé le binding source pour modifier ma base de donnée

    par exemple j'ai un text box je le racord avec un binding comme celui de laffichage mais quant je change la valeur dans ce dernier , elle ce met a jour automatiquement dans la base de donnée.
    quelque chose du genre :
    :edit quantité et un textbox
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    editquantite.DataBindings.Add(new Binding("Text", bindingproduction_planifier, "qte_encours", true, DataSourceUpdateMode.OnValidation));
    ensuit si je modifier la quantité dans le textbox je clique sur un bouton valider
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    production_planifier.Update(datasetproduction.Tables["production_planifier"]);
    et la nouvelle valeur s’affecte directement dans ma base de donnée . cette solution n'a pas marcher pour moi .
    merci d'avance
    Delphi XE8 Architect - Win 10

  7. #7
    Expert confirmé
    Inscrit en
    Avril 2008
    Messages
    2 564
    Détails du profil
    Informations personnelles :
    Âge : 64

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 564
    Points : 4 441
    Points
    4 441
    Par défaut
    rebonjour

    Ah non ce serait trop facile ....
    1/Rappel : DataTable = un array en memoire "photocopie" de la Table en base (BD)...donc DataTable <> Table

    a-/1er Manager : BindingSource => qui gere la "liaison" (binding) entre tes controls (textbox,dgv etc...) <=> et le DataTable ...

    b-/2eme Manager:Adapter => gere la liaison entre le DataTable <=> Table en base (BD) avec le concours d'un OleDbCommandBuilder initialise avec l'Adapter actuel...

    -OleDbCommandBuilder.Adapter.Fill
    -OleDbCommandBuilder.Adapter.Update
    -etc...
    code modifie avec un bouton Update :

    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
     
    //dropper sur le form:
    //-01 dataset personnalise
    //-01 dataadapter personnalise  
    //- 04 buttons+1 btn Update
    //- +1 btn Update
     
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Data.OleDb;
     
    namespace WinDGVSearch
    {
        public partial class Form2 : Form
        {
            BindingSource bindingproduction_planifier = new BindingSource();
            public Form2()
            {
                InitializeComponent();
     
     
            }
     
            OleDbCommandBuilder builder = null;
            private void btnFillDataTable_Click(object sender, EventArgs e)
            {
                personsTableAdapter1.Fill(personsDataSet1.Persons);
                bindingproduction_planifier.DataSource = personsDataSet1;
                bindingproduction_planifier.DataMember = personsDataSet1.Persons.TableName;
     
                this.label1.DataBindings.Add(new Binding("Text", bindingproduction_planifier, "Nom", true, DataSourceUpdateMode.OnPropertyChanged));
                this.label2.DataBindings.Add(new Binding("Text", bindingproduction_planifier, "Prenom", true, DataSourceUpdateMode.OnPropertyChanged));
     
                //INIT LE BUILDER...
                 builder = new OleDbCommandBuilder(personsTableAdapter1.Adapter);
     
            }
     
            private void btnMoveNext_Click(object sender, EventArgs e)
            {
                bindingproduction_planifier.MoveNext();
                this.lblEnregNum.Text = "Current Record N° : " + bindingproduction_planifier.Position.ToString();
            }
     
            private void btnMovePrevious_Click(object sender, EventArgs e)
            {
                bindingproduction_planifier.MovePrevious();
     
                this.lblEnregNum.Text = "Current Record N° : " + bindingproduction_planifier.Position.ToString();
            }
     
            private void btnAddNew_Click(object sender, EventArgs e)
            {
                //se position sur le dernier record ....
                bindingproduction_planifier.MoveLast();
     
                //ajout nouveau record à la vue....
                bindingproduction_planifier.AddNew();
                DataRowView drview = (DataRowView)bindingproduction_planifier.Current;
                drview.Row["Nom"]="adel";
                drview.Row["Prenom"] = "moustansir";
     
                //se position sur le record ajoute....
                bindingproduction_planifier.MoveNext();
     
                this.lblEnregNum.Text = "Current Record N° : " + bindingproduction_planifier.Position.ToString();
            }
            //MAJ EN BASE...
            private void btnUpdate_Click(object sender, EventArgs e)
            {
                 personsTableAdapter1.Adapter.UpdateCommand = builder.GetUpdateCommand();
                 personsTableAdapter1.Adapter.Update(personsDataSet1);
     
            }
     
        }
    }
    bon code...

  8. #8
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2012
    Messages
    238
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mars 2012
    Messages : 238
    Points : 77
    Points
    77
    Par défaut
    merci pour vos précieuse réponse .

    au début j'ai modifier mon code comme suite :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
                OleDbCommandBuilder builder = null;
                builder = new OleDbCommandBuilder(production_planifier);
                production_planifier.UpdateCommand = builder.GetUpdateCommand();
    production_planifier.Update(datasetproduction.Tables["production_planifier"]);
    mais j'ai remarqué que ça enregistre que dans l'adapter donc temporairement et a l'aide d'un datagridview j'ai remarqué que dé que je change de ligne l'enregistrement ce fait normalement donc j'ai modifier comme suite :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    OleDbCommandBuilder builder = null;
                builder = new OleDbCommandBuilder(production_planifier);
                production_planifier.UpdateCommand = builder.GetUpdateCommand();
                bindingproduction_planifier.MoveNext();
                bindingproduction_planifier.MovePrevious();
                production_planifier.Update(datasetproduction.Tables["production_planifier"]);
    et ça a marcher (si j'ai bien compris ça n'enregistre pas la ligne en cours )
    je crois que j'ai fais du bricolage malgré que ça a marcher mai bon je crois qu'il y a une solution pour le faire sans passé par le basculement de ligne.

    je vous remercie d'avance.
    Delphi XE8 Architect - Win 10

  9. #9
    Expert confirmé
    Inscrit en
    Avril 2008
    Messages
    2 564
    Détails du profil
    Informations personnelles :
    Âge : 64

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 564
    Points : 4 441
    Points
    4 441
    Par défaut
    re

    Comme j'ignore la structure de la totalite de ton code ,je ne peux rien dire mais ce code fonctionnne parfaitement (on n'as pas besoin des move)...

    Esuite les regles à respecter (mentionne dans le code deja donne) :
    Oledbbuilder
    -doit etre declare en portee class
    -doit etre initialiser une seule fois juste apres le fill
    -l'initialisation se fait avec un "Adapter...!!!" ...

    On ne cree pas à chaque fois un OledBuilder .Il y a un seul cree pour toute la session de travail juste apres Adapter.Fill ...
    Il faut suivre les prescriptions donnees sinon ca n'est pas la peine de poser des questions dans le forum.....
    voici une structure de code exemple....
    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
     
     using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Data.OleDb;
    namespace WinDGVSearch
    {
        public partial class Form4 : Form
        {
            string strCon = "etc...";
            DataSet datasetproduction = new DataSet();
            BindingSource bindingproduction_planifier = new BindingSource();
            OleDbDataAdapter production_planifier;
            //ON LE DECLARE ICI
            OleDbCommandBuilder builder = null;
            public Form4()
            {
                InitializeComponent();
            }
     
            private void btnFillDataTable_Click(object sender, EventArgs e)
            {
                using (OleDbConnection con = new OleDbConnection(strCon)) 
                {
                    con.Open();
     
                    string strSQL = "SELECT * FROM etc...;";
                    production_planifier = new OleDbDataAdapter(strSQL, strCon);
     
                    //fill
                    datasetproduction = new DataSet();
                    production_planifier.Fill(datasetproduction, "production_planifier");
     
                    bindingproduction_planifier.DataSource = datasetproduction;
                    bindingproduction_planifier.DataMember = datasetproduction.Tables["production_planifier"].TableName;
     
                    //ON LE CREE ICI UNE SEULE FOIS APRES CHARGEMENT...
                    builder = new OleDbCommandBuilder(production_planifier);
     
                    this.label1.DataBindings.Add(new Binding("Text", bindingproduction_planifier, "Nom", true, DataSourceUpdateMode.OnPropertyChanged));
                    this.label2.DataBindings.Add(new Binding("Text", bindingproduction_planifier, "Prenom", true, DataSourceUpdateMode.OnPropertyChanged));
     
                };//using ferme la connexion
     
            }
     
            private void btnMoveNext_Click(object sender, EventArgs e)
            {
                bindingproduction_planifier.MoveNext();
     
                   //EDIT D'UN RECORD DANS LA VUE(MODIF)...
     
                    DataRowView drview = (DataRowView)bindingproduction_planifier.Current;
                    drview.Row["Nom"] = "Tataouine ";
                    drview.Row["Prenom"] = "Les bains";
     
                    //ON NE SEME PAS LES "New Builder " c'est du wazaa a mouhanni wazaa...!!!
                    if ( builder !=null   )
                    {
                        production_planifier.UpdateCommand = builder.GetUpdateCommand();
                        production_planifier.Update(datasetproduction.Tables["production_planifier"]); 
                    }
            }
        }
    }
    bon code...

  10. #10
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2012
    Messages
    238
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mars 2012
    Messages : 238
    Points : 77
    Points
    77
    Par défaut


    j'ai fais excatement pareil mais ça marche pas sans le move je crois que c'est a cause du sgbd (access)

    voila le code complet

    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
     
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Data;
    using System.Data.SqlClient;
    using System.Data.OleDb;
     
    namespace Production
    {
     
        public partial class Form1 : Form
        {
                OleDbConnection Connectionproduction = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\\projet dedax\\gestion des projet\\gp.mdb");
                DataSet datasetproduction = new DataSet();
    OleDbDataAdapter production_planifier = new OleDbDataAdapter("SELECT * FROM production_planifier", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\\projet dedax\\gestion des projet\\gp.mdb");// je sais vous allez me dire pourquoi tu crée oledbconnection si tu l'utilise pas (je l'utilise ailleurs)
    BindingSource bindingproduction_planifier = new BindingSource();
                OleDbCommandBuilder builderproduction_planifier = null;
     
     
            public Form1()
            {
                InitializeComponent();
            }
    private void tableproduction_planifier(object sender, EventArgs e)
            {
     
                production_planifier.InsertCommand = new OleDbCommand("INSERT INTO production_planifier (cleproduction) VALUES (:cleproduction)", Connectionproduction);
                production_planifier.InsertCommand.Parameters.Add(":cleproduction", OleDbType.Integer,4);
                Connectionproduction.Open();
                production_planifier.Fill(datasetproduction, "production_planifier");
                builderproduction_planifier = new OleDbCommandBuilder(production_planifier);
                Connectionproduction.Close();
                gridopd.DataSource = datasetproduction;
                gridopd.DataMember = "production_planifier"; 
                bindingproduction_planifier.DataSource = datasetproduction;
                bindingproduction_planifier.DataMember = "production_planifier";
     
            }
    private void Form1_Load(object sender, EventArgs e)
            {
     
                listeboxopd.SetSelected(0, true);
                tableproduction_planifier(sender, e);
                //racorder editquantite aparente et edit quentite avec qte en cours
                editquantitéaparente.DataBindings.Add(new Binding("Text", bindingproduction_planifier, "qte_encours", true, DataSourceUpdateMode.OnPropertyChanged));
                editquantite.DataBindings.Add(new Binding("Text", bindingproduction_planifier, "qte_encours", true, DataSourceUpdateMode.OnValidation));
            } 
    private void boutonvaliderquantite_Click(object sender, EventArgs e)
            {
                panelquntité.Visible = false;
                panelglobal.Enabled = true;
     
                if (builderproduction_planifier != null)
                {
     
                    production_planifier.UpdateCommand = builderproduction_planifier.GetUpdateCommand();
                    bindingproduction_planifier.MoveNext();
                    bindingproduction_planifier.MovePrevious();
                    production_planifier.Update(datasetproduction.Tables["production_planifier"]);
                }
        }
    }
    voila merci encore.
    Delphi XE8 Architect - Win 10

Discussions similaires

  1. Manipulation des handle contexte
    Par rockbiker dans le forum DirectX
    Réponses: 1
    Dernier message: 09/05/2003, 18h51
  2. Manipuler JAVA et SSL ?
    Par jah dans le forum Sécurité
    Réponses: 6
    Dernier message: 05/05/2003, 00h30
  3. [VB6]manipuler les semaines en VB ?
    Par kamadji dans le forum VB 6 et antérieur
    Réponses: 7
    Dernier message: 02/05/2003, 12h33
  4. Réponses: 2
    Dernier message: 18/01/2003, 17h06
  5. Fonctions de manipulation des chaines et des dates
    Par Fares BELHAOUAS dans le forum Débuter
    Réponses: 3
    Dernier message: 09/11/2002, 22h43

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