//--- Sur le clic du bouton Ajout : ajout d'un nouveau rappel --- private void btnAjout_Click(object sender, EventArgs e) { if (this.txtRappel.Text != "") { DateTime ladate = new DateTime(this.dtpJour.Value.Year, this.dtpJour.Value.Month, this.dtpJour.Value.Day, this.dtpHeure.Value.Hour, this.dtpHeure.Value.Minute, 0); if (!this.rappels.ContainsKey(ladate)) { Rappel lerappel = new Rappel(this.txtRappel.Text, ladate, this.cboFrequence.SelectedIndex); this.rappels.Add(ladate, lerappel); this.majListeRappels(this.rappels.IndexOfKey(ladate)); } else { MessageBox.Show("Un rappel existe déjà à cette date et heure : \r\n" + this.rappels[ladate].getDate() + " : " + this.rappels[ladate].getLibelle()); } } else { MessageBox.Show("Le libellé du rappel doit être rempli"); } }
//--- toutes les 30s, controle les rappels arrivés à échéance --- private void tmrRappel_Tick(object sender, EventArgs e) { int k = 0; while (k < this.rappels.Count && this.rappels.Values[k].getDate() <= DateTime.Now) { MessageBox.Show(this.rappels.Values[k].getDate() + " : " + this.rappels.Values[k].getLibelle() + "\r\n" + "fréquence = " + this.Controls["grpEnsemble"].Controls["label" + this.rappels.Values[k].getFrequence()].Text); if (this.rappels.Values[k].getFrequence() == 0) { this.supprRappel(k); // suppression du rappel de fréquence unique } else { this.rappels.Values[k].suivant(); // changement d'échéance pour les autres types de rappels Rappel r = this.rappels.Values[k]; this.rappels.RemoveAt(k); this.rappels.Add(r.getDate(), r); this.majListeRappels(this.rappels.IndexOfKey(r.getDate())); } } }