Exemple #1
0
        /// <summary>
        /// Gets the step by Id.
        /// </summary>
        /// <param name="id">The id of the targeted Step.</param>
        /// <returns></returns>
        public static Etape GetById(int id)
        {
            /* On déclare et on crée une instance des variables nécéssaires pour la recherche */
            Etape step = new Etape();

            try
            {
                string rslt = Helper.service.LoadFile("etape.xml").ToString();

                StreamWriter sw = new StreamWriter(System.Windows.Forms.Application.StartupPath + "\\temp.xml");
                sw.Write(rslt);
                sw.Close();


                //XPathDocument XPathDocu = new XPathDocument((Stream)Helper.service.LoadFile("Experts.xml"));
                XPathDocument     XPathDocu = new XPathDocument(System.Windows.Forms.Application.StartupPath + "\\temp.xml");
                XPathNavigator    Navigator;
                XPathNodeIterator Nodes;

                /* On affecte false à  la
                 * /* On crée un navigateur */
                Navigator = XPathDocu.CreateNavigator();

                string ExpXPath = "//etape[@id='" + id + "']";
                /* On lance la recherche */
                Nodes = Navigator.Select(Navigator.Compile(ExpXPath));
                /* On vérifie si la recherche a été fructueuse */
                if (Nodes.Count != 0)
                {
                    Nodes.MoveNext(); // NOTE: Necéssaire pour se placer sur le noeud recherché
                    /* Encodage des données dans la classe Etape */
                    step.setId(id);
                    Nodes.Current.MoveToFirstChild(); /* On se déplace sur le premier noeud
                                                       * enfant "Libelle" */
                    step.setName(Nodes.Current.Value);
                    Nodes.Current.MoveToNext();       // On se déplace sur le noeud suivant "Description"
                    step.setDescription(Nodes.Current.Value);
                    Nodes.Current.MoveToNext();
                    //
                    //Get all the objects
                    //
                    step.setObjectList(XML3dObject.GetStepObjects(id));
                    Nodes.Current.MoveToNext(); // On se déplace sur le noeud suivant "Procedure"
                    step.setprocedure(XMLProcedure.GetById(Convert.ToInt32(Nodes.Current.Value)));
                }
                /* Si aucun expert n'a été trouvé */
                else
                {
                    step = null;
                }
            }
            catch (System.IO.FileNotFoundException x) { }
            catch (Exception x)
            {
                System.Windows.Forms.MessageBox.Show(x.ToString());
            }
            /* Renvoi de toutes les données dans une instance de la classe "etape" */
            return(step);
        }
Exemple #2
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            if (Step.getObjectList() != null && Step.getObjectList().Count > 0)
            {
                //
                //Crete the Step's elements.
                //
                Step.setName(txtBx_Title.Text);
                Step.setDescription(txtBx_Description.Text);
                Step.setObjectList(RenderForm.Objects);


                if (_Operation == Operation.AddNew)
                {
                    //Add the created step to the steps list of the procedure.

                    this.Brother.procedure.addEtape(Step);

                    //Fill the list view with the step's data.
                    ListViewItem item = new ListViewItem(new string[] { Step.getId().ToString(), Step.getName(), Step.getDescription() });
                    this.Brother.lstVew_Steps.Items.Add(item);
                }
                else
                {
                    //Get the selected item (step) from the list.
                    int          selected = Brother.lstVew_Steps.SelectedIndices[0];
                    ListViewItem item     = Brother.lstVew_Steps.Items[selected];

                    //Add the created step to the steps list of the procedure.

                    //Remove the old version of step.
                    this.Brother.procedure.steps.RemoveAt(selected);

                    //Insert the new version at the same place.
                    this.Brother.procedure.steps.Insert(selected, Step);

                    //Fill the list view with the step's data.
                    item = new ListViewItem(new string[] { Step.getId().ToString(), Step.getName(), Step.getDescription() });

                    //Remove the old version of step.
                    Brother.lstVew_Steps.Items.RemoveAt(selected);
                    //Insert the new version at the same place.
                    Brother.lstVew_Steps.Items.Insert(selected, item);
                }

                Dispose();
            }
            else
            {
                MessageBox.Show(this, "L'étape doit avoir au minimum un objet.", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            if (Step.getObjectList() != null && Step.getObjectList().Count > 0)
            {
                //
                //Crete the Step's elements.
                //
                Step.setName(txtBx_Title.Text);
                Step.setDescription(txtBx_Description.Text);
                Step.setObjectList(RenderForm.Objects);

                //Use the Tag object to transfere data between forms.
                this.Tag = Step;
                Close();
            }
            else
            {
                MessageBox.Show(this, "L'étape doit avoir au minimum un objet.", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }