예제 #1
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            //main.verbunden();
            //this.Dispose();
            kunden = dto.GetAlleKunden();

            try
            {
                int i = 0;
                while (true)
                {
                    if (kunden[i].Benutzername.Equals(textBoxName.Text))
                    {
                        if (kunden[i].Passwort.Equals(textBoxPW.Text))
                        {
                            main.verbunden();
                            this.Dispose();
                            break;
                        }
                        else
                        {
                            MessageBox.Show("Falsches Passwort");
                            DialogResult result = MessageBox.Show("Falsches Passwort", "Warning",
                                                                  MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                            if (result == DialogResult.Retry)
                            {
                                textBoxPW.Clear();
                                break;
                            }
                            else
                            {
                                textBoxName.Clear();
                                textBoxPW.Clear();
                                break;
                            }
                        }
                    }
                    if (i <= kunden.Count)
                    {
                        i++;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            catch (Exception)
            {
                DialogResult result = MessageBox.Show("Benutzer nicht vorhanden zur Registrierung?", "Warning",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (result == DialogResult.Yes)
                {
                    Registrieren r1 = new Registrieren();
                    r1.MdiParent = main;
                    this.Dispose();
                }
            } //
        }