public void SetComplementsSql(Boolean dernierDocument)
        {
            if (dernierDocument || Properties.Settings.Default.idSuperviseurActif == 0)
            {
                complementSQL1 = " TOP(10)";
                complementSQL2 = "";
                modeAffichageDixDerniers = true;
            }
            else
            {
                Superviseur supv = new Superviseur(Properties.Settings.Default.idSuperviseurActif);
                if (supv._derniereVacation.Date != DateTime.MaxValue.Date && supv._idSuperviseur != 0)
                {
                    complementSQL1 = " TOP(20)";
                    complementSQL2 = " WHERE dateTimeEditionBDD >= '" + supv._derniereVacation.ToString("yyyy-MM-dd") + "' ";
                    modeAffichageDixDerniers = false;
                }
                else
                {
                    SetComplementsSql(true);
                }

            }
        }
 private void UpdateSuperviseurDerniereVacation(object sender, ElapsedEventArgs e)
 {
     App._myTimerSuperviseur.Enabled = false;
     Superviseur newSupv = new Superviseur(Properties.Settings.Default.idSuperviseurActif);
     newSupv.UpdateDerniereVacation();
 }
 private void SetSuperviseur()
 {
     if (Properties.Settings.Default.idSuperviseurActif != 0)
     {
         Superviseur newSupv = new Superviseur(Properties.Settings.Default.idSuperviseurActif);
         this.labelSuperviseur.Content = Properties.Settings.Default.subdivisionTablette + " (" + UC_WIDGET_TimelinePresentation.GetVacationName(DateTime.Now) + ") - " + newSupv._prenomSuperviseur.Substring(0, 1) + ". " + newSupv._nomSuperviseur;
         App._myTimerSuperviseur.Start();
     }
     else
     {
         this.labelSuperviseur.Content = Properties.Settings.Default.subdivisionTablette + " (" + UC_WIDGET_TimelinePresentation.GetVacationName(DateTime.Now) + ")";
     }
     App.Current.Dispatcher.BeginInvoke(
             System.Windows.Threading.DispatcherPriority.Render,
                 new Action(
                     delegate()
                     {
                         App._myControleAccueil.widgetDernierDocuments.Update(true);
                     }
                 )
             );
 }
        private static void UpdateSuperviseurs()
        {
            Dictionary<string, object> arg = new Dictionary<string, object>();
            arg.Add("@sub", Properties.Settings.Default.subdivisionTablette);

            MySqlDataReader Reader = ConnectorMySql.ExecCommand(@"SELECT * FROM Superviseurs WHERE subdivisionSuperviseur = @sub", arg);
            List<Superviseur> myList = GetSuperviseurs();
            if (Reader != null)
            {
                while (Reader.Read())
                {
                    Superviseur newSupv = new Superviseur(GetDBUInt32("idSuperviseur", Reader),
                                                         GetDBString("nomSuperviseur", Reader),
                                                         GetDBString("prenomSuperviseur", Reader),
                                                         GetDBDateTime("derniereVacation", Reader),
                                                         GetDBString("subdivisionSuperviseur", Reader),
                                                         GetDBString("sectionSuperviseur", Reader));

                    bool isPresent = false;
                    foreach (Superviseur oldSupv in myList)
                    {
                        //Si le superviseur existe déjà
                        if (oldSupv._idSuperviseur == newSupv._idSuperviseur)
                        {
                            isPresent = true;
                            if (oldSupv._derniereVacation.Date != DateTime.MaxValue.Date && (oldSupv._derniereVacation > newSupv._derniereVacation || newSupv._derniereVacation.Date == DateTime.MaxValue.Date))
                            {
                                oldSupv.UpdateDerniereVacationInDistantDB();
                            }
                            newSupv.UpdateInLocalDB();
                            break;
                        }
                    }
                    if (!isPresent)
                    {
                        newSupv.StoreInLocalDB();
                    }
                }
                ConnectorMySql.Close(Reader);
                App.Current.Dispatcher.BeginInvoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(
                        delegate()
                        {
                            if (App.Current.MainWindow != null)
                            {
                                MainWindow wind = App.Current.MainWindow as MainWindow;
                                wind.RefreshMenuSuperviseurs();
                            }

                        }
                    ));
            }
        }