Exemplo n.º 1
0
        private void treeView_modemploye_AfterSelect(object sender, TreeViewEventArgs e)
        {
            Profil ressource = null;
            Chilkat.Xml xmlProfiles = new Chilkat.Xml();
            xmlProfiles.LoadXmlFile("profiles.xml");

            Chilkat.Xml xmlPoste7 = new Chilkat.Xml();
            xmlPoste7.LoadXmlFile("postes.xml");
            treeView_postdispo.Nodes.Clear();
            treeView_postechoisi.Nodes.Clear();
            FillTree(treeView_postdispo.Nodes, xmlPoste7);

            String textInForm;
            textInForm = treeView_modemploye.SelectedNode.Text.ToString();
            String id;
            int idprofil;
            id = findRessourceXML(textInForm, xmlProfiles);

            if (id != null)
            {
                profilSelected = (Profil)loader.findRessource(Convert.ToInt32(id), loader.profilCharge);
                ressource = profilSelected;
                idprofil = ressource.getId();
                numemp_textbox.Text = ressource.getId().ToString();
                nom_textbox.Text = ressource.getNom();
                prenom_textbox.Text = ressource.getPrenom();
                courriel_textbox.Text = ressource.getEmail();
                telephone_textbox.Text = ressource.getNumTelephone();
                DataTable datatable;
                DataTable datatable2;
                DBConnect proc = new DBConnect();
                datatable = proc.getPosteProfil2(idprofil);
                int pid;
                String pname;

                for(int i = 0; i < datatable.Rows.Count; i++)
                {

                    pid = Convert.ToInt32(datatable.Rows[i]["idPoste"]);
                    datatable2 = proc.getPoste2(pid);
                    pname = datatable2.Rows[0]["nom"].ToString();

                    //pname = datatable.Rows[i].ToString();

                    System.Windows.Forms.TreeNode name;
                    name = new System.Windows.Forms.TreeNode(pname);
                    this.treeView_postechoisi.Nodes.Add(pname);

                    for (int j = 0; j < treeView_postdispo.Nodes.Count; j++)
                    {
                        if (treeView_postdispo.Nodes[j].Text.ToString() == pname)
                        {
                            treeView_postdispo.Nodes[j].Remove();
                        }
                    }

                    this.treeView_postdispo.Nodes.Remove(name);

                }

            }
        }