public FrmMainWindow() { InitializeComponent(); FrmLogIn loginForm = new FrmLogIn(); DialogResult res = loginForm.ShowDialog(); if (res == DialogResult.OK) { MessageBox.Show("Enabled!!"); } else { this.Close(); //The main application is closed, when the user //does not enter the right password but instead //presses cancel! A different action does not make //sense. } //Testzwecke: this.customers = new List <Customer>(); for (int i = 0; i < 10; i++) { this.customers.Add(new Customer(((char)(i + 'A')).ToString())); } this.WriteCustomerDB(); //End Testzwecke! }
/// <summary> /// Loads the Login-Form and enables the Main-Form if the password is correct. /// Otherwise it closes the Form. /// </summary> /// <param name="sender">Form that is loaded</param> /// <param name="e">Form loaded event</param> private void FrmMainWindow_Load(object sender, EventArgs e) { //Fürs Testen kann die Passwortabfrage auskommentiert werden!! //this.InitializeForm(); FrmLogIn loginForm = new FrmLogIn(); DialogResult res = loginForm.ShowDialog(); if (res == DialogResult.OK) { MessageBox.Show("Enabled!!"); this.InitializeForm(); } else { this.Close(); //The main application is closed, when the user //does not enter the right password but instead //presses cancel! A different action does not make //sense. } }