浙大远程数据库应用程序的设计离线作业.docx
大学远程教育学院数据库应用程序设计课程作业:学号:年级:学习中心:作业第一章1.5 如何保存Delphi的项目?尝试自己动手创立一个项目,并保存。答:执行 File|Save All 菜单命令或单击工具栏中的 Save All 按钮便可保存,在保存时可以对工程文件和单元文件进展改名,但后缀名不能改。保存文件之后,单击工具中的 Run 按钮或按 F9 键,系统将开场编译、连接、运行该工程。1.7 尝试设计如图110所示的窗体。图见教材P15页图110图110第二章2.8设计如图25所示的界面。单击“按钮1”或“按钮2”时在标签上显示用户所执行的操作。单击“开启/停用按钮可控制“按钮1”和“按钮2”是否可用,单击“退出系统按钮时,完毕程序的运行。2.9 设计如图26所示的界面。当单击按钮时,可控制文本框中字体的颜色。图25图26 unit test; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) showLabel: TLabel; btn1: TButton; /按钮 1 btn2: TButton; /按钮 2 ctlBtn: TButton; /开启停用按钮exitBtn: TButton; /退出按钮 procedure btn1Click(Sender: TObject); procedure btn2Click(Sender: TObject); procedure exitBtnClick(Sender: TObject); procedure ctlBtnClick(Sender: TObject); private Private declarations public Public declarations end; var Form1: TForm1; ctlStatus:integer = 0; /控制按钮 1 和 2 的开启和关闭,0 表示当前为开启,1 表示关闭 implementation $R *.dfm procedure TForm1.btn1Click(Sender: TObject);begin 您点击了按钮 1' end; procedure TForm1.btn2Click(Sender: TObject); begin 您点击了按钮 2' end; procedure TForm1.exitBtnClick(Sender: TObject); begin form1.Close; end; procedure TForm1.ctlBtnClick(Sender: TObject); begin if ctlStatus = 0 then begin ctlStatus := 1; end else begin ctlStatus := 0; end; end; end. 2.9: unit test; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Label1: TLabel; Edit1: TEdit; btnRed: TButton; btnGreen: TButton; btnBlue: TButton; procedure btnRedClick(Sender: TObject); procedure btnGreenClick(Sender: TObject); procedure btnBlueClick(Sender: TObject); private Private declarations public Public declarations end; var Form1: TForm1; implementation $R *.dfm procedure TForm1.btnRedClick(Sender: TObject); begin end; procedure TForm1.btnGreenClick(Sender: TObject); begin end; procedure TForm1.btnBlueClick(Sender: TObject); begin end; end.第三章3.8 以下实数中哪些是合法的,哪些是不合法的?不合法的请说明理由。A0.25E+02B.25+2C25E+2D34.5E.123F-3E-4A合法,即为 25 B不合法,小数点前必须有数字,如表示为 0.25+2 C合法,即为 2500 D合法,即为 34.5 E不合法,同2 F合法,即为0.0003 3.12 数学式子sin30。写成Delphi表达式是以下哪个?ASin30BSin(30)CSIN30。DSin(30*Pi/180)D,需要把角度转化为弧度 第四章4.7 利用3个数字编辑框分别输入小时、分、秒,换算共有多少秒,然后使用标签输出。unit test; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Spin; type TForm1 = class(TForm) SpinEdit1: TSpinEdit; Label1: TLabel; Label2: TLabel; SpinEdit2: TSpinEdit; Label3: TLabel; SpinEdit3: TSpinEdit; Label4: TLabel; procedure SpinEdit1Change(Sender: TObject); procedure SpinEdit2Change(Sender: TObject); procedure SpinEdit3Change(Sender: TObject); private Private declarations procedure CalculateTimeToSencond(timeKind:String; time:integer); public Public declarations end; var Form1: TForm1; hour: integer = 0; minute: integer = 0; second: integer = 0; tot:integer = 0; implementation $R *.dfm procedure TForm1.CalculateTimeToSencond(timeKind:String; time:integer); begin if timeKind = 'hh' then hour := time else if timeKind = 'mi' then minute := time else if timeKind = 'ss' then second := time; tot := hour * 60 * 60 + minute * 60 + second; 总共为' + IntToStr(tot) + '秒' end; procedure TForm1.SpinEdit1Change(Sender: TObject); begin end; procedure TForm1.SpinEdit2Change(Sender: TObject); begin end; procedure TForm1.SpinEdit3Change(Sender: TObject); begin end; end. 4.8 在编辑框中输入一个实数,利用备注框输出该实数及其平方和平方根。unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Edit1: TEdit; Label1: TLabel; Memo1: TMemo; Label2: TLabel; procedure Edit1Change(Sender: TObject); private Private declarations public Public declarations end; var Form1: TForm1; num1 : Real; /原实数 num2 : Real; /实数平方 num3 : Real; /实数平方根 implementation $R *.dfm procedure TForm1.Edit1Change(Sender: TObject); begin begin num2 := Sqr(num1); num3 := Sqrt(num1); 实数为 : ' + FloatToStr(num1); 平方为 : ' + FloatToStr(num2); 平方根为 : ' + FloatToStr(num3); end; end; end. 第五章5.11 任意给定3个实数,按照从大到小的顺序依次输出这3个数。 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) num1Edit: TEdit; Label1: TLabel; Label2: TLabel; resultLabel: TLabel; num2Edit: TEdit; num3Edit: TEdit; procedure num1EditChange(Sender: TObject); procedure num2EditChange(Sender: TObject); procedure num3EditChange(Sender: TObject); private Private declarations procedure CompareNumber(); public Public declarations end; var Form1: TForm1; num1 : Real; /数字 1 num2 : Real; /数字 2 num3 : Real; /数字 3 compnum : Real; /比拟时转换 2 数 outStr : String; /输出结果; implementation $R *.dfm procedure TForm1.CompareNumber(); begin begin if num2 > num1 then begin compnum := num1; num1 := num2; num2 := compnum; end; if num3 > num1 then begin compnum := num1; num1 := num3; num3 := compnum; end; if num3 > num2 then begin compnum := num2; num2 := num3; num3 := compnum; end; outStr := FloatToStr(num1) + ',' + FloatToStr(num2) + ',' + FloatToStr(num3); end; end; procedure TForm1.num1EditChange(Sender: TObject); begin form1.CompareNumber; end; procedure TForm1.num2EditChange(Sender: TObject); begin form1.CompareNumber; end; procedure TForm1.num3EditChange(Sender: TObject); begin form1.CompareNumber; end; end. 5.13 假设工资的增幅标准为:假设根本工资大于等于1000元,增加工资20%;假设小于1000元大于等于800元,那么增加工资15%;假设小于800元,那么增加工资10%。请根据用户在文本框中输入的根本工资,计算出增加后的工资。unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Label1: TLabel; Edit1: TEdit; Label2: TLabel; resultLabel: TLabel; procedure Edit1Change(Sender: TObject); private Private declarations public Public declarations end; var Form1: TForm1; salary: Real; outSalary: Real; implementation $R *.dfm procedure TForm1.Edit1Change(Sender: TObject); begin if (salary >= 1000) then outSalary := salary * (1 + 0.2) else if (salary < 1000) And (salary >= 800) then outSalary := salary * (1 + 0.15) else if (salary < 800) then outSalary := salary * (1 + 0.1); end; end. 第六章6.5 设s=1X2X3XXn,求s不大于20000时最大的n。unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Label1: TLabel; Edit1: TEdit; Label2: TLabel; resultLabel: TLabel; procedure FormCreate(Sender: TObject); private Private declarations public Public declarations end; var Form1: TForm1; number, n, tot: Integer; implementation $R *.dfm procedure TForm1.FormCreate(Sender: TObject); begin tot := 1; n := 0; While tot <= number do begin n := n + 1; tot := tot * n; end; 1); end; end. 6.10 在标签上输出100200之间的所有的奇数,其中3的倍数除外。unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) resultLabel: TLabel; procedure FormCreate(Sender: TObject); private Private declarations public Public declarations end; var Form1: TForm1; number, i: Integer; outStr: String; implementation $R *.dfm procedure TForm1.FormCreate(Sender: TObject); begin for i:= 100 to 200 do begin if i mod 2 <> 0 then if i mod 3 <> 0 then outStr := outStr + ' ' + IntToStr(i); end; end; end.第七章7.4 求1200这200个数的和,当和大于10000时完毕计算。要求使用转向语句unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Label1: TLabel; procedure FormCreate(Sender: TObject); private Private declarations public Public declarations end; var Form1: TForm1; sum, n : integer; implementation $R *.dfm procedure TForm1.FormCreate(Sender: TObject); begin sum := 0; n := 0; repeat n := n + 1; sum := sum + n; if (sum > 10000) then break; until n >= 200; 总和为' + IntToStr(sum);end; end. 第八章8.8 编写函数,输出100500之间所有能同时被3和13整除的数。unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Label1: TLabel; procedure FormCreate(Sender: TObject); private Private declarations Function checkNum(num:integer):boolean; public Public declarations end; var Form1: TForm1; implementation $R *.dfm Function TForm1.checkNum(num:integer):boolean; var n :boolean; begin if (num mod 3 = 0) And (num mod 13 = 0) then n := true else n := false; result := n; end; procedure TForm1.FormCreate(Sender: TObject); var i : integer; var out : string; begin for i := 100 to 500 do begin if checkNum(i) then out := out + ' ' + IntToStr(i); end; end; end. 第九章9.2 翻开对话框组件和翻开图片对话框组件有什么异同点?答:两者都会翻开一个对话框用于选择电脑本地上的文件 不同的是前者可以选择全部类型的文件,而后者只可以选择图片类型的文件,并且可以预览图片第十章10.7 菜单命令项与工具栏按钮的单击事件中的代码是否可以关联?如何关联?答:将工具栏按钮 ToolButton 的 Style 属性设置为 tbsDropDown,然后在 MenuItem 属性中选择对应的菜单项即可第十一章11.4 调用子窗体的close方法时是否可关闭该子窗体?假设不能,需要怎么做?答:调用 close 方法只能最小化窗口,如果要真正关闭,需要调用 free 方法 第十二章12.3 使用红色的画笔在窗体中绘制一个半径为5的圆,并且用黄色来填充圆的部。unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormPaint(Sender: TObject); private Private declarations public Public declarations end; var Form1: TForm1; implementation $R *.dfm procedure TForm1.FormPaint(Sender: TObject); var r, x, y:integer; begin r := 5; Canvas.Ellipse(0, 0, r*2, r*2); end; end. 第十三章13.3 翻开一个文本文件有几种方法?区别是什么?1 Reset 过程以只读方式翻开一个文件。 2 Rewrite 过程创立并翻开文件,对于一个已经存在的文件,此操作将使文件被覆盖。3 Append 过程以追加方式翻开文件,并向已经存在的文本文件中追加文本。第十四章14.4 使用Database DeskTop设计如表145所示的数据表,并创立简单的应用程序完成数据的浏览和编辑功能。表145 数据表字段设置说明字段名类型长度说明Id字符型4产品编号Name字符型20产品名称Price数值型产品单价Count短整型产品库存量14.6 使用数据库软件如Sql Server2000创立如表146所示的数据表,并开发一个学生档案管理系统,完成学生根本信息的添加、删除、修改等。同时,可以按照学生的学号、等进展数据的查询。最后,将学生的根本信息以报表的方式输出。表146 数据表字段设置说明字段名类型长度说明Id字符型8学号Name字符型8Sex字符型2性别Birthday日期型4出生日期Address字符型50家庭住址