コード例 #1
0
        public void addPreset(Bloc bloc, int x)
        {
            TimeSpan dateDebut = new TimeSpan(bloc.getDebut().Hour, bloc.getDebut().Minute, bloc.getDebut().Second);
            TimeSpan dateFin   = new TimeSpan(bloc.getFin().Hour, bloc.getFin().Minute, bloc.getFin().Second);



            DateTime tempDebut = new DateTime(this.dateDuJour.Year, this.dateDuJour.Month, this.dateDuJour.Day) + dateDebut;
            DateTime tempFin   = new DateTime(this.dateFin.Year, this.dateFin.Month, this.dateFin.Day) + dateFin;


            Bloc tempBloc = new Bloc(tempDebut, tempFin, 0, 0, true);

            tempBloc.setRessourceAffectes(bloc.getRessourceAffectes());
            tempBloc.setRessourceVoulus(bloc.getListRessourceVoulus());
            tempBloc.setId(bloc.getId());



            if (placementValide(tempBloc))
            {
                //Ajout du block valide
                tempBloc.draw(width, grfx);
                loader.bloc.Add(tempBloc);
                tempBloc.save(true);
            }
            else
            {
                MessageBox.Show("Placement invalide");
            }
        }
コード例 #2
0
        //Retourne vrai si le placement est valide
        public bool placementValide(Bloc leBloc)
        {
            //Variables
            //Retirer lui-même du tableau
            int indexBloc = -1;
            int heureTempDebut;

            // MessageBox.Show("Heure temp "+tempHd);
            try
            {
                heureTempDebut = Int16.Parse(tempHd);
            }
            catch (Exception)
            {
                // MessageBox.Show("Erreur de parse");
                throw;
            }

            //Trouve son index
            for (int i = 0; i < listBloc.Count; i++)
            {
                //  MessageBox.Show("Heure de départ : " + listBloc[i].getDebut().Hour);
                if (listBloc[i].getDebut().Hour.Equals(heureTempDebut))
                {
                    indexBloc = i;
                    //  MessageBox.Show("Index du bloc :" + indexBloc);
                    break;
                }
            }
            //  MessageBox.Show("Début : " + leBloc.getDebut().Hour + " Fin : " + leBloc.getFin().Hour);

            for (int i = 0; i < listBloc.Count; i++)
            {/*
              * //Sois le bloc ajouté enpiète sur la fin du bloc existant ou sur le debut du bloc existant
              * if (((( leBloc.getDebut().Hour < listBloc[i].getFin().Hour && leBloc.getFin().Hour > listBloc[i].getFin().Hour)
              || (leBloc.getFin().Hour > listBloc[i].getDebut().Hour && leBloc.getDebut().Hour < listBloc[i].getDebut().Hour)
              || (leBloc.getDebut().Hour < listBloc[i].getDebut().Hour && leBloc.getFin().Hour > listBloc[i].getDebut().Hour)))
              ||    && (indexBloc != i))//Différent de lui-même*/
             //MessageBox.Show("Première condition : " + (leBloc.getDebut().Hour < listBloc[i].getFin().Hour && leBloc.getFin().Hour > listBloc[i].getDebut().Hour) + " \nDeuxième condition : " + (leBloc.getFin().Hour > listBloc[i].getDebut().Hour && leBloc.getDebut().Hour < listBloc[i].getDebut().Hour) + " \n Troisième condition : " + (leBloc.getDebut().Hour < listBloc[i].getDebut().Hour && leBloc.getFin().Hour > listBloc[i].getDebut().Hour) + " \n Index : " + (indexBloc != i));


                if (((leBloc.getDebut().Hour < listBloc[i].getFin().Hour&& leBloc.getFin().Hour > listBloc[i].getDebut().Hour) ||
                     (leBloc.getFin().Hour > listBloc[i].getDebut().Hour&& leBloc.getDebut().Hour < listBloc[i].getDebut().Hour) ||
                     (leBloc.getDebut().Hour <listBloc[i].getDebut().Hour&& leBloc.getFin().Hour> listBloc[i].getDebut().Hour)) &&
                    (indexBloc != i)) //Différent de lui-même*/
                {
                    return(false);    //Bloc existant
                }
            }
            return(true); //Aucun accros
        }
コード例 #3
0
 public bool placementValide(Bloc leBloc)
 {
     //Variables
     for (int i = 0; i < blocs.Count; i++)
     {
         //Sois le bloc ajouté enpiète sur la fin du bloc existant ou sur le debut du bloc existant
         if ((leBloc.getDebut() < blocs[i].getFin() && leBloc.getFin() > blocs[i].getFin()) ||
             (leBloc.getFin() > blocs[i].getDebut() && leBloc.getDebut() < blocs[i].getDebut()) ||
             (leBloc.getFin() == blocs[i].getFin() || leBloc.getDebut() == blocs[i].getDebut()))
         {
             return(false); //Bloc existant
         }
     }
     return(true); //Aucun accros
 }
コード例 #4
0
ファイル: Profil.cs プロジェクト: fredericboivin/holoraire
        public bool modifierBloc(Bloc leBloc, Bloc leBloc2, bool isPref)
        {
            int         nbBloc;
            bool        blocTrouve = false;
            List <Bloc> blocs      = null;

            if (isPref)
            {
                blocs = getPref();
            }
            else
            {
                blocs = getDispo();
            }

            nbBloc = blocs.Count;
            //Les conditions a modifier devront être unique a chaque blocs
            for (int i = 0; i < nbBloc; i++)
            {
                if (blocs[i].getDebut() == leBloc.getDebut())
                {
                    blocs[i]   = leBloc2;
                    blocTrouve = true;
                    break;
                }
            }

            return(blocTrouve);
        }
コード例 #5
0
ファイル: loader.cs プロジェクト: fredericboivin/holoraire
        //Modifis le bloc correspondant a celui fournis
        public bool modifierBloc(Bloc leBloc, Bloc leBloc2)
        {
            int  nbBloc     = bloc.Count;
            bool blocTrouve = false;

            //Les conditions a modifier devront être unique a chaque blocs
            for (int i = 0; i < nbBloc; i++)
            {
                if (bloc[i].getDebut() == leBloc.getDebut())
                {
                    bloc[i]    = leBloc2;
                    blocTrouve = true;
                    break;
                }
            }

            return(blocTrouve);
        }
コード例 #6
0
ファイル: loader.cs プロジェクト: fredericboivin/holoraire
        //Supprime le bloc correspondant a celui fournis
        public bool supprimerBloc(Bloc leBloc)
        {
            bool supConf = false;
            int  nbBloc  = bloc.Count;

            //Les conditions a modifier devront être unique a chaque blocs
            for (int i = 0; i < nbBloc; i++)
            {
                if (bloc[i].getDebut() == leBloc.getDebut())
                {
                    // bloc.Remove(bloc.ElementAt(i));
                    bloc.RemoveAt(i);
                    supConf = true;
                    break;
                }
            }

            return(supConf);
        }
コード例 #7
0
        public void modifierBlock(Bloc leBloc)
        {
            string hDebut = leBloc.getDebut().Hour + "";
            string hFin   = (leBloc.getFin().Hour + 1) + "";
            bool   preset = leBloc.getPreset();

            DateTime debut = leBloc.getDebut();
            DateTime fin   = leBloc.getFin();

            ModificationBloc modifbloc = new ModificationBloc(hDebut, hFin, preset, blocs);

            modifbloc.ShowDialog();

            if (modifbloc.isValide())
            {
                if (modifbloc.getCommande() == 0)
                {
                    //Modification d'un bloc
                    //Compute Nouvelle Date ** Ajouter validation **

                    int dateDebut = int.Parse(modifbloc.getHd());
                    int dateFin   = int.Parse(modifbloc.getHf());

                    DateTime tempDebut = new DateTime(debut.Year, debut.Month, debut.Day, dateDebut, debut.Minute, debut.Second);
                    DateTime tempFin   = new DateTime(fin.Year, fin.Month, fin.Day, dateFin - 1, fin.Minute, fin.Second);


                    Bloc leBloc2 = leBloc;
                    leBloc2.setDebut(tempDebut);
                    leBloc2.setFin(tempFin);
                    leBloc2.setPreset(modifbloc.getPreset());

                    if (modifbloc.placementValide(leBloc2))
                    {
                        if (loader != null && loader.modifierBloc(leBloc, leBloc2))
                        { //Ajout du bloc confirmé
                        } //
                        else
                        {
                            if (loader != null)
                            {
                                MessageBox.Show("Bloc introuvable");
                            }
                            else
                            {
                                if (profil != null && laGrille.isPref && profil.modifierBloc(leBloc, leBloc2, true))
                                { //lolnigger
                                }
                                else
                                {
                                    if (profil != null && !laGrille.isPref && profil.modifierBloc(leBloc, leBloc2, false))
                                    { //lolnigger
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                    }
                }


                else
                //Suppression d'un Bloc
                {
                    if (profil == null)
                    {
                        loader.supprimerBloc(leBloc);
                    }
                    else
                    {
                        if (loader == null && laGrille.isPref)
                        {
                            profil.getPref().Remove(leBloc);
                        }
                        else
                        {
                            if (loader == null && !laGrille.isPref)
                            {
                                profil.getDispo().Remove(leBloc);
                            }
                        }
                    }

                    DBConnect uneConnect = new DBConnect();
                    uneConnect.deleteBlock(leBloc.getId());
                }
            }
            modifbloc.Dispose();
        }
コード例 #8
0
ファイル: loader.cs プロジェクト: dangerdogz/holoraire
        //Supprime le bloc correspondant a celui fournis
        public bool supprimerBloc(Bloc leBloc)
        {
            bool supConf = false;
            int nbBloc = bloc.Count;
            //Les conditions a modifier devront être unique a chaque blocs
            for (int i = 0; i < nbBloc; i++)
            {
                if (bloc[i].getDebut() == leBloc.getDebut())
                {
                   // bloc.Remove(bloc.ElementAt(i));
                    bloc.RemoveAt(i);
                    supConf = true;
                    break;
                }

            }

            return supConf;
        }
コード例 #9
0
ファイル: loader.cs プロジェクト: dangerdogz/holoraire
        //Modifis le bloc correspondant a celui fournis
        public bool modifierBloc(Bloc leBloc, Bloc leBloc2)
        {
            int nbBloc = bloc.Count;
            bool blocTrouve = false;

            //Les conditions a modifier devront être unique a chaque blocs
            for (int i = 0; i < nbBloc; i++)
            {
                if (bloc[i].getDebut() == leBloc.getDebut())
                {
                    bloc[i] = leBloc2;
                    blocTrouve = true;
                    break;
                }

            }

            return blocTrouve;
        }
コード例 #10
0
ファイル: GrilleJour.cs プロジェクト: dangerdogz/holoraire
        public bool placementValide(Bloc leBloc)
        {
            //Variables
            for (int i = 0; i < blocs.Count; i++)
                {
                //Sois le bloc ajouté enpiète sur la fin du bloc existant ou sur le debut du bloc existant
                if ( (leBloc.getDebut() < blocs[i].getFin() && leBloc.getFin() > blocs[i].getFin())
                    || (leBloc.getFin() > blocs[i].getDebut() && leBloc.getDebut() < blocs[i].getDebut())
                    || (leBloc.getFin() == blocs[i].getFin() || leBloc.getDebut() == blocs[i].getDebut()))
                    {
                    return false; //Bloc existant
                    }

                }
            return true; //Aucun accros
        }
コード例 #11
0
ファイル: GrilleJour.cs プロジェクト: dangerdogz/holoraire
        public void modifierBlock(Bloc leBloc)
        {
            string hDebut = leBloc.getDebut().Hour + "";
            string hFin = (leBloc.getFin().Hour + 1) + "";
            bool preset = leBloc.getPreset();

            DateTime debut = leBloc.getDebut();
            DateTime fin = leBloc.getFin();

            ModificationBloc modifbloc = new ModificationBloc(hDebut, hFin, preset, blocs);
            modifbloc.ShowDialog();

            if (modifbloc.isValide())
            {
                if (modifbloc.getCommande() == 0)
                {
                    //Modification d'un bloc
                    //Compute Nouvelle Date ** Ajouter validation **

                    int dateDebut = int.Parse(modifbloc.getHd());
                    int dateFin = int.Parse(modifbloc.getHf());

                    DateTime tempDebut = new DateTime(debut.Year, debut.Month, debut.Day, dateDebut, debut.Minute, debut.Second);
                    DateTime tempFin = new DateTime(fin.Year, fin.Month, fin.Day, dateFin - 1, fin.Minute, fin.Second);

                    Bloc leBloc2 = leBloc;
                    leBloc2.setDebut(tempDebut);
                    leBloc2.setFin(tempFin);
                    leBloc2.setPreset(modifbloc.getPreset());

                    if (modifbloc.placementValide(leBloc2))
                    {

                        if (loader != null && loader.modifierBloc(leBloc, leBloc2))
                        { //Ajout du bloc confirmé

                        } //
                        else
                        {
                            if (loader != null)
                                MessageBox.Show("Bloc introuvable");
                            else
                            {

                                if (profil != null && laGrille.isPref && profil.modifierBloc(leBloc, leBloc2, true))
                                { //lolnigger

                                }
                                else
                                {
                                    if (profil != null && !laGrille.isPref && profil.modifierBloc(leBloc, leBloc2, false))
                                    { //lolnigger

                                    }
                                }

                            }

                        }
                    }
                    else
                    {

                    }
                }

                else
                //Suppression d'un Bloc
                {
                    if (profil == null)
                        loader.supprimerBloc(leBloc);
                    else
                    {
                        if (loader == null && laGrille.isPref)
                            profil.getPref().Remove(leBloc);
                        else
                        {
                            if (loader == null && !laGrille.isPref)
                                profil.getDispo().Remove(leBloc);
                        }

                    }

                DBConnect uneConnect = new DBConnect();
                uneConnect.deleteBlock(leBloc.getId());
                }

            }
            modifbloc.Dispose();
        }
コード例 #12
0
ファイル: GrilleJour.cs プロジェクト: dangerdogz/holoraire
        public void addPreset(Bloc bloc, int x)
        {
            TimeSpan dateDebut = new TimeSpan(bloc.getDebut().Hour, bloc.getDebut().Minute, bloc.getDebut().Second);
                TimeSpan dateFin = new TimeSpan(bloc.getFin().Hour, bloc.getFin().Minute, bloc.getFin().Second);

                DateTime tempDebut = new DateTime(this.dateDuJour.Year, this.dateDuJour.Month, this.dateDuJour.Day)+dateDebut;
                DateTime tempFin = new DateTime(this.dateFin.Year, this.dateFin.Month, this.dateFin.Day) +dateFin;

                Bloc tempBloc = new Bloc(tempDebut, tempFin, 0, 0, true);

                tempBloc.setRessourceAffectes(bloc.getRessourceAffectes());
                tempBloc.setRessourceVoulus(bloc.getListRessourceVoulus());
                tempBloc.setId(bloc.getId());

                if (placementValide(tempBloc))
                {
                    //Ajout du block valide
                    tempBloc.draw(width, grfx);
                    loader.bloc.Add(tempBloc);
                    tempBloc.save(true);
                }
                else
                    MessageBox.Show("Placement invalide");
        }
コード例 #13
0
        //Retourne vrai si le placement est valide
        public bool placementValide(Bloc leBloc)
        {
            //Variables
            //Retirer lui-même du tableau
            int indexBloc = -1;
            int heureTempDebut;

               // MessageBox.Show("Heure temp "+tempHd);
            try
                {
                heureTempDebut = Int16.Parse(tempHd);
                }
            catch (Exception)
                {
               // MessageBox.Show("Erreur de parse");
                throw;
                }

            //Trouve son index
            for (int i = 0; i < listBloc.Count; i++)
                {
                  //  MessageBox.Show("Heure de départ : " + listBloc[i].getDebut().Hour);
                if (listBloc[i].getDebut().Hour.Equals(heureTempDebut))
                    {
                    indexBloc = i;
                  //  MessageBox.Show("Index du bloc :" + indexBloc);
                    break;
                    }
                }
              //  MessageBox.Show("Début : " + leBloc.getDebut().Hour + " Fin : " + leBloc.getFin().Hour);

            for (int i = 0; i < listBloc.Count; i++)
            {/*
                //Sois le bloc ajouté enpiète sur la fin du bloc existant ou sur le debut du bloc existant
                if (((( leBloc.getDebut().Hour < listBloc[i].getFin().Hour && leBloc.getFin().Hour > listBloc[i].getFin().Hour)
                    || (leBloc.getFin().Hour > listBloc[i].getDebut().Hour && leBloc.getDebut().Hour < listBloc[i].getDebut().Hour)
                    || (leBloc.getDebut().Hour < listBloc[i].getDebut().Hour && leBloc.getFin().Hour > listBloc[i].getDebut().Hour)))
                    && (indexBloc != i))//Différent de lui-même*/
                //MessageBox.Show("Première condition : " + (leBloc.getDebut().Hour < listBloc[i].getFin().Hour && leBloc.getFin().Hour > listBloc[i].getDebut().Hour) + " \nDeuxième condition : " + (leBloc.getFin().Hour > listBloc[i].getDebut().Hour && leBloc.getDebut().Hour < listBloc[i].getDebut().Hour) + " \n Troisième condition : " + (leBloc.getDebut().Hour < listBloc[i].getDebut().Hour && leBloc.getFin().Hour > listBloc[i].getDebut().Hour) + " \n Index : " + (indexBloc != i));

                if (((leBloc.getDebut().Hour < listBloc[i].getFin().Hour && leBloc.getFin().Hour > listBloc[i].getDebut().Hour)
                    || (leBloc.getFin().Hour > listBloc[i].getDebut().Hour && leBloc.getDebut().Hour < listBloc[i].getDebut().Hour)
                    || (leBloc.getDebut().Hour < listBloc[i].getDebut().Hour && leBloc.getFin().Hour > listBloc[i].getDebut().Hour))
                    && (indexBloc != i))//Différent de lui-même*/
                    {
                    return false; //Bloc existant
                    }

            }
            return true; //Aucun accros
        }
コード例 #14
0
ファイル: Profil.cs プロジェクト: dangerdogz/holoraire
        public bool modifierBloc(Bloc leBloc, Bloc leBloc2, bool isPref)
        {
            int nbBloc;
            bool blocTrouve = false;
            List<Bloc> blocs = null;

            if (isPref)
                blocs = getPref();
            else
                {
                blocs = getDispo();
                }

            nbBloc = blocs.Count;
            //Les conditions a modifier devront être unique a chaque blocs
            for (int i = 0; i < nbBloc; i++)
            {
                if (blocs[i].getDebut() == leBloc.getDebut())
                {
                    blocs[i] = leBloc2;
                    blocTrouve = true;
                    break;
                }

            }

            return blocTrouve;
        }