⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 person.cpp

📁 用C++写的人事管理系统
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Person.h"
#include "Person_Info.h"        //员工资料窗体头文件
#include "Person_Assistant.h"   //输入辅助信息窗体头文件
#include "Info_Input.h"         //员工信息输入修改查询窗体头文件
#include "Login.h"              //登录窗体头文件
#include "Register.h"           //用户注册窗体头文件
#include "Pass_Pope_Modify.h"   //修改密码、权限窗体头文件
#include "Person_Info_Print.h"  //员工个人资料打印窗体头文件
#include "about.h"              //关于窗体头文件 
#include "Crypt.cpp"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TF_Main *F_Main;
//---------------------------------------------------------------------------
__fastcall TF_Main::TF_Main(TComponent* Owner)
        : TForm(Owner)
{   /*****主窗体初始化事件*****/
    /*****ADOConnection对象与数据库服务器系统初始化代码******/
    char Name_Com[MAX_COMPUTERNAME_LENGTH+1]; //MAX_COMPUTERNAME_LENGTH已由系统定义
    DWORD Size_Com = MAX_COMPUTERNAME_LENGTH+1;
    char Name_DS[MAX_COMPUTERNAME_LENGTH+200];
    if(GetComputerName(Name_Com,&Size_Com)){  //GetComputerName是取得计算机名API函数
      StrCopy(Name_DS,"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Person;Data Source="); //拷贝字符串
      StrCat(Name_DS,Name_Com);  //追加字符串
//      StrCat(Name_DS,";Locale Identifier=2052;Connect Timeout=15;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=");
//      StrCat(Name_DS,Name_Com);
    }
    else
      ShowMessage("获取计算机名失败");
    F_Main->ADOConnection_PM->Connected = false;  //断开连接
    F_Main->ADOConnection_PM->ConnectionString = Name_DS; //设置与数据库服务器连接属性字符串
    try{  //捕捉异常
      F_Main->ADOConnection_PM->Connected = true;
    }
    catch(...){ //异常处理
      Application->MessageBoxA("数据库服务器连接错误","异常对话框",MB_OK);
    }
}
//---------------------------------------------------------------------------

void __fastcall TF_Main::FormShow(TObject *Sender)
{   /*****主窗体OnShow事件*****/
    F_Login->ShowModal();  //首先进入用户登录窗口
}
//---------------------------------------------------------------------------

void __fastcall TF_Main::M_LoginClick(TObject *Sender)
{   /*****重新登录菜单项点击事件*****/
    F_Login->ShowModal();    //打开用户登录窗口
}
//---------------------------------------------------------------------------

void __fastcall TF_Main::M_RegistryClick(TObject *Sender)
{   /*****用户注册菜单项点击事件*****/
    F_Register->Show();     //打开用户注册窗口
}
//---------------------------------------------------------------------------

void __fastcall TF_Main::M_QuitClick(TObject *Sender)
{   /*****退出系统菜单项点击事件*****/
    Application->Terminate();  //程序中止,退出运行环境
}
//---------------------------------------------------------------------------

void __fastcall TF_Main::M_Pass_ModifyClick(TObject *Sender)
{   /*****修改密码菜单项点击事件*****/
    F_PP_Modi->Show();        //打开修改密码权限窗口
}
//---------------------------------------------------------------------------

void __fastcall TF_Main::M_Rele_ModifyClick(TObject *Sender)
{   /*****修改权限菜单项点击事件*****/
    F_PP_Modi->Show();       //打开修改密码权限窗口
}
//---------------------------------------------------------------------------

void __fastcall TF_Main::M_AboutClick(TObject *Sender)
{   /*****关于菜单项点击事件*****/
    F_About->Show();        //打开关于窗口
}
//---------------------------------------------------------------------------

void __fastcall TF_Main::M_Per_InfoClick(TObject *Sender)
{   /*****员工资料菜单项点击事件*****/
    F_Info->Show();  //打开员工信息管理窗口
}
//---------------------------------------------------------------------------

void __fastcall TF_Main::M_Info_PrintClick(TObject *Sender)
{   /*****员工打印菜单项点击事件*****/
    F_Info_Print->QuickRep1->Preview(); //打开快速报表
}
//---------------------------------------------------------------------------

void __fastcall TF_Main::M_DiplomaClick(TObject *Sender)
{   /*****学历菜单项点击事件*****/
    F_Assis->ADOT_Count->First();    //设定记录号计数数据表当前活动记录是第一条记录
    F_Assis->ADOT_Count->MoveBy(1);  //当前活动记录下移一条记录
//    F_Assis->ADOT_Count->RecNo = 2;  //设定计数表指针指向第2条记录
    F_Assis->DBLookupListBox1->ListField = "";  //先赋空值的目的是为了防止系统抛出异常
    F_Assis->DBLookupListBox1->KeyField = "";
    F_Assis->DBLookupListBox1->ListSource = F_Info->DS__Diploma;  //赋学历信息表
    F_Assis->DBLookupListBox1->KeyField = "Diploma_ID";  //赋记录号字段
    F_Assis->DBLookupListBox1->ListField = "Diploma_Name";  //赋学历名称字段
    F_Assis->Label1->Caption = "学历辅助信息列表";
    F_Assis->Show();
}
//---------------------------------------------------------------------------

void __fastcall TF_Main::M_PolityClick(TObject *Sender)
{   /*****面貌菜单项点击事件*****/
    F_Assis->ADOT_Count->First();    //设定记录号计数数据表当前活动记录是第一条记录
    F_Assis->ADOT_Count->MoveBy(4);  //当前活动记录下移四条记录
//    F_Assis->ADOT_Count->RecNo = 5;  //设定计数表指针指向第5条记录
    F_Assis->DBLookupListBox1->ListField = "";
    F_Assis->DBLookupListBox1->KeyField = "";
    F_Assis->DBLookupListBox1->ListSource = F_Info->DS_Polity;
    F_Assis->DBLookupListBox1->KeyField = "Polity_ID";
    F_Assis->DBLookupListBox1->ListField = "Polity_Name";
    F_Assis->Label1->Caption = "政治面貌辅助信息列表";
    F_Assis->Show();
}
//---------------------------------------------------------------------------

void __fastcall TF_Main::M_JobClick(TObject *Sender)
{   /*****职务菜单项点击事件*****/
    F_Assis->ADOT_Count->First();    //设定记录号计数数据表当前活动记录是第一条记录
    F_Assis->ADOT_Count->MoveBy(2);  //当前活动记录下移二条记录
//    F_Assis->ADOT_Count->RecNo = 3;  //设定计数表指针指向第3条记录
    F_Assis->DBLookupListBox1->ListField = "";
    F_Assis->DBLookupListBox1->KeyField = "";
    F_Assis->DBLookupListBox1->ListSource = F_Info->DS_Job;
    F_Assis->DBLookupListBox1->KeyField = "Job_ID";
    F_Assis->DBLookupListBox1->ListField = "Job_Name";
    F_Assis->Label1->Caption = "职务辅助信息列表";
    F_Assis->Show();
}
//---------------------------------------------------------------------------

void __fastcall TF_Main::M_PostClick(TObject *Sender)
{   /*****职称菜单项点击事件*****/
    F_Assis->ADOT_Count->First();    //设定记录号计数数据表当前活动记录是第一条记录
    F_Assis->ADOT_Count->MoveBy(3);  //当前活动记录下移三条记录
//    F_Assis->ADOT_Count->RecNo = 4;  //设定计数表指针指向第4条记录
    F_Assis->DBLookupListBox1->ListField = "";
    F_Assis->DBLookupListBox1->KeyField = "";
    F_Assis->DBLookupListBox1->ListSource = F_Info->DS_Post;
    F_Assis->DBLookupListBox1->KeyField = "Post_ID";
    F_Assis->DBLookupListBox1->ListField = "Post_Name";
    F_Assis->Label1->Caption = "职称辅助信息列表";
    F_Assis->Show();
}
//---------------------------------------------------------------------------

void __fastcall TF_Main::M_BranchClick(TObject *Sender)
{   /*****部门菜单项点击事件*****/
    F_Assis->ADOT_Count->First();    //设定记录号计数数据表当前活动记录是第一条记录
    F_Assis->ADOT_Count->MoveBy(5);  //当前活动记录下移五条记录
//    F_Assis->ADOT_Count->RecNo = 6;  //设定计数表指针指向第6条记录
    F_Assis->DBLookupListBox1->ListField = "";
    F_Assis->DBLookupListBox1->KeyField = "";
    F_Assis->DBLookupListBox1->ListSource = F_Info->DS_Branch;
    F_Assis->DBLookupListBox1->KeyField = "Branch_ID";
    F_Assis->DBLookupListBox1->ListField = "Branch_Name";
    F_Assis->Label1->Caption = "部门辅助信息列表";
    F_Assis->Show();
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -