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

📄 createacc.aspx.vb

📁 Website for Training and Palcement Officer
💻 VB
字号:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Sql

Partial Class tpo_Atudacc
    Inherits System.Web.UI.Page
    Dim cs As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"

    Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
        Page.Validate("vg1")
        If Not ckUseDefault.Checked() Then
            Page.Validate("vg2")
        End If
        lbError.Font.Bold = True
        lbError.ForeColor = Drawing.Color.Red
        If Page.IsValid() Then
            If Not drlType.SelectedValue.ToString() = "0" Then
                Dim errorMessages As New StringBuilder()
                Dim con As SqlConnection = New SqlConnection(cs)
                Select Case drlType.SelectedValue.ToString()
                    Case "1"
                        Dim cmd As SqlCommand = New SqlCommand("insert into CORDPASSTAB (UID,PASS) values(@uid,@pass)", con)
                        cmd.Parameters.AddWithValue("@uid", txbUID.Text.ToString())
                        If ckUseDefault.Checked() Then
                            cmd.Parameters.AddWithValue("@pass", "DKTE")
                        Else
                            cmd.Parameters.AddWithValue("@pass", txbPass.Text.ToString())
                        End If
                        Try
                            con.Open()
                            cmd.ExecuteNonQuery()
                            con.Close()
                            Response.Redirect("~/tpo/Success.aspx?type=CORD")
                        Catch ex As Exception
                            If ex.Message.Contains("PRIMARY KEY") Then
                                lbError.Text = "User ID already exist"
                            Else
                                lbError.Text = "Error in database connection"
                            End If

                        End Try
                        
                    Case "2"
                        Dim cmd As SqlCommand = New SqlCommand("insert into HRPASSTAB (UID,PASS) values(@uid,@pass)", con)
                        cmd.Parameters.AddWithValue("@uid", txbUID.Text.ToString())
                        If ckUseDefault.Checked() Then
                            cmd.Parameters.AddWithValue("@pass", "DKTE")
                        Else
                            cmd.Parameters.AddWithValue("@pass", txbPass.Text.ToString())
                        End If
                        Try
                            con.Open()
                            cmd.ExecuteNonQuery()
                            con.Close()
                            Response.Redirect("~/tpo/Success.aspx?type=HR")
                        Catch ex As Exception
                            If ex.Message.Contains("PRIMARY KEY") Then
                                lbError.Text = "User ID already exist"
                            Else
                                lbError.Text = "Error in database connection"
                            End If

                        End Try

                    Case "3"
                        Dim cmd As SqlCommand = New SqlCommand("insert into STUDPASSTAB (UID,PASS) values(@uid,@pass)", con)
                        cmd.Parameters.AddWithValue("@uid", txbUID.Text.ToString())
                        If ckUseDefault.Checked() Then
                            cmd.Parameters.AddWithValue("@pass", "DKTE")
                        Else
                            cmd.Parameters.AddWithValue("@pass", txbPass.Text.ToString())
                        End If
                        Try
                            con.Open()
                            cmd.ExecuteNonQuery()
                            con.Close()
                            Response.Redirect("~/tpo/Success.aspx?type=STUD")
                        Catch ex As Exception
                            If ex.Message.Contains("PRIMARY KEY") Then
                                lbError.Text = "User ID already exist"
                            Else
                                lbError.Text = "Error in database connection"
                            End If
                        End Try
                End Select
            Else
                lbError.Text = "Please select account type"
            End If
        Else
            lbError.Text = "Please seclect account type and fill all the fields"
        End If
                
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Page.MaintainScrollPositionOnPostBack = True
    End Sub

    Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckUseDefault.CheckedChanged
        If ckUseDefault.Checked() Then
            txbPass.ReadOnly = True
            txbConfirm.ReadOnly = True
            txbPass.BackColor = Drawing.Color.AliceBlue
            txbConfirm.BackColor = Drawing.Color.AliceBlue
            'cvConfirm.Enabled = False
            'rfvPass.Enabled = False
        Else
            txbPass.ReadOnly = False
            txbConfirm.ReadOnly = False
            txbPass.BackColor = Drawing.Color.White
            txbConfirm.BackColor = Drawing.Color.White
            'cvConfirm.Enabled = True
            'rfvPass.Enabled = True
        End If
    End Sub

   

    Protected Sub ImageButton3_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton3.Click
        Response.Redirect("~/tpo/TpoHome.aspx")
    End Sub


End Class

⌨️ 快捷键说明

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