Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.connexionButton.Click += new System.EventHandler(this.simpleButton1_Click);
- private void simpleButton1_Click(object sender, EventArgs e)
- {
- Boolean allowCnx = false;
- foreach (var row in myClass.ds.Tables["Users"].AsEnumerable())
- {
- if (row[1].ToString().ToLower() == idBox.Text.ToLower() && row[2].ToString().ToLower() == mdpBox.Text.ToLower())
- {
- allowCnx = true;
- }
- }
- if (allowCnx)
- {
- connexionButton.DialogResult = DialogResult.OK;
- }
- else
- XtraMessageBox.Show("Invalide Information", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- using (login loginForm = new login())
- {
- var result = loginForm.ShowDialog();
- if (result == DialogResult.OK)
- this.Show();
- else
- this.Close();
- }
- // Points to a different method than the one you posted
- // (simpleButton1_Click_1 instead of simpleButton1_Click)
- this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click_1);
- // This isn't simpleButton1_Click_1
- private void simpleButton1_Click(object sender, EventArgs e)
- // When you launch the login form, I do not know what you intended to do with your
- // calls to Show() and Close() but so long as you don't instend for them to do
- // anything to the loginForm, that's fine.
- using (login loginForm = new login())
- {
- if (loginForm.ShowDialog() == DialogResult.OK)
- // Do stuff if logged in
- else
- // Do stuff if failed
- }
- private void simpleButton1_Click(object sender, EventArgs e)
- {
- Boolean allowCnx = false;
- foreach (var row in myClass.ds.Tables["Users"].AsEnumerable())
- if (row[1].ToString().ToLower() == idBox.Text.ToLower() && row[2].ToString().ToLower() == mdpBox.Text.ToLower())
- {
- allowCnx = true;
- }
- if (allowCnx)
- {
- this.DialogResult = DialogResult.OK; // Don't set the DialogResult of a button. Set it for the form.
- }
- else
- {
- this.DialogResult = DialogResult.Abort; // Because we didn't succeed
- XtraMessageBox.Show("Invalide Information",
- "Erreur",
- MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click);
- public bool AllowConnection = false;
- private void simpleButton1_Click(object sender, EventArgs e)
- {
- foreach (var row in myClass.ds.Tables["Users"].AsEnumerable())
- {
- if (row[1].ToString().ToLower() == idBox.Text.ToLower() && row[2].ToString().ToLower() == mdpBox.Text.ToLower())
- AllowConnection = true;
- }
- if (!AllowConnection)
- XtraMessageBox.Show("Invalide Information", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- using (login loginForm = new login())
- {
- loginForm.ShowDialog();
- if (loginForm.AllowConnection)
- this.Show();
- else
- this.Close();
- }
- foreach (var row in myClass.ds.Tables["Users"].AsEnumerable())
- foreach (var row in myClass.ds.Tables["Users"].Rows)
- connexionButton.DialogResult = DialogResult.OK;
- this.DialogResult = DialogResult.OK;
Add Comment
Please, Sign In to add comment