⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webform1.aspx.vb

📁 使用工具为.net2003
💻 VB
📖 第 1 页 / 共 3 页
字号:

            '        'Create the SQL statement for addition
            '        strSQL = "INSERT INTO Orders (CustomerID, Freight, ShipName, " & _
            '        "ShipAddress) VALUES ('" & lstrCustomerID & "'," & ldblFreight & ",'" & _
            '        lstrShipName & "','" & lstrShipAddress & "')"

            '        dcOrder = New SqlCommand(strSQL, conn)
            '        conn.Open()
            '        dcOrder.ExecuteNonQuery()
            '        LogMessage(New Exception("Record added successfully..."), ExceptionType.Green)

            '        Dim dgTemp As New DataGrid
            '        dgTemp = CType(source, DataGrid)
            '        dgUniqueID = dgTemp.UniqueID
            '        dgEditItemIndex = -1
            '        '//Set the current PageIndex
            '        dgCurrentPageIndex = 0
            '    Catch exc As Exception
            '        LogMessage(exc)
            '        Exit Sub
            '    Finally
            '        dcOrder.Dispose()
            '        conn.Close()
            '    End Try

            '    'Rebind the DataGrid                    
            '    BindData()

            'Case "Edit"
            '    Try
            '        'Cast dgTemp to incoming DataGrid
            '        Dim dgTemp As New DataGrid
            '        dgTemp = CType(source, DataGrid)
            '        '//Getting the UniqueID of the child datagrid using the source object
            '        dgUniqueID = dgTemp.UniqueID
            '        '//Store the EditItemIndex to be used later in DataGrid1_ItemDataBound procedure
            '        dgEditItemIndex = e.Item.ItemIndex
            '        '//Store the current PageIndex
            '        dgCurrentPageIndex = dgTemp.CurrentPageIndex
            '        BindData()
            '    Catch exc As Exception
            '        LogMessage(exc)
            '        Exit Sub
            '    End Try

            'Case "Cancel"
            '    Try
            '        'Cast dgTemp to incoming DataGrid
            '        Dim dgTemp As New DataGrid
            '        dgTemp = CType(source, DataGrid)
            '        dgUniqueID = dgTemp.UniqueID
            '        dgEditItemIndex = -1
            '        '//Store the current PageIndex
            '        dgCurrentPageIndex = dgTemp.CurrentPageIndex
            '        BindData()
            '    Catch exc As Exception
            '        LogMessage(exc)
            '        Exit Sub
            '    End Try

            'Case "Update"

            '    Dim txtOrderID As TextBox
            '    Dim txtFreight As TextBox
            '    Dim txtShipName As TextBox
            '    Dim txtShipAddress As TextBox
            '    Dim ldblFreight As Double
            '    Dim lstrShipName As String
            '    Dim lstrShipAddress As String
            '    Dim lintOrderID As Int64

            '    'Read in the values of the TextBoxes 
            '    txtOrderID = e.Item.FindControl("edit_OrderID")
            '    lintOrderID = CInt(txtOrderID.Text) '//Order ID will be in Readonly format
            '    txtFreight = e.Item.FindControl("edit_Freight")
            '    ldblFreight = CDbl(txtFreight.Text)
            '    txtShipName = e.Item.FindControl("edit_ShipName")
            '    lstrShipName = txtShipName.Text
            '    txtShipAddress = e.Item.FindControl("edit_ShipAddress")
            '    lstrShipAddress = txtShipAddress.Text

            '    Dim conn
            '    Dim dcOrder

            '    Try
            '        conn = New SqlConnection("Persist Security Info=False;Data Source=127.0.0.1;Initial Catalog=test;User ID=sa;Password=;")

            '        'Create the SQL statement for updation
            '        strSQL = "UPDATE Orders set Freight = " & ldblFreight
            '        strSQL = strSQL & ",ShipName = '" & lstrShipName & "'"
            '        strSQL = strSQL & ",ShipAddress = '" & lstrShipAddress & "'"
            '        strSQL = strSQL & " WHERE OrderID = " & lintOrderID

            '        dcOrder = New SqlCommand(strSQL, conn)
            '        conn.Open()
            '        dcOrder.ExecuteNonQuery()
            '        LogMessage(New Exception("Record updated successfully..."), ExceptionType.Green)

            '        'Cast dgTemp to incoming DataGrid
            '        Dim dgTemp As New DataGrid
            '        dgTemp = CType(source, DataGrid)
            '        dgUniqueID = dgTemp.UniqueID
            '        dgEditItemIndex = -1
            '        '//Store the current PageIndex                    
            '        dgCurrentPageIndex = dgTemp.CurrentPageIndex
            '    Catch exc As Exception
            '        LogMessage(exc)
            '        Exit Sub
            '    Finally
            '        dcOrder.Dispose()
            '        conn.Close()
            '    End Try

            '    'Rebind the DataGrid                    
            '    BindData()

            'Case "Delete"

            '    Dim ldblOrderID As Int64

            '    'Read in the BoundColumn value of the hidden Order ID value                                
            '    ldblOrderID = CInt(e.Item.Cells(0).Text)

            '    Dim conn
            '    Dim dcOrder

            '    Try
            '        conn = New SqlConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath(ConfigurationSettings.AppSettings("MDBPATH")))

            '        'Create the SQL statement for addition
            '        strSQL = "DELETE FROM Orders WHERE OrderID = " & ldblOrderID

            '        dcOrder = New SqlCommand(strSQL, conn)
            '        conn.Open()
            '        dcOrder.ExecuteNonQuery()
            '        LogMessage(New Exception("Record deleted successfully..."), ExceptionType.Green)

            '        'Cast dgTemp to incoming DataGrid
            '        Dim dgTemp As New DataGrid
            '        dgTemp = CType(source, DataGrid)
            '        dgUniqueID = dgTemp.UniqueID
            '        dgEditItemIndex = -1
            '        '//Set the current PageIndex                    
            '        dgCurrentPageIndex = 0
            '    Catch exc As Exception
            '        LogMessage(exc)
            '        Exit Sub
            '    Finally
            '        dcOrder.Dispose()
            '        conn.Close()
            '    End Try

            '    'Rebind the DataGrid                    
            '    BindData()
        End Select
    End Sub

    '//Procedure for Child DataGrid paging
    Public Sub DataGrid2_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)
        dgCurrentPageIndex = e.NewPageIndex
        'Cast dgTemp to incoming DataGrid
        Dim dgTemp As New DataGrid
        dgTemp = CType(source, DataGrid)
        '//Getting the UniqueID of the child datagrid using the source object
        dgUniqueID = dgTemp.UniqueID
        '//Store the EditItemIndex to be used later in DataGrid1_ItemDataBound procedure
        dgEditItemIndex = -1
        BindData()
    End Sub

    '//Procedure for Child DataGrid Sorting
    Public Sub DataGrid2_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs)

        '//Store the Sort expression, to be used later
        dgSortExpression = e.SortExpression

        'Cast dgTemp to incoming DataGrid
        Dim dgTemp As New DataGrid
        dgTemp = CType(source, DataGrid)
        '//Getting the UniqueID of the child datagrid using the source object
        dgUniqueID = dgTemp.UniqueID
        '//Store the EditItemIndex to be used later in DataGrid1_ItemDataBound procedure
        dgEditItemIndex = -1
        dgCurrentPageIndex = 0

        '//Get the Sort Expression to sort the child grid
        Dim SortExpr As String
        SortExpr = getSortExpression(dgTemp)
        BindData(, SortExpr)

    End Sub

    '//This function returns the new sort expression to sort the child DataGrid
    Private Function getSortExpression(ByVal dgTemp As DataGrid) As String
        Dim SortExprs() As String
        Dim CurrentSearchMode As String, NewSearchMode As String
        Dim ColumnToSort As String, NewSortExpr As String

        '  Parse the sort expression - delimiter space
        SortExprs = Split(dgSortExpression, " ")
        ColumnToSort = SortExprs(0)

        ' If a sort order is specified get it, else default is Ascending
        If SortExprs.Length() > 1 Then
            CurrentSearchMode = SortExprs(1).ToUpper()
            If CurrentSearchMode = "ASC" Then
                NewSearchMode = "DESC"
            Else
                NewSearchMode = "ASC"
            End If
        Else   ' If no mode specified, Default is descending
            NewSearchMode = "DESC"
        End If

        '  Derive the new sort expression. 
        NewSortExpr = ColumnToSort & " " & NewSearchMode

        Return NewSortExpr

    End Function

    '//This function alters the child datagrid sort expression
    Private Sub alterSortExpression(ByVal dgTemp As DataGrid)
        Dim SortExprs() As String
        Dim ColumnToSort As String, NewSortExpr As String

        '  Parse the sort expression - delimiter space
        SortExprs = Split(dgSortExpression, " ")
        ColumnToSort = SortExprs(0)

        ' Figure out the column index 
        Dim iIndex As Integer
        Select Case ColumnToSort.ToUpper()
            Case "[分录表].[科目代码]"
                iIndex = 1
            Case "[分录表].[借方]"
                iIndex = 2
            Case "[分录表].[贷方]"
                iIndex = 3
        End Select

        ' alter the column's sort expression 
        dgTemp.Columns(iIndex).SortExpression = getSortExpression(dgTemp)

    End Sub

#End Region


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim examine As Mvc.Examine = New Mvc.Examine
        lblShowBal.Text = examine.calTrailbalance()
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -