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

📄 kqxt_xtsjgl.aspx.vb

📁 vb2005电子书籍——vb.net项目开发宝典源码
💻 VB
字号:
Namespace wsbgxt

Partial Class kqxt_xtsjgl
    Inherits System.Web.UI.Page
    Private Shared kqDV As DataView
    Private Shared lIndex As Integer
    Private Shared operateindex As Integer
    Private Shared iclskq As New clsDataSet
    Private Shared kqDS As DataSet

#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
            If Session("id") Is Nothing Then
                Response.Redirect("../NotLogin.aspx?FromPageName=kqxt/kqxt_xtsjgl")
            End If
            If Not IsPostBack Then
                LoadData()
            End If
        End Sub

        Private Sub LoadData()
            '控件初始化
            txtNYF.Text = ""
            txtSBSJSZ.Text = ""
            txtBYGZTS.Text = ""
            txtBYMTXSS.Text = ""
            txtKGSX.Text = ""
            txtBZ.Text = ""
            '转载数据
            kqDS = iclskq.CreateDataSet("select * from n_oa02_gzsjdmb_ent", "kq_table")
            kqDV = New DataView(kqDS.Tables(0))
            grds.DataSource = kqDV
            grds.DataBind()
        End Sub

        Private Function AddRow() As Boolean
            Dim temprow As DataRow
            Dim lb As Boolean
            temprow = kqDS.Tables(0).NewRow()
            temprow(1) = txtNYF.Text
            temprow(2) = txtSBSJSZ.Text
            temprow(3) = CInt(txtBYGZTS.Text)
            temprow(4) = CInt(txtBYMTXSS.Text)
            temprow(5) = txtKGSX.Text
            temprow(6) = txtBZ.Text
            kqDS.Tables(0).Rows.Add(temprow)
            lb = iclskq.UpdateDataSet(kqDS)
            If lb Then
                Return True
            Else
                Return False
            End If
        End Function

        Private Function DeleteRow() As Boolean
            Dim lb As Boolean
            kqDS.Tables(0).Rows(lIndex).Delete()

            lb = iclskq.UpdateDataSet(kqDS)
            If lb Then
                Return True
            Else
                Return False
            End If
        End Function

        Private Function UpdateRow() As Boolean
            Dim lb As Boolean
            kqDS.Tables(0).Rows(lIndex).Item("nyf") = txtNYF.Text
            kqDS.Tables(0).Rows(lIndex).Item("sbsjsz") = txtSBSJSZ.Text
            kqDS.Tables(0).Rows(lIndex).Item("bygzts") = txtBYGZTS.Text
            kqDS.Tables(0).Rows(lIndex).Item("bymtxss") = txtBYMTXSS.Text
            kqDS.Tables(0).Rows(lIndex).Item("kgsx") = txtKGSX.Text
            kqDS.Tables(0).Rows(lIndex).Item("bz") = txtBZ.Text
            lb = iclskq.UpdateDataSet(kqDS)
            If lb Then
                Return True
            Else
                Return False
            End If
        End Function

    'datagrid 的分页处理
    Sub ChangeGridPage(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)
        grds.EditItemIndex = -1
        grds.CurrentPageIndex = e.NewPageIndex
        grds.DataSource = kqDV
        grds.DataBind()
    End Sub


    Sub grds_ItemCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)

        lIndex = e.Item.ItemIndex
        lIndex = lIndex + grds.CurrentPageIndex * grds.PageSize
       


        If e.CommandSource.commandname = "kqUpdate" Or e.CommandSource.commandname = "kqDelete" Then

            btnADD.Visible = False
            btnOK.Visible = True

            txtNYF.Text = e.Item.Cells(1).Text
            txtSBSJSZ.Text = e.Item.Cells(2).Text
            txtBYGZTS.Text = e.Item.Cells(3).Text
            txtBYMTXSS.Text = e.Item.Cells(4).Text
            txtKGSX.Text = e.Item.Cells(5).Text
            txtBZ.Text = e.Item.Cells(6).Text
        End If


        If e.CommandSource.commandname = "kqUpdate" Then
            operateindex = 0
        ElseIf e.CommandSource.commandname = "kqDelete" Then
            operateindex = 1
        End If
    End Sub

    Private Sub btnADD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnADD.Click
        If AddRow() Then
            LoadData()
        End If
    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        If operateindex = 0 Then
            UpdateRow()
        Else
            DeleteRow()
        End If
        LoadData()
    End Sub
End Class

End Namespace

⌨️ 快捷键说明

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