员工信息系统

#include <iostream>
#include <iomanip>
#include <ctime>
#include <vector>
#include <cstring>
#include <algorithm>
#include <fstream>
using namespace std;
class manager;
class employeeInfo;
manager *gMgr;
string strDept[]={"IT","Sales","H.R.","F.D.","Porduct","P.R.D.","Admin"};
string strTitle[]={"Chairman","Director","Manager","Secretary","staff","supervisor"};
class employeeInfo
{
    public:
    typedef struct
    {
    int id;
    int department;
    int salary;
    int jobTitle;
    int entryDate;
    char name[40];
    } data;
    vector<data> infoCollection;
    public:
    bool loadFile(string fname)
    {

    }
    bool saveToFile()
    {

    }
    friend class manager;
};
class manager
{
    class create
    {
        public:
        int m_id;
        bool check()
        {

        }
        bool matchId(employeeInfo::data a)
        {
            if(m_id==a.id)return true;
            return false;
        }
        bool addAnEmployee(employeeInfo::data& a,manager *p=gMgr)
        {
            m_id=a.id;
            if(p->ee.infoCollection.size()==0){p->ee.infoCollection.push_back(a);return true;}
            vector<employeeInfo::data>::iterator it=find_if(p->ee.infoCollection.begin(),p->ee.infoCollection.end(),bind1st(mem_fun(&manager::create::matchId),this));
            if(it!=p->ee.infoCollection.end()){return false;}
            p->ee.infoCollection.push_back(a);
            return true;
        }
    };
    class update
    {
        public:
        int m_id;
        bool matchId(employeeInfo::data a)
        {
            if(m_id==a.id)return true;
            return false;
        }
        bool modify(vector<employeeInfo::data>& a,manager *p=gMgr)
        {
            vector<employeeInfo::data>::iterator it=a.begin();
            while(it!=a.end())
            {
                m_id=it->id;
                vector<employeeInfo::data>::iterator t=find_if(p->ee.infoCollection.begin(),p->ee.infoCollection.end(),bind1st(mem_fun(&manager::update::matchId),this));
                if(t==p->ee.infoCollection.end()){++it;continue;}
                (*t)=(*it);
                ++it;
            }
            return true;
        }
    };
    class read
    {
        public:
            int m_id;
            int m_dept;
            vector<employeeInfo::data> m_container;
            bool matchId(employeeInfo::data a)
            {
                if(a.id==m_id)return true;
                return false;
            }
            bool matchDept(employeeInfo::data a)
            {
                if(a.department==m_dept){m_container.push_back(a);return true;}
                return false;
            }
            bool readById(int id,employeeInfo::data& a,manager *p=gMgr)
            {
                m_id=id;
                vector<employeeInfo::data>::iterator it=find_if(p->ee.infoCollection.begin(),                 p->ee.infoCollection.end(),bind1st(mem_fun(&manager::read::matchId),this));
                if(it==p->ee.infoCollection.end())return false;
                a=*it;
                return true;
            }
            vector<employeeInfo::data> readByDept(int dept,manager *p=gMgr)
            {
                m_dept=dept;
                m_container.clear();
                for_each(p->ee.infoCollection.begin(),p->ee.infoCollection.end(),bind1st(mem_fun(&manager::read::matchDept),this));
                return m_container;
            }

    };
    class del
    {
        public:
            int m_id;
            bool matchId(employeeInfo::data a)
            {
                if(m_id==a.id)return true;
                return false;
            }
            bool delById(vector<int>& a,manager *p=gMgr)
            {
                vector<int>::iterator it=a.begin();
                while(it!=a.end())
                {
                    m_id=*it;
                    vector<employeeInfo::data>::iterator t=remove_if(p->ee.infoCollection.begin(),p->ee.infoCollection.end(),                     bind1st(mem_fun(&manager::del::matchId),this));
                    p->ee.infoCollection.resize(t-p->ee.infoCollection.begin());
                    ++it;
                }
                return true;
            }
    };
    public:
    employeeInfo& ee;
    manager(employeeInfo a):ee(a){}
    public:
    create creater;
    update updater;
    read reader;
    del deler;
};

class shell
{
    public:
        manager& mgr;
        shell(manager mgr):mgr(mgr){}
        void start()
        {
            int selection;
            cout<<"--------------------MainMenu-----------------------"<<endl;
            cout<<"1.insertAnRecord 2.readByStaffId 3.readByDepartment"<<endl<<"4.delSomeRecords 5.modifyARecord 6.exit"<<endl;
            cout<<"input:[operation code]+[content] or [conditions]"<<endl;
            cout<<"---------------------------------------------------"<<endl;
            next:cin>>selection;
            switch(selection)
            {
                case 1:
                    insertAnRecord();
                    goto next;
                case 2:
                    readByStaffId();
                    goto next;
                case 3:
                    readByDept();
                    goto next;
                case 4:
                    delSomeRecords();
                    cin.clear();
                    cin.sync();
                    goto next;
                case 5:
                    updateARecord();
                    goto next;
                case 6:
                    exit(1);
                default:
                    cout<<"Select a valid instruction No. please."<<endl;
                    goto next;
            }

        }
        void insertAnRecord()
        {
            typename employeeInfo::data data;
            cin>>data.id>>data.department>>data.jobTitle>>data.salary>>data.entryDate>>data.name;
            bool flag=mgr.creater.addAnEmployee(data);
            if(flag)cout<<"added."<<endl;
            else cout<<"already exist."<<endl;
        }
        void readByStaffId()
        {
            int a;
            cin>>a;
            employeeInfo::data b;
            cout<<setiosflags(ios::left);
            cout<<"-----------------------------------------------------------"<<endl;
            cout<<setw(10)<<"ID"<<setw(10)<<"DEPT."<<setw(10)<<"NAME"<<setw(10)<<"TITLE"<<setw(10)<<"WAGE"<<setw(10)<<"DOE"<<setw(10)<<endl;
            cout<<"-----------------------------------------------------------"<<endl;
            if(!mgr.reader.readById(a,b)){cout<<"search done."<<endl;return;}
            cout<<setw(10)<<b.id<<setw(10)<<strDept[b.department]<<setw(10)<<b.name<<setw(10)<<strTitle[b.jobTitle]<<setw(10)<<b.salary<<setw(10)<<b.entryDate<<setw(10)<<endl;
            cout<<"search done."<<endl;
        }
        void readByDept()
        {
            int a;
            cin>>a;
            vector<employeeInfo::data> b=mgr.reader.readByDept(a);
            vector<employeeInfo::data>::iterator it=b.begin();
            cout<<setiosflags(ios::left);
            cout<<"-----------------------------------------------------------"<<endl;
            cout<<setw(10)<<"ID"<<setw(10)<<"DEPT."<<setw(10)<<"NAME"<<setw(10)<<"Title"<<setw(10)<<"WAGE"<<setw(10)<<"DOE"<<setw(10)<<endl;
            cout<<"-----------------------------------------------------------"<<endl;
            while(it!=b.end())
            {
                cout<<setw(10)<<it->id<<setw(10)<<strDept[it->department]<<setw(10)<<it->name<<setw(10)<<strTitle[it->jobTitle]<<setw(10)<<it->salary<<setw(10)<<it->entryDate<<setw(10)<<endl;
                ++it;
            }
            cout<<"search done."<<endl;
        }
        void delSomeRecords()
        {
            vector<int> a;
            int b;
            while(cin>>b)
            {
                a.push_back(b);
            }
            cout<<"deleted"<<endl;
            mgr.deler.delById(a);
        }
        void updateARecord()
        {
            vector<employeeInfo::data> a;
            employeeInfo::data b;
            cin>>b.id>>b.department>>b.jobTitle>>b.salary>>b.entryDate>>b.name;
            a.push_back(b);
            mgr.updater.modify(a);
            cout<<"updated."<<endl;
        }
};
int main()
{
    employeeInfo ee;
    ee.loadFile("1.txt");
    manager mgr(ee);
    gMgr=&mgr;
    shell sh(mgr);
    sh.start();
    return 0;
}

员工信息系统

时间: 2024-07-30 23:15:21

员工信息系统的相关文章

python学习day13一周总结补充+员工信息系统编写

补充内容:eval 将字符串变成变量名locals   看输入的是否是字典中的一个keyfunc.__name____怎么看变量名的数据类型斐波那契数列li=[1,1]while li[-1]<1000000:    li.append(li[-1]+li[-2])print(li) li=[1,1]while len(li)<50:    li.append(li[-1]+li[-2])print(li) 最后两个数相加变成下个数,判断什么时候停下来 员工信息系统编译思路 在编译程序之前,先

python练习——moudule02——员工信息增删改查

#作业名称:员工信息的增删改查 #作业需求: 1.可进行模糊查询,语法至少支持下面3种: select name,age from staff_table where age > 22 select * from staff_table where dept = "IT" select * from staff_table where enroll_date like "2013" 查到的信息,打印后,最后面还要显示查到的条数 2.可创建新员工纪录,以phon

Java从入门到精通pdf电子版

Java从入门到精通pdf电子版 链接:https://pan.baidu.com/s/1nzy8LV6d2_qAD3oKS-Fj9Q 提取码:at3x 简介: <Java从入门到精通>从初学者小白角度出发,通过通俗易懂的白话语言.丰富多彩的实战实例,详细介绍了使用Java语言进行程序开发应该掌握的各方面技术和技能,让你在编程开发中越走越远 目录 · · · · · · 第一篇 基础篇 第1章 Java概述 第2章 Java基本语言 第3章 控制流程语句 第4章 数组 第二篇 面向对象 第5章

二叉树增删改查 &amp;&amp; 程序实现

二叉排序树定义 一棵空树,或者是具有下列性质的二叉树:(1)若左子树不空,则左子树上所有结点的值均小于它的根结点的值:(2)若右子树不空,则右子树上所有结点的值均大于它的根结点的值:(3)左.右子树也分别为二叉排序树:(4)没有键值相等的结点. 二叉树删除节点 二叉排序树删除节点的时候为其删除后还是一个二叉排序树,要对不同的情况进行分别处理 1.p结点为叶子结点,即PL(左子树)和PR(右子树)均为空树.由于删去叶子结点不破坏整棵树的结构,则可以直接删除此子结点. 2.p结点只有左子树PL或右子

管理没有完美 只有和谐

赢在和谐 第一部分:管理没有完美 只有和谐 前 言 和谐是当今社会发展的主旋律,在社会各方面.各层次.各领域的竞争达到白热化的情况下,提倡和谐无疑具有重大的意义.因为人们已经开始充分认识到,只有和谐才能发展:只有和谐才能进步:只有和谐才能实现终极突破. 和谐的发展观为企业的发展提供了一个崭新的思路.在市场竞争日益激烈的情况下,企业耗费很大的精力才有可能获得竞争的胜利.然而,胜利的结果通常不是丰厚的利润:相反,还有可能是巨额的亏损.在疲于应对外部竞争的同时,企业的领导者还不得不应对企业内部员工的竞

商品订购及货物采购信息系统(需求分析)

这个系统是之前有人提过的一个小的管理信息系统,后来自己用Java+mysql实现了所有功能,现在整理一下,望各位能够批评指正,谢谢.  系统整体需求说明 订单采购管理:某公司为企业客户提供食品.蔬菜.肉制品等商品采购配送服务.为此公司需要保存企业客户的基本信息,其基本信息包括企业名称.客户简称.企业法人.企业地址.邮政编码.开户银行.账号以及企业客户的联系人,联系人信息包括联系人姓名.联系人电话.手机.电子信箱.一个企业客户可以有多个联系人. 公司为企业客户提供的商品信息描述包括商品名称.包装方

信息系统监理师课程3月15日作业

第一章:监理基础1.目前我国信息服务管理包括哪四个方面措施?答:目前我国信息服务管理包括:1.计算机信息系统集成单位资质管理:2.信息系统项目经理资格管理:3.信息系统工程监理单位资质管理:4.信息系统工程监理人员资格管理. 2.什么是信息系统工程?答:信息系统工程是指信息化工程建设中的信息网络系统.信息资源系统个.信息应用系统的新建.升级.改造工程. 3.什么是四控三管一协调?答:1.四控:信息系统工程质量控制.信息系统工程进度控制.信息系统工程投资控制.信息系统工程变更控制:2.三管:信息系

web人力资源信息系统开发日志③

第三阶段(2017年5月21-6月20日):主要开发内容重心转向用户业务管理层,业务逻辑是用PHP程序对数据库表进行调用,满足业务管理需求.数据库除了安装PDO驱动外还需要安装ODBC相应的驱动,便于以后使用ODBC数据源接口,在MySQL官网下载mysql-connector-odbc稳定5.3版本32位安装,然后在启动->windows文件管理->ODBC数据资源管理程序中添加相应的mysql驱动程序.主体开发可参考fastphp.ppphp轻量级开发框架.H-ui前端框架.敏捷框架.Me

信息系统项目3月16日作业

3月16日作业: 一,本章课程重点: 项目整体管理的过程包括如下内容: 项目启动 制定初步的范围说明书 制定项目管理计划 指导和管理项目的执行 监督和控制项目 整体变更控制 项目收尾 启动前加入背景介绍 收尾后加入经验教训就是论文论项目整体管理大纲 项目启动:项目立项以后就要正式启动项目,启动是以书面的.正式的形式肯定项目的成立于存在,同时以书面正式的形式为项目经理进行授权 项目正常的作用和内容 项目章程是正式批准一个项目的文档,或者是批准现行现行项目是否进入下一阶段的文档.项目章程应当由项目组