on.TableHeader
End Sub
Imports AjaxControlToolkit
Imports System.Data
Imports System.Data.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
Dim con As New SqlConnection("Data Source=ERP;Initial Catalog=account_org2;Persist Security Info=True;User ID=sa;Password=@rc1982")
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
GridView1.DataBind()
command()
End If
End Sub
Protected Sub LinkButton1_Click(sender As Object, e As EventArgs)
command()
Dim btnsubmit As LinkButton = TryCast(sender, LinkButton)
Dim gRow As GridViewRow = DirectCast(btnsubmit.NamingContainer, GridViewRow)
lblbarcode.Text = GridView1.DataKeys(gRow.RowIndex).Value.ToString()
If Not IsDBNull(Convert.ToString(gRow.Cells(3))) Or Not IsDBNull(gRow.Cells(3).Text) Then
lblbarcode.Text = gRow.Cells(0).Text
txtbarcodetext.Text = gRow.Cells(1).Text
txtproductcode.Text = gRow.Cells(2).Text
DropDownList2.SelectedIndex = -1
txtlocation.Text = gRow.Cells(4).Text
Me.ModalPopupExtender1.Show()
Else
lblbarcode.Text = gRow.Cells(0).Text
txtbarcodetext.Text = gRow.Cells(1).Text
txtproductcode.Text = gRow.Cells(2).Text
DropDownList2.Text = gRow.Cells(3).Text
txtlocation.Text = gRow.Cells(4).Text
Me.ModalPopupExtender1.Show()
End If
End Sub
Protected Sub btnModity_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click
Dim BARCODE As String = lblbarcode.Text
con.Open()
Dim cmd As New SqlCommand("update csbarcode set barcodetext='" + txtbarcodetext.Text + "', productcode='" + txtproductcode.Text + "', unitcode='" + DropDownList2.text + "', location='" + txtlocation.Text + "' where barcode=" + "'" + BARCODE + "'", con)
cmd.ExecuteNonQuery()
con.Close()
Dim msg = "อัพเดทเสร็จสมบูรณ์ !!!"
Dim title = "แจ้งการอัพเดท"
MsgBox(msg, MsgBoxStyle.OkOnly, title)
GridView1.DataBind()
End Sub
Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles btnInsert.Click
Me.ModalPopupExtender2.Show()
End Sub
Protected Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
Dim searchword As String
searchword = "select*from csbarcode where barcode like '%" + txtsearch.Text.ToString() + "%'" & _
"or barcodetext like '%" + txtsearch.Text.ToString() + "%'" & _
"or productcode like '%" + txtsearch.Text.ToString() + "%'"
SqlDataSource.SelectCommand = searchword
GridView1.DataBind()
command()
End Sub
Protected Sub Add_Click(sender As Object, e As EventArgs) Handles Add.Click
If txtinserbarcode.Text <> "" Then
Dim strSQL As String
strSQL = "insert into CSBARCODE (BARCODE,BARCODETEXT,PRODUCTCODE,UNITCODE,CLOSEFLAG,TRFLAG,ROWORDER,SYSDOCFLAG,Location) values ('" & txtinserbarcode.Text & "','" & txtinsertbarcodetext.Text & "','" & txtinsertbarcodetext.Text & "','" & DropDownList2.Text & "','0','1','0','0','" & txtinsertlocation.Text & "')"
con.Open()
Dim cmd As New SqlCommand(strSQL, con)
cmd.ExecuteNonQuery()
con.Close()
Dim msg = "เพิ่มข้อมูลสำเร็จ"
Dim title = "แจ้งการเพิ่มข้อมูล"
MsgBox(msg, MsgBoxStyle.OkOnly, title)
Else
Dim msg = "กรุณากรอกข้อมูลให้ครบถ้วน"
Dim title = "แจ้งการกรอกข้อมูล"
MsgBox(msg, MsgBoxStyle.OkOnly, title)
End If
End Sub
Sub command()
GridView1.HeaderRow.Cells(0).Attributes("data-class") = "expand"
'Attribute to hide column in Phone.
GridView1.HeaderRow.Cells(2).Attributes("data-hide") = "phone"
GridView1.HeaderRow.Cells(3).Attributes("data-hide") = "phone"
GridView1.HeaderRow.Cells(4).Attributes("data-hide") = "phone"
'Adds THEAD and TBODY to GridView.
GridView1.HeaderRow.TableSection = TableRowSection.TableHeader
End Sub
End Class
End Class