Advertisement
Guest User

Untitled

a guest
Jul 10th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 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. using System.Data.SqlClient;
  11. using MySql.Data.MySqlClient;
  12.  
  13. namespace WindowsFormsApp1
  14. {
  15. public partial class Form1 : Form
  16. {
  17. public Form1()
  18. {
  19.  
  20. InitializeComponent();
  21. label1.Text = "Vortex Simulations";
  22. label1.BackColor = Color.Transparent;
  23. label1.ForeColor = Color.White;
  24.  
  25. label2.Text = "Staff Management System";
  26. label2.BackColor = Color.Transparent;
  27. label2.ForeColor = Color.White;
  28.  
  29.  
  30. email.BackColor = Color.Transparent;
  31. email.ForeColor = Color.White;
  32. email.Text = "Email Address";
  33. this.FormBorderStyle = FormBorderStyle.FixedSingle;
  34.  
  35. password.Text = "Password";
  36. password.BackColor = Color.Transparent;
  37. password.ForeColor = Color.White;
  38.  
  39. login.Text = "Log In";
  40. login.BackColor = Color.Purple;
  41. login.ForeColor = Color.White;
  42.  
  43. passwordbox.PasswordChar = '●';
  44. passwordbox.MaxLength = 24;
  45. emailbox.MaxLength = 34;
  46.  
  47. this.Text = "Vortex Staff Login";
  48.  
  49.  
  50. }
  51.  
  52. private void label1_Click(object sender, EventArgs e)
  53. {
  54. }
  55.  
  56. private void emailbox_Click(object sender, EventArgs e)
  57. {
  58. if (emailbox.Name == "emailbox")
  59. {
  60.  
  61. }
  62. }
  63.  
  64. private void emailbox_Leave(object sender, EventArgs e)
  65. {
  66. if(emailbox.Name == "emailbox")
  67. {
  68.  
  69. }
  70. }
  71.  
  72. private void login_Click(object sender, EventArgs e)
  73. {
  74. string connString = "datasource=mailsd.me;username=whenoffi_admin;port=3306;password=redstone2;database=whenoffi_vortexusers;";
  75. MySqlConnection conn = new MySqlConnection(connString);
  76. MySqlCommand cmd = new MySqlCommand("SELECT * FROM users WHERE email = '" + emailbox.Text + "' AND password = '" + passwordbox.Text + "'", conn);
  77. MySqlDataReader dr;
  78. conn.Open();
  79. dr = cmd.ExecuteReader();
  80. int count = 0;
  81. while (dr.Read())
  82. {
  83. count = count + 1;
  84. }
  85.  
  86. if (count == 1)
  87. {
  88. this.Hide();
  89. Form2 form2 = new Form2();
  90.  
  91.  
  92.  
  93. form2.Closed += (s, args) => this.Close();
  94. form2.Show();
  95.  
  96. MessageBox.Show("OK, " + emailbox.Text);
  97. }
  98. else if (count > 1)
  99. {
  100. MessageBox.Show("Duplicate email and password");
  101. }
  102. else
  103. {
  104. MessageBox.Show("Your email or password is not correct");
  105. }
  106. conn.Close();
  107. emailbox.Clear();
  108. passwordbox.Clear();
  109. }
  110. public string emailboxtext
  111. {
  112. get { return emailbox.Text; }
  113. }
  114.  
  115.  
  116. }
  117.  
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement