SQLConnection.Close()
SQLConnection.Open()
Dim where As String = ""
where = "and b.status like '%" + TextBox1.Text + "%' group BY amount DESC LIMIT 0,5 "
Dim cryrpt As New cry_producttop
SQLStatement = "select a.bill_id,a.ps_date,a.sum_price,a.emp_id,a.cus_id,a.status,b.pro_id,b.pro_name,b.amount,SUM(b.amount),b.pro_price,b.tax_sell,b.status from product_sell a left join product_sell_detail b on a.bill_id = b.bill_id where a.ps_date between '" + Convert.ToDateTime(DateTimePicker1.Text).ToString("yyyy-MM-dd", New System.Globalization.CultureInfo("en-US")) + "' and '" + Convert.ToDateTime(DateTimePicker2.Text).ToString("yyyy-MM-dd", New System.Globalization.CultureInfo("en-US")) + "' " + where
cmd = New MySqlCommand(SQLStatement, SQLConnection)
Dim a As MySqlDataReader = cmd.ExecuteReader
If a.HasRows Then
dt = New DataTable
dt.Load(a)
cryrpt.SetDataSource(dt)
CrystalReportViewer1.ReportSource = cryrpt
cryrpt.SetParameterValue("date_from", DateTimePicker1.Text)
cryrpt.SetParameterValue("date_to", DateTimePicker2.Text)
Label3.Text = ""
Else
CrystalReportViewer1.ReportSource = Nothing
MessageBox.Show("ไม่พบข้อมูล")
End If
CrystalReportViewer1.Refresh()
SQLConnection.Close()
End Sub