📄 frmstuinfo.frm
字号:
Caption = "性别"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column03
DataField = "系别"
Caption = "系别"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column04
DataField = "宿舍号"
Caption = "宿舍号"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column05
DataField = "床位号"
Caption = "床位号"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column06
DataField = "备注"
Caption = "备注"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
ColumnWidth = 1065.26
EndProperty
BeginProperty Column01
ColumnWidth = 915.024
EndProperty
BeginProperty Column02
ColumnWidth = 555.024
EndProperty
BeginProperty Column03
ColumnWidth = 750.047
EndProperty
BeginProperty Column04
ColumnWidth = 1124.787
EndProperty
BeginProperty Column05
EndProperty
BeginProperty Column06
EndProperty
EndProperty
End
Begin MSDataGridLib.DataGrid DataGrid3
Height = 3495
Left = 480
TabIndex = 33
Top = 840
Width = 7215
_ExtentX = 12726
_ExtentY = 6165
_Version = 393216
HeadLines = 1
RowHeight = 15
FormatLocked = -1 'True
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 7
BeginProperty Column00
DataField = "学号"
Caption = "学生学号"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = "姓名"
Caption = "学生姓名"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column02
DataField = "性别"
Caption = "性别"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column03
DataField = "系别"
Caption = "系别"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column04
DataField = "宿舍号"
Caption = "宿舍号"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column05
DataField = "床位号"
Caption = "床位号"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column06
DataField = "备注"
Caption = "备注"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
ColumnWidth = 1065.26
EndProperty
BeginProperty Column01
ColumnWidth = 915.024
EndProperty
BeginProperty Column02
ColumnWidth = 555.024
EndProperty
BeginProperty Column03
ColumnWidth = 750.047
EndProperty
BeginProperty Column04
ColumnWidth = 1124.787
EndProperty
BeginProperty Column05
EndProperty
BeginProperty Column06
EndProperty
EndProperty
End
End
End
Attribute VB_Name = "frmstuinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim con As ADODB.Connection
Private Sub cmdcancel_Click()
txtstuid.Text = ""
txtstuname.Text = ""
txtstusex.Text = ""
txtstuxb.Text = ""
txtstussh.Text = ""
txtstucwh.Text = ""
Text3.Text = ""
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdsave_Click()
'保存记录
Dim myrs As New ADODB.Recordset
myrs.Open "SELECT * FROM 学生信息", con, adOpenDynamic, adLockOptimistic, adCmdText
myrs.AddNew
If txtstuid.Text = Empty Then
MsgBox "学号不能为空!"
txtstuid.SetFocus
Exit Sub
End If
If txtstuname.Text = Empty Then
MsgBox "姓名不能为空!"
txtstuname.SetFocus
Exit Sub
End If
If Combosex.Text = Empty Then
MsgBox "请选择性别!"
Combosex.SetFocus
Exit Sub
End If
If txtxb.Text = Empty Then
MsgBox "请输入系别!"
txtxb.SetFocus
Exit Sub
End If
If txtssh.Text = Empty Then
MsgBox "请输入宿舍号!"
txtssh.SetFocus
Exit Sub
End If
If txtcwh.Text = Empty Then
MsgBox "请输入床位号!"
txtcwh.SetFocus
Exit Sub
End If
myrs.Fields(0) = txtstuid.Text
myrs.Fields(1) = txtstuname.Text
myrs.Fields(2) = Combosex.Text
myrs.Fields(3) = txtxb.Text
myrs.Fields(4) = txtssh.Text
myrs.Fields(5) = txtcwh.Text
myrs.Fields(6) = Text3.Text
myrs.Update '调用Recordset对象Update方法保存数据
Set DataGrid1.DataSource = myrs
MsgBox "添加学生信息成功!"
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command5_Click()
Unload Me
End Sub
Private Sub Command6_Click()
Dim tx As New ADODB.Recordset
Dim query As String
If DataGrid1 <> "" Then
If MsgBox("是否确认删除?", vbYesNo + vbCritical, "删除") = vbYes Then
query = "SELECT * FROM 学生信息"
tx.Open query, con, 3, 3, 1
tx.Delete
tx.Update
MsgBox "删除记录成功!刷新后可看到!"
End If
Else
MsgBox "请选择需要删除的记录!", vbOKOnly, "删除"
End If '删除一条记录
End Sub
Private Sub cssh_Click()
Dim rs As New ADODB.Recordset
Dim query1 As String
query1 = "SELECT * FROM 学生信息 WHERE " & "宿舍号" & " = '" & Trim(tssh.Text) & "'"
rs.Open query1, con, adOpenForwardOnly, adLockReadOnly
Set DataGrid1.DataSource = Nothing
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
rs.MoveLast
End If
If rs.RecordCount > 0 Then
Set DataGrid1.DataSource = rs
MsgBox "总共查到" & rs.RecordCount & "记录", vbInformation
Else
MsgBox "没有找到记录,请重新输入查询数据", vbInformation
End If
cssh.Text = ""
End Sub
Private Sub Form_Load()
'创建连接,并打开
Set con = New ADODB.Connection
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\数据.mdb;Persist Security Info=False"
con.CursorLocation = adUseClient
con.Open
Dim rs As New ADODB.Recordset '加载学生信息表信息记录
rs.CursorLocation = adUseClient
rs.Open "Select * from 学生信息", con
Set DataGrid1.DataSource = rs
Set DataGrid3.DataSource = rs
End Sub
Private Sub simpleinquire_Click()
'查找记录
Dim rs As New ADODB.Recordset
Dim query1 As String
query1 = "SELECT * FROM 学生信息 WHERE " & "学号" & " = '" & Trim(txh.Text) & "'"
rs.Open query1, con, adOpenForwardOnly, adLockReadOnly
Set DataGrid1.DataSource = Nothing
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
rs.MoveLast
End If
If rs.RecordCount > 0 Then
Set DataGrid1.DataSource = rs
MsgBox "总共查到" & rs.RecordCount & "记录", vbInformation
Else
MsgBox "没有找到记录,请重新输入查询数据", vbInformation
End If
txh.Text = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -