人力资源管理系统源代码
c语言设计的人事管理系统源码

#include<iostream.h>#include<string.h>#include<iomanip.h>#include<fstream.h>#include<stdio.h>#include<stdlib.h>#include<conio.h>int k=1,i; //定义一个标志变量class birthday{ //定义出生年月日类public:int year;int month;int day;};class people{ //声明人员基类,以后在这个基础上派生出其它类public:people(){}virtual void enter(); //虚基函数,搭成一个框架,以后在此基础上扩充virtual void display();virtual int get_no(){return number;}virtual char * get_name(){return name;}virtual void change_infor(){} //信息修改函数virtual void readfile(){} //从文件中读virtual void write(){} //将信息写入文件people operator = (people p1); //运算符重载int operator == (people p1);virtual ~people(){};protected:char name[12];int number;char sex;birthday bir;char id[15];};people people::operator =(people p1)//定义运算符重载{strcpy(name,); number=p1.number; sex=p1.sex; bir.day=p1.bir.day;bir.month=p1.bir.month; bir.year=p1.bir.year;strcpy(id,p1.id);return p1;}int people::operator ==(people p1){if(id==p1.id) return 1;else return 0;}void people::enter(){ //定义信息输入函数cout<<"输入姓名:"; cin>>name;cout<<"输入编号:"; cin>>number;cout<<"输入性别:"; cin>>sex;cout<<"生日是(年月日):"; cin>>bir.year>>bir.month>>bir.day;cout<<"身份证号:";cin>>id;}void people::display(){ //定义信息显示函数cout<<setw(8)<<"姓名"<<setw(8)<<"编号"<<setw(8)<<"性别"<<setw(8)<<"出生日期"<<setw(8)<<"身份证号"<<endl;cout<<setw(8)<<name<<setw(8)<<number<<setw(8)<<sex<<setw(8)<<bir.year<<setw(8)<<bir.mo nth<<setw(8)<<bir.day<<setw(8)<<id<<endl;}class student:virtual public people{ //以公有方式派生出学生类protected:char classnumber[20];public:student(){}virtual void enter(){people::enter();cout<<"输入班级名称:";cin>>classnumber;}virtual void display();virtual void readfile();virtual void write();virtual void change_infor();virtual ~student(){};};class teacher:virtual public people{ //以公有方式派生出老师类protected:char principalship[16];char department[16];public:teacher(){}virtual void enter(){people::enter();cout<<"输入老师的职务:";cin>>principalship;cout<<"\n 输入老师所在的部门:";cin>>department;}virtual void display();virtual void readfile();virtual void write();virtual void change_infor();virtual ~teacher(){}};//class graduate:virtual public student{ //以公有方式派生出研究生类protected:char subject[16];teacher adviser;public:graduate(){};virtual void enter(){student::enter();cout<<"输入研究生的专业:";cin>>subject;cout<<"输入导师的情况:"<<endl;adviser.enter();}virtual void display();virtual void readfile();virtual void write();virtual void change_infor();virtual ~graduate(){};};class teacher_asistant:public teacher,public graduate{ //以公有方式派生出助教类public:teacher_asistant(){};virtual void enter(){graduate::enter();cout<<"请输入助教生所在职务:";cin>>principalship;cout<<"请输入所在部门:";cin>>department;}virtual void display();virtual void readfile();virtual void write();virtual void change_infor();virtual ~teacher_asistant(){}};void student::display(){ //定义派生类学生的信息显示函数cout<<setw(8)<<"姓名"<<setw(8)<<"编号"<<setw(5)<<"性别"<<setw(12)<<"出生日期"<<setw(12)<<"身份证号"<<setw(12)<<"班级名称"<<endl;cout<<setw(8)<<name<<setw(8)<<number<<setw(5)<<sex<<setw(4)<<bir.year<<setw(4)<<bir.mo nth<<setw(4)<<bir.day<<setw(10)<<id<<setw(12)<<classnumber<<endl;}void student::write(){ //定义派生类学生的信息写入文件函数student stu;char ch;ofstream myfile("student.txt",ios::app);do{stu.enter();myfile.write((char *)&stu,sizeof(stu));cout<<"还需要输入下个学生的信息吗(y/n):";cin>>ch;}while(ch=='y'||ch=='Y');myfile.close();}void student::readfile(){ //定义派生类学生的读文件函数ifstream myfile("student.txt",ios::nocreate);while(myfile){student stu;if(myfile.read((char*)&stu,sizeof(stu))){if(stu.number!=-1) //删除一个学生的信息,通过不显示来定义删除stu.display();}}myfile.close();}void student::change_infor(){ //定义派生类学生的信息修改函数student stu;int num,p;cout<<"请输入你要修改或者删除的学生的编号:";cin>>num;fstream myfile("student.txt",ios::in|ios::out);while(myfile.good()){myfile.read((char*)&stu,sizeof(stu));if(num==stu.number){myfile.seekg(-sizeof(stu),ios::cur);cout<<"你是要修改还是要删除该学生的记录(1:删除2:修改):";cin>>p;if(p==1){stu.number=-1;break;}else {cout<<"请输入新的信息"<<endl;stu.enter();break;}}}myfile.write((char *)&stu,sizeof(stu));myfile.close();}void teacher::display(){cout<<setw(8)<<"姓名"<<setw(8)<<"编号"<<setw(5)<<"性别"<<setw(12)<<"出生日期"<<setw(12)<<"身份证号"<<setw(10)<<"职务"<<setw(10)<<"部门"<<endl;cout<<setw(8)<<name<<setw(8)<<number<<setw(5)<<sex<<setw(4)<<bir.year<<setw(4)<<bir.mo nth<<setw(4)<<bir.day<<setw(12)<<id<<setw(10)<<principalship<<setw(10)<<department<<endl ;}void teacher::readfile(){ifstream myfile("teacher.txt",ios::nocreate);while(myfile){people *p;teacher tec;p=&tec;if(myfile.read((char*)&tec,sizeof(tec))){if(tec.number!=-1)p->display();}}myfile.close();}//void teacher::write(){teacher tec;char ch;ofstream myfile("teacher.txt",ios::app);do{tec.enter();myfile.write((char *)&tec,sizeof(tec));cout<<"还需要输入下个学生的信息吗(y/n):";cin>>ch;}while(ch=='y'||ch=='Y');myfile.close();}void teacher::change_infor(){teacher tec;int num,p;cout<<"请输入你要修改或者删除的老师的编号:";cin>>num;fstream myfile("teacher.txt",ios::in|ios::out);while(myfile.good()){myfile.read((char*)&tec,sizeof(tec));if(num==tec.number){myfile.seekg(-sizeof(tec),ios::cur);cout<<"你是要修改还是要删除该老师的记录(1:删除2:修改):";cin>>p;if(p==1){tec.number=-1;break;}else {cout<<"请输入新的信息"<<endl;tec.enter();break;}}}myfile.write((char *)&tec,sizeof(tec));myfile.close();}void graduate::display(){cout<<setw(8)<<"姓名"<<setw(8)<<"编号"<<setw(5)<<"性别"<<setw(12)<<"出生日期"<<setw(8)<<"身份证号"<<setw(8)<<"班级名称"<<setw(10)<<"专业"<<endl;cout<<setw(8)<<name<<setw(8)<<number<<setw(5)<<sex<<setw(4)<<bir.year<<setw(4)<<bir.mo nth<<setw(4)<<bir.day<<setw(8)<<id<<setw(8)<<classnumber<<setw(10)<<subject<<endl;cout<<"他的导师的情况是:"<<endl;adviser.display();}void graduate::readfile(){ifstream myfile("graduate.txt",ios::nocreate);while(myfile){people *p;graduate gra;p=&gra;if(myfile.read((char*)&gra,sizeof(gra))){if(gra.number!=-1)p->display();}}myfile.close();}void graduate::write(){graduate gra;char ch;ofstream myfile("graduate.txt",ios::app);do{gra.enter();myfile.write((char *)&gra,sizeof(gra));cout<<"还需要输入下个研究生的信息吗(y/n):";cin>>ch;}while(ch=='y'||ch=='Y');myfile.close();}void graduate::change_infor(){graduate gra;int num,p;cout<<"请输入你要修改或者删除的研究生的编号:";cin>>num;fstream myfile("graduate.txt",ios::in|ios::out);while(myfile.good()){myfile.read((char*)&gra,sizeof(gra));if(num==gra.number){myfile.seekg(-sizeof(gra),ios::cur);cout<<"你是要修改还是要删除该研究生的记录(1:删除2:修改):";cin>>p;if(p==1){gra.number=-1;break;}else {cout<<"请输入新的信息"<<endl;gra.enter();break;}}}myfile.write((char *)&gra,sizeof(gra));myfile.close();}void teacher_asistant::display(){cout<<setw(8)<<"姓名"<<setw(8)<<"编号"<<setw(5)<<"性别"<<setw(12)<<"出生日期"<<setw(12)<<"身份证号"<<setw(8)<<"班级名称"<<setw(10)<<"专业"<<setw(10)<<"职务"<<setw(10)<<"部门"<<endl;cout<<setw(8)<<name<<setw(8)<<number<<setw(5)<<sex<<setw(4)<<bir.year<<setw(4)<<bir.mo nth<<setw(4)<<bir.day<<setw(8)<<id<<setw(8)<<classnumber<<setw(10)<<subject<<setw(10)<< principalship<<setw(10)<<department<<endl;cout<<"他的导师的情况是:"<<endl;adviser.display();}void teacher_asistant::readfile(){ifstream myfile("tec_asistant.txt",ios::nocreate);while(myfile){people *p;teacher_asistant tec_asis;p=&tec_asis;if(myfile.read((char*)&tec_asis,sizeof(tec_asis))){if(tec_asis.number!=-1)p->display();}}myfile.close();}void teacher_asistant::write(){teacher_asistant tec_asis;char ch;ofstream myfile("tec_asistant.txt",ios::app);do{tec_asis.enter();myfile.write((char *)&tec_asis,sizeof(tec_asis));cout<<"还需要输入下个助教生的信息吗(y/n):";cin>>ch;}while(ch=='y'||ch=='Y');myfile.close();}//void teacher_asistant::change_infor(){teacher_asistant tec_asis;int num,p;cout<<"请输入你要修改或者删除的助教生的编号:";cin>>num;fstream myfile("tec_asistant.txt",ios::in|ios::out);while(myfile.good()){myfile.read((char*)&tec_asis,sizeof(tec_asis));if(num==tec_asis.number){myfile.seekg(-sizeof(tec_asis),ios::cur);cout<<"你是要修改还是要删除该助教生的记录(1:删除2:修改):";cin>>p;if(p==1){tec_asis.number=-1;break;}else {cout<<"请输入新的信息"<<endl;tec_asis.enter();break;}}}myfile.write((char *)&tec_asis,sizeof(tec_asis));myfile.close();}void menu(){cout<<"\n\n\t\t**************************************************"<<endl;cout<<"\t\t*\t 人事管理系统\t *"<<endl;cout<<"\t\t*------------------------------------------------*"<<endl;cout<<" \t\t* 1.请输入人事信息 2.显示人事信息*"<<endl;cout<<" \t\t* 3.对信息的修改或删除 4.返回主菜单0.退出*"<<endl;cout<<"\t\t**************************************************"<<endl;cout<<" \t\t\t\t请选择操作(0=======4) "<<endl;cout<<"\t\t\t\t 请选择:";}void select(){people *pt;student st; teacher te; graduate gr; teacher_asistant t_a;if(i==1) pt=&st;else if(i==2) pt=&gr;else if(i==3) pt=&te;else if(i==4) pt=&t_a;do{int ch;cin>>ch;switch(ch){case 0:exit(0);case 1:pt->write();cout<<"你还想进行何种操作:";break;case 2:pt->readfile();cout<<"你还想进行何种操作:";break;case 3:pt->change_infor();cout<<"你还想进行何种操作:";break;case 4:k=0;break;default:cout<<"你的选择错误,请重新选择:";break;}}while(k);}void main(){b:cout<<"\n\n\t\t***************************************************"<<endl;cout<<"\t\t*\t 人事管理系统\t *"<<endl;cout<<"\t\t*-----------------------------------------------------*"<<endl;cout<<"\t\t* 1:学生*"<<endl;cout<<"\t\t* 2:研究生*"<<endl;cout<<"\t\t* 3:教师*"<<endl;cout<<"\t\t* 4:助教*"<<endl;cout<<"\t\t* 0:退出*"<<endl;cout<<"***************************************************"<<endl;cout<<"请选择(0---4):";cin>>i;switch(i){case 0:cout<<"你已经退出系统";getch();exit(0);case 1:{system("cls");menu();select();break;}case 2:{system("cls");menu();select();break;}case 3:{system("cls");menu();select();break;}case 4:{system("cls");menu();select();break;}default :cout<<"你的选择有误,请重新选择:";break;}if(k==0)k=1;system("cls");goto b;}。
人力资源管理系统代码

timAmRingOutTime dateTime,--下班时间
timsAmOnStatus varchar(10),--上班状态(迟到,早退,旷工,请假,出差, 正常(默认))
timsAmRingStatus varchar(10),--下班状态(迟到,早退,旷工,请假,出差, 正常(默认))
(
traId int identity(1,1) primary key not null,--标识列
traDeptNumId int,--我方部门编号(外键)
traDeptId int,--对方部门编号(外键)
traEmpId int,--申请人(外键)
traEmpNum int,--调用的对方员工(外键)
traContent varchar(800),--申请调用内容
tralyTime datetime,--申请时间
traStatus int,--审批状态(0:正在审批中,1:审批通过,2:审批未通过)
trsEmpName int,--审批人(外键)
traTime dateTime,--审批时间
(
useId int identity(1,1) primary key not null,--标识列
useName varchar(50),--状态名称(试用期,正式员工,离职员工,退休员工)
useState int ,--状态(0:表示正常使用中,1:表示已冻结)
useRemark text--备注
use master
if exists(select * from sysdatabases where name='HR_System')
人事管理系统数据库源代码

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;namespace WebApplication1{public partial class WebForm1 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e) {Response.Redirect("~/登录.aspx");}protected void Button2_Click(object sender, EventArgs e) {Response.Redirect("~/人员信息查询.aspx");}protected void Button3_Click(object sender, EventArgs e){Response.Redirect("~/人员修改.aspx");}protected void Button4_Click(object sender, EventArgs e) {Response.Redirect("~/部门信息.aspx");}protected void Button5_Click(object sender, EventArgs e) {Response.Redirect("~/工资信息.aspx");}}}using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;namespace WebApplication1{public partial class部门信息 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e){bool find =false;SqlConnection con=new SqlConnection("server=localhost;Integrated Security=SSPI;database=人事管理系统");con.Open();string cmdstr="select * from 部门表";SqlDataAdapter da=new SqlDataAdapter(cmdstr,con);DataSet ds=new DataSet();da.Fill(ds);for(int i=0;i<ds.Tables[0].Rows.Count;i++){for(int j=0;j<ds.Tables[0].Columns.Count;j++){String data=(ds.Tables[0].Rows[i][j].ToString()).Trim();if(data==TextBox1.Text.Trim()){TextBox2.Text=ds.Tables[0] .Rows[i]["部门代码"].ToString();TextBox3.Text=ds.Tables[0] .Rows[i]["部门名称"].ToString();find=true;}}}if (find == false){Response.Write("<script>window.alert('没有有关记录!')</script>"); con.Close();}}protected void Button2_Click(object sender, EventArgs e){Response.Redirect("~/Default.aspx");}}}using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;using System.Data.SqlTypes;namespace WebApplication1{public partial class_Default : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){}protected void TextBox1_TextChanged(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e){SqlConnection con = new SqlConnection("server=localhost;IntegratedSecurity=SSPI;database=人事管理系统");string strCount;strCount = "select * from 人事表"; con.Open();SqlCommand com = new SqlCommand(strCount, con);SqlDataReader dr = com.ExecuteReader();string strUsername = "", strPassword = "";while (dr.Read()){if (TextBox1.Text == dr["编号"].ToString()||TextBox2.Text == dr["顾客密码"].ToString()){strUsername = dr["编号"].ToString();strPassword = dr["顾客密码"].ToString();break;}}dr.Close();con.Close();if (strUsername == ""){Response.Write("<script language=javascript>alert('登录成功!');</script>");return;}}protected void Button2_Click(object sender, EventArgs e){Response.Redirect("~/Default.aspx");}}}using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;namespace WebApplication1{public partial class工资信息 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){}protected void TextBox2_TextChanged(object sender, EventArgs e){}protected void TextBox5_TextChanged(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e){bool find = false;SqlConnection con = new SqlConnection("server=localhost;Integrated Security=SSPI;database=人事管理系统");con.Open();string cmdstr = "select * from 工资表";SqlDataAdapter da = new SqlDataAdapter(cmdstr, con);DataSet ds = new DataSet();da.Fill(ds);for (int i = 0; i < ds.Tables[0].Rows.Count; i++){for (int j = 0; j < ds.Tables[0].Columns.Count; j++){String data = (ds.Tables[0].Rows[i][j].ToString()).Trim();if (data == TextBox1.Text.Trim()){TextBox2.Text = ds.Tables[0].Rows[i]["应发工资"].ToString(); TextBox3.Text = ds.Tables[0].Rows[i]["岗位津贴"].ToString(); TextBox4.Text = ds.Tables[0].Rows[i]["奖励"].ToString();TextBox5.Text = ds.Tables[0].Rows[i]["保险"].ToString();find = true;}}}if (find == false){Response.Write("<script>window.alert('没有有关记录!')</script>");con.Close();}}protected void Button2_Click(object sender, EventArgs e){Response.Redirect("~/Default.aspx");}}}using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;namespace WebApplication1{public partial class人员信息 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e){Response.Redirect("~/Default.aspx");}protected void Button2_Click(object sender, EventArgs e){bool find =false;SqlConnection con = new SqlConnection("server=localhost;Integrated Security=SSPI;database=人事管理系统");con.Open();string cmdstr="select * from 工资表";SqlDataAdapter da=new SqlDataAdapter(cmdstr,con);DataSet ds=new DataSet();da.Fill(ds);for(int i=0;i<ds.Tables[0].Rows.Count;i++){for(int j=0;j<ds.Tables[0].Columns.Count;j++){String data=(ds.Tables[0].Rows[i][j].ToString()).Trim();if(data==TextBox1.Text.Trim()){TextBox2.Text=ds.Tables[0] .Rows[i]["应发工资"].ToString();TextBox3.Text=ds.Tables[0] .Rows[i]["岗位津贴"].ToString();TextBox4.Text=ds.Tables[0] .Rows[i]["奖励"].ToString();TextBox5.Text = ds.Tables[0].Rows[i]["保险"].ToString();find=true;}}}if (find == false){Response.Write("<script>window.alert('没有有关记录!')</script>"); con.Close();}}}}using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;namespace WebApplication1{public partial class人员修改 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){}protected void TextBox5_TextChanged(object sender, EventArgs e){}protected void Button2_Click(object sender, EventArgs e){SqlConnection con=new SqlConnection("server=localhost;IntegratedSecurity=SSPI;database=人事管理系统");con.Open();string insert="insert into 人事表(员工号,姓名,性别,职称,学历) values("+""+ TextBox1.Text.Trim() +""+","+"" + TextBox2.Text.Trim() +""+","+ TextBox3.Text.Trim() + "," +""+ TextBox4.Text.Trim() +""+","+"" +TextBox5.Text.Trim() + ""+")";Response.Write(insert);SqlCommand cmd1=new SqlCommand(insert,con);con.Close();}protected void Button1_Click(object sender, EventArgs e){Response.Redirect("~/Default.aspx");}protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) {}}}。
人力资源管理系统代码 ASP

<!--#include file=DataBase/conn.asp--><%If request("action")="login" thenadmin_name=request("admin_name")'获取用户名admin_pass=request("admin_pass")'获取密码username=trim(request("admin_name"))password=trim(request("admin_pass"))for i=1 to len(username)user=mid(username,i,1)if user="'" or user="%" or user="<" or user=">" or user="&" or user="|" thenresponse.write "<script language=JavaScript>" & "alert('您的用户名含有非法字符,请重新输入!');" & "history.back()" & "</script>"response.endend ifnextfor i=1 to len(password)pass=mid(password,i,1)if pass="'" or pass="%" or pass="<" or pass=">" or upass="&" or pass="|" then response.write "<script language=JavaScript>" & "alert('您的密码含有非法字符,请重新输入!');" & "history.back()" & "</script>"response.endend ifnextset rs=server.CreateObject("adodb.recordset")sql="select * from tb_User where username='"&admin_name&"'and userpwd='"&admin_pass&"' "rs.open sql,conn,1,1if rs.eof then response.write "<br><br><br><br><font size=2><center>对不起,您输入的用户名或密码,请重新输入,谢谢!<a href=login.asp>返回</a></font>"else session("admin_name")=request("admin_name") response.Redirect("index.asp")'跳转到管理首页end ifrs.closeset rs=nothingconn.closeset conn=nothingend if%>6 首页设计网站首页主要由两部部分组成,一部分是管理导航区,另一部分是展示区。
人员信息管理系统源代码

#include<stdio.h>/*人员信息管理系统*/#include<string.h>#include<malloc.h>#include<stdlib.h>#define Max 10000typedef struct Node{int NO; // 编号char name[30]; // 姓名char sex[10]; // 性别int age; // 年龄char ZhiWu[30]; // 职务char Zhicheng[30]; //职称char ZZMM[30]; // 政治面貌char XueLi[30]; // 最高学历int OnTime; // 任职时间int CTime; // 来院时间char RenLB[30]; // 人员类别}Worker;Worker Q[Max];int top;int cnt = 0;int Insert() //输入人员信息{Worker *q;if( ( q = (Worker *)malloc( sizeof( Worker) ) ) == NULL )exit(0); printf( "请依次输入:编号,姓名,性别,年龄,职务,职称,政治面貌,最高学历,任职时间,来院时间,人员类别\n" );scanf( "%d %s %s %d %s %s %s %s %d %d %s", &(q->NO), q->name, q->sex, &(q->age), q->ZhiWu, q->Zhicheng, q->ZZMM, q->XueLi, &(q->OnTime), &(q->CTime), q->RenLB );Q[top++] = (*q);printf( "已加入\n" );return top;}int Delete() //按编号删除人员信息{int NO;int i, j, ok = 0;printf( "请依次输入: 编号\n" );scanf( "%d", &NO );for( i = 0; i < top; i++ ){if( Q[i].NO ==NO ){for( j = i+1; j < top; j++ ){Q[j-1] = Q[j];}top--;ok = 1;break;}}if( ok == 0 )printf( "无此人\n" );else printf( "已删除\n" );return top;}void Search() //搜索人员信息{int NO;char name[30];int i, ok = 0;Worker *q;printf( "请依次输入: 编号和姓名\n" );scanf( "%d %s", &NO, name );for( i = 0; i < top; i++ ){if( Q[i].NO ==NO && strcmp( Q[i].name, name ) == 0 ) {ok = 1;break;}}q = &(Q[i]);if( ok == 0 )printf( "无此人\n" );else{printf( "该人信息为:\n" );printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (q->NO), q->name, q->sex, (q->age), q->ZhiWu, q->Zhicheng, q->ZZMM, q->XueLi,(q->OnTime), (q->CTime), q->RenLB );}}void Sort(Worker *Q) //按要求进行排序分类{int way,i,j,flag=1;Worker temp;printf( "输入按什么排序:1 --- 年龄; 2 ---- 来院时间\n" );scanf( "%d", &way );if( way == 1 ){for(i=1;i<top&&flag==1;i++){flag=0;for(j=0;j<top-i;j++){if(Q[j].age>Q[j+1].age){flag=1;temp=Q[j];Q[j]=Q[j+1];Q[j+1]=temp;}}for(i=0;i<cnt;i++)printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (Q[i].NO),Q[i].name, Q[i].sex, (Q[i].age),Q[i].ZhiWu, Q[i].Zhicheng, Q[i].ZZMM, Q[i].XueLi, (Q[i].OnTime), (Q[i].CTime), Q[i].RenLB );}}else if( way == 2 ){for(i=1;i<top&&flag==1;i++){flag=0;for(j=0;j<top-i;j++){if(Q[j].CTime>Q[j+1].CTime){flag=1;temp=Q[j];Q[j]=Q[j+1];Q[j+1]=temp;}}for(i=0;i<cnt;i++)printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (Q[i].NO),Q[i].name, Q[i].sex, (Q[i].age),Q[i].ZhiWu, Q[i].Zhicheng, Q[i].ZZMM, Q[i].XueLi, (Q[i].OnTime), (Q[i].CTime), Q[i].RenLB );}for(i=0;i<cnt;i++)printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (Q[i].NO),Q[i].name, Q[i].sex, (Q[i].age),Q[i].ZhiWu, Q[i].Zhicheng, Q[i].ZZMM, Q[i].XueLi, (Q[i].OnTime), (Q[i].CTime), Q[i].RenLB );}}void COUNT_1() //统计在职人数{int i;for( i = 0; i < top; i++ ){if( strcmp( Q[i].RenLB, "退休人员" ) != 0 &&strcmp( Q[i].RenLB, "临时工" ) != 0 ){Worker *q;q = &(Q[i]);cnt++;printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (q->NO), q->name, q->sex, (q->age), q->ZhiWu, q->Zhicheng, q->ZZMM, q->XueLi, (q->OnTime), (q->CTime), q->RenLB );}}printf( "共有%d 在职人数\n", cnt );}void COUNT_2() //统计党员人数{int i;for( i = 0; i < top; i++ ){if( strcmp( Q[i].ZZMM, "党员" ) == 0 ){Worker *q;q = &(Q[i]);cnt++;printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (q->NO), q->name, q->sex, (q->age), q->ZhiWu, q->Zhicheng, q->ZZMM, q->XueLi, (q->OnTime), (q->CTime), q->RenLB );}}printf( "共有%d 党员\n", cnt );}void COUNT_3() // 统计女工人数{int i;for( i = 0; i < top; i++ ){if( strcmp( Q[i].sex, "女" ) == 0 ){Worker *q;q = &(Q[i]);cnt++;printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (q->NO), q->name, q->sex, (q->age), q->ZhiWu, q->Zhicheng, q->ZZMM, q->XueLi, (q->OnTime), (q->CTime), q->RenLB );}}printf( "共有%d 女性员工\n", cnt );}void COUNT_4() //统计高学历人数{int i;for( i = 0; i < top; i++ ){if( strcmp( Q[i].XueLi, "研究生" ) == 0|| strcmp( Q[i].XueLi, "副教授" ) == 0|| strcmp( Q[i].XueLi, "教授" ) == 0|| strcmp( Q[i].XueLi, "院士" ) == 0|| strcmp( Q[i].XueLi, "博士" ) == 0|| strcmp( Q[i].XueLi, "博士后" ) == 0|| strcmp( Q[i].XueLi, "助理教授" ) == 0 ){Worker *q;q = &(Q[i]);cnt++;printf( "%d %s %s %d %s %s %s %s %d %d %s\n", (q->NO), q->name, q->sex, (q->age), q->ZhiWu, q->Zhicheng, q->ZZMM, q->XueLi, (q->OnTime), (q->CTime), q->RenLB );}printf( "共有%d 高学历员工\n", cnt );}void Count() //统计函数{int way;printf( "输入按什么统计:1 --- 在职人数; 2 --- 党员人数;3 --- 女工人数;4 --- 高学历高职称人数: \n" );printf( "输入统计关键字:" );scanf( "%d", &way );switch( way ){case 1: COUNT_1(); break;case 2: COUNT_2(); break;case 3: COUNT_3(); break;case 4: COUNT_4(); break;}}void Edit() // 编辑存储功能{}int main(){int way;top = 0;printf( "\n\n" );printf( "****************************************************************** **\n" );printf( " * 1:添加人员,输入人员相关信息*\n" );printf( " * 2: 删除人员,提供职工号*\n" );printf( " * 3: 查询提供编号和姓名*\n" );printf( " * 4: 统计提供相应方式对应输入*\n" );printf( " * 5: 排序,按程序要求提供相应的关键字*\n" );printf( " * 6: 编辑存储*\n" );printf( "****************************************************************** **\n" );while( 1 ){printf( "输入需要操作:way = " ); // 选择功能if( scanf( "%d", &way ) == EOF )break; // 以 ctrl + Z 结束输入switch(way){case 1: Insert(); break;case 2: Delete(); break;case 3: Search(); break;case 4: Count(); break;case 5: Sort(Q); break;case 6: Edit(); break;}}return 0;}。
用c语言编写企业人事管理信息系统

企业人事管理信息系统(两种方法)方法一#include "stdio.h"#include "stdlib.h"#include "string.h"struct date{int year,month,day;};typedef struct manrecord{int id;char name[20];char sex[10];char dept[20];struct date worktime;struct manrecord *next;}Elemtype;Elemtype *init(){Elemtype *h;h=(Elemtype *)malloc(sizeof(Elemtype));if (h==NULL){printf("内存空间不足!\n");return NULL;}else{h->next=NULL;return h;}}void term( Elemtype *h){Elemtype *p,*q;p=h;while (p!=NULL){q=p;p=p->next;free(q);}}Elemtype * isidExist(Elemtype *h,int id){Elemtype *p;p=h->next;while (p!=NULL)if (p->id==id)return p;elsep=p->next;return NULL;}void inputStaff(Elemtype *h){Elemtype *p;int id;while (1){printf("输入员工编号(小于等于0,则结束输入):");scanf("%d",&id);if (id<=0){printf("数据输入结束。
\n");break;}p=(Elemtype *)malloc(sizeof(Elemtype));if (p==NULL){printf("内存空间不足,输入结束。
python人员信息管理系统源代码

python人员信息管理系统源代码Python人员信息管理系统源代码简介本文介绍了一个基于Python的人员信息管理系统的源代码,该系统可以实现人员信息的添加、修改、删除和查询等功能。
技术栈- Python 3.8.5- SQLite3- tkinter功能模块1. 数据库连接模块该模块用于连接SQLite3数据库,并创建一个名为“person.db”的数据库。
2. 数据库表创建模块该模块用于创建一个名为“person_info”的表,该表包含以下字段:id、name、age、gender和address。
3. 添加人员信息模块该模块用于向数据库中添加一条人员信息记录,包括姓名、年龄、性别和地址。
4. 修改人员信息模块该模块用于修改数据库中已有的一条人员信息记录,可以修改姓名、年龄、性别和地址。
5. 删除人员信息模块该模块用于从数据库中删除一条已有的人员信息记录,根据id进行删除。
6. 查询人员信息模块该模块用于查询数据库中所有的人员信息记录,并将结果显示在窗口中。
源代码实现1. 数据库连接实现:import sqlite3def connect_db():conn = sqlite3.connect("person.db") cursor = conn.cursor()return conn, cursordef close_db(conn, cursor):cursor.close()conn.close()2. 数据库表创建实现:def create_table():conn, cursor = connect_db()sql = '''create table person_info(id integer primary key autoincrement,name text,age integer,gender text,address text)'''cursor.execute(sql)mit()close_db(conn, cursor)3. 添加人员信息实现:def add_person(name, age, gender, address):conn, cursor = connect_db()sql = "insert into person_info(name, age, gender, address) values(?, ?, ?, ?)"cursor.execute(sql, (name, age, gender, address))mit()close_db(conn, cursor)4. 修改人员信息实现:def update_person(id_, name=None, age=None, gender=None, address=None):conn,cursor=connect_db()sql="update person_info set"if name is not None:sql+=" name='{}',".format(name)if age is not None:sql+=" age='{}',".format(age)if gender is not None:sql+=" gender='{}',".format(gender)if address is not None:sql+=" address='{}',".format(address)# 去掉最后一个逗号sql=sql[:-1]# 根据id更新sql+="where id={}".format(id_)cursor.execute(sql)mit()close_db(conn,cursor)5. 删除人员信息实现:def delete_person(id_):conn,cursor=connect_db()sql="delete from person_info where id={}".format(id_)cursor.execute(sql)mit()close_db(conn,cursor)6. 查询人员信息实现:def query_all_person():conn,cursor=connect_db()sql="select * from person_info"cursor.execute(sql)# 获取所有查询结果result=cursor.fetchall()close_db(conn,cursor)return result7. 界面实现:import tkinter as tkimport tkinter.messagebox as messageboxclass Application(tk.Frame):def __init__(self, master=None):super().__init__(master)self.master = masterself.pack()self.create_widgets()def create_widgets(self):# 添加人员信息部分self.add_label = bel(self, text="添加人员信息") self.add_label.grid(row=0, column=0)_label = bel(self, text="姓名")_label.grid(row=1, column=0)_entry = tk.Entry(self)_entry.grid(row=1, column=1)self.age_label = bel(self, text="年龄")self.age_label.grid(row=2, column=0)self.age_entry = tk.Entry(self)self.age_entry.grid(row=2, column=1)self.gender_label = bel(self, text="性别")self.gender_label.grid(row=3, column=0)# 性别用单选框实现gender_var=tk.StringVar()gender_var.set("男")male_radiobutton=tk.Radiobutton(self,text="男",value="男",variable=gender_var)male_radiobutton.grid(row=3,column=1)female_radiobutton=tk.Radiobutton(self,text="女",value="女",variable=gender_var)female_radiobutton.grid(row=3,column=2)# 地址用文本框实现self.address_label=bel(self,text="地址")self.address_label.grid(row=4,column=0)self.address_text=tk.Text(self,width=20,height=5)self.address_text.grid(row=4,column=1)# 添加按钮self.add_button = tk.Button(self, text="添加",command=self.add_person)self.add_button.grid(row=5, column=1)# 修改人员信息部分self.update_label = bel(self, text="修改人员信息")self.update_label.grid(row=6, column=0)self.id_label = bel(self, text="ID")self.id_label.grid(row=7, column=0)self.id_entry = tk.Entry(self)self.id_entry.grid(row=7, column=1)# 修改的内容用文本框实现self.update_label = bel(self, text="修改的内容") self.update_label.grid(row=8, column=0)# 姓名_update_label = bel(self, text="姓名") _update_label.grid(row=9, column=0)# 用Entry实现_update_entry = tk.Entry(self)_update_entry.grid(row=9, column=1)# 年龄self.age_update_label = bel(self, text="年龄") self.age_update_label.grid(row=10, column=0)# 用Entry实现self.age_update_entry = tk.Entry(self)self.age_update_entry.grid(row=10, column=1)# 性别gender_var=tk.StringVar()gender_var.set("男")male_radiobutton=tk.Radiobutton(self,text="男",value="男",variable=gender_var)male_radiobutton.grid(row=11,column=1)female_radiobutton=tk.Radiobutton(self,text="女",value="女",variable=gender_var)female_radiobutton.grid(row=11,column=2)# 地址self.address_update_label = bel(self, text="地址")self.address_update_label.grid(row=12, column=0)# 用Text实现self.address_update_text = tk.Text(self, width=20, height=5)self.address_update_text.grid(row=12, column=1)# 修改按钮self.update_button = tk.Button(self, text="修改", command=self.update_person)self.update_button.grid(row=13, column=1)# 删除人员信息部分self.delete_label = bel(self, text="删除人员信息") self.delete_label.grid(row=14, column=0)self.id_delete_label = bel(self, text="ID")self.id_delete_label.grid(row=15, column=0)self.id_delete_entry = tk.Entry(self)self.id_delete_entry.grid(row=15, column=1)# 删除按钮self.delete_button = tk.Button(self, text="删除", command=self.delete_person)self.delete_button.grid(row=16, column=1)# 查询人员信息部分self.query_label = bel(self, text="查询人员信息")self.query_label.grid(row=17,columnspan-2,pady-10)# 用Treeview实现表格显示查询结果columns=("ID","姓名","年龄","性别","地址")# 设置列宽和对齐方式等属性treeview=tk.ttk.Treeview(self,columns=columns,show="heading s")treeview.column("ID",width=50,anchor="center")treeview.column("姓名",width=100,anchor="center")treeview.column("年龄",width=50,anchor="center")treeview.column("性别",width=50,anchor="center")treeview.column("地址",width=150)# 设置表头for col in columns:treeview.heading(col,text=col)# 查询按钮self.query_button = tk.Button(self, text="查询",command=self.query_person)self.query_button.grid(row=18,columnspan-2,pady-10)# 添加treeview组件treeview.grid(row-19,columnspan-2,pady-10)def add_person(self):name = _entry.get()age = self.age_entry.get()gender = gender_var.get()address = self.address_text.get(1.0, tk.END).strip()if not name or not age or not gender or not address:messagebox.showwarning(title="提示", message="请填写完整信息!")returntry:age = int(age)except ValueError:messagebox.showwarning(title="提示", message="年龄必须是数字!")returnadd_person(name, age, gender, address)messagebox.showinfo(title="提示", message="添加成功!")def update_person(self):id_ = self.id_entry.get()if not id_:messagebox.showwarning(title-"提示",message-"请填写ID!")returntry:id_=int(id_)except ValueError:messagebox.showwarning(title-"提示",message-"ID必须是数字!")returnname=_update_entry.get()age=self.age_update_entry.get()gender=gender_var.get()address=self.address_update_text.get(1.0,tk.END).strip()if not name and not age and not gender and not address: messagebox.showwarning(title-"提示",message-"请填写修改的内容!")returntry:if age:age=int(age)except ValueError:messagebox.showwarning(title-"提示",message-"年龄必须是数字!")returnupdate_person(id_,name,age,gender,address)messagebox.showinfo(title="提示",message="修改成功!")def delete_person(self):id_ = self.id_delete_entry.get()if not id_:messagebox.showwarning(title="提示", message="请填写ID!")returntry:id_ = int(id_)except ValueError:messagebox.showwarning(title="提示", message="ID必须是数字!")returndelete_person(id_)messagebox.showinfo(title="提示", message="删除成功!")def query_person(self):# 先清空treeviewfor item in treeview.get_children():treeview.delete(item)# 获取所有人员信息result=query_all_person()# 将查询结果插入到treeview中for row in result:treeview.insert("",tk.END,values=row)if __name__ == '__main__':root = ()root.title("人员信息管理系统")app = Application(master=root)app.mainloop()总结本文介绍了一个基于Python的人员信息管理系统的源代码,该系统可以实现人员信息的添加、修改、删除和查询等功能。
企业人事管理系统java源代码

企业⼈事管理系统java源代码import java.awt.* ;import java.awt.event.*;import java.sql.*;import java.util.*;import javax.swing.*;import javax.swing.border.*;public class A extends JFrame{protected JPanel p = new JPanel();protected JPanel p1 = new JPanel();protected JPanel p2 = new JPanel();protected JPanel p3= new JPanel();JMenuBar M =new JMenuBar();JMenu m1 = new JMenu("基本信息模块");JMenu m2 = new JMenu("考勤考评信息模块");JMenu m3 = new JMenu("系统维护信息模块");JMenuItem mm1 = new JMenuItem("员⼯基本信息"); JMenuItem mm2 = new JMenuItem("员⼯家庭成员基本信息"); JMenuItem mm3 = new JMenuItem("员⼯培训信息"); JMenuItem mm4 = new JMenuItem("员⼯考勤信息"); JMenuItem mm5 = new JMenuItem("员⼯考评信息"); JMenuItem mm6 = new JMenuItem("普通管理员"); JMenuItem mm7 = new JMenuItem("⾼级管理员"); JMenuItem mm8 = new JMenuItem("退出");protected JLabel l1 = new JLabel("员⼯编号:");protected JLabel l2 = new JLabel("姓名:");protected JLabel l3 = new JLabel("性别:");protected JLabel l4 = new JLabel("年龄:");protected JLabel l5 = new JLabel("部门:");protected JTextField t1 = new JTextField(10);protected JTextField t2 = new JTextField(10);protected JTextField t3 = new JTextField(10);protected JTextField t4 = new JTextField(10);protected JTextField t5 = new JTextField(10);private JButton b1 = new JButton("查询");private JButton b2 = new JButton("插⼊");private JButton b3 = new JButton("修改");private JButton b4 = new JButton("删除");private JButton b5 = new JButton("清除");private JButton b6 = new JButton("下⼀条");private Connection c; // @jve:decl-index=0:private Statement s; // @jve:decl-index=0:private ResultSet r; // @jve:decl-index=0:{super("⼈事管理系统");getContentPane().add(p);setJMenuBar(M);M.add(m1);M.add(m2);M.add(m3);m1.add(mm1);m1.add(mm2);m1.add(mm3);m1.addSeparator();m1.add(mm8);m2.add(mm4);m2.add(mm5);m3.add(mm6);m3.add(mm7);p.add(p1,BorderLayout.NORTH);p.add(p2,BorderLayout.CENTER);p.add(p3,BorderLayout.SOUTH);p1.setLayout(new GridLayout(5,2,1,3));p1.add(l1);p1.add(t1);p1.add(l2);p1.add(t2);p1.add(l3);p1.add(t3);p1.add(l4);p1.add(t4);p1.add(l5);p1.add(t5);p2.add(b1);p1.add(b2);p2.add(b3);p1.add(b4);p2.add(b5);p3.add(b6);t1.setText("");t2.setText("");t3.setText("");t4.setText("");t5.setText("");setSize(350,300);setVisible(true);try{Class.forName("sun.jdbc.odbc.JdbcOdbcDrive");c=DriverManager.getConnection("jdbc:odbc:sd","sa",null);s=c.createStatement();r=s.executeQuery("select * from 员⼯基本信息表");}catch (SQLException e){JOptionPane.showMessageDialog(null ,e.getMessage(),"操作错误!",JOptionPane.ERROR_MESSAGE); System.exit(1);}catch(ClassNotFoundException e)JOptionPane.showMessageDialog(null ,e.getMessage(),"驱动程序找不到!",JOptionPane.ERROR_MESSAGE); System.exit(1);}addWindowListener( new WindowAdapter(){public void windowClosing(WindowEvent event){try {s.close();c.close();catch(SQLException e){JOptionPane.showMessageDialog(null,e.getMessage(),"不能关闭!",JOptionPane.ERROR_MESSAGE); System.exit(1);}}});b1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent event){try{r=s.executeQuery("select * from 员⼯基本信息表" + "where 员⼯编号='"+t1.getText()+"'");if(r.next()){t1.setText(r.getString(1));t2.setText(r.getString(2));t3.setText(r.getString(3));t4.setText(r.getString(4));t5.setText(r.getString(5));JOptionPane.showMessageDialog(null,"查询成功!","查询操作",JOptionPane.ERROR_MESSAGE);}else{t2.setText("");t3.setText("");t4.setText("");t5.setText("");JOptionPane.showMessageDialog(null,"查询失败!","查询操作",JOptionPane.ERROR_MESSAGE);}catch(NumberFormatException e){System.out.println(e);}catch(SQLException e){System.out.println(e);}});b2.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent event){String v1,v2,v3,v4,v5;v1=t1.getText();v2=t2.getText();v3=t3.getText();v4=t4.getText();v5=t5.getText();if((!v1.equals( "" ))&&(!v2.equals(""))&&(!v3.equals(""))&&(!v4.equals(""))&&(!v5.equals (""))){try{int n1 = Integer.parseInt(v4);int r1 = s.executeUpdate("INSERT INTO 员⼯基本信息表"+ "values('"+v1+"','"+v2+"','"+v3+"',"+n1+",'"+v5+"')"); if(r1!=0){t1.setText("");t2.setText("");t3.setText("");t4.setText("");t5.setText("");JOptionPane.showMessageDialog(null,"插⼊成功!","插⼊操作",JOptionPane.ERROR_MESSAGE);}}catch (NumberFormatException e ){System.out.println(e);}catch (SQLException e){System.out.println(e);}}else{JOptionPane.showMessageDialog(null,"插⼊失败!","插⼊操作",JOptionPane.ERROR_MESSAGE);}}});b3.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent event)try {int r1=s.executeUpdate("update 员⼯基本信息表set 姓名='"+t2.getText()+"'," +"性别='"+t3.getText()+"'," +"年龄="+Integer.parseInt(t4.getText())+"," +"部门='"+t5.getText()+"'"+"where 员⼯编号='"+t1.getText()+"'");if(r1!=0){JOptionPane.showMessageDialog(null,"修改成功!","修改操作",JOptionPane.ERROR_MESSAGE);}else{JOptionPane.showMessageDialog(null,"修改失败!","修改操作",JOptionPane.ERROR_MESSAGE);}} catch (NumberFormatException e ){System.out.println(e);}catch (SQLException e){System.out.println(e);}}});b4.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent event){try{int r1=s.executeUpdate("delete from 员⼯基本信息表"+"where 员⼯编号='"+t1.getText()+"'");if(r1!=0){t1.setText("");t2.setText("");t3.setText("");t4.setText("");t5.setText("");JOptionPane.showMessageDialog(null,"删除成功!","删除操作",JOptionPane.ERROR_MESSAGE);}else{JOptionPane.showMessageDialog(null,"删除失败!","删除操作",JOptionPane.ERROR_MESSAGE);}} catch (NumberFormatException e ){System.out.println(e);}catch (SQLException e){System.out.println(e);}}});b5.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent event){t1.setText("");t2.setText("");t3.setText("");t4.setText("");t5.setText("");}});b6.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent event){try{if(r.next())t1.setText(r.getString(1));t2.setText(r.getString(2));t3.setText(r.getString(3));t4.setText(""+r.getInt(4));t5.setText(r.getString(5));}catch (NumberFormatException e ){System.out.println(e);} catch (SQLException e){System.out.println(e);}}});mm8.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent event){System.exit(0);}});}public static void main(String args[]){new A();}}。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
1)登陆窗体代码设计
窗体代码主要实现了连接数据库的功能,这里用于连接用户信息表。
其程序如下:
Private Sub Form_Load()
Dim i As Integer
If App.PrevInstance Then
MsgBox ("程序已经运行,不能再次装载。
"), vbExclamation
Unload Me
End If
'本段代码用于判定本程序是否已经装载于内存中,以避免程序的多重启动
i = 0
Open App.Path + "\user.ini" For Input As #1
Do While Not EOF(1)
Input #1, user(i), pws(i), state(i), Emplo(i)
If state(i) = "A" Then
Combo1.AddItem user(i)
End If
i = i + 1
Loop Close #1
Combo1.ListIndex = 1
'在窗口装载阶段读取用户设置文件获取用户信息并装载于用户列表框中
End Sub
(2)“取消”按钮是退出登录界面,退出系统的。
其代码如下:
Private Sub CmdCancel_Click()
Unload Me
End
End Sub
(3)“确定”按钮代码设计
“确定”按钮代码主要实现了用户登陆时,用户名和密码的认证,当用户名或密码错误时,系统提示错误。
其程序如下:
Private Sub cmdOK_Click()
If txtPassword = pws(Combo1.ListIndex) Then
CurId = Combo1.ListIndex
EmploID = Emplo(CurId)
CurUser = user(CurId)
CurPsw = pws(CurId)
Me.Hide
'Load FrmMain
FrmMain.Show
Else MsgBox "Invalid Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If End Sub
(1)窗体选择的单击事件代码设计
窗体选择的单击事件代码主要实现了进入本系统所有模块的功能,这里有以下几个模块,它们分别是员工信息模块,假条信息模块,工资管理模块,用户设置模块等/其程序如下:
Private Sub Toolbar2_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Index
Case 1
Call showemployee ‘显示员工信息模块
Case 2
Call showleave ‘显示假条信息模块
Case 3
Call showsalary ‘显示工资信息模块
Case 4
If frmLogin.CurUser = "root" Then
FrmSys.Show
Else
FrmPsw.Show
Pwin = "Frmmain"
FrmMain.Enabled = False
End If
End Select
End Sub
(2)命令按钮的单击事件代码设计
命令按钮的代码主要实现了进入本系统部分主要模块的功能,这里有以下几个功能,它们分别是编辑,删除,查询,设置。
其程序如下:
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Index
Case 1 'edit
FrmEdit.Show
FrmMain.Enabled = False
Case 2 'del
If DBGA.SelBookmarks.Count = 1 Then
If MsgBox("确定要删除吗?", vbOKCancel, "确定") = vbOK Then DataA.Recordset.Delete cuAp = 0
Else MsgBox "请选择要删除的条目!"
End If
Case 3 'seek
FrmSearch.Show
Case 4 'setup
FrmSetup.Show
End Select
End Sub
(3)口令修改的主要代码设计
“确定”按钮的代码主要实现了用户密码的修改功能,当旧密码错误或两次新密码输入不一致时,系统会提示错误。
其程序如下:
Private Sub cmdOK_Click()
Dim fil, i, Usercount As Integer
If TxtNew1.Text <> TxtNew2.Text Then
MsgBox "two times no yizhi"
TxtNew1.SetFocus
TxtNew2.Text = ""
SendKeys "{Home}+{End}"
Exit Sub
ElseIf Txtold.Text <> frmLogin.CurPsw Then
MsgBox "old password wrong"
Txtold.SetFocus
TxtNew1.Text = ""
TxtNew2.Text = ""
SendKeys "{Home}+{End}"
Exit Sub
Else fil = FreeFile()
Open App.Path + "\user.ini" For Input As #fil
i = 0
Do While Not EOF(fil)
Input #fil, user(i), pws(i)
Input #fil, state(i), Emplo(i)
i = i + 1
Loop
Usercount = i
Close #fil
pws(frmLogin.CurId) = TxtNew1.Text
frmLogin.CurPsw = TxtNew1.Text
fil = FreeFile()
Open App.Path + "\user.ini" For Output As #fil
For i = 0 To Usercount - 1
Print #fil, user(i); ","; pws(i); ","; state(i); ","; Emplo(i)
Next i
Close #fil
Txtold.Text = ""
TxtNew1.Text = ""
TxtNew2.Text = ""
Me.Hide
If FrmMain.Pwin = "Frmmain" Then
FrmMain.Enabled = True
FrmMain.SetFocus
Else Call FrmSys.ActiveAll
FrmSys.SetFocus End If End If End Sub。