default.aspx.vb

来自「its it tracker and used for track」· VB 代码 · 共 39 行

VB
39
字号
Imports System.Data.SqlClient
Imports System.Data

Partial Public Class _default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            BindGrid()
        End If
    End Sub
    Private Sub BindGrid()
        Dim ds As New DataSet
        Dim cn As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings.Item("dfs_ITracker_dbConnectionString").ToString)
        cn.Open()
        Dim sb As New StringBuilder
        With sb
            .Append("select * ")
            .Append("from inventory ")
            .Append("where inventory.inv_qty <= inventory.inv_ReorderPt ")
        End With
        Dim cmd As New SqlCommand(sb.ToString, cn)
        cmd.CommandType = CommandType.Text
        Dim da As New SqlDataAdapter(cmd)
        da.Fill(ds)
        gvReorderAlerts.DataSource = ds.Tables(0)
        gvReorderAlerts.DataBind()
    End Sub

    Private Sub gvReorderAlerts_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvReorderAlerts.RowCommand
        If e.CommandName = "Select" Then
            Response.Redirect("~/Details.aspx?id=" & CType(e.CommandSource, GridView).DataKeys(CInt(e.CommandArgument)).Value.ToString)
        End If
    End Sub

    Private Sub _default_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        Me.MasterPageFile = System.Configuration.ConfigurationManager.AppSettings("MasterPageName")
    End Sub
End Class

⌨️ 快捷键说明

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