Guest User

Untitled

a guest
Dec 26th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. private void btn_AdminReg_Click(object sender, EventArgs e)
  2. {
  3. this.Hide();
  4. Admin_Login login = new Admin_Login(1);
  5. login.Show();
  6. }
  7.  
  8. public partial class Admin_Login : MetroFramework.Forms.MetroForm
  9. {
  10. int separator; // this is used to separate different logins
  11.  
  12. public Admin_Login(int value)
  13. {
  14. InitializeComponent();
  15. separator = value;
  16. }
  17.  
  18. //------- Legend ---------
  19. //if separator= 1 : AdminTerminal
  20. //if separator= 2 : UpdatingTerminal
  21. //if separator= 3 : View Registration
  22. //if separator= 4 : Registration
  23. //if separator= 5 : Reports
  24. //if separator= 6 : Cancel Union
  25.  
  26. static string path = Path.GetFullPath(Environment.CurrentDirectory);
  27. static string dataBaseName = "Trade_Union_Registration.mdf";
  28.  
  29. private void btn_Login_Click(object sender, EventArgs e)
  30. {
  31. if (separator == 1)
  32. {
  33. Data getTable = new Data();
  34. DataTable table = getTable.GetData("select UserName,Password from SuperUser where UserName='" + txt_UserName.Text + "' and Password='" + txt_Password.Text + "'");
  35.  
  36. if (table.Rows.Count == 1)
  37. {
  38. this.Hide();
  39. TerminalAdmin AdminTerminal = new TerminalAdmin();
  40. AdminTerminal.Show();
  41. }
  42. else
  43. {
  44. MetroFramework.MetroMessageBox.Show(this, "Invalid Username/Password please check your Username and Password and try again.", "Access Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);
  45. txt_Password.Clear();
  46. }
  47. }
  48. else if (separator == 2)
  49. {
  50. Data getTable = new Data();
  51. DataTable table = getTable.GetData("select UserName,Password from Admin_Table where UserName='" + txt_UserName.Text + "' and Password='" + txt_Password.Text + "'");
  52.  
  53. if (table.Rows.Count == 1)
  54. {
  55. Data getter = new Data();
  56. DataTable dt = getter.GetData("select UserID from Admin_Table where UserName='" + txt_UserName.Text + "'");
  57. MessageBox.Show(dt.Rows[0][0].ToString());
  58. this.Hide();
  59. Updating form = new Updating(dt.Rows[0][0].ToString(), txt_UserName.Text);
  60. form.Show();
  61. }
Add Comment
Please, Sign In to add comment