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

📄 defaultvb.aspx.vb

📁 Telerik是很大的第三方软件制造商
💻 VB
字号:

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Data.OleDb
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports Telerik.QuickStart
Imports Telerik.WebControls


Namespace Telerik.CallbackExamplesVB.Demos.Configurator
    '/ <summary>
    '/ Summary description for _Default.
    '/ </summary>

    Public Class DefaultVB
        Inherits XhtmlPage
        Protected CallbackDropDownList3 As CallbackDropDownList
        Protected Label1 As System.Web.UI.WebControls.Label
        Protected Label2 As System.Web.UI.WebControls.Label
        Protected WithEvents ddlProcessor As Telerik.WebControls.CallbackDropDownList
        Protected WithEvents ddlMemory As Telerik.WebControls.CallbackDropDownList
        Protected WithEvents ddlMonitor As Telerik.WebControls.CallbackDropDownList
        Protected WithEvents ddlHdd As Telerik.WebControls.CallbackDropDownList
        Protected Label3 As System.Web.UI.WebControls.Label
        Protected lblCPU As System.Web.UI.WebControls.Label
        Protected lblMemory As System.Web.UI.WebControls.Label
        Protected lblHDD As System.Web.UI.WebControls.Label
        Protected lblMonitor As System.Web.UI.WebControls.Label
        Protected WithEvents LoadingPanel1 As Telerik.WebControls.LoadingPanel
        Protected WithEvents Img1 As System.Web.UI.HtmlControls.HtmlImage
        Protected lblTotal As System.Web.UI.WebControls.Label


        Private Sub PopulateDropDown(ByVal category As String, ByVal ddl As CallbackDropDownList, ByVal conn As OleDbConnection)
            ddl.Items.Clear()
            Dim dt As New DataTable()
            Dim adapter As New OleDbDataAdapter()
            adapter.SelectCommand = New OleDbCommand("SELECT * FROM " + category, conn)
            adapter.Fill(dt)

            ddl.DataTextField = "Name"
            ddl.DataValueField = "ID"
            ddl.DataSource = dt
            ddl.DataBind()
            ddl.Items.Insert(0, category)
            ddl.SelectedIndex = 0
        End Sub 'PopulateDropDown


        Private Sub LoadData()
            Dim path As String = Server.MapPath("~/Callback/data/data.mdb")
            Dim dbCon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path)
            dbCon.Open()

            PopulateDropDown("PROCESSOR", ddlProcessor, dbCon)
            PopulateDropDown("MEMORY", ddlMemory, dbCon)
            PopulateDropDown("HDD", ddlHdd, dbCon)
            PopulateDropDown("MONITOR", ddlMonitor, dbCon)

            dbCon.Close()
        End Sub 'LoadData


        Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Not Page.IsPostBack Then
                LoadData()
            End If
        End Sub 'Page_Load

#Region "Web Form Designer generated code"

        Protected Overrides Sub OnInit(ByVal e As EventArgs)
            '
            ' CODEGEN: This call is required by the ASP.NET Web Form Designer.
            '
            InitializeComponent()
            MyBase.OnInit(e)
        End Sub 'OnInit


        '/ <summary>
        '/		Required method for Designer support - do not modify
        '/		the contents of this method with the code editor.
        '/ </summary>
        Private Sub InitializeComponent()

        End Sub 'InitializeComponent

#End Region


        Private Function GetPrice(ByVal category As String, ByVal componentIndex As Integer) As Decimal
            If componentIndex < 1 Then
                Return 0
            End If
            Dim path As String = Server.MapPath("~/Callback/data/data.mdb")
            Dim dbCon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path)
            dbCon.Open()
            Dim command As New OleDbCommand(String.Format("SELECT price FROM {0} WHERE id = {1}", category, componentIndex), dbCon)
            Dim price As Decimal = CDec(command.ExecuteScalar())
            dbCon.Close()
            Return price
        End Function 'GetPrice


        Private Sub CalcTotal()
            Dim cpu As Decimal = GetPrice("PROCESSOR", ddlProcessor.SelectedIndex)
            Dim memory As Decimal = GetPrice("MEMORY", ddlMemory.SelectedIndex)
            Dim monitor As Decimal = GetPrice("MONITOR", ddlMonitor.SelectedIndex)
            Dim hdd As Decimal = GetPrice("HDD", ddlHdd.SelectedIndex)

            lblTotal.Text = "$" + (cpu + memory + monitor + hdd).ToString()
        End Sub 'CalcTotal


        Private Sub ddlProcessor_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlProcessor.SelectedIndexChanged
            If ddlProcessor.SelectedIndex > 0 Then
                lblCPU.Text = GetPrice("PROCESSOR", ddlProcessor.SelectedIndex).ToString()
            Else
                lblCPU.Text = "0"
            End If
            CalcTotal()
            lblCPU.Text = "$" + lblCPU.Text
        End Sub 'ddlProcessor_SelectedIndexChanged


        Private Sub ddlMemory_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlMemory.SelectedIndexChanged
            If ddlMemory.SelectedIndex > 0 Then
                lblMemory.Text = GetPrice("MEMORY", ddlMemory.SelectedIndex).ToString()
            Else
                lblMemory.Text = "0"
            End If
            CalcTotal()
            lblMemory.Text = "$" + lblMemory.Text
        End Sub 'ddlMemory_SelectedIndexChanged


        Private Sub ddlHdd_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlHdd.SelectedIndexChanged
            If ddlHdd.SelectedIndex > 0 Then
                lblHDD.Text = GetPrice("HDD", ddlHdd.SelectedIndex).ToString()
            Else
                lblHDD.Text = "0"
            End If
            CalcTotal()
            lblHDD.Text = "$" + lblHDD.Text
        End Sub 'ddlHdd_SelectedIndexChanged


        Private Sub ddlMonitor_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlMonitor.SelectedIndexChanged
            If ddlMonitor.SelectedIndex > 0 Then
                lblMonitor.Text = GetPrice("MONITOR", ddlMonitor.SelectedIndex).ToString()
            Else
                lblMonitor.Text = "0"
            End If
            CalcTotal()
            lblMonitor.Text = "$" + lblMonitor.Text
        End Sub 'ddlMonitor_SelectedIndexChanged
    End Class 'DefaultVB
End Namespace 'Telerik.CallbackExamplesVB.Demos.Configurator

⌨️ 快捷键说明

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