-------------------------------------------------------------------------------------------------------
代码4FormBiographySearch.vb窗体代码
-------------------------------------------------------------------------------------------------------
Imports System.Data.SqlClient
Public Class FormBiographySearch
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim strSql As String = "select * from Strbiogrophy where Strname like '%" & Me.txtName.Text & "%'"
Dim ds As New DataSet
Dim strSql1 As String = "select Strname from Strbiogrophy where Strname like '%" & Me.txtName.Text & "%'"
Dim dbobj As New ConnSqlServer.db
Dim dr As System.Data.SqlClient.SqlDataReader
dr = dbobj.DataReader(strSql1)
If dr.Read() And Me.txtName.Text <> "" Then
dbobj.ReturnDataSet(strSql, ds)
Me.DataGridView1.DataSource = ds.Tables()
Else
MessageBox.Show("无此姓名!")
End If
End Sub
Private Sub btnCancle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancle.Click
Me.txtName.Text = ""
Me.txtNo.Text = ""
Me.txtAge.Text = ""
Me.txtSex.Text = ""
Me.txtTel.Text = ""
End Sub
Private Sub btnUpdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdata.Click
Dim dbobj As New ConnSqlServer.db
Dim Strno As String = txtNo.Text
Dim strSql As String = "select * from Strbiogrophy"
Dim ds As New DataSet
Dim strSql1 As String = "select Strno from Strbiogrophy where Strno = '" & Me.txtNo.Text & "'"
Dim myReturn As DialogResult
Dim sql As String = "Update Strbiogrophy Set Strname='" & Me.txtName.Text & "', Strage='" & Me.txtAge.Text & "', Strsex='" & Me.txtSex.Text & "', Strtel='" & Me.txtTel.Text & "' where Strno='" & Strno & "'"
Dim dr As System.Data.SqlClient.SqlDataReader
dr = dbobj.DataReader(strSql1)
If dr.Read() Then
If txtNo.Text <> "" And txtName.Text <> "" Then
myReturn = Windows.Forms.MessageBox.Show("确定要修改资料吗?", "修改资料", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
If myReturn = Windows.Forms.DialogResult.OK Then
dbobj.RunSql(sql)
MessageBox.Show("修改成功")
dbobj.ReturnDataSet(strSql, ds)
Me.DataGridView1.DataSource = ds.Tables(0)
End If
Else
MessageBox.Show("编号和姓名不能为空!")
End If
Else
MessageBox.Show("无此编号")
End If
End Sub
Private Sub FormBiographySearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
btnUpdata.Enabled = False
btnDelete.Enabled = False
Dim dbobj As New ConnSqlServer.db
Dim strSql As String = "select * from Strbiogrophy"
Dim ds As New DataSet
dbobj.ReturnDataSet(strSql, ds)
Me.DataGridView1.DataSource = ds.Tables(0)
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndelete.Click
Dim dbobj As New ConnSqlServer.db
Dim Strno As String = txtNo.Text
Dim sql As String = "Delete from Strbiogrophy where Strno='" & Strno & "'"
Dim strSql As String = "select * from Strbiogrophy"
Dim ds As New DataSet
Dim strSql1 As String = "select Strno from Strbiogrophy where Strno = '" & Me.txtNo.Text & "'"
Dim myReturn As DialogResult
Dim dr As System.Data.SqlClient.SqlDataReader
dr = dbobj.DataReader(strSql1)
If dr.Read() Then
If txtNo.Text <> "" Then
myReturn = Windows.Forms.MessageBox.Show("确定要删除资料吗?", "删除资料", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
If myReturn = Windows.Forms.DialogResult.OK Then
dbobj.RunSql(sql)
MessageBox.Show("删除成功")
dbobj.ReturnDataSet(strSql, ds)
Me.DataGridView1.DataSource = ds.Tables(0)
Me.txtName.Text = ""
Me.txtNo.Text = ""
Me.txtAge.Text = ""
Me.txtSex.Text = ""
Me.txtTel.Text = ""
End If
Else
MessageBox.Show("编号不能为空!")
End If
Else
<< 上一页 [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] ... 下一页 >>