Advertisement
Guest User

Untitled

a guest
Mar 13th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp3
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. CreateUsers();
  19. }
  20. AdminPanel _AdminPanel;
  21.  
  22. string[,] userdata = new string[3, 2];
  23.  
  24. private void CreateUsers()
  25. {
  26. userdata[0, 0] = "jan";
  27. userdata[0, 1] = "abc123";
  28.  
  29. userdata[0, 0] = "adm";
  30. userdata[0, 1] = "123456";
  31.  
  32. userdata[0, 0] = "admin";
  33. userdata[0, 1] = "12345";
  34. }
  35.  
  36.  
  37. private void LoginButton_Click(object sender, EventArgs e)
  38. {
  39. if(txt_login.Text.Length == 0)
  40. {
  41. txt_login.Focus();
  42. }
  43.  
  44. if(txt_password.Text.Length == 0)
  45. {
  46. txt_password.Focus();
  47. }
  48. auth(txt_login.Text, txt_password.Text);
  49. }
  50.  
  51. private void CloseButton_Click(object sender, EventArgs e)
  52. {
  53. Close();
  54. }
  55.  
  56. private void auth(string user, string password)
  57. {
  58. for(int i = 0; i < userdata.GetLength(0); i++)
  59. {
  60. if(user== userdata[i,0] && password == userdata[i, 1])
  61. {
  62. if ((_AdminPanel = (AdminPanel)checkifwinopen(typeof(AdminPanel))) == null)
  63. {
  64. _AdminPanel = new AdminPanel();
  65. _AdminPanel.Show();
  66. }
  67. else _AdminPanel.BringToFront();
  68. break;
  69. }
  70. }
  71.  
  72. }
  73. private Form checkifwinopen(Type FormType)
  74. {
  75. foreach(Form OpenForm in Application.OpenForms)
  76. {
  77. if (OpenForm.GetType() == FormType) return OpenForm;
  78. }
  79. return null;
  80. }
  81. }
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement