证券考试《投资分析》模拟题.docx
《证券考试《投资分析》模拟题.docx》由会员分享,可在线阅读,更多相关《证券考试《投资分析》模拟题.docx(19页珍藏版)》请在冰豆网上搜索。
证券考试《投资分析》模拟题
PrivateSubCommand1_Click()
DimmrcAsADODB.Recordset
DimtxtsqlAsString
DimmsgtextAsString
IfTrim(txtsid.Text)=""Then
MsgBox"请输入学号!
",vbOKOnly+vbExclamation,"警告"
txtsid.SetFocus
Else
txtsql="select*fromstudent_Info"
Setmrc=executesql(txtsql,msgtext)
'判断数据集是否为空
While(mrc.EOF=False)
'判断是否有重复记录
IfTrim(mrc.Fields(0))=Trim(txtsid)Then
MsgBox"学号已经存在,请重新输入学号!
",vbOKOnly+vbExclamation,"警告"
txtsid.SetFocus
ExitSub
'txtsid.Text=""
Else
mrc.MoveNext
EndIf
Wend
EndIf
IfTrim(txtname.Text)=""Then
MsgBox"请输入姓名!
",vbOKOnly+vbExclamation,"警告"
txtname.SetFocus
ExitSub
EndIf
IfTrim(txtgraduationceremony_Name.Text)=""Then
MsgBox"请输入毕业设计名称!
",vbOKOnly+vbExclamation,"警告"
Comboclassno.SetFocus
ExitSub
EndIf
IfTrim(result.Text)=""Then
MsgBox"请输入分数!
",vbOKOnly+vbExclamation,"警告"
txttel.SetFocus
ExitSub
EndIf
IfNotIsNumeric(Trim(txtsid.Text))Then
MsgBox"学号请输入数字!
",vbOKOnly+vbExclamation,"警告"
ExitSub
txtsid.SetFocus
EndIf
txtsql="select*fromstudent_Infowherestudent_id='"&Trim(txtsid.Text)&"'"
Setmrc=executesql(txtsql,msgtext)
Ifmrc.EOF=FalseThen
MsgBox"学号重复,请重新输入!
",vbOKOnly+vbExclamation,"警告"
mrc.Close
txtsid.SetFocus
Else
mrc.Close
txtsql="select*fromstudent_Info"
Setmrc=executesql(txtsql,msgtext)
mrc.AddNew
mrc.Fields(0)=Trim(txtsid.Text)
mrc.Fields
(1)=Trim(txtname.Text)
mrc.Fields
(2)=Trim(txtgraduationceremony_Name.Text)
mrc.Fields(3)=Trim(txtresult.Text)
mrc.Update
MsgBox"添加毕业设计成绩信息成功!
",vbOKOnly+vbExclamation,"添加"
mrc.Close
Me.Hide
EndIf
EndSub
PrivateSubCommand2_Click()
UnloadMe
EndSub
PrivateSubForm_Load()
EndSub
DimmybookmarkAsVariant
DimiAsInteger
DimmccleanAsBoolean
DimtxtsqlAsString
DimmsgtextAsString
DimmrcAsADODB.Recordset
DimmrccAsADODB.Recordset
PrivateSubForm_Load()
txtsid.Enabled=False
txtname.Enabled=False
txtclassno.Enabled=False
txtgraduationceremony_No.Enabled=False
txtgraduationceremony_Name.Enabled=False
txtgraduationceremony_Type.Enabled=False
txtgraduationceremony_origin.Enabled=False
txtsql="select*fromgraduationceremony_info"
Setmrc=executesql(txtsql,msgtext)
mrc.MoveFirst
CallviewData
mybookmark=mrc.Bookmark
mcclean=True
EndSub
'定义viewData函数,用来在文本框中显示数据。
PublicSubviewData()
txtsid.Text=mrc.Fields(0)
txtname.Text=mrc.Fields
(1)
txtgraduationceremony_No.Text=mrc.Fields
(2)
txtgraduationceremony_Name.Text=mrc.Fields(3)
txtgraduationceremony_Type.Text=mrc.Fields(4)
txtgraduationceremony_origin.Text=mrc.Fields(5)
EndSub
'最后一条记录按钮代码:
PrivateSubcmdLast_Click()
mrc.MoveLast
CallviewData
EndSub
'下一条记录按钮代码:
PrivateSubcmdNext_Click()
mrc.MoveNext
'判断是否到达起始位置
Ifmrc.EOFThen
mrc.MoveFirst
EndIf
CallviewData
EndSub
'第一条记录按钮代码:
PrivateSubcmdOK_Click()
mrc.MoveFirst
CallviewData
EndSub
'上一条记录按钮代码:
PrivateSubcmdPrevious_Click()
mrc.MovePrevious
Ifmrc.BOFThen
mrc.MoveLast
EndIf
CallviewData
EndSub
'修改记录按钮代码:
PrivateSubcmdEdit_Click()
txtsql="select*fromaddgraduationceremony_Info"
Setmrcc=executesql(txtsql,msgtext)
mrcc.AddNew
mrcc.Fields(0)=Trim(txtsid.Text)
mrcc.Fields
(1)=Trim(txtname.Text)
mrcc.Fields
(2)=Trim(txtgraduationceremony_No.Text)
mrcc.Fields(3)=Trim(txtgraduationceremony_Name.Text)
mrcc.Fields(4)=Trim(txtgraduationceremony_Type.Text)
mrcc.Fields(5)=Trim(txtgraduationceremony_origin.Text)
mrcc.Update
mrcc.Close
mcclean=False
Frame1.Enabled=False
'使移动记录按钮失效
cmdok.Enabled=False
cmdprevious.Enabled=False
cmdnext.Enabled=False
cmdlast.Enabled=False
'使各个文本档有效
txtsid.Enabled=True
txtname.Enabled=True
txtgraduationceremony_No.Enabled=True
txtgraduationceremony_Name.Enabled=True
txtgraduationceremony_Type.Enabled=True
txtgraduationceremony_origin.Enabled=True
cmdupdate.Enabled=True
cmdcancel.Enabled=True
cmddelete.Enabled=True
'记下当前记录位置
mybookmark=mrc.Bookmark
txtsql="select*fromgraduationceremony_Info"
Setmrcc=executesql(txtsql,msgtext)
Fori=1Tomrcc.RecordCount
txtclassno.AddItemmrcc.Fields(0)
mrcc.MoveNext
Nexti
mrcc.Close
EndSub
'更新记录按钮代码:
PrivateSubcmdUpdate_Click()
IfmccleanThen
MsgBox"请先按修改毕业设计资料信息按钮!
",vbOKOnly+vbExclamation,"警告"
ExitSub
EndIf
IfTrim(txtsid.Text)=""Then
MsgBox"请输入学号!
",vbOKOnly+vbExclamation,"警告"
txtsid.SetFocus
ExitSub
EndIf
IfTrim(txtname.Text)=""Then
MsgBox"请输入名字!
",vbOKOnly+vbExclamation,"警告"
txtname.SetFocus
ExitSub
EndIf
IfTrim(txtgraduationceremony_No.Text)=""Then
MsgBox"请输入毕业设计编号!
",vbOKOnly+vbExclamation,"警告"
graduationceremony_No.SetFocus
ExitSub
EndIf
IfTrim(txtgraduationceremony_Name.Text)=""Then
MsgBox"请输入毕业设计名称!
",vbOKOnly+vbExclamation,"警告"
txttel.SetFocus
ExitSub
EndIf
IfTrim(txtgraduationceremony_Type.Text)=""Then
MsgBox"请输入毕业设计类别!
",vbOKOnly+vbExclamation,"警告"
txttel.SetFocus
ExitSub
EndIf
IfTrim(txtgraduationceremony_origin.Text)=""Then
MsgBox"请输入毕业设计来源!
",vbOKOnly+vbExclamation,"警告"
txttel.SetFocus
ExitSub
EndIf
IfNotIsNumeric(Trim(txtsid.Text))Then
MsgBox"学号请输入数字!
",vbOKOnly+vbExclamation,"警告"
txtsid.SetFocus
ExitSub
EndIf
'判断是否有重复记录
mrc.Delete
txtsql="select*fromstudent_Infowherestudent_ID='"&Trim(txtsid.Text)&"'"
Setmrcc=executesql(txtsql,msgtext)
Ifmrcc.EOF=FalseThen
MsgBox"学号重复,请重新输入!
",vbOKOnly+vbExclamation,"警告"
mrcc.Close
txtsql="select*fromaddstudent_Info"
Setmrcc=executesql(txtsql,msgtext)
mrcc.MoveLast
txtsid.Text=mrcc.Fields(0)
txtname.Text=mrcc.Fields
(1)
txtclassno.Text=mrcc.Fields
(2)
txttel.Text=mrcc.Fields(3)
mrcc.Close
txtsql="select*fromgraduationceremony_Info"
Setmrcc=executesql(txtsql,msgtext)
mrcc.AddNew
mrcc.Fields(0)=Trim(txtsid.Text)
mrcc.Fields
(1)=Trim(txtname.Text)
mrcc.Fields
(2)=Trim(txtgraduationceremony_No.Text)
mrcc.Fields(3)=Trim(txtgraduationceremony_Name.Text)
mrcc.Fields(4)=Trim(txtgraduationceremony_Type.Text)
mrcc.Fields(5)=Trim(txtgraduationceremony_origin.Text)
mrcc.Update
mrcc.Close
txtsql="select*fromgraduationceremony_Info"
Setmrc=executesql(txtsql,msgtext)
mrc.Bookmark=mybookmark
CallviewData
txtsid.SetFocus
Else
mrcc.Close
txtsql="select*fromaddgraduationceremony_Info"
Setmrcc=executesql(txtsql,msgtext)
mrcc.MoveLast
mrcc.Delete
mrcc.Close
txtsql="select*fromgraduationceremony_Info"
Setmrc=executesql(txtsql,msgtext)
mrc.AddNew
mrc.Fields(0)=Trim(txtsid.Text)
mrc.Fields
(1)=Trim(txtname.Text)
mrcc.Fields
(2)=Trim(txtgraduationceremony_No.Text)
mrcc.Fields(3)=Trim(txtgraduationceremony_Name.Text)
mrcc.Fields(4)=Trim(txtgraduationceremony_Type.Text)
mrcc.Fields(5)=Trim(txtgraduationceremony_origin.Text)
mrc.Update
MsgBox"修改毕业设计信息成功!
",vbOKOnly+vbExclamation,"修改毕业设计信息"
mrc.Close
txtsql="select*fromgraduationceremony_Info"
Setmrc=executesql(txtsql,msgtext)
mrc.Bookmark=mybookmark
CallviewData
Frame1.Enabled=True
cmdok.Enabled=True
cmdprevious.Enabled=True
cmdnext.Enabled=True
cmdlast.Enabled=True
txtsid.Enabled=False
txtname.Enabled=False
txtgraduationceremony_No.Enabled=False
txtgraduationceremony_Name.Enabled=False
txtgraduationceremony_Type.Enabled=False
txtgraduationceremony_origin.Enabled=False
mcclean=True
EndIf
EndIf
EndIf
EndSub
'删除记录按钮代码:
PrivateSubcmdDelete_Click()
'记下当前记录位置
mybookmark=mrc.Bookmark
str2$=MsgBox("是否删除当前记录?
",vbOKCancel,"删除当前记录")
'判断按钮类型
Ifstr2$=vbOKThen
'移动到数据集下一条记录
mrc.MoveNext
'判断数据集对象是否为空
Ifmrc.EOFThen
mrc.MoveFirst
mybookmark=mrc.Bookmark
mrc.MoveLast
mrc.Delete
mrc.Close
txtsql="select*fromgraduationceremony_Info"
Setmrc=executesql(txtsql,msgtext)
mrc.Bookmark=mybookmark
'调用函数显示数据
CallviewData
Else
mybookmark=mrc.Bookmark
'移动到前一条记录
mrc.MovePrevious
mrc.Delete
mrc.Close
txtsql="select*fromgraduationceremony_Info"
Setmrc=executesql(txtsql,msgtext)
'回到原来位置
mrc.Bookmark=mybookmark-1
CallviewData
EndIf
Else
mrc.Bookmark=mybookmark
CallviewData
EndIf
EndSub
'取消修改按钮代码:
PrivateSubcmdcancel_Click()
IfNotmccleanThen
txtsql="select*fromaddgraduationceremony_Info"
Setmrcc=executesql(txtsql,msgtext)
mrcc.MoveLast
mrcc.Delete
mrcc.Close
'使各个按钮有效
Frame1.Enabled=True
cmdok.Enabled=True
cmdprevious.Enabled=True
cmdnext.Enabled=True
cmdlast.Enabled=True
'使各个文本框失效
txtsid.Enabled=False
txtname.Enabled=False
txtgraduationceremony_No.Enabled=False
txtgraduationceremony_Name.Enabled=False
txtgraduationceremony_Type.Enabled=False
txtgraduationceremony_origin.Enabled=False
'回到开始记录位置
mrc.Bookmark=mybookmark
mcclean=True
CallviewData
Else
MsgBox"未作修改不用取消!
",vbOKOnly+vbExclamation,"警告"
EndIf
EndSub
PrivateSubCommand1_Click()
PrivateSubcmdinquire_Click()
DimtxtsqlAsString
DimmsgtextAsString
Dimdd(4)AsBoolean
DimmrcAsADODB.Recordset
txtsql="select*fromstudent_infowhere"
'判断是否学号查询方式
IfCheck1.ValueThen
IfTrim(txtsid.Text)=""Then
sMeg="学号不能为空"
MsgBoxsMeg,vbOKOnly+vbExclamation,"警告"
txtsid.SetFocus
ExitSub
Else
'判断输入学号是否为数字
IfNotIsNumeric(Trim(txtsid.Text))Then
MsgBox"学号请使用数字形式!
",vbOKOnly+vbExclamation,"警告"
ExitSub
txtsid.SetFocus
EndIf
dd(0)=True
'组合查询语句
txtsql=txtsql&"student_ID='"&Trim(txtsid.Text)&"'"
'Setmrc=ExecuteSQL(txtSQL,MsgText)
EndIf
EndIf