Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 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.Windows.Forms;
  9.  
  10. namespace projekt2
  11. {
  12. public partial class Main : Form
  13. {
  14. public Main()
  15. {
  16. InitializeComponent();
  17. CreateUsers();
  18. }
  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[1, 0] = "adm";
  30. userdata[1, 1] = "123456";
  31.  
  32. userdata[2, 0] = "admin";
  33. userdata[2, 1] = "12345";
  34. }
  35.  
  36.  
  37. private void Main_Load(object sender, EventArgs e)
  38. {
  39.  
  40. }
  41.  
  42. private void textBox2_TextChanged(object sender, EventArgs e)
  43. {
  44.  
  45. }
  46.  
  47. private void label2_Click(object sender, EventArgs e)
  48. {
  49.  
  50. }
  51.  
  52. private void button1_Click(object sender, EventArgs e)
  53. {
  54. if (textBox1.Text.Length == 0)
  55. {
  56. textBox1.Focus();
  57. return;
  58. }
  59. if (textBox2.Text.Length == 0)
  60. {
  61. textBox2.Focus();
  62. return;
  63. }
  64. auth(textBox1.Text, textBox2.Text);
  65. }
  66.  
  67. private void button2_Click(object sender, EventArgs e)
  68. {
  69. Close();
  70. }
  71.  
  72. private void auth(string user, string password)
  73. {
  74. for (int i = 0; i < userdata.GetLength(0); i++)
  75. {
  76. //trzecie okno, rozszerzenie tablicy, warunek (5 uzytkownikow, 2 administratorow)
  77.  
  78. if(user == userdata[i, 0] && password == userdata[i,1])
  79.  
  80.  
  81.  
  82. if ((_AdminPanel =
  83. (AdminPanel)checkifwinopen(typeof(AdminPanel))) == null)
  84. {
  85. _AdminPanel = new AdminPanel();
  86. _AdminPanel.Show();
  87. }
  88. else _AdminPanel.BringToFront();
  89. break;
  90. }
  91. }
  92.  
  93.  
  94. private Form checkifwinopen(Type FormType)
  95. {
  96. foreach (Form OpenForm in Application.OpenForms)
  97. {
  98. if (OpenForm.GetType() == FormType) return OpenForm;
  99. }
  100.  
  101. return null;
  102.  
  103. }
  104. }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement