 |
|

Public Class frmDetailCar
Dim df As String
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
txtcarID.DataBindings.Clear()
txtcarID.DataBindings.Add("Text", ds.Tables("car"), "carID")
txtcarName.DataBindings.Clear()
txtcarName.DataBindings.Add("Text", ds.Tables("car"), "carName")
txtcarType.DataBindings.Clear()
txtcarType.DataBindings.Add("Text", ds.Tables("car"), "carType")
txtcaryear.DataBindings.Clear()
txtcaryear.DataBindings.Add("Text", ds.Tables("car"), "caryear")
txtcarColor.DataBindings.Clear()
txtcarColor.DataBindings.Add("Text", ds.Tables("car"), "carColor")
End With
End If
End Sub
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
-----------------------------
อยากจะเพิ่ม checkbox ลงในgridview เเล้วไห้เซฟได้ครับ
Tag : .NET, Ms Access, Win (Windows App), VS 2008 (.NET 3.x), Windows
|
|
 |
 |
 |
 |
Date :
2014-03-13 15:08:54 |
By :
marginyord |
View :
844 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |