예제 #1
0
 private void Button1_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrWhiteSpace(tbUname.Text) && !String.IsNullOrWhiteSpace(tbName.Text) && !String.IsNullOrWhiteSpace(tbPassword.Text) && !String.IsNullOrWhiteSpace(tbBalance.Text))
     {
         double strbalance = Convert.ToDouble(tbBalance.Text);
         bool   taken = false, valid = false;
         if (tbUname.Text.Length < 6)
         {
             MessageBox.Show("Username atleast has 6 Characters");
             tbUname.Focus();
         }
         else if (tbName.Text.Length < 5)
         {
             MessageBox.Show("Username atleast has 5 Characters");
             tbName.Focus();
         }
         else if (tbPassword.Text.Length < 6)
         {
             MessageBox.Show("Username atleast has 4 Characters");
             tbPassword.Focus();
         }
         else
         {
             valid = true;
         }
         for (int i = 0; i < bankmgr.UserList.Count; i++)
         {
             if (tbUname.Text == bankmgr.UserList[i]._username() || tbName.Text == bankmgr.UserList[i]._name())
             {
                 taken = true;
                 MessageBox.Show("Username or Nickname has been taken!", "Not Available", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 break;
             }
         }
         if (!taken && valid)
         {
             bankmgr account = new bankmgr(tbUname.Text, tbName.Text, tbPassword.Text, strbalance);
             bankmgr.AddUserToList(account);
             MessageBox.Show("Hello " + account._name() + ", your registration is successful!", "Account Registration", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
         }
     }
     else
     {
         MessageBox.Show("Please fill the data!", "Account Registration", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #2
0
 public static void AddUserToList(bankmgr account)
 {
     UserList.Add(account);
 }