📄 transquery.aspx.vb
字号:
Imports System.Data.SqlClient
Public Class transquery
Inherits System.Web.UI.Page
Protected WithEvents txtFromDate As System.Web.UI.WebControls.TextBox
Protected WithEvents txtToDate As System.Web.UI.WebControls.TextBox
Protected WithEvents txtFromAmt As System.Web.UI.WebControls.TextBox
Protected WithEvents txtToAmt As System.Web.UI.WebControls.TextBox
Protected WithEvents ddlTType As System.Web.UI.WebControls.DropDownList
Protected WithEvents txtFromCno As System.Web.UI.WebControls.TextBox
Protected WithEvents txtTOCno As System.Web.UI.WebControls.TextBox
Protected WithEvents btnQuery As System.Web.UI.WebControls.Button
Protected WithEvents btnHome As System.Web.UI.WebControls.Button
Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub btnQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuery.Click
Dim cond As String
cond = " acno = '" & Session("acno") & "'"
If txtFromDate.Text <> "" Then
cond = cond & " and tdate >= '" & txtFromDate.Text & "'"
End If
If txtToDate.Text <> "" Then
cond = cond & " and tdate <= '" & txtToDate.Text & "'"
End If
If txtFromAmt.Text <> "" Then
cond = cond & " and tamt >= " & txtFromAmt.Text
End If
If txtToAmt.Text <> "" Then
cond = cond & " and tamt <= " & txtToAmt.Text
End If
If ddlTType.SelectedIndex <> 0 Then
cond = cond & " and ttype = '" & ddlTType.SelectedItem.Value & "'"
End If
If txtFromCno.Text <> "" Then
cond = cond & " and cno >= " & txtFromCno.Text
End If
If txtTOCno.Text <> "" Then
cond = cond & " and cno <= " & txtTOCno.Text
End If
Dim con As New SqlConnection(Application("cs"))
Dim da As New SqlDataAdapter("select tid, tdate,tdesc,cno, deposit=case ttype when 'd' then tamt else null end, withdraw=case ttype when 'w' then tamt else null end from transactions where " & cond, con)
Dim ds As New DataSet()
da.Fill(ds, "trans")
' calculate totals and add new row to TRANS table
Dim row As DataRow
Dim td, tw As Long
For Each row In ds.Tables(0).Rows
If Not IsDBNull(row.Item("deposit")) Then
td += row.Item("deposit")
Else
tw += row.Item("withdraw")
End If
Next
' add row
row = ds.Tables(0).NewRow
row.Item("deposit") = td
row.Item("withdraw") = tw
row.Item("tdesc") = "Totals"
ds.Tables(0).Rows.Add(row)
DataGrid1.DataSource = ds.Tables(0)
DataGrid1.DataBind()
End Sub
Private Sub btnHome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHome.Click
Server.Transfer("default.aspx")
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -