Rumus Module Imports MySql.Data.MySqlClient Module Module1 Public CONN As MySqlConnection Public DA As MySqlDataAdapter Public DS As New DataSet Public CMD As MySqlCommand Public DR As MySqlDataReader Public STR As String Public myData As DataTable Sub koneksi() Try Dim STR As String = "Server=localhost;user id=root;password=;database=tiket" CONN = New MySqlConnection(STR) If CONN.State = ConnectionState.Closed Then CONN.Open() End If Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub End Module rumus login Imports MySql.Data.MySqlClient Public Class Form1 Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If e.KeyChar = Chr(13) Then TextBox2.Focus() End If End Sub Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If e.KeyChar = Chr(13) Then Button1.Focus() End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Call koneksi() CMD = New MySqlCommand("select * from login where Nama='" & TextBox1.Text & "' and Password='" & TextBox2.Text & "'", CONN) DR = CMD.ExecuteReader DR.Read()
If Not DR.HasRows Then MsgBox("Login gagal") TextBox1.Clear() TextBox2.Clear() TextBox1.Focus() Else Me.Visible = False Form2.Show() End If End Sub End Class rumus input data Imports MySql.Data.MySqlClient Public Class Form3 Sub segar3() DGV4.Update() DGV4.Refresh() End Sub Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Call segar3() End Sub Private Sub Form3_Activated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Activated Call koneksi() DA = New MySqlDataAdapter("select * from user", CONN) DS = New DataSet DA.Fill(DS, "user") DGV4.DataSource = DS.Tables("user") End Sub Private Sub DGV4_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV4.CellContentClick Call segar3() End Sub Private Sub DGV4_CellMouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV4.CellMouseClick TextBox1.Text = DGV4.Rows(e.RowIndex).Cells(0).Value TextBox2.Text = DGV4.Rows(e.RowIndex).Cells(1).Value TextBox3.Text = DGV4.Rows(e.RowIndex).Cells(2).Value TextBox4.Text = DGV4.Rows(e.RowIndex).Cells(3).Value ComboBox1.Text = DGV4.Rows(e.RowIndex).Cells(4).Value TextBox6.Text = DGV4.Rows(e.RowIndex).Cells(5).Value
ComboBox2.Text = DGV4.Rows(e.RowIndex).Cells(6).Value TextBox8.Text = DGV4.Rows(e.RowIndex).Cells(7).Value TextBox1.Text = DGV4.Rows(e.RowIndex).Cells(0).Value TextBox2.Text = DGV4.Rows(e.RowIndex).Cells(1).Value TextBox3.Text = DGV4.Rows(e.RowIndex).Cells(2).Value TextBox4.Text = DGV4.Rows(e.RowIndex).Cells(3).Value ComboBox1.Text = DGV4.Rows(e.RowIndex).Cells(4).Value TextBox6.Text = DGV4.Rows(e.RowIndex).Cells(5).Value ComboBox2.Text = DGV4.Rows(e.RowIndex).Cells(6).Value TextBox8.Text = DGV4.Rows(e.RowIndex).Cells(7).Value Call segar3() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Call koneksi() Dim tambah As String Try tambah = "INSERT INTO user VALUES('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "')" CMD = New MySqlCommand(tambah, CONN) CMD.ExecuteNonQuery() If MsgBox("data tersimpan", MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "Sukses") = MsgBoxResult.Ok Then TextBox1.Clear() TextBox2.Clear() TextBox3.Clear() TextBox4.Clear() TextBox1.Focus() End If Catch ex As Exception If MsgBox("tambah gagal", MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "Gagal") = MsgBoxResult.Ok Then TextBox1.Clear() TextBox2.Clear() TextBox3.Clear() TextBox4.Clear() TextBox2.Focus() End If End Try End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Call koneksi() Try DA = New MySqlDataAdapter("Update user set username='" & TextBox1.Text & "', password='" & TextBox2.Text & "', namalengkap= '" & TextBox3.Text & "', alamat= '" & TextBox4.Text & "', negara= '" & ComboBox1.Text & "',
kodepost= '" & TextBox6.Text & "', kota= '" & ComboBox2.Text & "', email= '" & TextBox8.Text & "'", CONN) DS = New DataSet DA.Fill(DS, "user") Call segar3() MsgBox("Data Telah di Upgrade") Catch ex As Exception Call segar3() MsgBox("Data Gagal di Upload") End Try End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Form2.Show() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Call koneksi() Try DS = New DataSet DA = New MySqlDataAdapter("delete from user where username='" & TextBox1.Text & "'", CONN) DA.Fill(DS, "user") Call segar3() MsgBox("Data telah Di Hapus") Catch ex As Exception Call segar3() MsgBox("Data Gagal Di Hapus") End Try End Sub End Class