Dim create_date As String = DateTimePicker1.Value.ToString("yyyy-MM-dd") ' วันที่จาก DateTimePicker
Dim todate_date As String = Date.Now.ToString("yyyy-MM-dd") 'วันที่ปัจจุบัน
' ส่วน formate วันที่ลองหาเองน่ะ เพราะว่าผมไม่รู้ว่าคุณเก็บแบบไหน?
Dim strSql As String = "SELECT * FROM product WHERE create_date = '" + create_date + "';"
Imports System.Data.SqlClient
Imports Microsoft.Reporting.WinForms
Public Class frmReportSellToday
Dim ds As New DataSet
Dim da As New SqlDataAdapter
Private Sub frmReportSellToday_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'dsReportSell.dtReportSellToday' table. You can move, or remove it, as needed.
'Me.dtReportSellTodayTableAdapter.FillReportSellToday(Me.dsReportSell.dtReportSellToday)
'call connection db
Call dbConnection()
'Me.dtReportSellTodayTableAdapter.FillReportSellToday(Me.dsReportSell.dtReportSellToday)
Me.rvSellToday.RefreshReport()
End Sub
Private Sub dtpSearchReport_ValueChanged(sender As Object, e As EventArgs) Handles dtpSearchReport.ValueChanged
Dim sqlSellect As String
sqlSellect = "SELECT sd.id,sd.dates,sd.item_count,sd.grand_total,sd.status,sdi.code, sdi.name_thai, sdi.sell_price, sdi.amount, sdi.total, sdi.pin"
sqlSellect &= "FROM sell_docs AS sd INNER JOIN sell_doc_items AS sdi ON (sd.id=sdi.sell_doc_id)"
sqlSellect &= " WHERE dates='" & dtpSearchReport.Value.ToString("yyyy-MM-dd") & "'"
cmd = New SqlCommand
With cmd
.Connection = conn
.CommandText = sqlSellect
.CommandType = CommandType.Text
End With
da.Fill(ds, "sell")
dt = New DataTable
rvSellToday.LocalReport.DataSources.Add(New ReportDataSource("DataSetReportToday", dt))
rvSellToday.LocalReport.ReportPath = "C:\DATA\CoffeePOS\CoffeePOS\ReportSellToday.rdlc"
rvSellToday.LocalReport.Refresh()
End Sub
End Class
Imports System.Data.SqlClient
Imports Microsoft.Reporting.WinForms
Public Class frmReportSellToday
Dim ds As New DataSet
Dim da As New SqlDataAdapter
Private Sub frmReportSellToday_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'dsReportSell.dtReportSellToday' table. You can move, or remove it, as needed.
'Me.dtReportSellTodayTableAdapter.FillReportSellToday(Me.dsReportSell.dtReportSellToday)
'call connection db
Call dbConnection()
Call LoadReport(Date.Now.ToString("yyyy-MM-dd")) 'โหลด form ให้เอาวันที่ปัจจุบัน
'Me.dtReportSellTodayTableAdapter.FillReportSellToday(Me.dsReportSell.dtReportSellToday)
'Me.rvSellToday.RefreshReport()
End Sub
Private Sub dtpSearchReport_ValueChanged(sender As Object, e As EventArgs) Handles dtpSearchReport.ValueChanged
Call LoadReport(dtpSearchReport.Value.ToString("yyyy-MM-dd")) ' Changed ให้เอาวันที่จาก dtpSearchReport
End Sub
Private Sub LoadReport(ByVal date_value As String)
Try
Dim sqlSellect As String
sqlSellect = "SELECT sd.id,sd.dates,sd.item_count,sd.grand_total,sd.status,sdi.code, sdi.name_thai, sdi.sell_price, sdi.amount, sdi.total, sdi.pin"
sqlSellect &= "FROM sell_docs AS sd INNER JOIN sell_doc_items AS sdi ON (sd.id=sdi.sell_doc_id)"
sqlSellect &= " WHERE dates='" & date_value & "'"
cmd = New SqlCommand
With cmd
.Connection = conn
.CommandText = sqlSellect
.CommandType = CommandType.Text
End With
da.Fill(ds, "sell")
dt = New DataTable
rvSellToday.LocalReport.DataSources.Add(New ReportDataSource("DataSetReportToday", dt))
rvSellToday.LocalReport.ReportPath = "C:\DATA\CoffeePOS\CoffeePOS\ReportSellToday.rdlc"
rvSellToday.LocalReport.Refresh()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Imports Microsoft.Reporting.WinForms
Imports System.Data.SqlClient
Public Class frmReportSellToday
Private adaters As dsReportSellTableAdapters.dtReportSellTodayTableAdapter = New dsReportSellTableAdapters.dtReportSellTodayTableAdapter()
Private table As New dsReportSell.dtReportSellTodayDataTable()
Private myDataSource As New ReportDataSource("DataSetReportToday", DirectCast(table, DataTable))
Private Sub frmReportSellToday_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.rvSellToday.RefreshReport()
End Sub
Private Sub dtpSearchDate_ValueChanged(sender As Object, e As EventArgs) Handles dtpSearchDate.ValueChanged
adaters.FillByReportSellToday(table, dtpSearchDate.Value.ToString("yyy-MM-dd"))
Me.rvSellToday.LocalReport.ReportPath = "C:\DATA\CoffeePOS\CoffeePOS\ReportSellToday.rdlc"
Me.rvSellToday.LocalReport.DataSources.Clear()
Me.rvSellToday.LocalReport.DataSources.Add(myDataSource)
Me.rvSellToday.LocalReport.Refresh()
Me.rvSellToday.RefreshReport()
End Sub
End Class