Beispiel #1
0
        /// <summary>
        /// Permet de récupérer la description de l'énumération
        /// </summary>
        /// <param name="value">Enumération</param>
        /// <returns>Description</returns>
        public static string GetDescription(this TypeOperation value)
        {
            FieldInfo field = value.GetType().GetField(value.ToString());

            object[] attribs = field.GetCustomAttributes(typeof(DescriptionAttribute), true);
            if (attribs.Length > 0)
            {
                return(((DescriptionAttribute)attribs[0]).Description);
            }
            return(string.Empty);
        }
Beispiel #2
0
 public OperationWindow(Compte c, ListView l, TypeOperation t)
 {
     InitializeComponent();
     compte            = c;
     listViewComptes   = l;
     type              = t;
     Title             = type.ToString() + " N° : " + compte.NumeroCompte;
     bOperation.Click += (sender, e) =>
     {
         if (type == TypeOperation.Depot)
         {
             Operation o = new Operation(Convert.ToDecimal(montant.Text), compte.Id);
             o.Add();
             if (o.Id > 0)
             {
                 compte.Solde += o.Montant;
                 compte.Update();
                 message.Content             = "Opération effectuée";
                 listViewComptes.ItemsSource = Compte.GetComptes();
             }
             else
             {
                 message.Content = "Erreur operation";
             }
         }
         else if (type == TypeOperation.Retrait)
         {
             Operation o = new Operation(Convert.ToDecimal(montant.Text) * -1, compte.Id);
             if (compte.Solde >= o.Montant * -1)
             {
                 o.Add();
                 if (o.Id > 0)
                 {
                     compte.Solde += o.Montant;
                     compte.Update();
                     message.Content             = "Opération effectuée";
                     listViewComptes.ItemsSource = Compte.GetComptes();
                 }
                 else
                 {
                     message.Content = "Erreur operation";
                 }
             }
             else
             {
                 message.Content = "pas de solde";
             }
         }
     };
 }