前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >职员管理系统

职员管理系统

作者头像
凡尘扰凡心
发布2023-02-27 15:06:28
5260
发布2023-02-27 15:06:28
举报
文章被收录于专栏:默认分类

main.cpp的内容

代码语言:javascript
复制
#include"add.h"
#include
#include
#include
#include
#include
using namespace std;
void CreatAdmin();
int main()
{
    char Choice;
    string UserName,PassWord;
    string InputUserName,InputPassWord;
    ifstream fin("admin.dat",ios::in);
    if(!fin)
    {
        cout<<"还未创建admin用户,请创建";
        CreatAdmin();
        fin.close();
    }
    fin.close();
    fin.open("admin.dat",ios::in);
    fin>>UserName;
    fin>>PassWord;
    cout<<"请输入admin用户名"<>InputUserName;
    cout<<"请输入admin密码"<>InputPassWord;
    if(UserName==InputUserName && InputPassWord==PassWord)
    {
        system("cls");
        cout<<"已进入系统!"<>Choice;
        while (1)
        {
            JusticeUsersChoice(Choice);
            system("color 04");
            cout<<"请选择操作\n1.存入信息\n2.删除信息\n3.查找信息\n4.遍历信息\n5.修改信息"<>Choice;
        }
        

    }
    else{
        cout<<"用户名或者密码不正确"<>UserName;
    cout<<"请输入admin密码"<>PassWord;
    fout<

add.h的内容

代码语言:javascript
复制
#include
#include
#include
#include
using namespace std;
void GetUserInput();
void PrintWlecome(string UserName);
void GetUserInput();
void JusticeUsersChoice(char Choice);
void PointReadFile();
void ThroughAll();
void ReviseData();
bool DeletInfo();
void LogWrite();
class Person
{
private:
    string name;
    string id;
    string numbers;
    string address;
    char sex;
    string age;
    double salary;
    string diploma;

public:
    void Set_value(string name1,string id1,string number,string address1,char sex1,double salary1,string age1,string diploma1)
    {
        name=name1;
        id=id1;
        numbers=number;
        address=address1;
        sex=sex1;
        salary=salary1;
        diploma=diploma1;
        age=age1;

    }
    friend ofstream &operator<<(ofstream &fout,Person &a)
    {
        fout<>(ifstream &fin,Person &people)
    {
        fin>>people.id;
        fin>>people.name;
        fin>>people.address;
        fin>>people.sex;
        fin>>people.age;
        fin>>people.salary;
        fin>>people.diploma;
        return fin;
    }

};
void LogWrite(Person people,string operate)
{
    SYSTEMTIME systime={0};
    GetSystemTime(&systime);
    ofstream fout("log.txt",ios::app);
    fout<>id1>>name1>>number1>>address1>>sex1>>age1>>salary1>>diploma1;
    people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
    people.print();
    people.Write();
    LogWrite(people,"输入");

}
void JusticeUsersChoice(char Choice)
{
    if(Choice=='1')
        {
            GetUserInput();

        }
        else if(Choice=='2')
        {
            DeletInfo();
        }
         else if(Choice=='3')
        {
            PointReadFile();
        }
         else if(Choice=='4')
        {
            ThroughAll();
        }
        else if(Choice=='5')
        {
            ReviseData();
        }
        else{
            cout<<"好歹也要选择一个嘛"<>Choice;
    if(Choice=='1')
    {
        cout<<"请输入id"<>FoundName;
    }
    else
    {
        cout<<"请输入学历"<>Diploma;
    }
    if(!fin)
    {
        cout<<"打开文件num.dat失败"<>id1;
    fin>>name1;
    fin>>number1;
    fin>>address1;
    fin>>sex1;
    fin>>age1;
    fin>>salary1;
    fin>>diploma1;
    people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
    if(FoundName==id1)
    {
        break;
    }
    else if(Diploma==diploma1&&!fin.eof())
    {
        cout<<"id 名字 number 地址 性别 年龄 薪水 学历"<>FoundId;
    while (point)
    {

    fin>>id1;
    fin>>name1;
    fin>>number1;
    fin>>address1;
    fin>>sex1;
    fin>>age1;
    fin>>salary1;
    fin>>diploma1;
    people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
    point=!fin.eof();  
    if(point!=1)
    {
        break;
    }
    if(FoundId!=id1)
    {
        fout<>id1;
            fin>>name1;
            fin>>number1;
            fin>>address1;
            fin>>sex1;
            fin>>age1;
            fin>>salary1;
            fin>>diploma1;
            people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
            point=!fin.eof();  
            if(point)
            {
                fout<>FoundId;
    while (point)
    {

    fin>>id1;
    fin>>name1;
    fin>>number1;
    fin>>address1;
    fin>>sex1;
    fin>>age1;
    fin>>salary1;
    fin>>diploma1;
    people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
    point=!fin.eof();  
    if(point!=1)
    {
        break;
    }
    if(FoundId!=id1)
    {
        fout<>id1>>name1>>number1>>address1>>sex1>>age1>>salary1>>diploma1;
    people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
    fout<>id1;
            fin>>name1;
            fin>>number1;
            fin>>address1;
            fin>>sex1;
            fin>>age1;
            fin>>salary1;
            fin>>diploma1;
            people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
            point=!fin.eof();  
            if(point)
            {
                fout<>id1;
    // fin>>name1;
    // fin>>number1;
    // fin>>address1;
    // fin>>sex1;
    // fin>>age1;
    // fin>>salary1;
    // fin>>diploma1;
    fin>>people;
    point=!fin.eof();
    // people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1);
    if(point!=1)
    {
        break;
    }
    cout<
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档