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(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MyBank bank = new MyBank(); try { bank.Load(); } catch (System.IO.FileNotFoundException) { DialogResult res = MessageBox.Show( "Невозможно загрузить данные приложения. Продолжить?", "", MessageBoxButtons.YesNo ); // If yes - create new MyBank, serialize and open register window // If no - close application switch (res) { case DialogResult.Yes: //bank.FillTestData(10); bank.Save(); Program.context = new ApplicationContext(new RegisterForm(bank)); break; case DialogResult.No: return; } } if (context == null) { context = new ApplicationContext(new LoginForm(bank)); } Application.Run(context); }
private void SaveToolStripMenuItem_Click(object sender, EventArgs e) { bank.Save(); isDirty = false; }