Imports System.Data
Imports System.Data.OleDb
Public Class frm_Transaction
Dim Conn As OleDbConnection
Private dataset As DataSet
Private cmd As OleDbCommand
Private objDataAdapter As OleDbDataAdapter
Private objDataTable As DataTable
Dim ck As String
Private Sub frm_Transaction_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblText.Text = "ชนิดการทำรายการ : R = Receive การรับเข้าสินค้า A = Adjust การปรับยอดสินค้า B = Billing ออกบิลจ่ายสินค้า"
Conn = New OleDbConnection(conStr)
Conn.Open()
btnSearch.Enabled = False
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
If (RbtnR.Checked = True) Then
ck = "R"
ReadData()
ElseIf (RbtnB.Checked = True) Then
ck = "B"
ReadData()
ElseIf (RbtnA.Checked = True) Then
ck = "A"
ReadData()
ElseIf (RbtnRB.Checked = True) Then
ReadDataAB()
ElseIf (RbtnAll.Checked = True) Then
ReadDataAll()
End If
FillDataGridView()
End Sub
Private Sub ReadDataAll()
Dim sql As String = ""
sql = "SELECT TransactionStore.EnterDate, TransactionStore.Type, TransactionStore.ItemCode, Item.ItemName, Lot.LotNo, Location.LocName, Store.StoreName, TransactionStore.Qty, TransactionStore.TotalCost, "
sql &= "Employee.EmployeeName, TransactionStore.UserID FROM (((((TransactionStore LEFT JOIN Item ON TransactionStore.ItemCode = Item.ItemCode) "
sql &= "LEFT JOIN Lot ON TransactionStore.LotNo = Lot.LotNo) "
sql &= "LEFT JOIN Location ON Lot.LocID = Location.LocID) "
sql &= "LEFT JOIN Store ON Location.StoreID = Store.StoreID) "
sql &= "LEFT JOIN Employee ON TransactionStore.EmployeeCode = Employee.EmployeeCode) ORDER BY TransactionStore.EnterDate ASC"
cmd = New OleDbCommand(sql, Conn)
Dim adapter As New OleDbDataAdapter(cmd)
dataset = New DataSet()
adapter.Fill(dataset, "cust")
End Sub
Private Sub ReadData()
Dim sql As String = ""
sql = "SELECT TransactionStore.EnterDate, TransactionStore.Type, TransactionStore.ItemCode, Item.ItemName, Lot.LotNo, Location.LocName, Store.StoreName, TransactionStore.Qty, TransactionStore.TotalCost, "
sql &= "Employee.EmployeeName, TransactionStore.UserID FROM (((((TransactionStore LEFT JOIN Item ON TransactionStore.ItemCode = Item.ItemCode) "
sql &= "LEFT JOIN Lot ON TransactionStore.LotNo = Lot.LotNo) "
sql &= "LEFT JOIN Location ON Lot.LocID = Location.LocID) "
sql &= "LEFT JOIN Store ON Location.StoreID = Store.StoreID) "
sql &= "LEFT JOIN Employee ON TransactionStore.EmployeeCode = Employee.EmployeeCode) WHERE (TransactionStore.EnterDate >= #" & DtpStart.Value.ToShortDateString & "#) AND (TransactionStore.EnterDate <= #" & DtpEnd.Value.ToShortDateString & "#) AND (TransactionStore.Type = '" & ck & "') ORDER BY TransactionStore.EnterDate ASC"
cmd = New OleDbCommand(sql, Conn)
Dim adapter As New OleDbDataAdapter(cmd)
dataset = New DataSet()
adapter.Fill(dataset, "cust")
End Sub
Private Sub ReadDataAB()
Dim sql As String = ""
sql = "SELECT TransactionStore.EnterDate, TransactionStore.Type, TransactionStore.ItemCode, Item.ItemName, Lot.LotNo, Location.LocName, Store.StoreName, TransactionStore.Qty, TransactionStore.TotalCost, "
sql &= "Employee.EmployeeName, TransactionStore.UserID FROM (((((TransactionStore LEFT JOIN Item ON TransactionStore.ItemCode = Item.ItemCode) "
sql &= "LEFT JOIN Lot ON TransactionStore.LotNo = Lot.LotNo) "
sql &= "LEFT JOIN Location ON Lot.LocID = Location.LocID) "
sql &= "LEFT JOIN Store ON Location.StoreID = Store.StoreID) "
sql &= "LEFT JOIN Employee ON TransactionStore.EmployeeCode = Employee.EmployeeCode) WHERE (TransactionStore.Type = '" & "R" & "' OR TransactionStore.Type = '" & "B" & "') ORDER BY TransactionStore.EnterDate ASC"
cmd = New OleDbCommand(sql, Conn)
Dim adapter As New OleDbDataAdapter(cmd)
dataset = New DataSet()
adapter.Fill(dataset, "cust")
End Sub
Tag : .NET, Ms Access, Win (Windows App), VS 2005 (.NET 2.x)
Private Sub ReadData()
Dim sql As String = ""
sql = "SELECT TransactionStore.EnterDate, TransactionStore.Type, TransactionStore.ItemCode, Item.ItemName, Lot.LotNo, Location.LocName, Store.StoreName, TransactionStore.Qty, TransactionStore.TotalCost, "
sql &= "Employee.EmployeeName, TransactionStore.UserID FROM (((((TransactionStore LEFT JOIN Item ON TransactionStore.ItemCode = Item.ItemCode) "
sql &= "LEFT JOIN Lot ON TransactionStore.LotNo = Lot.LotNo) "
sql &= "LEFT JOIN Location ON Lot.LocID = Location.LocID) "
sql &= "LEFT JOIN Store ON Location.StoreID = Store.StoreID) "
sql &= "LEFT JOIN Employee ON TransactionStore.EmployeeCode = Employee.EmployeeCode) WHERE (format(TransactionStore.EnterDate,'ddmmyyyy') BETWEEN format(#" & DtpStart.Value.ToShortDateString & "#,'dd/mm/yyyy') AND format(#" & DtpEnd.Value.ToShortDateString & "#,'ddmmyyyy')) AND (TransactionStore.Type = '" & ck & "') ORDER BY TransactionStore.EnterDate ASC"
cmd = New OleDbCommand(sql, Conn)
Dim adapter As New OleDbDataAdapter(cmd)
dataset = New DataSet()
adapter.Fill(dataset, "cust")
End Sub
Private Sub ReadData()
Dim sql As String = ""
sql = "SELECT TransactionStore.EnterDate, TransactionStore.Type, TransactionStore.ItemCode, Item.ItemName, Lot.LotNo, Location.LocName, Store.StoreName, TransactionStore.Qty, TransactionStore.TotalCost, "
sql &= "Employee.EmployeeName, TransactionStore.UserID FROM (((((TransactionStore LEFT JOIN Item ON TransactionStore.ItemCode = Item.ItemCode) "
sql &= "LEFT JOIN Lot ON TransactionStore.LotNo = Lot.LotNo) "
sql &= "LEFT JOIN Location ON Lot.LocID = Location.LocID) "
sql &= "LEFT JOIN Store ON Location.StoreID = Store.StoreID) "
sql &= "LEFT JOIN Employee ON TransactionStore.EmployeeCode = Employee.EmployeeCode) WHERE (format(TransactionStore.EnterDate,'ddmmyyyy') BETWEEN format(#" & DtpStart.Value.ToShortDateString & "#,'ddmmyyyy') AND format(#" & DtpEnd.Value.ToShortDateString & "#,'ddmmyyyy')) AND (TransactionStore.Type = '" & ck & "') ORDER BY TransactionStore.EnterDate ASC"
cmd = New OleDbCommand(sql, Conn)
Dim adapter As New OleDbDataAdapter(cmd)
dataset = New DataSet()
adapter.Fill(dataset, "cust")
End Sub