Ejemplo n.º 1
0
 // Saves new data, returns true if changed
 private bool Save()
 {
     try
     {
         if (bank.Find(loginTextBox.Text) != null &&
             loginTextBox.Text != customer.Login)
         {
             throw new InputException("Этот логин уже занят!");
         }
         customer.Change(
             new Customer(
                 loginTextBox.Text,
                 passwordTextBox.Text,
                 fullNameTextBox.Text,
                 accNumberTextBox.Text,
                 addressTextBox.Text,
                 birthDateTimePicker.Value
                 )
             );
         isDirty = true;
     }
     catch (InputException e)
     {
         MessageBox.Show(e.Message, "", MessageBoxButtons.OK);
         return(false);
     }
     return(true);
 }
Ejemplo n.º 2
0
        private void RegisterButton_Click(object sender, EventArgs e)
        {
            Customer customer = new Customer(
                loginTextBox.Text,
                passwordTextBox.Text,
                fullNameTextBox.Text,
                accNumberTextBox.Text,
                addressTextBox.Text,
                birthDateTimePicker.Value
                );

            try
            {
                if (bank.Find(customer.Login) != null)
                {
                    throw new InputException("Этот логин уже занят!");
                }
                customer.CheckData();
            }
            catch (InputException exception)
            {
                MessageBox.Show(exception.Message);
                return;
            }

            // If no exceptions - register and login

            bank.Customers.Add(customer);
            bank.Save();
            Program.context.MainForm = new MainMenuForm(bank, customer);
            Close();
            Program.context.MainForm.Show();
        }
Ejemplo n.º 3
0
        private void LogInButton_Click(object sender, EventArgs e)
        {
            string   login    = loginTextBox.Text;
            string   password = passwordTextBox.Text;
            Customer customer = bank.Find(login);

            if (customer == null || customer.Password != password)
            {
                MessageBox.Show("Не верные данные. " +
                                "Попробуйте снова или создайте новый аккаунт");
                return;
            }

            // If no exceptions - login

            Program.context.MainForm = new MainMenuForm(bank, customer);
            Close();
            Program.context.MainForm.Show();
        }