Private Sub frmDetailCar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
connectsql()
showtable()
End Sub
Private Sub showtable() 'ฟังก์ชันโชว์ตาราง'
Dim ds As New DataSet
ds = querysql("car", "select * from car")
DataGridView1.DataSource = ds.Tables("car")
End Sub
Private Sub DataGridView1_CellMouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Dim ds As New DataSet
Dim idpro As String
If IsDBNull(DataGridView1.CurrentRow.Cells("carID").Value) = False Then
idpro = DataGridView1.CurrentRow.Cells("carID").Value
ds = querysql("car", "select * from car where carID like ' " & idpro & "'")
With ds
Private Function checkdata()
Dim result As Boolean
If txtcarID.Text = "Or txtcarName.Text = "" Or txtcarType.Text ="" Or txtcaryear.Text ="" Or txtcarColor.Text ="" Then" Then
MessageBox.Show("กรุณาใส่ข้อมูลให้ครบ")
result = False
Else
result = True
End If
Return result
End Function
Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
Dim result As Boolean
result = checkdata()
If result = True Then
querysql("car", "INSERT INTO car(carID,carName,carType,caryear,carColor)VALUES('" & txtcarID.Text & "','" & txtcarName.Text & "','" & txtcarType.Text & "','" & txtcaryear.Text & "','" & txtcarColor.Text & "')")
showtable()
End If
End Sub