📄 transactions.vb
字号:
Option Strict Off
Imports System
Imports System.Collections
Imports System.Text
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class BaseClass
Inherits System.Web.UI.Page
protected Grid1 as DataGrid
Protected Message as label, title as label
Protected aposted_display as dropdownlist, selection as dropdownlist
Protected AddPanel as Panel
Protected adate as TextBox, aref as TextBox, adr_amount as TextBox
Protected acr_amount as TextBox , anarr as TextBox
Protected addshow as button
Dim myConnection As OleDbConnection
Dim myCommand As OleDbDataAdapter
Dim ds As New DataSet
Dim ConnStr As String
Dim SQL As String
Sub Page_Load(Source As Object, E As EventArgs)
ConnStr = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=ASPNET;User ID=sa;"
myConnection = New OleDbConnection(ConnStr)
if NOT (isPostBack)
dim code as string, display as string
'work around for RC version. The Request.Form did not seem
'to work in the RC version
'code = Request.Form("Selection")
'title.text = code
code = Session("TheSelectionValue")
title.text = Session("TheSelectionText")
if code = "" then
response.redirect("selection.aspx")
end if
UpdateSelection(code)
rebind
end if
End Sub
Sub ReBind()
SQL = " select m.code_value,m.code_display,t.*, h.* ,"
sql = sql + "(select code_display from masters where code_value = t.posted_to) as posted_display"
sql = sql + " from tr_header h,transactions t, masters m "
sql = sql + " where t.doc_no = h.doc_no "
sql = sql + " and m.code_value = t.code_value"
sql = sql + " and m.code_value = (select selection from tblSelection)"
myCommand = New OleDbDataAdapter(SQL, myConnection)
'use Fill method to populate dataset
myCommand.Fill(ds, "transactions")
'Binding a Grid
Grid1.DataSource=ds.Tables("transactions").DefaultView
Grid1.DataBind()
'populate account selection drop down list
' which is visible in the add mode
SQL = "Select * from masters where code_value <> "
SQL = SQL + " (select selection from tblSelection)"
myCommand = New OleDbDataAdapter(SQL, myConnection)
myCommand.Fill(ds, "masters")
aposted_display.DataSource=ds.Tables("masters").DefaultView
aposted_display.DataBind()
addshow.visible = true
End Sub
Sub Grid1_Edit(Sender As Object, E As DataGridCommandEventArgs)
Grid1.EditItemIndex = E.Item.ItemIndex
ReBind()
End Sub
Sub Grid1_Cancel(Sender As Object, E As DataGridCommandEventArgs)
Grid1.EditItemIndex = -1
ReBind()
End Sub
Sub RunSql(vsql as string)
try
'sql = "Execute p_test " + vkey
Dim mycommand2 As New OleDbCommand(vsql,myConnection)
myConnection.Open()
myCommand2.ExecuteNonQuery()
myConnection.Close()
'turn off editing
Grid1.EditItemIndex = -1
Catch ex As OleDbException
' SQL error
Dim errItem As OleDbError
Dim errString As String
For Each errItem In ex.Errors
errString += ex.Message + "<br/>"
Next
Message.Style("color") = "red"
Response.write("DataBase Error :" + errString)
catch myException as Exception
Response.Write("Exception: " + myException.ToString())
Message.Style("color") = "red"
Finally
message.text = vsql
end try
End sub
sub hidePanel()
if AddPanel.visible = true then
AddPanel.visible = false
'reset values
adate.text = ""
aref.text = ""
adr_amount.text = ""
acr_amount.text = ""
anarr.text = ""
end if
end sub
Sub UpdateSelection(vselection)
sql = "delete from tblSelection "
sql = sql + " insert into tblSelection(selection)"
sql = sql + " values('" + vselection + "')"
runSql(sql)
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -