Exemplo n.º 1
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();
        }