Private Sub edit_Data()
Dim sqlQuery1 As String
Dim conn As New OleDbConnection
sqlQuery1 = "UPDATE locker SET " _
& "CODE='" & Txt_c.Text & "'," _
& "NAME='" & Txt_n.Text & "'," _
& "DEP='" & Txt_dep.Text & "'," _
& "LOCKER='" & Txt_locker.Text & "'" _
& "WHERE NO='" & Txt_no.Text & "'"
'MessageBox.Show(sqlQuery1)
Dim com As New OleDbCommand()
With com
.CommandType = CommandType.Text
.CommandText = sqlQuery1
.Connection = conn
.ExecuteNonQuery()
End With
End Sub
Private Sub Btn_u_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_u.Click
If MessageBox.Show("คุณต้องการแก้ไขข้อมูลนี้หรือไม่", "ข้อความเตือน", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
edit_Data()
ShowData()
MessageBox.Show("แก้ไขข้อมูลเสร็จสมบูรณ์", "ข้อความ", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
Private Sub edit_Data()
Dim sqlQuery1 As String
Dim conn As New OleDbConnection
sqlQuery1 = "UPDATE locker SET " _
& "CODE='" & Txt_c.Text & "'," _
& "NAME='" & Txt_n.Text & "'," _
& "DEP='" & Txt_dep.Text & "'," _
& "LOCKER='" & Txt_locker.Text & "'" _
& "WHERE NO='" & Txt_no.Text & "'"
'MessageBox.Show(sqlQuery1)
Dim com As New OleDbCommand()
With com
.CommandType = CommandType.Text
.CommandText = sqlQuery1
.Connection = conn
.ExecuteNonQuery()
End With
End Sub
Private Sub DataGridView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.Click
Try
Txt_no.Text = DataGridView1.CurrentRow.Cells(0).Value.ToString
Txt_c.Text = DataGridView1.CurrentRow.Cells(1).Value.ToString
Txt_n.Text = DataGridView1.CurrentRow.Cells(2).Value.ToString
Txt_dep.Text = DataGridView1.CurrentRow.Cells(3).Value.ToString
Txt_locker.Text = DataGridView1.CurrentRow.Cells(4).Value.ToString
Btn_u.Enabled = True
'cmdClear.Enabled = True
Btn_d.Enabled = True
Btn_a.Enabled = True
Catch
End Try
End Sub