📄 frmxs2.frm
字号:
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 360
TabIndex = 21
Top = 1440
Width = 1095
End
Begin VB.Label Label5
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "班 级"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 360
TabIndex = 20
Top = 1920
Width = 1095
End
Begin VB.Label Label6
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "数学成绩"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3960
TabIndex = 19
Top = 960
Width = 1095
End
Begin VB.Label Label7
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "语文成绩"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3960
TabIndex = 18
Top = 480
Width = 1095
End
Begin VB.Label Label8
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "英语成绩"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3960
TabIndex = 17
Top = 1440
Width = 1095
End
Begin VB.Label Label9
BackColor = &H00E2F0C1&
BackStyle = 0 'Transparent
Caption = "共"
Height = 255
Left = 4080
TabIndex = 16
Top = 2040
Width = 255
End
Begin VB.Label Label10
BackStyle = 0 'Transparent
Caption = "条记录"
Height = 255
Left = 5640
TabIndex = 15
Top = 2040
Width = 735
End
End
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 2055
Left = 0
TabIndex = 11
Top = 3360
Width = 9015
_ExtentX = 15901
_ExtentY = 3625
_Version = 393216
Rows = 6
Cols = 8
FixedCols = 0
BackColor = 15518939
ForeColor = 33023
BackColorFixed = 16761024
ForeColorFixed = 16576
BackColorSel = -2147483646
ForeColorSel = 12648447
BackColorBkg = 14743774
GridColor = 16761024
GridColorFixed = 16761087
GridLinesFixed = 3
SelectionMode = 1
AllowUserResizing= 1
Appearance = 0
FormatString = "序号|学号|姓名|性别|班级|语文成绩|数学成绩|英语成绩"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "楷体_GB2312"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Label Label1
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "学生管理系统"
BeginProperty Font
Name = "隶书"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF8080&
Height = 495
Left = 2400
TabIndex = 12
Top = 120
Width = 4215
End
End
Attribute VB_Name = "frmXs2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim jfm As New ADODB.Recordset
Dim Cj As New ADODB.Recordset
Dim xsjl As New ADODB.Connection
Dim SQL As String
Private Sub CmdClear_Click()
Call Clear
End Sub
Private Sub CmdDelete_Click()
If TxtXH.Text = "" Then
MsgBox "学号不能为空!", vbOKOnly, "information"
TxtXH.SetFocus
Exit Sub
End If
SQL = "delete from 学生档案 where 学号='" & TxtXH.Text & "'"
cnn.Execute (SQL)
Call Data_Display
Call Clear
End Sub
Private Sub CmdExit_Click()
Unload Me
End Sub
Private Sub CmdSave_Click()
'On Error Resume Next
Dim Msg As String
Dim Sid As Integer
Dim jfm As New ADODB.Recordset
Dim Cj As New ADODB.Recordset
Dim SQL As String
'Dim xsjl As String
'检查是否存在该学生生数据
If TxtXH.Text = "" Then
MsgBox "学号不能为空!", vbOKOnly, "information"
TxtXH.SetFocus
Exit Sub
End If
If IsNumeric(TxtYw.Text) = False Then
MsgBox "语文成绩为数字,请重新输入!", vbOKOnly, "information"
TxtYw.SetFocus
Exit Sub
End If
If IsNumeric(TxtSx.Text) = False Then
MsgBox "数学成绩为数字,请重新输入!", vbOKOnly, "information"
TxtSx.SetFocus
Exit Sub
End If
If IsNumeric(TxtYy.Text) = False Then
MsgBox "英语成绩为数字,请重新输入!", vbOKOnly, "information"
TxtYy.SetFocus
Exit Sub
End If
SQL = "select 学号 from 学生档案 where 学号='" & TxtXH.Text & "'"
Set xsjl = cnn.Execute(SQL)
If xsjl.BOF And xsjl.EOF Then
SQL = "insert into 学生档案 (学号,姓名,性别,班级) "
SQL = SQL & "values ('" & TxtXH.Text & "','" & TxtXM.Text & "','" & TxtXB.Text & "','" & TxtBJ.Text & "')"
cnn.Execute (SQL)
SQL = "select max(s_id) from 学生档案"
Set jfm = cnn.Execute(SQL)
SQL = "insert into 学生成绩 (s_id,学习科目,成绩) values (" & jfm(0) & ",'语文','" & TxtYw.Text & "')"
cnn.Execute (SQL)
SQL = "insert into 学生成绩 (s_id,学习科目,成绩) values (" & jfm(0) & ",'数学','" & TxtSx.Text & "')"
cnn.Execute (SQL)
SQL = "insert into 学生成绩 (s_id,学习科目,成绩) values (" & jfm(0) & ",'英语','" & TxtYy.Text & "')"
cnn.Execute (SQL)
MsgBox "存盘成功!", vbOKOnly, "information"
Else
SQL = "update 学生档案 set 姓名='" & TxtXM.Text & "',性别='" & TxtXB.Text & "',班级='" & TxtBJ.Text & "' where 学号='" & TxtXH.Text & "'"
cnn.Execute (SQL)
SQL = "select s_id from 学生档案 where 学号='" & TxtXH.Text & "'"
Set jfm = cnn.Execute(SQL)
SQL = "update 学生成绩 set 成绩='" & TxtYw.Text & "' where s_id=" & jfm(0) & " and 学习科目='语文'"
cnn.Execute (SQL)
SQL = "update 学生成绩 set 成绩='" & TxtSx.Text & "' where s_id=" & jfm(0) & " and 学习科目='数学'"
cnn.Execute (SQL)
SQL = "update 学生成绩 set 成绩='" & TxtYy.Text & "' where s_id=" & jfm(0) & " and 学习科目='英语'"
cnn.Execute (SQL)
MsgBox "修改成功!", vbOKOnly, "information"
End If
Call Data_Display
End Sub
Private Sub Command1_Click()
TxtCx1.Text = Trim(TxtCx1.Text)
TxtCx2.Text = Trim(TxtCx2.Text)
If TxtCx1.Text <> "" And TxtCx2.Text <> "" Then
SQL = "select * from 学生档案 where " & Combo1.Text & " like '" & TxtCx1.Text & "' and " & Combo2.Text & " like '" & TxtCx2.Text & "'"
GoTo cont1
End If
If TxtCx1.Text <> "" Then
SQL = "select * from 学生档案 where " & Combo1.Text & " like '" & TxtCx1.Text & "'"
GoTo cont1
End If
If TxtCx2.Text <> "" Then
SQL = "select * from 学生档案 where " & Combo2.Text & " like '" & TxtCx2.Text & "'"
GoTo cont1
End If
SQL = "select * from 学生档案"
cont1:
Set jfm = cnn.Execute(SQL)
Call Data_Display
End Sub
Private Sub Form_Load()
TextJls.Text = ""
Call Clear
Call MSFG_Clear
SQL = "select * from 学生档案"
Set jfm = cnn.Execute(SQL)
Call Data_Display
End Sub
Private Sub MSFG_Clear()
MSFlexGrid1.ColWidth(0) = 800
MSFlexGrid1.ColAlignment(0) = flexAlignCenterCenter
MSFlexGrid1.ColWidth(1) = 800
MSFlexGrid1.ColWidth(2) = 1400
MSFlexGrid1.ColWidth(3) = 800
MSFlexGrid1.ColWidth(4) = 1300
MSFlexGrid1.ColWidth(5) = 1200
MSFlexGrid1.ColWidth(6) = 1200
MSFlexGrid1.ColWidth(7) = 1200
MSFlexGrid1.Rows = 1
End Sub
Private Sub Clear()
TxtXH.Text = ""
TxtXM.Text = ""
TxtXB.Text = ""
TxtBJ.Text = ""
TxtYw.Text = ""
TxtSx.Text = ""
TxtYy.Text = ""
TxtCx1.Text = ""
Combo1.Text = "学号"
TxtCx2.Text = ""
Combo2.Text = "姓名"
End Sub
Private Sub Data_Display()
Dim i As Integer
MSFlexGrid1.Rows = 1 '清空表
If (Not jfm.BOF) And (Not jfm.EOF) Then
i = 0
jfm.MoveFirst
Do While Not jfm.EOF
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
i = i + 1
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 0) = i
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 1) = Trim(jfm("学号"))
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 2) = Trim(jfm("姓名"))
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 3) = Trim(jfm("性别"))
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 4) = Trim(jfm("班级"))
SQL = "select * from 学生成绩 where s_id='" & Trim(jfm("s_id")) & "'"
Set Cj = cnn.Execute(SQL)
If (Not Cj.BOF) And (Not Cj.EOF) Then
Cj.MoveFirst
Do While Not Cj.EOF
If Trim(Cj("学习科目")) = "语文" Then
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 5) = Trim(Cj("成绩"))
End If
If Trim(Cj("学习科目")) = "数学" Then
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 6) = Trim(Cj("成绩"))
End If
If Trim(Cj("学习科目")) = "英语" Then
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 7) = Trim(Cj("成绩"))
End If
Cj.MoveNext
Loop
End If
jfm.MoveNext
Loop
TextJls.Text = i
End If
End Sub
Private Sub MSFlexGrid1_Click()
TxtXH.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1)
TxtXM.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2)
TxtXB.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 3)
TxtBJ.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 4)
TxtYw.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5)
TxtSx.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 6)
TxtYy.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 7)
End Sub
Private Sub MSFlexGrid1_RowColChange()
Call MSFlexGrid1_Click
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -