《Delphi+Access学生信息管理系统1.0(9页).doc》由会员分享,可在线阅读,更多相关《Delphi+Access学生信息管理系统1.0(9页).doc(9页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、-Delphi+Access学生信息管理系统1.0-第 9 页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;
2、Button1: TButton; Button2: TButton; ComboBox1: 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
3、 Timer1Timer(Sender: TObject); private Private declarations 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.adoTab
4、le1.Open; while dataModule1.adoTable1.EOF true do begin comboBox1.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 : strin
5、g;begin user1 := comboBox1.Text; pwd1 := edit1.Text; dataModule1.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.AD
6、OQuery1.Close; dataModule1.ADOQuery1.SQL.Clear; dataModule1.ADOQuery1.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.
7、Text := ; comboBox1.SetFocus; DataModule1.adoTable1.Close;end;procedure 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
8、 (shpBall1.Left = 100) then isStop := true; end else lblMsg.Visible := 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)
9、MainMenu1: TMainMenu; view1: TMenuItem; User: TMenuItem; quit1: TMenuItem; DBGrid1: 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; editSe
10、c: TEdit; editMin: TEdit; editHour: TEdit; procedure view1Click(Sender: TObject); procedure quit1Click(Sender: TObject); procedure AddUserClick(Sender: TObject); procedure userMangClick(Sender: TObject); procedure AddClick(Sender: TObject); procedure helpClick(Sender: TObject); procedure FormShow(Se
11、nder: TObject); procedure FormCreate(Sender: TObject); procedure time1Timer(Sender: TObject); private Private declarations public Public declarations end;var FormConsole: TFormConsole;implementation$R *.dfm uses UnitView, UnitAdd, UnitDataModule, UnitUserMang, UnitLogin;var hour, min, sec, msec : wo
12、rd;procedure TFormConsole.view1Click(Sender: TObject);begin formView.ShowModal;end;procedure TFormConsole.quit1Click(Sender: TObject);begin Application.Terminate;end;procedure TFormConsole.AddUserClick(Sender: TObject);begin formAdd.ShowModal;end;procedure TFormConsole.userMangClick(Sender: TObject)
13、;begin formUserMang.ShowModal;end;procedure TFormConsole.AddClick(Sender: TObject);begin if (nowPower = 1) then formAdd.ShowModal else ShowMessage(您没有权限添加新用户,请联系管理员!);end;procedure TFormConsole.helpClick(Sender: TObject);begin ShowMessage(Delphi学生信息管理系统1.0,纪念于2012.5.20.);end;procedure TFormConsole.F
14、ormShow(Sender: TObject);begin with dataModule1.ADOQuery1 do begin Close; SQL.Text := select * from Student; Open; end;end;procedure TFormConsole.FormCreate(Sender: TObject);begin DecodeTime(Now, hour, min, sec, msec); editHour.Text := IntToStr(hour); editMin.Text := IntToStr(min); editSec.Text := I
15、ntToStr(sec);end;procedure TFormConsole.time1Timer(Sender: TObject);begin sec := sec+1; if (sec = 60) then begin min := min+1; sec := 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(mi
16、n); editSec.Text := IntToStr(sec);end;end.添加用户界面:UnitAdd.pasunit UnitAdd;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, jpeg, ExtCtrls;type TFormAdd = class(TForm) Image1: TImage; lblUser: TLabel; lblPwd2: TLabel; lblPower: TLabel; jlblPwd
17、1: TLabel; editUser: TEdit; editPwd2: TEdit; editPwd1: TEdit; ComboBox1: TComboBox; btnQuit: TButton; btnOk: TButton; procedure btnQuitClick(Sender: TObject); procedure btnOkClick(Sender: TObject); private Private declarations public Public declarations end;var FormAdd: TFormAdd;implementation$R *.d
18、fm uses UnitDataModule;procedure TFormAdd.btnQuitClick(Sender: TObject);begin Close;end;procedure TFormAdd.btnOkClick(Sender: TObject);var user1, pwd1, pwd2, power : String;begin user1 := editUser.Text; pwd1 := editPwd1.Text; pwd2 := editPwd2.Text; power := IntToStr(comboBox1.ItemIndex+1); if dataMo
19、dule1.ADOTable1.FieldValuesuser = user1 then begin ShowMessage(用户已存在!); editUser.Clear; editUser.SetFocus; end else begin if (user1 ) and (pwd1 ) and (pwd1 = pwd2) then begin with DataModule1.ADOTable1 do begin Open; Append; FieldByName(user).AsString := user1; FieldByName(pwd).AsString := pwd2; Fie
20、ldByName(power).AsString := power; Post; end; ShowMessage(添加成功!); DataModule1.ADOTable1.Close; end else begin ShowMessage(用户名或密码为空或密码不一致,请重新输入!); editUser.Clear; editPwd1.Clear; editPwd2.Clear; editUser.SetFocus; end; end;end;end.数据链接模块:UnitDataModule.pasunit UnitDataModule;interfaceuses SysUtils, C
21、lasses, DB, ADODB;type TDataModule1 = class(TDataModule) ADOConnection1: TADOConnection; ADOTable1: TADOTable; DataSource1: TDataSource; ADOQuery1: TADOQuery; ADOQuery2: TADOQuery; DataSource2: TDataSource; ADOQuery2user: TWideStringField; ADOQuery2pwd: TWideStringField; ADOQuery2power: TIntegerFiel
22、d; procedure ADOQuery2pwdGetText(Sender: TField; var Text: String; DisplayText: Boolean); private Private declarations public Public declarations end;var DataModule1: TDataModule1;implementation$R *.dfm uses UnitUserMang;procedure TDataModule1.ADOQuery2pwdGetText(Sender: TField; var Text: String; Di
23、splayText: Boolean);begin Text := *;end;end.用户管理界面(可修改、添加星号密码,用户管理有登录用户的权限区别):UnitUserMang.pasunit UnitUserMang;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls, jpeg;type TformUserMang = class(TForm) Image1
24、: TImage; DBNavigator1: TDBNavigator; editPower: TEdit; editUser: TEdit; lblPower: TLabel; lblUser: TLabel; btnUserQuery1: TButton; DBGrid1: TDBGrid; procedure btnUserQuery1Click(Sender: TObject); procedure FormShow(Sender: TObject); private Private declarations public Public declarations end;var fo
25、rmUserMang: TformUserMang; user1, power1, strSql2 : String;implementation$R *.dfm uses UnitDataModule, UnitLogin, UnitView;procedure TformUserMang.btnUserQuery1Click(Sender: TObject);begin user1 := %+Trim(editUser.Text)+%; power1 := %+Trim(editPower.Text)+%; with dataModule1.ADOQuery2 do begin Close
26、; 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) then begin formUserMang.DBGrid1.ReadOnly := true; formUserMang.DBNavigator1.Visib
27、leButtons := formView.DBNavigator1.VisibleButtons-nbInsert, nbDelete; end;end;end.学生信息查询界面(包括普通模糊查询、范围查询、实时动态查询以及自定义语句查询):UnitView.pasunit UnitView;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls
28、, 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; Label5: TLabel; Label4: TLabel; Label2: TLabel; Label11
29、: 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; procedure btnQueryClick(Sender: TObject
30、); 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 end;var FormView: TFormView;
31、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; case radioGr
32、oup1.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 Student where
33、 ; 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); age3 :=
34、 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(strSql
35、); 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: TObject)
36、;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
37、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.