Beispiel #1
0
        public void Test5Etape()
        {
            voilier1Context model1            = new voilier1Context();
            DateTime        etape1Time        = new DateTime(2020, 3, 2, 0, 0, 0);
            DateTime        etape2Time        = new DateTime(2020, 3, 9, 16, 30, 0);
            Etape           etape1            = new Etape(3, "etape002", etape1Time, etape2Time, 10, 7);
            Etape           etape2            = new Etape(2, "etape002", etape1Time, etape2Time, 10, 7);
            GestionEtape    modelGestionEtape = new GestionEtape();

            modelGestionEtape.SupprimerEtape(etape1);
            modelGestionEtape.SupprimerEtape(etape2);
            modelGestionEtape.AjouterEtape(etape1);
            modelGestionEtape.AjouterEtape(etape2);
            var listeEtape = from f in model1.Etape select f;

            modelGestionEtape.DisplayEtape(listeEtape.ToList());

            Assert.AreEqual(etape1.IdEtape, listeEtape.ToList()[1].IdEtape);
            Assert.AreEqual(etape1.Nom, listeEtape.ToList()[1].Nom);
            Assert.AreEqual(etape1.DateDebut, listeEtape.ToList()[1].DateDebut);
            Assert.AreEqual(etape1.DateFin, listeEtape.ToList()[1].DateFin);
            Assert.AreEqual(etape1.VoilierEtapeIdVoilierEtape, listeEtape.ToList()[1].VoilierEtapeIdVoilierEtape);
            Assert.AreEqual(etape1.VoilierIdVoilier, listeEtape.ToList()[1].VoilierIdVoilier);

            Assert.AreEqual(etape2.IdEtape, listeEtape.ToList()[0].IdEtape);
            Assert.AreEqual(etape2.Nom, listeEtape.ToList()[0].Nom);
            Assert.AreEqual(etape2.DateDebut, listeEtape.ToList()[0].DateDebut);
            Assert.AreEqual(etape2.DateFin, listeEtape.ToList()[0].DateFin);
            Assert.AreEqual(etape2.VoilierEtapeIdVoilierEtape, listeEtape.ToList()[0].VoilierEtapeIdVoilierEtape);
            Assert.AreEqual(etape2.VoilierIdVoilier, listeEtape.ToList()[0].VoilierIdVoilier);
        }
Beispiel #2
0
    /// <summary>
    /// Change l'état dans lequel se trouve le personnage
    /// </summary>
    /// <param name="_state"></param>
    public virtual void SwitchState(Etape _state)
    {
        HumanState = _state;
        switch (HumanState)
        {
        case Etape.Tuto:
            break;

        case Etape.Moving:
            break;

        case Etape.GoCovered:
            break;

        case Etape.Covered:
            col.enabled = false;
            break;

        case Etape.GoUncovered:
            break;

        case Etape.Uncovered:
            col.enabled = true;
            break;
        }
    }
        private void BTN_Etape_Click(object sender, EventArgs e)
        {
            //Vérifie si l'étape est deja présente ou si c'est une ville de départ ou d'arrivée et si c'est une ville valide
            if ((!LB_Etapes.Items.Contains(C_Etape.Text)) && (C_VilleDepart.Text != C_Etape.Text) && (C_VilleArrivee.Text != C_Etape.Text) && C_Etape.Items.Contains(C_Etape.Text) != false)
            {
                // Ajoute l'item dans la ListeBox.
                LB_Etapes.Items.Add(C_Etape.Text);
                // Recherche la ville étape dans la List des ville étape
                Ville v = rechercheVilleEtape(C_Etape.Text);
                //Si v != null alors étape trouvée.
                if (v != null)
                {
                    // Création de l'étape
                    Etape villeEtape = new Etape(0, 0, v.getNom(), v.getCodePostal(), this.i);
                    // Ajout dans la liste
                    this.listeEtapes.Add(villeEtape);
                    // Mise à jour de l'ordre de la ville d'arrivée
                    Etape lastEtape = listeEtapes[listeEtapes.Count - 2];
                    listeEtapes.Remove(lastEtape);
                    this.arrivee = new Etape(0, 0, lastEtape.getVille(), lastEtape.getCodePostal(), (byte)(lastEtape.getOrdre() + 1));
                    listeEtapes.Add(this.arrivee);

                    this.i++;
                }
            }
        }
 public static List <Etape> getEtapesFromNode(JSONNode node)
 {
     if (node != null)
     {
         List <Etape> etapes = new List <Etape> ();
         foreach (JSONNode x in node["etapes"].AsArray)
         {
             Etape e = new Etape();
             foreach (Types t in System.Enum.GetValues(typeof(Types)))
             {
                 if (t.ToString().Equals(x ["type"]))
                 {
                     e.type = t;
                     break;
                 }
             }
             e.titre   = x ["titre"];
             e.contenu = x ["contenu"];
             e.taille  = Taille.getTailleFromNode(x["taille"]);
             e.ancrage = Ancrage.getAncrageFromNode(x["ancrage"]);
             etapes.Add(e);
         }
         return(etapes);
     }
     else
     {
         return(null);
     }
 }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Instruction,Nom,RecetteID")] Etape etape)
        {
            if (id != etape.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(etape);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EtapeExists(etape.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RecetteID"] = new SelectList(_context.Recette, "ID", "ID", etape.RecetteID);
            return(View(etape));
        }
        private void btn_AddStep_Click(object sender, EventArgs e)
        {
            this.procedure.setName(txtBx_Title.Text);
            this.procedure.setDescription(txtBx_Description.Text);

            //steps[steps.Count - 1] is the previous step of the one which is about to be created.
            //The last step is previous of the one to create now.
            Etape prevStep;

            if (this.procedure.steps != null && this.procedure.steps.Count > 0)
            {
                prevStep = this.procedure.steps[this.procedure.steps.Count - 1];
            }
            else
            {
                prevStep = null;
            }

            frm_AddStep frm = new frm_AddStep(prevStep, null, this.procedure, Operation.AddNew);

            frm.ShowDialog();
            //Add the created step to the steps list of the procedure.
            if (frm.Tag != null)
            {
                Etape step = (Etape)frm.Tag;
                this.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() });
                lstVew_Steps.Items.Add(item);
            }
        }
        public static void GetReceipe(Object recette)
        {
            Recette receipe = (Recette)recette;

            //Explode the steps from the receipe in an array
            string[] steps = Regex.Split(receipe.liste_etapes_recette, ";");

            //Foreach step in the steps array
            foreach (var step in steps)
            {
                int stepId = Convert.ToInt32(step);

                //From BDD we get all objects needed
                composé actualCompose = BDDController.Instance.DB.composé.SingleOrDefault(c => c.id_compose == stepId);
                Etape   actualStep    = BDDController.Instance.DB.Etape.SingleOrDefault(e => e.id_etape == actualCompose.id_etape);
                Console.WriteLine(actualCompose.id_Ingredient);
                Ustensile ustensile = BDDController.Instance.DB.Ustensile.SingleOrDefault(e => e.id_Ustensile == actualStep.id_Ustensile);
                LoggerController.AppendLineToFile(Parameters.LOG_PATH, actualCompose.id_etape.ToString());

                //Foreach steps in the receipe we create a new thread.
                Thread t = new Thread(delegate()
                {
                    //We use the method ass call back function of the thread.
                    //Two arg sent : step and ustensile object
                    CookCallback(actualStep, ustensile);
                });

                //Start the thread
                t.Start();
            }
        }
Beispiel #8
0
 public bool ModifierPersnne(Etape Etape)
 {
     // Mettre le statut de l'entité à "Modifiée" dans l'ORM
     model.Entry(Etape).State = EntityState.Modified;
     // Valide les changement dans la base de données
     return(model.SaveChanges() > 0);
 }
        private void lstVew_Steps_MouseClick(object sender, MouseEventArgs e)
        {
            //Get the selected item (step) from the list.
            int          selected = lstVew_Steps.SelectedIndices[0];
            ListViewItem item     = lstVew_Steps.Items[selected];
            //Etape step = new Etape(Convert.ToInt32(item.SubItems[0].Text), item.SubItems[1].Text, item.SubItems[2].Text, this.procedure);
            Etape step = null;
            //Gets the id of the selected Step.
            int id = Convert.ToInt32(item.SubItems[0].Text);

            //In the list of the procedure steps we look for the step with the previous Id.
            foreach (Etape stp in this.procedure.steps)
            {
                if (stp.getId() == id)
                {
                    step = stp;
                    break;
                }
            }
            lstVew_3dObjects.Items.Clear();
            foreach (Object3d obj in step.getObjectList())
            {
                lstVew_3dObjects.Items.Add(obj.getName());
            }
        }
Beispiel #10
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);
        }
        private void btn_ModifySetp_Click(object sender, EventArgs e)
        {
            if (lstVew_Steps.SelectedIndices.Count > 0)
            {
                //Set the procedure data if its not already set.
                this.procedure.setName(txtBx_Title.Text);
                this.procedure.setDescription(txtBx_Description.Text);

                //Get the selected item (step) from the list.
                int          selected = lstVew_Steps.SelectedIndices[0];
                ListViewItem item     = lstVew_Steps.Items[selected];

                //Etape step = new Etape(Convert.ToInt32(item.SubItems[0].Text), item.SubItems[1].Text, item.SubItems[2].Text, this.procedure);
                Etape step = null;

                //Gets the id of the selected Step.
                int id = Convert.ToInt32(item.SubItems[0].Text);
                //MessageBox.Show("SelectedStepId: " + id, "frm_AddProcedure.btn_ModifyStep");
                //In the list of the procedure steps we look for the step with the previous Id.
                foreach (Etape stp in this.procedure.steps)
                {
                    if (stp.getId() == id)
                    {
                        step = stp;
                        break;
                    }
                }

                //We send the slected step to the update form.
                frm_AddStep frm = new frm_AddStep(null, step, this.procedure, Operation.Update);
                frm.ShowDialog();

                //Add the created step to the steps list of the procedure.
                if (frm.Tag != null)
                {
                    step = (Etape)frm.Tag;
                    //Remove the old version of step.
                    this.procedure.steps.RemoveAt(selected);

                    //Insert the new version at the same place.
                    this.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.
                    lstVew_Steps.Items.RemoveAt(selected);
                    //Insert the new version at the same place.
                    lstVew_Steps.Items.Insert(selected, item);
                }
            }
            else
            {
                MessageBox.Show(this, "Sélectionner une étape SVP.", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #12
0
        public bool SupprimerEtape(int id)
        {
            Etape p = RechercherEtape(id);

            if (p == null)
            {
                return(false);
            }
            return(SupprimerEtape(p));
        }
        private void C_VilleArrivee_TextChanged(object sender, EventArgs e)
        {
            Ville v = rechercheVilleEtape(C_VilleArrivee.Text);

            if (v != null)
            {
                listeEtapes.Remove(this.arrivee);
                this.arrivee = new Etape(0, 0, v.getNom(), v.getCodePostal(), (byte)(listeEtapes.Count + 1));
                listeEtapes.Add(this.arrivee);
            }
        }
        private void C_VilleDepart_TextChanged(object sender, EventArgs e)
        {
            Ville v = rechercheVilleEtape(C_VilleDepart.Text);

            if (v != null)
            {
                listeEtapes.Remove(this.depart);
                this.depart = new Etape(0, 0, v.getNom(), v.getCodePostal(), 1);
                listeEtapes.Add(this.depart);
            }
        }
Beispiel #15
0
 public Etape AjouterEtape(Etape Etape)
 {
     // Ajoute le produit à l'ORM EF
     model.Etape.Add(Etape);
     // Valide les changement dans la base de données
     if (model.SaveChanges() > 0)
     {
         return(Etape);
     }
     return(null);
 }
Beispiel #16
0
        public frm_AddStep(Etape prevStep, Etape step, Procedure procedure, Operation operation)
        {
            InitializeComponent();

            this.Step       = step;
            this.Procedure  = procedure;
            this._Operation = operation;


            this.prevStep = prevStep;
        }
Beispiel #17
0
 public bool SupprimerEtape(Etape produit)
 {
     if (produit != null)
     {
         // Supprime le produit dans l'ORM
         model.Etape.Remove(produit);
         // Valide les changement dans la base de données
         return(model.SaveChanges() > 0);
     }
     return(false);
 }
        private void btn_Down_Click(object sender, EventArgs e)
        {
            if (lstVew_Steps.SelectedIndices.Count > 0)
            {
                int selected = lstVew_Steps.SelectedIndices[0];
                if (selected < lstVew_Steps.Items.Count - 1)
                {
                    //Save the lower step to move up later.
                    ListViewItem item = (ListViewItem)lstVew_Steps.Items[selected + 1].Clone();

                    //Keep the order of Ids the same.
                    item.Text = lstVew_Steps.Items[selected].Text;
                    lstVew_Steps.Items[selected].Text = lstVew_Steps.Items[selected + 1].Text;

                    //Remove the item we saved
                    lstVew_Steps.Items.RemoveAt(selected + 1);

                    //Move the step down.
                    lstVew_Steps.Items.Insert(selected, item);


                    //Save the lower step to move down later.
                    //Make a copy of the upper element.
                    Etape etp = new Etape();
                    etp.setId(this.procedure.steps[selected + 1].getId());
                    etp.setName(this.procedure.steps[selected + 1].getName());
                    etp.setDescription(this.procedure.steps[selected + 1].getDescription());
                    etp.setprocedure(this.procedure.steps[selected + 1].getprocedure());
                    foreach (Object3d obj in this.procedure.steps[selected + 1].getObjectList())
                    {
                        etp.addObject3d(obj);
                    }

                    //Keep the order of Ids the same.
                    etp.setId(this.procedure.steps[selected].getId());
                    this.procedure.steps[selected].setId(this.procedure.steps[selected + 1].getId());

                    //Remove the item we saved
                    this.procedure.steps.RemoveAt(selected + 1);

                    //Move the step up.
                    this.procedure.steps.Insert(selected, etp);

                    //Use this variable so that the app delete the old steps and reinsert them in the specified order.
                    StepsRemoved = true;
                    //MessageBox.Show("selected-1: " + this.procedure.steps[selected - 1].getId() + "  selected: " + this.procedure.steps[selected].getId());
                }
            }
            else
            {
                MessageBox.Show(this, "Sélectionner une étape SVP.", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public async Task <IActionResult> Create([Bind("ID,Instruction,Nom,RecetteID")] Etape etape)
        {
            if (ModelState.IsValid)
            {
                _context.Add(etape);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RecetteID"] = new SelectList(_context.Recette, "ID", "ID", etape.RecetteID);
            return(View(etape));
        }
Beispiel #20
0
        public frm_Add3dObject(Control paretn, Etape step, Object3d lastObj)
        {
            InitializeComponent();
            this.pParetn = paretn;

            btn_DrawObject.Enabled     = false;
            grpbx_Manipulation.Enabled = false;

            this.Step    = step;
            this.LastObj = lastObj;

            //this._Operation = operation;

            //if (this._Operation == Operation.AddNew)
            {
                //MessageBox.Show("Step.Name: "+this.Step.getName(),"frm_AddP=Object.Constructor");
                if (LastObj != null)
                {
                    number = LastObj.getNb() + 1;
                }

                if (this.Step != null)
                {
                    lbl_StepName.Text = "Etape: " + this.Step.getName();

                    //MessageBox.Show("frm_AddStep.RenderForm.Objects.count: " + RenderForm.Objects.Count.ToString());
                    if (RenderForm.Objects != null && RenderForm.Objects.Count > 0)
                    {
                        foreach (Object3d obj in RenderForm.Objects)
                        {
                            //Fill the list box of the created objects.
                            {
                                lstbx_Objects.Items.Add(obj);
                                //obj.LoadMesh();
                                //lstbx_Objets.Items.Add(file_info);
                                tabControl1.SelectedIndex = 0;
                            }
                        }
                    }
                    //----------------------------------
                }
                else
                {
                    MessageBox.Show("Step null", "frm_AddObject.Constructor");
                }
            }
            //else
            {
            }
        }
Beispiel #21
0
 // Use this for initialization
 public Scenario()
 {
     niveau      = PlayerPrefs.GetInt(Constants.MAIN_GAME_LVL);
     scenario    = new Etape[9];
     scenario[0] = new Etape(60, Constants.MECANO_GAME_LVL1_UNLOCK);
     scenario[1] = new Etape(80, Constants.PROPULSION_GAME_LVL1_UNLOCK);
     scenario[2] = new Etape(110, Constants.PAINT_GAME_LVL1_UNLOCK);
     scenario[3] = new Etape(120, Constants.MECANO_GAME_LVL2_UNLOCK);
     scenario[4] = new Etape(130, Constants.PROPULSION_GAME_LVL2_UNLOCK);
     scenario[5] = new Etape(180, Constants.PAINT_GAME_LVL2_UNLOCK);
     scenario[6] = new Etape(190, Constants.MECANO_GAME_LVL3_UNLOCK);
     scenario[7] = new Etape(200, Constants.PROPULSION_GAME_LVL3_UNLOCK);
     scenario[8] = new Etape(250, Constants.PAINT_GAME_LVL3_UNLOCK);
 }
Beispiel #22
0
 // Use this for initialization
 public Scenario()
 {
     niveau = PlayerPrefs.GetInt (Constants.MAIN_GAME_LVL);
     scenario = new Etape[9];
     scenario[0] = new Etape(60,Constants.MECANO_GAME_LVL1_UNLOCK);
     scenario[1] = new Etape(80,Constants.PROPULSION_GAME_LVL1_UNLOCK);
     scenario[2] = new Etape(110,Constants.PAINT_GAME_LVL1_UNLOCK);
     scenario[3] = new Etape(120,Constants.MECANO_GAME_LVL2_UNLOCK);
     scenario[4] = new Etape(130,Constants.PROPULSION_GAME_LVL2_UNLOCK);
     scenario[5] = new Etape(180,Constants.PAINT_GAME_LVL2_UNLOCK);
     scenario[6] = new Etape(190,Constants.MECANO_GAME_LVL3_UNLOCK);
     scenario[7] = new Etape(200,Constants.PROPULSION_GAME_LVL3_UNLOCK);
     scenario[8] = new Etape(250,Constants.PAINT_GAME_LVL3_UNLOCK);
 }
Beispiel #23
0
        public usrStep(RenderForm parent, usrProcedure brother, Etape prevStep, Etape step, Procedure procedure, Operation operation)
        {
            InitializeComponent();

            pParent = parent;
            Brother = brother;

            this.Step       = step;
            this.Procedure  = procedure;
            this._Operation = operation;


            this.prevStep = prevStep;
        }
Beispiel #24
0
 public static bool Add(Etape etape)
 {
     //If the file exists we insert a new element.
     //The number root children must be at least and element and the MaxID element = 2.
     if (Helper.service.FileExists("etape.xml"))
     {
         //System.Windows.Forms.MessageBox.Show("Insert");
         return(Insert(etape));
     }
     else //Otherwise we create the file and insert the first elemet.
     {
         //System.Windows.Forms.MessageBox.Show("FirstAdd");
         return(FirstAdd(etape));
     }
 }
 public static Dictionary <string, Tuteur> getTuteursFromNode(JSONNode node)
 {
     if (node != null)
     {
         Dictionary <string, Tuteur> tuteurs = new Dictionary <string, Tuteur> ();
         foreach (JSONNode x in node["tuteurs"].AsArray)
         {
             Tuteur t = new Tuteur();
             t.scene  = x ["scene"];
             t.id     = x ["id"];
             t.etapes = Etape.getEtapesFromNode(x);
             tuteurs.Add(t.id, t);
         }
         return(tuteurs);
     }
     else
     {
         return(null);
     }
 }
        private void BTN_SupprimerEtape_Click(object sender, EventArgs e)
        {
            // Supprime la ville de la liste des étapes
            // Recherche la ville étape dans la List des ville étape
            Etape etape = rechercheEtapeDansListe(LB_Etapes.SelectedItem.ToString());

            if (etape != null)
            {
                listeEtapes.Remove(etape);
            }

            LB_Etapes.Items.Remove(LB_Etapes.SelectedItem);

            // Mise à jour de l'ordre de la ville d'arrivée
            Etape lastEtape = listeEtapes[listeEtapes.Count - 1];

            listeEtapes.Remove(lastEtape);
            this.arrivee = new Etape(0, 0, lastEtape.getVille(), lastEtape.getCodePostal(), (byte)(lastEtape.getOrdre() - 1));
            listeEtapes.Add(this.arrivee);

            this.i--;
        }
        public static List <Etape> GetEtapes(int idTraitement, bool expand = false)
        {
            List <Etape> etapes   = new List <Etape>();
            List <int>   idEtapes = new List <int>();

            if (ConnexionBD.Instance().EstConnecte())
            {
                ConnexionBD.Instance().ExecuterRequete(
                    String.Format(
                        "SELECT idEtape _id, description nom " +
                        "FROM Etapes " +
                        "WHERE idTraitement = {0}",
                        idTraitement
                        ), lecteur =>
                {
                    Etape etape = new Etape {
                        Description = lecteur.GetString("nom")
                    };

                    if (expand)
                    {
                        idEtapes.Add(int.Parse(lecteur.GetString("_id")));
                    }

                    etapes.Add(etape);
                }
                    );
                if (expand)
                {
                    for (int i = 0; i < etapes.Count; i++)
                    {
                        etapes[i].Instructions = new ObservableCollection <string>(DataModelInstructionEtape.GetInstructions(idEtapes[i]));
                    }
                }
            }

            return(etapes);
        }
Beispiel #28
0
        private void lstVew_Steps_DoubleClick(object sender, EventArgs e)
        {
            if (lstVew_Steps.SelectedIndices.Count > 0)
            {
                //Set the procedure data if its not already set.
                this.procedure.setName(txtBx_Title.Text);
                this.procedure.setDescription(txtBx_Description.Text);

                //Get the selected item (step) from the list.
                int          selected = lstVew_Steps.SelectedIndices[0];
                ListViewItem item     = lstVew_Steps.Items[selected];

                Etape step = null;

                //Gets the id of the selected Step.
                int id = Convert.ToInt32(item.SubItems[0].Text);

                //In the list of the procedure steps we look for the step with the previous Id.
                foreach (Etape stp in this.procedure.steps)
                {
                    if (stp.getId() == id)
                    {
                        step = stp;
                        break;
                    }
                }

                usrStep usr = new usrStep(this.pParent, this, null, step, this.procedure, Operation.Update);
                usr.Location = new Point(5, 115);
                this.Hide();
                this.Parent.Controls.Add(usr);
            }
            else
            {
                MessageBox.Show(this, "Sélectionner une étape SVP.", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private static void CookCallback(Object step, Object paramUstensile)
        {
            //Cast the good type
            Etape     actualStep = (Etape)step;
            Ustensile ustensile  = (Ustensile)paramUstensile;

            //Init a kitchenController
            KitchenToolsController kitchenToolsController = new KitchenToolsController();

            //Try to get the tool
            kitchenToolsController.SetInUseTool(ustensile.nom_ust_Ustensile);

            //Take one permit on Semaphore
            _cooker.WaitOne();

            //Clear stock
            //BDDController.Instance.DB.Stock.Remove...

            //Sleep represent the time of the step
            Thread.Sleep(Convert.ToInt32(actualStep.temps_etape) * 1000);

            //When step is done, semaphore is release. Cooker is free.
            _cooker.Release(1);
        }
Beispiel #30
0
        private void btn_UpdateProcedure_Click(object sender, EventArgs e)
        {
            frm_ListOf frm = new frm_ListOf(Subject.ProcedureSbjct);

            frm.ShowDialog();

            if (frm.Tag != null)
            {
                Procedure proc = (Procedure)frm.Tag;

                foreach (Etape etp in Etape.GetByProcedure(proc.getId()))
                {
                    proc.addEtape(etp);
                    //MessageBox.Show("etp.Objects.count: "+etp.getObjectList().Count,"RenderForm.btn_UpdateProcedure");
                }


                //frm_AddProcedure frmProc = new frm_AddProcedure(proc.getPanne().getTypePanne(), proc.getPanne(), proc, Operation.Update);
                //frmProc.ShowDialog();
                usrProcedure usrproc = new usrProcedure(this, proc.getPanne().getTypePanne(), proc.getPanne(), proc, Operation.Update);
                usrproc.Location = new Point(5, 115);
                this.Controls.Add(usrproc);
            }
        }
        private void btn_Save_DataBase_Click(object sender, EventArgs e)
        {
            //try
            {
                //
                //Remember that this button could be used to add new elements to the DB as it could be used to update them.
                //Put in mind to treat this issue.Abdelalim
                //

                //Check for emty fields.
                if (Check_Fields())
                {
                    if (this.procedure.steps.Count > 0)
                    {
                        //Set the procedure final values
                        this.procedure.setName(txtBx_Title.Text);
                        this.procedure.setDescription(txtBx_Description.Text);

                        //Set the failuretype final values
                        if (this.failureType == null)
                        {
                            this.failureType = new TypePanne();
                        }
                        this.failureType.setName(txtBx_FailureType.Text);
                        this.failureType.setDescription(FailureTypeDesc);

                        //Set the failure final values
                        if (this.Failure == null)
                        {
                            this.Failure = new Panne();
                        }
                        this.Failure.setName(txtBx_Failure.Text);
                        this.Failure.setDescription(FailureDesc);
                        this.failureType.addPanne(Failure);

                        //Add new proecedure.
                        if (this._Operation == Operation.AddNew)
                        {
                            //If no existing Failure type is chosen create new one.
                            if (this.failureType == null)
                            {
                                //Get the Id of the new failure type (type de panne).
                                this.failureType = new TypePanne();
                                this.failureType.setName(txtBx_FailureType.Text);
                                this.failureType.setDescription(FailureTypeDesc);
                            }
                            //If no existing Failure is chosen create new one.
                            if (this.Failure == null)
                            {
                                this.Failure = new Panne();
                                this.Failure.setName(txtBx_Failure.Text);
                                this.Failure.setDescription(FailureDesc);

                                //Add _Failure to the list of failures of the FailureType object.
                                this.failureType.addPanne(this.Failure);
                            }

                            //Addthe procedure to the Failure's list of procedures.
                            this.Failure.addProcedure(procedure);

                            //Save the failure type (le type de panne).
                            if (!failureType.Exists())//If a new type is created we save it to the data base.
                            {
                                failureType.Add();
                                Failure.Add();// Save the failure to the DB since it belongs to a newly created FailureType.
                            }
                            else//If the FailureType exists we check for the the failure(panne).
                            //Save the failure (la panne).
                            {
                                failureType.Update(failureType.getId());
                                if (!Failure.Exists())//If a new type is created we save it to the data base.
                                {
                                    Failure.Add();
                                }
                                else
                                {
                                    Failure.Update(Failure.getId());
                                }
                            }
                            //
                            //Saving the procedure.
                            //
                            procedure.AddToDB();
                            //MessageBox.Show("Proc.Steps.count: " + this.procedure.getEtapes().Count, "frm_AddProcedure.btn_Save");
                            //Save the steps.
                            foreach (Etape step in this.procedure.getEtapes())
                            {
                                //Associates each step with the current procedure.
                                //procedure.addEtape(step);
                                step.setprocedure(this.procedure);
                                //MessageBox.Show("Etape.Proc: " + step.getprocedure().getId(), "frm_AddProcedure.btn_Save");
                                //Save the step and its objects to the file etape.xml.
                                step.Add();
                            }
                        }
                        else//Update an existing procedure.
                        {
                            //Addthe procedure to the Failure's list of procedures.
                            this.Failure.addProcedure(procedure);
                            //MessageBox.Show("Falure.name: " + Failure.getId(), "frm_AddPrecedure.btn_Save");
                            //
                            //Saving the procedure.
                            //
                            procedure.Update(this.procedure.getId());

                            //Save the steps.
                            if (StepsRemoved)
                            {
                                //Remove all the steps of the current procedure from the data base.
                                //MessageBox.Show("Proc.steps.count: " + this.procedure.getEtapes().Count, "frm_AddProcedure.btn_Save");
                                Etape.RemoveByProcedure(this.procedure.getId());
                            }

                            //In case we allow the user to update the failure and its type from this GUI.
                            //Update the FailureType.
                            failureType.Update(failureType.getId());
                            //Update the failure (la panne).
                            Failure.Update(Failure.getId());

                            //MessageBox.Show("Steps.Count: "+this.procedure.getEtapes().Count, "frm_AddProcedure.btn_Save");
                            foreach (Etape step in this.procedure.steps)
                            {
                                //Associates each step with the current procedure.
                                step.setprocedure(this.procedure);
                                //If the current step exists in the DB means we're about to update it.
                                if (step.Exists())
                                {
                                    step.Update(step.getId());
                                }
                                else
                                {
                                    //Save the step and its objects to the file etape.xml.
                                    step.Add();
                                    //MessageBox.Show("Step "+step.getName()+" added","frm_AddProcedure.btn_Save");
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(this, "La procedure doit avoir au minimum une étape.", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show(this, "Remplir les champs importants d'abord.", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                MessageBox.Show(this, "Opération terminée avec succès.", "Message d'information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Tag = this.procedure;
                this.Close();
            }
            //catch (Exception x) { MessageBox.Show(x.ToString()); }
        }