人事管理系统实验报告书
附录:源程序 //-------------------主窗体 查询与浏览--------------------------------------- #include #pragma hdrstop #include "Unit1.h" #include "Unit2.h" #include "Unit3.h" #include "Unit4.h" #include "Unit5.h" #include "Unit6.h" #pragma package(smart_init) #pragma resource "*.dfm" TFmain *Fmain; bool onshow=false; __fastcall TFmain::TFmain(TComponent* Owner) : TForm(Owner) { } void __fastcall TFmain::N5Click(TObject *Sender) { Close();//退出程序 } void __ fastcall TFmain::SpeedButton3Click(TObject *Sender) { DataModule3->ADOQuery1->First() ; StatusBar1->Panels->Items[0]->Text="数据指向第一个"; } void __fastcall TFmain::SpeedButton1Click(TObject *Sender) { DataModule3->ADOQuery1->Prior() ; StatusBar1->Panels->Items[0]->Text="数据指向上一个"; } void __fastcall TFmain::SpeedButton2Click(TObject *Sender) { DataModule3->ADOQuery1->Next() ; StatusBar1->Panels->Items[0]->Text="数据指向下一个"; } void __fastcall TFmain::SpeedButton4Click(TObject *Sender) { DataModule3->ADOQuery1->Last() ; StatusBar1->Panels->Items[0]->Text="数据指向最后"; } void __fastcall TFmain::Button2Click(TObject *Sender) { //添加新的数据 Fadd->Caption="添加数据"; DataModule3->ADOQuery1->Append() ; Fadd->ShowModal() ; } void __fastcall TFmain::FormClose(TObject *Sender, TCloseAction &Action) { //对退出程序做确认处理 if(MessageBox(this->Handle,"确定要退出吗?","提示",MB_YESNO+MB_ICONQUESTION) == IDNO) Action=caNone; } void __fastcall TFmain::N10Click(TObject *Sender) { AboutBox->ShowModal() ; //显示关于对话框 } void __fastcall TFmain::Button4Click(TObject *Sender) { //以下为查找语句 AnsiString sql; if(Edit1->Text=="")return; if( ComboBox1->Text =="精确")sql=" ='"+Edit1->Text+"';"; else sql=" like '%"+Edit1->Text+"%';"; sql="select * from renshi where "+ComboBox2->Text+sql; StatusBar1->Panels->Items[0]->Text=sql; DataModule3->ADOQuery1->Active =false; DataModule3->ADOQuery1->SQL->Clear(); DataModule3->ADOQuery1->SQL->Add(sql); DataModule3->ADOQuery1->Active =true; if(DataModule3->ADOQuery1->RecordCount==0) StatusBar1->Panels->Items[1]->Text="无符合条件数据"; else StatusBar1->Panels->Items[1]->Text="符合条件数据个数为:"+IntToStr(DataModule3->ADOQuery1->RecordCount); } void __fastcall TFmain::Button6Click(TObject *Sender) { //以下为显示所有数据 AnsiString sql; sql="select * from renshi;"; StatusBar1->Panels->Items[0]->Text="显示全部数据"; DataModule3->ADOQuery1->Active =false; DataModule3->ADOQuery1->SQL->Clear(); DataModule3->ADOQuery1->SQL->Add(sql); DataModule3->ADOQuery1->Active =true; if(DataModule3->ADOQuery1->RecordCount==0) StatusBar1->Panels->Items[1]->Text="无符合条件数据"; else StatusBar1->Panels->Items[1]->Text="数据总量为:"+IntToStr(DataModule3->ADOQuery1->RecordCount); } void __fastcall TFmain::Button1Click(TObject *Sender) { //刷新显示 DataModule3->ADOQuery1->Active =false; DataModule3->ADOQuery1->Active =true; } void __fastcall TFmain::N9Click(TObject *Sender) { //帮助内容 ShowMessage("\ 大家好,虽然只是一个简单的程序但是也要写帮助。\n\ 简单的操作如下:\n\ 一、打开程序。\n\ 二、可以进行数据的添加、删除、浏览、查找\n\ 三、关闭。\n\ 谢谢使用!\n\ "); } void __fastcall TFmain::Button3Click(TObject *Sender) { //数据删除操作 AnsiString printstr="确定删除编号为"+DataModule3->ADOQuery1->FieldByName("编号")->AsString+"的数据吗?"; if(MessageDlg(printstr,mtWarning,TMsgDlgButtons() Delete() ; StatusBar1->Panels->Items[0]->Text="数据已经删除"; } } void __fastcall TFmain::N3Click(TObject *Sender) { //更改显示字体 if(FontDialog1->Execute())Fmain->Font=FontDialog1->Font; } void __fastcall TFmain::N12Click(TObject *Sender) { //更改窗体颜色 if(ColorDialog1->Execute()) { Fmain->Color=ColorDialog1->Color;//主窗体 Fadd->Color=ColorDialog1->Color; //添加、修改窗体 } } void __fastcall TFmain::N13Click(TObject *Sender) { //更改数据域颜色 if(ColorDialog1->Execute()) DBGrid1->Color=ColorDialog1->Color; } void __fastcall TFmain::N11Click(TObject *Sender) { Fshow->QuickRep1->Preview();//打印数据 } void __fastcall TFmain::Button5Click(TObject *Sender) { Fadd->Caption="修改数据"; Fadd->ShowModal() ; //修改数据 } void __fastcall TFmain::FormShow(TObject *Sender) { if(onshow==false) { Fwelcome->ShowModal() ; onshow=true; return; } } //-------------------------------------------------------------------------- //------------系统封面------------------------------------------------------ #include #pragma hdrstop #include "Unit2.h" #include "Unit1.h" #pragma package(smart_init) #pragma resource "*.dfm" TFwelcome *Fwelcome; int logintime=15; //进入系统等待时间X秒 __fastcall TFwelcome::TFwelcome(TComponent* Owner) : TForm(Owner) { } void __fastcall TFwelcome::Timer1Timer(TObject *Sender) { if(logintime==0){ Timer1->Enabled=false; Close(); } logintime--; SpeedButton1->Caption ="进入("+IntToStr(logintime)+")"; } void __fastcall TFwelcome::SpeedButton2Click(TObject *Sender) { Application->Terminate() ; } void __fastcall TFwelcome::SpeedButton1Click(TObject *Sender) { logintime=15; Timer1->Enabled=false; Close(); } //-------------------------------------------------------------------------- //---------------------数据修改窗体----------------------------------------- #include #pragma hdrstop #include "Unit4.h" #include "Unit3.h" #pragma package(smart_init) #pragma resource "*.dfm" TFadd *Fadd; __fastcall TFadd::TFadd(TComponent* Owner) : TForm(Owner) { } void __fastcall TFadd::Button1Click(TObject *Sender) { if(DBEdit1->Text =="")return; DataModule3->ADOQuery1->Refresh() ; Close(); } void __fastcall TFadd::Button2Click(TObject *Sender) { DataModule3->ADOQuery1->Cancel() ; Close(); } void __fastcall TFadd::FormClose(TObject *Sender, TCloseAction &Action) { DataModule3->ADOQuery1->Cancel() ; } //-------------------------------------------------------------------------- fastcall TFmain::SpeedButton3Click(TObject *Sender) { DataModule3->ADOQuery1->First() ; StatusBar1->Panels->Items[0]->Text="数据指向第一个"; } void __fastcall TFmain::SpeedButton1Click(TObject *Sender) { DataModule3->ADOQuery1->Prior() ; StatusBar1->Panels->Items[0]->Text="数据指向上一个"; } void __fastcall TFmain::SpeedButton2Click(TObject *Sender) { DataModule3->ADOQuery1->Next() ; StatusBar1->Panels->Items[0]->Text="数据指向下一个"; } void __fastcall TFmain::SpeedButton4Click(TObject *Sender) { DataModule3->ADOQuery1->Last() ; StatusBar1->Panels->Items[0]->Text="数据指向最后"; } void __fastcall TFmain::Button2Click(TObject *Sender) { //添加新的数据 Fadd->Caption="添加数据"; DataModule3->ADOQuery1->Append() ; Fadd->ShowModal() ; } void __fastcall TFmain::FormClose(TObject *Sender, TCloseAction &Action) { //对退出程序做确认处理 if(MessageBox(this->Handle,"确定要退出吗?","提示",MB_YESNO+MB_ICONQUESTION) == IDNO) Action=caNone; } void __fastcall TFmain::N10Click(TObject *Sender) { AboutBox->ShowModal() ; //显示关于对话框 } void __fastcall TFmain::Button4Click(TObject *Sender) { //以下为查找语句 AnsiString sql; if(Edit1->Text=="")return; if( ComboBox1->Text =="精确")sql=" ='"+Edit1->Text+"';"; else sql=" like '%"+Edit1->Text+"%';"; sql="select * from renshi where "+ComboBox2->Text+sql; StatusBar1->Panels->Items[0]->Text=sql; DataModule3->ADOQuery1->Active =false; DataModule3->ADOQuery1->SQL->Clear(); DataModule3->ADOQuery1->SQL->Add(sql); DataModule3->ADOQuery1->Active =true; if(DataModule3->ADOQuery1->RecordCount==0) StatusBar1->Panels->Items[1]->Text="无符合条件数据"; else StatusBar1->Panels->Items[1]->Text="符合条件数据个数为:"+IntToStr(DataModule3->ADOQuery1->RecordCount); } void __fastcall TFmain::Button6Click(TObject *Sender) { //以下为显示所有数据 AnsiString sql; sql="select * from renshi;"; StatusBar1->Panels->Items[0]->Text="显示全部数据"; DataModule3->ADOQuery1->Active =false; DataModule3->ADOQuery1->SQL->Clear(); DataModule3->ADOQuery1->SQL->Add(sql); DataModule3->ADOQuery1->Active =true; if(DataModule3->ADOQuery1->RecordCount==0) StatusBar1->Panels->Items[1]->Text="无符合条件数据"; else StatusBar1->Panels->Items[1]->Text="数据总量为:"+IntToStr(DataModule3->ADOQuery1->RecordCount); } void __fastcall TFmain::Button1Click(TObject *Sender) { //刷新显示 DataModule3->ADOQuery1->Active =false; DataModule3->ADOQuery1->Active =true; } void __fastcall TFmain::N9Click(TObject *Sender) { //帮助内容 ShowMessage("\ 大家好,虽然只是一个简单的程序但是也要写帮助。\n\ 简单的操作如下:\n\ 一、打开程序。\n\ 二、可以进行数据的添加、删除、浏览、查找\n\ 三、关闭。\n\ 谢谢使用!\n\ "); } void __fastcall TFmain::Button3Click(TObject *Sender) { //数据删除操作 AnsiString printstr="确定删除编号为"+DataModule3->ADOQuery1->FieldByName("编号")->AsString+"的数据吗?"; if(MessageDlg(printstr,mtWarning,TMsgDlgButtons() Delete() ; StatusBar1->Panels->Items[0]->Text="数据已经删除"; } } void __fastcall TFmain::N3Click(TObject *Sender) { //更改显示字体 if(FontDialog1->Execute())Fmain->Font=FontDialog1->Font; } void __fastcall TFmain::N12Click(TObject *Sender) { //更改窗体颜色 if(ColorDialog1->Execute()) { Fmain->Color=ColorDialog1->Color;//主窗体 Fadd->Color=ColorDialog1->Color; //添加、修改窗体 } } void __fastcall TFmain::N13Click(TObject *Sender) { //更改数据域颜色 if(ColorDialog1->Execute()) DBGrid1->Color=ColorDialog1->Color; } void __fastcall TFmain::N11Click(TObject *Sender) { Fshow->QuickRep1->Preview();//打印数据 } void __fastcall TFmain::Button5Click(TObject *Sender) { Fadd->Caption="修改数据"; Fadd->ShowModal() ; //修改数据 } void __fastcall TFmain::FormShow(TObject *Sender) { if(onshow==false) { Fwelcome->ShowModal() ; onshow=true; return; } } //-------------------------------------------------------------------------- //------------系统封面------------------------------------------------------ #include #pragma hdrstop #include "Unit2.h" #include "Unit1.h" #pragma package(smart_init) #pragma resource "*.dfm" TFwelcome *Fwelcome; int logintime=15; //进入系统等待时间X秒 __fastcall TFwelcome::TFwelcome(TComponent* Owner) : TForm(Owner) { } void __fastcall TFwelcome::Timer1Timer(TObject *Sender) { if(logintime==0){ Timer1->Enabled=false; Close(); } logintime--; SpeedButton1->Caption ="进入("+IntToStr(logintime)+")"; } void __fastcall TFwelcome::SpeedButton2Click(TObject *Sender) { Application->Terminate() ; } void __fastcall TFwelcome::SpeedButton1Click(TObject *Sender) { logintime=15; Timer1->Enabled=false; Close(); } //-------------------------------------------------------------------------- //---------------------数据修改窗体----------------------------------------- #include #pragma hdrstop #include "Unit4.h" #include "Unit3.h" #pragma package(smart_init) #pragma resource "*.dfm" TFadd *Fadd; __fastcall TFadd::TFadd(TComponent* Owner) : TForm(Owner) { } void __fastcall TFadd::Button1Click(TObject *Sender) { if(DBEdit1->Text =="")return; DataModule3->ADOQuery1->Refresh() ; Close(); } void __fastcall TFadd::Button2Click(TObject *Sender) { DataModule3->ADOQuery1->Cancel() ; Close(); } void __fastcall TFadd::FormClose(TObject *Sender, TCloseAction &Action) { DataModule3->ADOQuery1->Cancel() ; } //--------------------------------------------------------------------------