Public Class oooooo
Private Sub delsale_Load(sender As Object, e As EventArgs) Handles MyBase.Load
refresh_edit_user()
End Sub
Private Sub refresh_edit_user()
'DBฐานข้อมูลขายสินค้า
sql = String.Format("select * from sales where CUS_ID like '{0}' ",
cusid.Text)
DataGridView1.DataSource = cmd_dataTable()
End Sub
Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
Dim i As Integer = DataGridView1.CurrentRow.Index
'เลขรหัสสินค้า
TextBox1.Text = DataGridView1.Item(0, i).Value
'ชื่อสินค้า
TextBox2.Text = DataGridView1.Item(1, i).Value
'รหัสลูกค้า
TextBox3.Text = DataGridView1.Item(2, i).Value
'ราคา
TextBox4.Text = DataGridView1.Item(3, i).Value
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If confirm("คุณต้องการจะลบใช่หรือไม่") = vbNo Then Return
sql = "delete from sales where CUS_ID ='" & TextBox3.Text & "'"
If cmd_excuteNonquery() = 0 Then
fail("ไม่สำเร็จ")
Else
ok("สำเร็จ")
refresh_edit_user()
End If
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
End Sub
End Class
Tag : .NET, Ms SQL Server 2008, VB.NET, C#, VS 2010 (.NET 4.x), VS 2012 (.NET 4.x)