clientcontrol.ascx.vb

来自「这是一个订单管理系统」· VB 代码 · 共 99 行

VB
99
字号
Imports OrderDll

Partial Class ClientControl
    Inherits System.Web.UI.UserControl
    Public strType As String
    Private strId As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsPostBack = False Then
            If strType = "ADD" Then
                AddInit()
            Else
                EditInit()
            End If
            Me.btnCancel.Text = "返回"
        End If

    End Sub

    Protected Sub btnAct_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAct.Click
        If strType = "ADD" Then
            Btn_Add()
        Else
            Btn_Edit()
        End If
    End Sub

    Protected Sub Btn_Add()
        Dim id As String
        Dim name As String
        Dim type As String
        Dim cc As New ClassClient

        id = Me.TxtClientId.Text.ToString.Replace("'", "''").Trim()
        name = Me.TxtClientName.Text.ToString.Replace("'", "''").Trim()
        type = Me.dplType.SelectedValue

        If cc.Add(id, name, type, 0) = False Then
            TxtClientId.Text = ""
            TxtClientName.Text = ""
            dplType.SelectedValue = "0"
        Else

        End If
    End Sub

    Protected Sub Btn_Edit()
        Dim id As String
        Dim name As String
        Dim type As String
        Dim cc As New ClassClient
        Dim ds As New Data.DataSet

        strId = Me.Request.QueryString("CID")
        id = Me.strId.Replace("'", "''")
        name = Me.TxtClientName.Text.ToString.Replace("'", "''").Trim()
        type = Me.dplType.SelectedValue

        If cc.Edit(id, name, type) = False Then
            If cc.GetRowById(ds, strId.Replace("'", "''")) = False Then
                Me.TxtClientId.Text = strId
                Me.TxtClientId.Enabled = False
                Me.TxtClientName.Text = ds.Tables(0).Rows(0).Item(1)
                Me.dplType.SelectedValue = ds.Tables(0).Rows(0).Item(2).ToString
            End If
        Else

        End If
    End Sub

    Protected Sub AddInit()
        Me.btnAct.Text = "添加"


    End Sub

    Protected Sub EditInit()
        Dim ds As New Data.DataSet
        Dim cc As New ClassClient
        Me.btnAct.Text = "修改"
        strId = Me.Request.QueryString("CID")
        If cc.GetRowById(ds, strId.Replace("'", "''")) = False Then
            Me.TxtClientId.Text = strId
            Me.TxtClientId.Enabled = False
            Me.TxtClientName.Text = ds.Tables(0).Rows(0).Item(1)
            Me.dplType.SelectedValue = ds.Tables(0).Rows(0).Item(2).ToString

        Else
            Me.Visible = False
        End If


    End Sub

    Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Response.Redirect("ClientManager.aspx")
    End Sub
End Class

⌨️ 快捷键说明

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