Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 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 MySql.Data.MySqlClient;
  11.  
  12. namespace e_money
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21.  
  22.  
  23. public static string Username = "";
  24. public static string Password = "";
  25.  
  26. private void button1_Click(object sender, EventArgs e)
  27. {
  28. DataTable table = new DataTable();
  29. Form2 Menu = new Form2();
  30. Username = textBox1.Text;
  31. Password = textBox2.Text;
  32. MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=e-money");
  33. MySqlDataAdapter adapter;
  34. con.Open();
  35. adapter = new MySqlDataAdapter("SELECT * FROM users WHERE username = '" + textBox1.Text + "' AND password = '" + textBox2.Text + "'", con);
  36. adapter.Fill(table);
  37.  
  38. if (table.Rows.Count <= 0)
  39. {
  40. MessageBox.Show("Username atau Password salah", "Error", MessageBoxButtons.OK);
  41. }
  42. else
  43. {
  44. kirim_user.Username = textBox1.Text;
  45. kirim_user.Password = textBox2.Text;
  46. this.Hide();
  47. Menu.Show();
  48. }
  49. con.Close();
  50. }
  51.  
  52. private void textBox1_TextChanged(object sender, EventArgs e)
  53. {
  54.  
  55. }
  56.  
  57. private void Form1_Load(object sender, EventArgs e)
  58. {
  59.  
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement