1、Delphi学习记念所有资源文献(可直接用Delphi打开编辑)下载地址:效果图:源码:登录界面(从Access数据库读取对比顾客名与密码):UnitLogin.pasunit UnitLogin;interfaceuses Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms, Dialogs,StdCtrls,ExtCtrls,jpeg;type TFormLogin = class(TForm) Image1:TImage; Button1:TButton; Button2:TButton; ComboBox
2、1:TComboBox; Edit1:TEdit; Label1:TLabel; Timer1:TTimer; lblMsg:TLabel; Label2:TLabel; shpBall2:TShape; shpBall1:TShape; procedure FormShow(Sender:TObject); procedure Button1Click(Sender:TObject); procedure Button2Click(Sender:TObject); procedure Timer1Timer(Sender:TObject); private Private declarati
3、ons public Public declarations end;var FormLogin:TFormLogin; nowUser:String; nowPower:integer;implementation$R *.dfm uses UnitDataModule,UnitConsole;var isStop:boolean;procedure TFormLogin.FormShow(Sender:TObject);begin dataModule1.adoTable1.Open; while dataModule1.adoTable1.EOF true do begin comboB
4、ox1.Items.Append(dataModule1.adoTable1.FieldValuesuser); dataModule1.adotable1.Next; end; dataModule1.adoTable1.Close; isStop := false; lblMsg.Visible := false;end;procedure TFormLogin.Button1Click(Sender:TObject);var user1,pwd1 :string;begin user1 := comboBox1.Text; pwd1 := edit1.Text; dataModule1.
5、adoTable1.Open; dataModule1.adoTable1.First; while not dataModule1.adoTable1.EOF do begin if (user1 = DataModule1.adoTable1.FieldValuesuser) and ( pwd1 = DataModule1.adoTable1.FieldValuespwd) then begin nowUser := user1; dataModule1.ADOQuery1.Close; dataModule1.ADOQuery1.SQL.Clear; dataModule1.ADOQu
6、ery1.SQL.Add(select power from Account where user=+nowUser+); dataModule1.ADOQuery1.Open; nowPower := dataModule1.ADOQuery1.Fields0.AsInteger; formConsole.Show; Exit; end; DataModule1.adoTable1.Next; end; ShowMessage(登录失败,请重试!); edit1.Text := ; comboBox1.SetFocus; DataModule1.adoTable1.Close;end;pro
7、cedure TFormLogin.Button2Click(Sender:TObject);begin Application.Terminate;end;procedure TFormLogin.Timer1Timer(Sender:TObject);begin if (not isStop) then begin shpBall1.Left := shpBall1.Left-10; shpBall2.Left := shpBall2.Left+10; if (shpBall1.Left = 100) then isStop := true; end else lblMsg.Visible
8、 := true; end;end.预览界面:UnitConsole.pasunit UnitConsole;interfaceuses Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms, Dialogs,Menus,Grids,DBGrids,StdCtrls,ExtCtrls,jpeg;type TFormConsole = class(TForm) MainMenu1:TMainMenu; view1:TMenuItem; User:TMenuItem; quit1:TMenuItem; DBGrid1:
9、TDBGrid; DBGrid2:TDBGrid; Add:TMenuItem; help:TMenuItem; userMang:TMenuItem; time1:TTimer; Image1:TImage; lblSec:TLabel; lblNote:TLabel; lblMin:TLabel; lblHour:TLabel; Label2:TLabel; Label1:TLabel; editSec:TEdit; editMin:TEdit; editHour:TEdit; procedure view1Click(Sender:TObject); procedure quit1Cli
10、ck(Sender:TObject); procedure AddUserClick(Sender:TObject); procedure userMangClick(Sender:TObject); procedure AddClick(Sender:TObject); procedure helpClick(Sender:TObject); procedure FormShow(Sender:TObject); procedure FormCreate(Sender:TObject); procedure time1Timer(Sender:TObject); private Privat
11、e declarations public Public declarations end;var FormConsole:TFormConsole;implementation$R *.dfm uses UnitView,UnitAdd,UnitDataModule,UnitUserMang,UnitLogin;var hour,min,sec,msec :word;procedure TFormConsole.view1Click(Sender:TObject);begin formView.ShowModal;end;procedure TFormConsole.quit1Click(S
12、ender:TObject);begin Application.Terminate;end;procedure TFormConsole.AddUserClick(Sender:TObject);begin formAdd.ShowModal;end;procedure TFormConsole.userMangClick(Sender:TObject);begin formUserMang.ShowModal;end;procedure TFormConsole.AddClick(Sender:TObject);begin if (nowPower = 1) then formAdd.Sh
13、owModal else ShowMessage(您没有权限添加新顾客,请联系管理员!);end;procedure TFormConsole.helpClick(Sender:TObject);begin ShowMessage(Delphi学生信息管理系统1.0,纪念于.5.20.);end;procedure TFormConsole.FormShow(Sender:TObject);begin with dataModule1.ADOQuery1 do begin Close; SQL.Text := select * from Student; Open; end;end;proce
14、dure TFormConsole.FormCreate(Sender:TObject);begin DecodeTime(Now,hour,min,sec,msec); editHour.Text := IntToStr(hour); editMin.Text := IntToStr(min); editSec.Text := IntToStr(sec);end;procedure TFormConsole.time1Timer(Sender:TObject);begin sec := sec+1; if (sec = 60) then begin min := min+1; sec :=
15、0; end; if (min = 60) then begin hour := hour+1; min := 0; end; if (hour = 24) then begin hour := 0; end; editHour.Text := IntToStr(hour); editMin.Text := IntToStr(min); editSec.Text := IntToStr(sec);end;end.添加顾客界面:UnitAdd.pasunit UnitAdd;interfaceuses Windows,Messages,SysUtils,Variants,Classes,Grap
16、hics,Controls,Forms, Dialogs,StdCtrls,jpeg,ExtCtrls;type TFormAdd = class(TForm) Image1:TImage; lblUser:TLabel; lblPwd2:TLabel; lblPower:TLabel; jlblPwd1:TLabel; editUser:TEdit; editPwd2:TEdit; editPwd1:TEdit; ComboBox1:TComboBox; btnQuit:TButton; btnOk:TButton; procedure btnQuitClick(Sender:TObject
17、); procedure btnOkClick(Sender:TObject); private Private declarations public Public declarations end;var FormAdd:TFormAdd;implementation$R *.dfm uses UnitDataModule;procedure TFormAdd.btnQuitClick(Sender:TObject);begin Close;end;procedure TFormAdd.btnOkClick(Sender:TObject);var user1,pwd1,pwd2,power
18、 :String;begin user1 := editUser.Text; pwd1 := editPwd1.Text;pwd2 := editPwd2.Text; power := IntToStr(comboBox1.ItemIndex+1); if dataModule1.ADOTable1.FieldValuesuser = user1 then begin ShowMessage(顾客已存在!); editUser.Clear; editUser.SetFocus; end else begin if (user1 ) and (pwd1 ) and (pwd1 = pwd2) t
19、hen begin with DataModule1.ADOTable1 do begin Open; Append; FieldByName(user).AsString := user1; FieldByName(pwd).AsString := pwd2; FieldByName(power).AsString := power; Post; end; ShowMessage(添加成功!); DataModule1.ADOTable1.Close; end else begin ShowMessage(顾客名或密码为空或密码不一致,请重新输入!); editUser.Clear;edit
20、Pwd1.Clear;editPwd2.Clear; editUser.SetFocus; end; end;end;end.数据链接模块:UnitDataModule.pasunit UnitDataModule;interfaceuses SysUtils,Classes,DB,ADODB;type TDataModule1 = class(TDataModule) ADOConnection1:TADOConnection; ADOTable1:TADOTable; DataSource1:TDataSource; ADOQuery1:TADOQuery; ADOQuery2:TADOQ
21、uery; DataSource2:TDataSource; ADOQuery2user:TWideStringField; ADOQuery2pwd:TWideStringField; ADOQuery2power:TIntegerField; procedure ADOQuery2pwdGetText(Sender:TField;var Text:String; DisplayText:Boolean); private Private declarations public Public declarations end;var DataModule1:TDataModule1;impl
22、ementation$R *.dfm uses UnitUserMang;procedure TDataModule1.ADOQuery2pwdGetText(Sender:TField; var Text:String;DisplayText:Boolean);begin Text := *;end;end.顾客管理界面(可修改、添加星号密码,顾客管理有登录顾客权限区别):UnitUserMang.pasunit UnitUserMang;interfaceuses Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Fo
23、rms, Dialogs,ExtCtrls,DBCtrls,Grids,DBGrids,StdCtrls,jpeg;type TformUserMang = class(TForm) Image1:TImage; DBNavigator1:TDBNavigator; editPower:TEdit; editUser:TEdit; lblPower:TLabel; lblUser:TLabel; btnUserQuery1:TButton; DBGrid1:TDBGrid; procedure btnUserQuery1Click(Sender:TObject); procedure Form
24、Show(Sender:TObject); private Private declarations public Public declarations end;var formUserMang:TformUserMang; user1,power1,strSql2 :String;implementation$R *.dfm uses UnitDataModule,UnitLogin,UnitView;procedure TformUserMang.btnUserQuery1Click(Sender:TObject);begin user1 := %+Trim(editUser.Text)
25、+%; power1 := %+Trim(editPower.Text)+%; with dataModule1.ADOQuery2 do begin Close; SQL.Clear; strSql2 := select * from Account where ; strSql2 :=strSql2+user like +user1+ and power like +power1+; SQL.Add(strSql2); Open; end;end;procedure TformUserMang.FormShow(Sender:TObject);begin if (nowPower 1) t
26、hen begin formUserMang.DBGrid1.ReadOnly := true; formUserMang.DBNavigator1.VisibleButtons := formView.DBNavigator1.VisibleButtons-nbInsert,nbDelete; end;end;end.学生信息查询界面(涉及普通模糊查询、范畴查询、实时动态查询以及自定义语句查询):UnitView.pasunit UnitView;interfaceuses Windows,Messages,SysUtils,Variants,Classes,Graphics,Control
27、s,Forms, Dialogs,DB,ADODB,ExtCtrls,DBCtrls,Grids,DBGrids,StdCtrls,Buttons, jpeg;type TFormView = class(TForm) DBGrid1:TDBGrid; DBNavigator1:TDBNavigator; btnQuery:TBitBtn; Image1:TImage; RadioGroup1:TRadioGroup; RadioButton1:TRadioButton; Label9:TLabel; Label8:TLabel; Label7:TLabel; Label6:TLabel; L
28、abel5:TLabel; Label4:TLabel; Label2:TLabel; Label11:TLabel; Label10:TLabel; Label1:TLabel; editSid3:TEdit; editSid2:TEdit; editSid:TEdit; editRange:TEdit; editName:TEdit; editHome:TEdit; editDIY2:TEdit; editDIY1:TEdit; editAge3:TEdit; editAge2:TEdit; editAge:TEdit; Label3:TLabel; editSex:TEdit; proc
29、edure btnQueryClick(Sender:TObject); procedure FormShow(Sender:TObject); procedure RadioButton1Click(Sender:TObject); procedure RadioGroup1Click(Sender:TObject); procedure editSidChange(Sender:TObject); procedure editSexChange(Sender:TObject); private Private declarations public Public declarations
30、end;var FormView:TFormView; sid1,name1,sex1,age1,home1,range1,strSql :String; sid2,sid3,age2,age3,diy1,diy2 :String;implementation$R *.dfm uses UnitDataModule,UnitUserMang,UnitLogin;procedure TFormView.btnQueryClick(Sender:TObject);begin DataModule1.ADOQuery1.Close; DataModule1.ADOQuery1.SQL.Clear;
31、case radioGroup1.ItemIndex of 0:begin sid1 := %+Trim(editSid.Text)+%;name1 := %+Trim(editName.Text)+%; age1 := %+Trim(editAge.Text)+%; home1 := %+Trim(editHome.Text)+%;range1 := %+Trim(editRange.Text)+%; sex1 := %+Trim(editSex.Text)+%; with DataModule1.ADOQuery1 do begin strSql := select * from Stud
32、ent where ; strSql := strSql+sid like +sid1+ and name like +name1+ and sex like +sex1+; strSql := strSql+ and age like +age1+ and home like +home1+ and range like +range1+; SQL.Add(strSql); Open; end; end; 1:begin sid2 := Trim(editSid2.Text);sid3 := Trim(editSid3.Text); age2 := Trim(editAge2.Text);a
33、ge3 := Trim(editAge3.Text); if (sid2 = ) then sid2 := sid like % else sid2 := sid=+sid2; if (sid3 = ) then sid3 := else sid3 := and sid=+age2; if (age3 = ) then age3 := else age3 := and age=+age3; strSql := select * from Student where+sid2+sid3+age2+age3; with DataModule1.ADOQuery1 do begin SQL.Add(
34、strSql); Open; end; end; else begin diy1 := Trim(editDIY1.Text);diy2 := Trim(editDIY2.Text); if (diy1 = ) and (diy2 = ) then begin diy1 := select * ;diy2 := ;end; with DataModule1.ADOQuery1 do begin SQL.Add(diy1+ from Student +diy2); Open; end; end; end;end;procedure TFormView.FormShow(Sender:TObjec
35、t);begin radioGroup1.ItemIndex := 0; if (nowPower = 3) then begin formView.DBGrid1.ReadOnly := true; editDIY1.Text := select * ; editDIY1.Enabled := false;editDIY2.Enabled := false; formView.DBNavigator1.VisibleButtons := formView.DBNavigator1.VisibleButtons-nbInsert,nbDelete; end;end;procedure TFor
36、mView.RadioButton1Click(Sender:TObject);begin btnQuery.Enabled := false;end;procedure TFormView.RadioGroup1Click(Sender:TObject);begin if radioGroup1.ItemIndex = 2 then begin radioButton1.Checked := false; btnQuery.Enabled := true; end;end;procedure TFormView.editSidChange(Sender:TObject);begin if (radioButton1.Checked = true) then btnQueryClick(Sender);end;procedure TFormView.editSexChange(Sender:TObject);begin if (radioButton1.Checked = true) then btnQueryClick(Sender);end;end.
©2010-2024 宁波自信网络信息技术有限公司 版权所有
客服电话:4008-655-100 投诉/维权电话:4009-655-100