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

📄 form1.vb

📁 ASP做成的同学录,
💻 VB
📖 第 1 页 / 共 2 页
字号:
        Me.Label6.Location = New System.Drawing.Point(240, 64)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(64, 23)
        Me.Label6.TabIndex = 5
        Me.Label6.Text = "  家:"
        '
        'GroupBox2
        '
        Me.GroupBox2.Controls.Add(Me.Label7)
        Me.GroupBox2.Controls.Add(Me.Button2)
        Me.GroupBox2.Controls.Add(Me.Button3)
        Me.GroupBox2.Controls.Add(Me.Button5)
        Me.GroupBox2.Controls.Add(Me.Button6)
        Me.GroupBox2.Controls.Add(Me.Button1)
        Me.GroupBox2.Controls.Add(Me.TextBox7)
        Me.GroupBox2.Controls.Add(Me.Button4)
        Me.GroupBox2.Location = New System.Drawing.Point(8, 168)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(472, 96)
        Me.GroupBox2.TabIndex = 7
        Me.GroupBox2.TabStop = False
        '
        'Button4
        '
        Me.Button4.Enabled = False
        Me.Button4.Location = New System.Drawing.Point(376, 56)
        Me.Button4.Name = "Button4"
        Me.Button4.TabIndex = 5
        Me.Button4.Text = "查询"
        '
        'TextBox7
        '
        Me.TextBox7.Location = New System.Drawing.Point(216, 56)
        Me.TextBox7.Name = "TextBox7"
        Me.TextBox7.Size = New System.Drawing.Size(144, 21)
        Me.TextBox7.TabIndex = 6
        Me.TextBox7.Text = ""
        '
        'SqlDataAdapter1
        '
        Me.SqlDataAdapter1.DeleteCommand = Me.SqlDeleteCommand1
        Me.SqlDataAdapter1.InsertCommand = Me.SqlInsertCommand1
        Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
        Me.SqlDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "classmater", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("tong_id", "tong_id"), New System.Data.Common.DataColumnMapping("tong_name", "tong_name"), New System.Data.Common.DataColumnMapping("tong_phone", "tong_phone"), New System.Data.Common.DataColumnMapping("tong_shou", "tong_shou"), New System.Data.Common.DataColumnMapping("tong_school", "tong_school"), New System.Data.Common.DataColumnMapping("tong_home", "tong_home")})})
        Me.SqlDataAdapter1.UpdateCommand = Me.SqlUpdateCommand1
        '
        'SqlDeleteCommand1
        '
        Me.SqlDeleteCommand1.CommandText = "DELETE FROM classmater WHERE (tong_id = @Original_tong_id) AND (tong_home = @Orig" & _
        "inal_tong_home OR @Original_tong_home IS NULL AND tong_home IS NULL) AND (tong_n" & _
        "ame = @Original_tong_name OR @Original_tong_name IS NULL AND tong_name IS NULL) " & _
        "AND (tong_phone = @Original_tong_phone OR @Original_tong_phone IS NULL AND tong_" & _
        "phone IS NULL) AND (tong_school = @Original_tong_school OR @Original_tong_school" & _
        " IS NULL AND tong_school IS NULL) AND (tong_shou = @Original_tong_shou OR @Origi" & _
        "nal_tong_shou IS NULL AND tong_shou IS NULL)"
        Me.SqlDeleteCommand1.Connection = Me.SqlConnection1
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_tong_id", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "tong_id", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_tong_home", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "tong_home", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_tong_name", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "tong_name", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_tong_phone", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "tong_phone", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_tong_school", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "tong_school", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_tong_shou", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "tong_shou", System.Data.DataRowVersion.Original, Nothing))
        '
        'SqlConnection1
        '
        Me.SqlConnection1.ConnectionString = "workstation id=HUANG;packet size=4096;integrated security=SSPI;data source=HUANG;" & _
        "persist security info=False;initial catalog=tongxue"
        '
        'SqlInsertCommand1
        '
        Me.SqlInsertCommand1.CommandText = "INSERT INTO classmater(tong_id, tong_name, tong_phone, tong_shou, tong_school, to" & _
        "ng_home) VALUES (@tong_id, @tong_name, @tong_phone, @tong_shou, @tong_school, @t" & _
        "ong_home); SELECT tong_id, tong_name, tong_phone, tong_shou, tong_school, tong_h" & _
        "ome FROM classmater WHERE (tong_id = @tong_id)"
        Me.SqlInsertCommand1.Connection = Me.SqlConnection1
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@tong_id", System.Data.SqlDbType.VarChar, 50, "tong_id"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@tong_name", System.Data.SqlDbType.VarChar, 50, "tong_name"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@tong_phone", System.Data.SqlDbType.VarChar, 50, "tong_phone"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@tong_shou", System.Data.SqlDbType.VarChar, 50, "tong_shou"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@tong_school", System.Data.SqlDbType.VarChar, 50, "tong_school"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@tong_home", System.Data.SqlDbType.VarChar, 50, "tong_home"))
        '
        'SqlSelectCommand1
        '
        Me.SqlSelectCommand1.CommandText = "SELECT tong_id, tong_name, tong_phone, tong_shou, tong_school, tong_home FROM cla" & _
        "ssmater"
        Me.SqlSelectCommand1.Connection = Me.SqlConnection1
        '
        'SqlUpdateCommand1
        '
        Me.SqlUpdateCommand1.CommandText = "UPDATE classmater SET tong_id = @tong_id, tong_name = @tong_name, tong_phone = @t" & _
        "ong_phone, tong_shou = @tong_shou, tong_school = @tong_school, tong_home = @tong" & _
        "_home WHERE (tong_id = @Original_tong_id) AND (tong_home = @Original_tong_home O" & _
        "R @Original_tong_home IS NULL AND tong_home IS NULL) AND (tong_name = @Original_" & _
        "tong_name OR @Original_tong_name IS NULL AND tong_name IS NULL) AND (tong_phone " & _
        "= @Original_tong_phone OR @Original_tong_phone IS NULL AND tong_phone IS NULL) A" & _
        "ND (tong_school = @Original_tong_school OR @Original_tong_school IS NULL AND ton" & _
        "g_school IS NULL) AND (tong_shou = @Original_tong_shou OR @Original_tong_shou IS" & _
        " NULL AND tong_shou IS NULL); SELECT tong_id, tong_name, tong_phone, tong_shou, " & _
        "tong_school, tong_home FROM classmater WHERE (tong_id = @tong_id)"
        Me.SqlUpdateCommand1.Connection = Me.SqlConnection1
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@tong_id", System.Data.SqlDbType.VarChar, 50, "tong_id"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@tong_name", System.Data.SqlDbType.VarChar, 50, "tong_name"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@tong_phone", System.Data.SqlDbType.VarChar, 50, "tong_phone"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@tong_shou", System.Data.SqlDbType.VarChar, 50, "tong_shou"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@tong_school", System.Data.SqlDbType.VarChar, 50, "tong_school"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@tong_home", System.Data.SqlDbType.VarChar, 50, "tong_home"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_tong_id", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "tong_id", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_tong_home", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "tong_home", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_tong_name", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "tong_name", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_tong_phone", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "tong_phone", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_tong_school", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "tong_school", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_tong_shou", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "tong_shou", System.Data.DataRowVersion.Original, Nothing))
        '
        'DataGrid1
        '
        Me.DataGrid1.DataMember = ""
        Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DataGrid1.Location = New System.Drawing.Point(8, 264)
        Me.DataGrid1.Name = "DataGrid1"
        Me.DataGrid1.Size = New System.Drawing.Size(480, 144)
        Me.DataGrid1.TabIndex = 8
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(128, 56)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(72, 23)
        Me.Label7.TabIndex = 7
        Me.Label7.Text = "输入学号:"
        '
        'GroupBox3
        '
        Me.GroupBox3.Location = New System.Drawing.Point(8, 152)
        Me.GroupBox3.Name = "GroupBox3"
        Me.GroupBox3.Size = New System.Drawing.Size(472, 24)
        Me.GroupBox3.TabIndex = 9
        Me.GroupBox3.TabStop = False
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(488, 421)
        Me.Controls.Add(Me.GroupBox3)
        Me.Controls.Add(Me.DataGrid1)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox1)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "Form1"
        Me.Text = "三年二帮"
        CType(Me.DataSet11, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim form1_show As New Form2
        form1_show.Show()



    End Sub



    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'SqlConnection1.Open()
        SqlDataAdapter1.Fill(DataSet11)

      

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click


        Me.BindingContext(DataSet11, "classmater").Position -= 1
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Me.BindingContext(DataSet11, "classmater").Position += 1
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        'dataAdapter下有自带几个command(, 像selectcommand用来选择)
        'insertcommand插入()
        'deletecommand删除的()
        SqlDataAdapter1.SelectCommand.CommandText = "select * from  classmater where tong_id= '" & TextBox7.Text & "'"
        SqlDataAdapter1.Fill(DataSet11, "one    ")
        DataGrid1.DataSource = DataSet11.Tables("one    ")

      


    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
       
        Me.BindingContext(DataSet11, "classmater").EndCurrentEdit()
        Me.BindingContext(DataSet11, "classmater").AddNew()
      

        TextBox1.ReadOnly = False
        TextBox2.ReadOnly = False
        TextBox3.ReadOnly = False
        TextBox4.ReadOnly = False
        TextBox5.ReadOnly = False
        TextBox6.ReadOnly = False

        If Button6.Text = "添加" Then
            Button6.Text = "确定"

        Else
            Button6.Text = "添加"

        End If
        If Button6.Text = "确定" Then
        Else
            Button6.Text = "添加"

        End If




        SqlDataAdapter1.Update(DataSet11)

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        '删除表中记录···

        If (Me.BindingContext(DataSet11, "classmater").Count > 0) Then
            Me.BindingContext(DataSet11, "classmater").RemoveAt(Me.BindingContext(DataSet11, "classmater").Position)
        End If
        If MessageBox.Show("确定删除吗?", MessageBoxButtons.OKCancel) = DialogResult.OK Then
            SqlDataAdapter1.Update(DataSet11)
        End If

    End Sub



    Private Sub TextBox7_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox7.MouseEnter
        '当鼠标9移动到textbox7时,全选textbox7中的文本

        TextBox7.Focus()
        TextBox7.SelectAll()

    End Sub



    Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged
        If TextBox7.Text = "" Then
            Button4.Enabled = False
        Else
            Button4.Enabled = True

        End If

    End Sub
End Class

⌨️ 快捷键说明

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