《面向对象程序设计考试步骤》由会员分享,可在线阅读,更多相关《面向对象程序设计考试步骤(12页珍藏版)》请在金锄头文库上搜索。
1、面向对象程序设计考试步骤面向对象程序设计考试步骤 1 1、系统登录、系统登录 (1 1)画面板画面板:注意点注意点:修改窗体的修改窗体的 iconicon 属性、窗体的属性、窗体的 MaximizeMaximize 属性为属性为 FlaseFlase、按钮、按钮 的的 FlatStyleFlatStyle 属性为属性为 FlatFlat、textbox2textbox2 的的 PasswordcharPasswordchar 改为改为 “*”“*” (2 2)新建窗体新建窗体 MDIForm1MDIForm1 (3 3)连接数据库:工具)连接数据库:工具 选择工具箱项,加入选择工具箱项,加入
2、OleDbConnection1OleDbConnection1 空间,新建连接,空间,新建连接, 数据源选择数据源选择 MicrosoftMicrosoft AccessAccess 数据库、项目添加引用数据库、项目添加引用 ,加入,加入 adodbadodb (4 4)写入)写入 button1button1、button2button2 的代码的代码 (5 5)在)在 MDIForm1MDIForm1 中创建状态栏,并传入用户名中创建状态栏,并传入用户名 2 2、界面设计、界面设计 (1 1)新建)新建 Form2Form2、Form3Form3、Form4Form4 窗体窗体 (2 2
3、)将)将 MDIForm1MDIForm1 的的 IsmdicainterIsmdicainter 设置为设置为 TrueTrue (3 3)将)将 Form2Form2、Form3Form3、Form4Form4 的的 LoadLoad 事件写为:事件写为:Me.MdiParentMe.MdiParent = = MDIForm1MDIForm1 (4 4)做菜单)做菜单 MenustripMenustrip、ToolstripToolstrip(TextImageRelationshipTextImageRelationship、DisplayStyleDisplayStyle) (5 5
4、)做连接,使窗体居中)做连接,使窗体居中 3 3、公式计算、公式计算 (1 1)文本框()文本框(NameName)txtAnswer1txtAnswer1、txtAnswer2txtAnswer2;命令按钮(;命令按钮(NameName) Command1Command1、Command2Command2 4 4、工资卡类、工资卡类 (1 1)新建类)新建类 SalaryCardSalaryCard,并写入代码,并写入代码 (2 2)做登陆界面)做登陆界面 form3form3,新建存取款界面,新建存取款界面 form5form5,form5form5 的的 texttext 改为:改为:A
5、TMATMATMATM 的的 passwordcharpasswordchar 改为:改为:“*”“*”注意:取款时必须再次核实密码注意:取款时必须再次核实密码! ! 5 5、数据库操作、数据库操作 (1 1)在)在 form4form4 中添加中添加 BindingSource1BindingSource1(DatememberDatemember、DateSourceDateSource) 、 BindingNavigator1BindingNavigator1(BindingSourceBindingSource)控件)控件(2 2)画界面)画界面(2 2)新建窗体新建窗体 MDIFor
6、m1MDIForm1 (3 3)连接数据库:工具)连接数据库:工具 选择工具箱项,加入选择工具箱项,加入 OleDbConnection1OleDbConnection1 空间,新建连接,空间,新建连接, 数据源选择数据源选择 MicrosoftMicrosoft AccessAccess 数据库、项目添加引用数据库、项目添加引用 ,加入,加入 adodbadodb (4 4)写入)写入 button1button1、button2button2 的代码的代码6 6、报表、报表 (1 1)报表中的表头添加、日期移动位置、统计供应商个数)报表中的表头添加、日期移动位置、统计供应商个数 (2 2)
7、报表创建时的选择)报表创建时的选择 AttentionAttention详细代码详细代码Form1Form1(登陆界面):(登陆界面):PublicPublic ClassClass Form1Form1DimDim countcount AsAs IntegerInteger登陆按钮代码登陆按钮代码PrivatePrivate SubSub Button1_Click()Button1_Click() HandlesHandles Button1.ClickButton1.ClickDimDim str1str1 AsAs StringString = = “select“select *
8、* fromfrom S S wherewhere Sno=“Sno=“ + + Trim(TextBox1.Text)Trim(TextBox1.Text) + + “DimDim str2str2 AsAs StringString = = “select“select * * fromfrom S S wherewhere Sname=“Sname=“ + + Trim(TextBox2.Text)Trim(TextBox2.Text) + + “ andand Sno=“Sno=“ + + Trim(TextBox1.Text)Trim(TextBox1.Text) + + “DimD
9、im strstr AsAs NewNew ADODB.RecordsetADODB.RecordsetWithWith strstr.Open(str1,.Open(str1, OleDbConnection1.ConnectionString,OleDbConnection1.ConnectionString, ADODB.CursorTypeEnum.adOpenKeyset,ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockReadOnly)ADODB.LockTypeEnum.adLockReadOnly)IfIf
10、 .EOF.EOF = = FalseFalse ThenThen.Close().Close().Open(str2,.Open(str2, OleDbConnection1.ConnectionString,OleDbConnection1.ConnectionString, ADODB.CursorTypeEnum.adOpenKeyset,ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockReadOnly)ADODB.LockTypeEnum.adLockReadOnly)IfIf .EOF.EOF = = Fals
11、eFalse ThenThenMe.Hide()Me.Hide()MDIForm1.Show()MDIForm1.Show()ElseElsecountcount +=+= 1 1IfIf countcount 2 2 ThenThenMessageBox.Show(“MessageBox.Show(“您的输入错误次数已达三次,系统将自动退出您的输入错误次数已达三次,系统将自动退出, , “ “提提示示“,“, MessageBoxButtons.OK,MessageBoxButtons.OK, MessageBoxIcon.Warning)MessageBoxIcon.Warning)End
12、EndEndEnd IfIfMessageBox.Show(“MessageBox.Show(“登陆信息错误,请检查后重新输入登陆信息错误,请检查后重新输入“,“, “ “提示提示“,“, MessageBoxButtons.OK,MessageBoxButtons.OK, MessageBoxIcon.Warning)MessageBoxIcon.Warning)TextBox2.SelectAll()TextBox2.SelectAll()TextBox2.Focus()TextBox2.Focus()EndEnd IfIfElseElsecountcount +=+= 1 1IfIf c
13、ountcount 2 2 ThenThenMessageBox.Show(“MessageBox.Show(“您的输入错误次数已达三次,系统将自动退出您的输入错误次数已达三次,系统将自动退出?“,?“, “ “提示提示“,“, MessageBoxButtons.OK,MessageBoxButtons.OK, MessageBoxIcon.Warning)MessageBoxIcon.Warning)EndEndEndEnd IfIfMessageBox.Show(“MessageBox.Show(“登陆信息错误,请检查后重新输入登陆信息错误,请检查后重新输入“,“, “ “提示提示“,“
14、, MessageBoxButtons.OK,MessageBoxButtons.OK, MessageBoxIcon.Warning)MessageBoxIcon.Warning)TextBox1.SelectAll()TextBox1.SelectAll()TextBox1.Focus()TextBox1.Focus()EndEnd IfIfEndEnd WithWithIfIf countcount 2 2 ThenThenMessageBox.Show(“MessageBox.Show(“您的输入错误次数已达三次,系统将自动您的输入错误次数已达三次,系统将自动 退出退出 “,“, “
15、“提示提示“,“, MessageBoxButtons.OK,MessageBoxButtons.OK, MessageBoxIcon.Warning)MessageBoxIcon.Warning)EndEnd IfIfEndEnd SubSub取消按钮代码取消按钮代码PrivatePrivate SubSub Button2_Click()Button2_Click() HandlesHandles Button2.ClickButton2.ClickEndEndEndEnd SubSub账号输入框代码账号输入框代码PrivatePrivate SubSub TextBox1_KeyPress()TextBox1_KeyPress() HandlesHandles TextBox1.KeyPressTextBox1.KeyPressIfIf e.KeyChare.KeyChar = = Chr(13)Chr(13) ThenThenTextBox2.Focus()TextBox2.Focus()ElseIfElseIf e.KeyChare.KeyChar = = Chr(8)Chr(8) ThenThene.Handlede.Handled = = FalseFalseElseIfElseIf e.KeyChare.KeyCh