Guest User

Untitled

a guest
Dec 26th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 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 Admin_Login_Load(object sender, EventArgs e)
  30. {
  31.  
  32.  
  33. }
  34.  
  35. private void btn_Login_Click(object sender, EventArgs e)
  36. {
  37. // try
  38. // {
  39. if (separator == 1)
  40. {
  41.  
  42.  
  43. Data getTable = new Data();
  44. DataTable table = getTable.GetData("select UserName,Password from SuperUser where UserName='" + txt_UserName.Text + "' and Password='" + txt_Password.Text + "'");
  45.  
  46.  
  47. if (table.Rows.Count == 1)
  48. {
  49. this.Hide();
  50. TerminalAdmin AdminTerminal = new TerminalAdmin();
  51. AdminTerminal.Show();
  52.  
  53. }
  54. else
  55. {
  56. MetroFramework.MetroMessageBox.Show(this, "Invalid Username/Password please check your Username and Password and try again.", "Access Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);
  57. txt_Password.Clear();
  58. }
  59. }
  60. else if (separator == 2)
  61. {
  62.  
  63. Data getTable = new Data();
  64. DataTable table = getTable.GetData("select UserName,Password from Admin_Table where UserName='" + txt_UserName.Text + "' and Password='" + txt_Password.Text + "'");
  65.  
  66. if (table.Rows.Count == 1)
  67. {
  68. Data getter = new Data();
  69. DataTable dt = getter.GetData("select UserID from Admin_Table where UserName='" + txt_UserName.Text + "'");
  70. MessageBox.Show(dt.Rows[0][0].ToString());
  71. this.Hide();
  72. Updating form = new Updating(dt.Rows[0][0].ToString(), txt_UserName.Text);
  73. form.Show();
  74.  
  75. }
Add Comment
Please, Sign In to add comment