Beispiel #1
0
 private void acc_menu()
 {
     while (1 == 1)
     {
         int account = 0;
         Int32.TryParse(view.Account(), out account);
         if (account == 1)
         {
             List <Account> accounts = model.account_print();
             if (accounts.Count == 0)
             {
                 view.err_empty_table("account");
             }
             else
             {
                 view.print_Accounts(accounts);
             }
         }
         else if (account == 2)
         {
             int id = 0;
             Int32.TryParse(view.get_id(), out id);
             Account accounts = model.account_get_by_id(id);
             if (accounts == null)
             {
                 view.err_wrong_ID("account");
             }
             else
             {
                 view.print_Account(accounts);
             }
         }
         else if (account == 3)
         {
             Account d = new Account();
             d.Name = view.acc_get_name();
             while (d.Name.Length == 0)
             {
                 view.err_empty("account name");
                 d.Name = view.acc_get_name();
             }
             d.Pword = view.acc_get_pass();
             while (d.Pword.Length == 0)
             {
                 view.err_empty("account country");
                 d.Pword = view.acc_get_pass();
             }
             int new_id = model.account_add(d);
             view.successfull_operation("account", new_id, "added");
         }
         else if (account == 4)
         {
             int id = 0;
             Int32.TryParse(view.get_id(), out id);
             bool del = model.account_delete(id);
             if (del == false)
             {
                 view.err_wrong_ID("account");
             }
             else
             {
                 view.successfull_operation("account", id, "deleted");
             }
         }
         else if (account == 5)
         {
             int id = 0;
             Int32.TryParse(view.get_id(), out id);
             if (model.account_get_by_id(id) == null)
             {
                 view.err_wrong_ID("account");
             }
             else
             {
                 Account d = new Account();
                 d.Name = view.acc_get_name();
                 while (d.Name.Length == 0)
                 {
                     view.err_empty("account name");
                     d.Name = view.acc_get_name();
                 }
                 d.Pword = view.acc_get_pass();
                 while (d.Pword.Length == 0)
                 {
                     view.err_empty("account country");
                     d.Pword = view.acc_get_pass();
                 }
                 model.account_edit(d);
                 view.successfull_operation("account", id, "edited");
             }
         }
         else if (account == 6)
         {
             break;
         }
         else
         {
             view.err_wrong_option();
         }
     }
 }