ปุ่ม OK พอกดแล้วจะเรียก ฟังชั่น ตัวนี้ทำงานอ่ะครับ
Code (VB.NET)
Sub InputHK(BC As String, ii As Integer)
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
Dim dt2 As DataTable
Connect()
'Dim dr As DataRow
'' Try
Dim sql_search As String
Dim search As String
Dim search2 As String
Dim num As Integer
sql_search = "SELECT Item_Detail.Item_Barcode,Item_Detail.Item_Name,Item_Detail.Item_AticleCode,Item_Stock.ItemStock,Item_Detail.Item_UnitPrice FROM Item_Stock INNER JOIN Item_Detail ON Item_Stock.ID_Item_Stock = Item_Detail.ID_Item_Detail"
'sql_search = "SELECT Item_Detail.Item_Barcode,Item_Stock.ItemStock,Item_Detail.Item_UnitPrice FROM Item_Stock INNER JOIN Item_Detail ON Item_Stock.ID_Item_Stock = Item_Detail.ID_Item_Detail"
Dim sqlWhere As String
sqlWhere = " where Item_barcode LIKE'" & BC.ToString & "'"
Dim sqlemp As String
'Dim group As String = "GROUP BY IT_PlannedList.PlannedListID, IT_PlannedList.ItemNo, IT_Description.Item_Desc, IT_PlannedList.ContractorID, Contractor.Contractor_Name, IT_PlannedList.OrderedTimes, IT_PlannedList.Qty, IT_PlannedList.Unit, IT_TransContractor.ModelID, IT_PlannedList.DateCreated ORDER BY IT_PlannedList.ItemNo"
sqlemp = sql_search & sqlWhere '& group
Dim OledbCmd As OleDbCommand
OledbCmd = New OleDbCommand(sqlemp, conn)
Dim oledbReader As OleDbDataReader = OledbCmd.ExecuteReader()
Dim Def0 As Integer = 0
Dim dis As Integer = 0
While oledbReader.Read
'MsgBox(oledbReader.Item(0).ToString & " - " & oledbReader.Item(1).ToString & " - " & oledbReader.Item(2).ToString & " - " & oledbReader.Item(3).ToString & " - " & oledbReader.Item(4).ToString)
' dt.Rows.Add()
Dim ResutlNum As Integer = CInt(oledbReader.Item(3)) - CInt(ii)
Dim RSTotal As Integer = (CInt(oledbReader.Item(4).ToString) * CInt(ii)) - dis
' MessageBox.Show(ResutlNum.ToString)
Dim dr As DataRow
dr = dt.NewRow
dr(0) = oledbReader.Item(0).ToString
dr(1) = oledbReader.Item(1).ToString
dr(2) = oledbReader.Item(2).ToString
dr(3) = FormatNumber(oledbReader.Item(4).ToString, 2)
dr(4) = ii
dr(5) = FormatNumber(dis.ToString, 2)
dr(6) = FormatNumber(RSTotal.ToString, 2)
'dr(6) = BC.ToString
dt.Rows.Add(dr)
sell.GridControl1.DataSource = dt
Price_Array(CInt(BC_CKrow)) = CInt(RSTotal.ToString)
Price_OArray(CInt(BC_CKrow)) = CInt(RSTotal.ToString)
' MessageBox.Show(BC_CKrow.ToString)
End While
BC_CKrow = BC_CKrow + 1
SumTotalCost2()
End Sub