Tag : .NET, Ms Access, VBScript, Crystal Report, Win (Windows App), VB.NET
Date :
2011-04-20 23:37:27
By :
sayki
View :
1228
Reply :
4
No. 1
Guest
โค๊ตครับ Code (VB.NET)
Option Explicit On
Option Strict On
Public Class frmReportSaleOrder
Private Sub frmReportSaleOrder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.optOrders.Checked = True
Me.optDay.Checked = True
Me.dtpD.Value = Now
Me.dtpM.Value = Now
Me.dtpY.Value = Now
End Sub
Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
Me.Close()
End Sub
Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrint.Click
If Me.optSale.Checked Then
Me.ReportSale()
End If
If Me.optOrders.Checked Then
Me.ReportOrders()
End If
End Sub
Sub ReportOrders()
Dim Yx As Integer = CInt(Val(Now.ToString("yyyy")))
Dim F As New frmShowReport
If Me.optDay.Checked Then
Dim Y1 As Integer = Me.dtpD.Value.Year
Dim Y2 As Integer = Me.dtpD2.Value.Year
F.Report_Name = "rptordersdaily"
F.Query_String = "{orders.or_date} in datetime(" & Y1.ToString & "," & Me.dtpD.Value.ToString("MM,dd") & ",0,0,0) "
F.Query_String &= "to datetime(" & Y2.ToString & "," & Me.dtpD2.Value.ToString("MM,dd") & ",23,59,59) "
F.Query_String &= " and {orders.or_status}='1' "
F.Title1 = "สรุปการสั่งซื้อประจำวันที่ " & Me.dtpD.Value.ToString("d MMMM yyyy")
F.Title1 &= " ถึงวันที่ " & Me.dtpD2.Value.ToString("d MMMM yyyy")
F.ShowDialog()
End If
If Me.optMonth.Checked Then
F.Report_Name = "rptordersmonthly"
F.Query_String &= " month({orders.or_date})=" & Me.dtpM.Value.Month.ToString
F.Query_String &= " and year({orders.or_date})=" & Me.dtpM.Value.Year.ToString
F.Query_String &= " and {orders.or_status}='1' "
F.Title1 = "สรุปการสั่งซื้อประจำเดือน " & Me.dtpM.Value.ToString("MMMM yyyy")
F.ShowDialog()
End If
If Me.optYear.Checked Then
F.Report_Name = "rptordersyearly"
F.Query_String &= " year({orders.or_date})=" & Me.dtpY.Value.Year.ToString
F.Query_String &= " and {orders.or_status}='1' "
F.Title1 = "สรุปการสั่งซื้อประจำปี " & Me.dtpY.Value.ToString("yyyy")
F.ShowDialog()
End If
End Sub
Sub ReportSale()
Dim F As New frmShowReport
If Me.optDay.Checked Then
Dim Y1 As Integer = Me.dtpD.Value.Year
Dim Y2 As Integer = Me.dtpD2.Value.Year
F.Report_Name = "rptsaledaily"
F.Query_String = "{sale.sa_date} in datetime(" & Y1.ToString & "," & Me.dtpD.Value.ToString("MM,dd") & ",0,0,0) "
F.Query_String &= "to datetime(" & Y1.ToString & "," & Me.dtpD2.Value.ToString("MM,dd") & ",23,59,59) "
F.Query_String &= " and {sale.sa_status}='1' "
F.Title1 = "สรุปการขายประจำวันที่ " & Me.dtpD.Value.ToString("d MMMM yyyy")
F.Title1 &= " ถึงวันที่ " & Me.dtpD2.Value.ToString("d MMMM yyyy")
F.ShowDialog()
End If
If Me.optMonth.Checked Then
F.Report_Name = "rptsalemonthly"
F.Query_String &= " month({sale.sa_date})=" & Me.dtpM.Value.Month.ToString
F.Query_String &= " and year({sale.sa_date})=" & Me.dtpM.Value.Year.ToString
F.Query_String &= " and {sale.sa_status}='1' "
F.Title1 = "สรุปการขายประจำเดือน " & Me.dtpM.Value.ToString("MMMM yyyy")
F.ShowDialog()
End If
If Me.optYear.Checked Then
F.Report_Name = "rptsaleyearly"
F.Query_String &= " year({sale.sa_date})=" & Me.dtpY.Value.Year.ToString
F.Query_String &= " and {sale.sa_status}='1' "
F.Title1 = "สรุปการขายประจำปี " & Me.dtpY.Value.ToString("yyyy")
F.ShowDialog()
End If
End Sub
End Class