public FrmEcheance(Echeance echeance, Action callBack) : this(callBack) { this.oldEcheance = echeance; guna2TxtTitre.Text = echeance.Titre; guna2TxtDescription.Text = echeance.Description.ToString(); guna2TxtMontant.Text = echeance.Montant.ToString(); guna2DateTimePickerDateDebut.Text = echeance.DateDebut.ToString(); guna2DateTimePickerDateFin.Text = echeance.DateFin.ToString(); guna2DateTimePickerDelai.Text = echeance.DelaisPayement.ToString(); }
public void Add(Echeance echeance) { var index = echeances.IndexOf(echeance); if (index >= 0) { throw new DuplicateNameException("This echeance title already exists !"); } echeances.Add(echeance); Save(); }
public void Set(Echeance oldEcheance, Echeance newEcheance) { var oldIndex = echeances.IndexOf(oldEcheance); var newIndex = echeances.IndexOf(newEcheance); if (oldIndex < 0) { throw new KeyNotFoundException("The echeance doesn't exists !"); } if (newIndex >= 0 && oldIndex != newIndex) { throw new DuplicateNameException("This echeance title already exists !"); } echeances[oldIndex] = newEcheance; Save(); }
private void guna2GradientCreer_Click(object sender, EventArgs e) { try { checkForm(); Echeance newEcheance = new Echeance ( int.Parse(guna2TxtMontant.Text), guna2TxtTitre.Text.ToUpper(), guna2TxtDescription.Text, DateTime.Parse(guna2DateTimePickerDateDebut.Text), DateTime.Parse(guna2DateTimePickerDateFin.Text), DateTime.Parse(guna2DateTimePickerDelai.Text) ); EcheanceBLO echeanceBLO = new EcheanceBLO(ConfigurationManager.AppSettings["DbFolder"]); if (this.oldEcheance == null) { echeanceBLO.CreateEcheance(newEcheance); } else { echeanceBLO.EditEcheance(oldEcheance, newEcheance); } MessageBox.Show ( "Echeance creer !", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information ); if (callBack != null) { callBack(); } if (oldEcheance != null) { Close(); } guna2TxtTitre.Clear(); guna2TxtDescription.Clear(); guna2TxtMontant.Clear(); guna2TxtTitre.Focus(); } catch (TypingException ex) { MessageBox.Show ( ex.Message, "Typing error", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } catch (DuplicateNameException ex) { MessageBox.Show ( ex.Message, "Duplicate error", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } catch (KeyNotFoundException ex) { MessageBox.Show ( ex.Message, "Not found error", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } catch (Exception ex) { ex.WriteToFile(); MessageBox.Show ( "An error occurred! Please try again later.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error ); } }
public void EditEcheance(Echeance oldEcheance, Echeance newEcheance) { echeanceRepo.Set(oldEcheance, newEcheance); }
public void DeleteEcheance(Echeance echeance) { echeanceRepo.Remove(echeance); }
public void CreateEcheance(Echeance echeance) { echeanceRepo.Add(echeance); }
public void Remove(Echeance echeance) { echeances.Remove(echeance);//base sur Echeance.Equals redefini Save(); }