Guest User

Untitled

a guest
Jan 16th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. this.connexionButton.Click += new System.EventHandler(this.simpleButton1_Click);
  2.  
  3. private void simpleButton1_Click(object sender, EventArgs e)
  4. {
  5. Boolean allowCnx = false;
  6.  
  7. foreach (var row in myClass.ds.Tables["Users"].AsEnumerable())
  8. {
  9. if (row[1].ToString().ToLower() == idBox.Text.ToLower() && row[2].ToString().ToLower() == mdpBox.Text.ToLower())
  10. {
  11. allowCnx = true;
  12. }
  13. }
  14.  
  15. if (allowCnx)
  16. {
  17. connexionButton.DialogResult = DialogResult.OK;
  18. }
  19. else
  20. XtraMessageBox.Show("Invalide Information", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
  21. }
  22.  
  23. using (login loginForm = new login())
  24. {
  25. var result = loginForm.ShowDialog();
  26. if (result == DialogResult.OK)
  27. this.Show();
  28. else
  29. this.Close();
  30. }
  31.  
  32. // Points to a different method than the one you posted
  33. // (simpleButton1_Click_1 instead of simpleButton1_Click)
  34. this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click_1);
  35.  
  36. // This isn't simpleButton1_Click_1
  37. private void simpleButton1_Click(object sender, EventArgs e)
  38.  
  39. // When you launch the login form, I do not know what you intended to do with your
  40. // calls to Show() and Close() but so long as you don't instend for them to do
  41. // anything to the loginForm, that's fine.
  42. using (login loginForm = new login())
  43. {
  44. if (loginForm.ShowDialog() == DialogResult.OK)
  45. // Do stuff if logged in
  46. else
  47. // Do stuff if failed
  48. }
  49.  
  50. private void simpleButton1_Click(object sender, EventArgs e)
  51. {
  52. Boolean allowCnx = false;
  53.  
  54. foreach (var row in myClass.ds.Tables["Users"].AsEnumerable())
  55. if (row[1].ToString().ToLower() == idBox.Text.ToLower() && row[2].ToString().ToLower() == mdpBox.Text.ToLower())
  56. {
  57. allowCnx = true;
  58. }
  59.  
  60. if (allowCnx)
  61. {
  62. this.DialogResult = DialogResult.OK; // Don't set the DialogResult of a button. Set it for the form.
  63. }
  64. else
  65. {
  66. this.DialogResult = DialogResult.Abort; // Because we didn't succeed
  67. XtraMessageBox.Show("Invalide Information",
  68. "Erreur",
  69. MessageBoxButtons.OK,
  70. MessageBoxIcon.Error);
  71. }
  72. }
  73.  
  74. this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click);
  75.  
  76. public bool AllowConnection = false;
  77. private void simpleButton1_Click(object sender, EventArgs e)
  78. {
  79. foreach (var row in myClass.ds.Tables["Users"].AsEnumerable())
  80. {
  81. if (row[1].ToString().ToLower() == idBox.Text.ToLower() && row[2].ToString().ToLower() == mdpBox.Text.ToLower())
  82. AllowConnection = true;
  83. }
  84.  
  85. if (!AllowConnection)
  86. XtraMessageBox.Show("Invalide Information", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
  87. }
  88.  
  89. using (login loginForm = new login())
  90. {
  91. loginForm.ShowDialog();
  92. if (loginForm.AllowConnection)
  93. this.Show();
  94. else
  95. this.Close();
  96. }
  97.  
  98. foreach (var row in myClass.ds.Tables["Users"].AsEnumerable())
  99.  
  100. foreach (var row in myClass.ds.Tables["Users"].Rows)
  101.  
  102. connexionButton.DialogResult = DialogResult.OK;
  103.  
  104. this.DialogResult = DialogResult.OK;
Add Comment
Please, Sign In to add comment