Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. Imports System.Data.Odbc
  2. Public Class Login
  3.  
  4. Dim hitung As Integer
  5.  
  6. Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  7. Call koneksi()
  8. cmd = New OdbcCommand("select * from user where id_user='" & TextBox1.Text & "' and password_user='" & TextBox2.Text & "' and status_user='" & ComboBox1.Text & "'", conn)
  9. dr = cmd.ExecuteReader
  10. dr.Read()
  11. If dr.HasRows Then
  12. '=========================
  13. If TextBox2.Text <> dr("password_user") Then
  14. MsgBox("Password Salah")
  15. TextBox2.Focus()
  16.  
  17. Exit Sub
  18. End If
  19. '===================
  20. TextBox1.Clear()
  21. TextBox2.Clear()
  22. ComboBox1.Text = ""
  23. TextBox1.Focus()
  24. Me.Visible = False
  25. menuutama.Show()
  26.  
  27. '======================================================== logger
  28. menuutama.PanelKode.Text = dr("id_user")
  29. menuutama.PanelNama.Text = dr("nama_user")
  30. menuutama.PanelStatus.Text = UCase(dr("status_user"))
  31.  
  32. '=============================================== hak akses
  33. If menuutama.PanelStatus.Text <> "ADMIN" Then
  34. menuutama.UserToolStripMenuItem.Visible = False
  35. menuutama.Button1.Visible = False
  36. Else
  37. menuutama.UserToolStripMenuItem.Visible = True
  38. menuutama.Button1.Visible = True
  39. End If
  40. Else
  41. MsgBox("Login Gagal")
  42. TextBox1.Clear()
  43. TextBox2.Clear()
  44. ComboBox1.Text = ""
  45. TextBox1.Focus()
  46.  
  47. hitung = hitung + 1
  48. If hitung = 3 Then
  49. End
  50. Me.Close()
  51. End If
  52. End If
  53. End Sub
  54.  
  55. Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  56. Me.Close()
  57. End Sub
  58.  
  59. Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  60. Me.CenterToScreen()
  61. TextBox2.PasswordChar = "*"
  62. Call tampil_status()
  63. End Sub
  64.  
  65. Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
  66. If e.KeyChar = Chr(13) Then
  67. Button1.Focus()
  68. End If
  69. End Sub
  70. Sub tampil_status()
  71. 'nampilin status combobox dinamis
  72. Call koneksi()
  73. cmd = New OdbcCommand("select distinct status_user from user", conn)
  74. dr = cmd.ExecuteReader
  75. ComboBox1.Items.Clear()
  76. Do While dr.Read
  77. ComboBox1.Items.Add(dr.Item("status_user"))
  78. Loop
  79. End Sub
  80.  
  81.  
  82. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement