作业

这是我写的最长的一段代码,也是我使用的最基本的知识。很多要求我只达到的最低的标准。

描述:

说明:一个员工工资管理程序,有新建、存储、显示、修改和删除的功能。
要求:
1) 利用工号区别员工身份,工号用字符数组的形式,从000001开始编号,该工号不能人工修改,是由计算机自动根据录入的先后复制的,录入数据时不必输入工号。
2) 可以选择现实的多种排序形式,如按姓名的顺序、工资总额的顺序、职务工资或奖金的顺序。
3) 每次显示时,将所有要显示数据的工资总额、职务工资总额、奖金总额一起计算显示。
4) 可以根据工号或姓名修改、删除数据,在修改、删除时现要求用户确认,确认后再进行操作。

这是我的一个作业

缺陷://调试出来了
1、完全是由结构体做的
2、一个函数
3、不能实时保存,只是结束后单纯的保存
4、不能读取,保存后重新新建的文档后,之前的就没了
5、工号有问题
6、存储因为是结构体,只能存取一定量的数据,这些数据全都是自己用N定的。存取的数据需要去自己改。
7、调试了很长时间,自己因为只是知道概念,而导致,作业不够完善,经常出错。
8、俩个作业,第一个基础点,在选择的第二个作业,自己使用类,让自己做得更加的完善。
想法
做下一个作业,使用类,函数不只放一个地方,主函数,只调用函数。
做的时候,让自己可以读取之前保存的数据。
可以使用读取的指针的位置。

//
#include<iostream>
#include<string>
#include<fstream>
#define N 20
using namespace std;

struct sale
{
    char num[6]="00000";
    bool flag = 0;//证明是否有数据存在
    char name[10]="abc";
    int gongzi=999;//职务工资
    int all=1000;//职务总额
    int prize=1;//奖金
    typename int *zhizheng;
}*head, *inputposition, *checkposition;

int input_message(sale people[])
{
    checkposition = people;
    int shuzi = 1;
    for (int i = 0; i < N; i++)//输入工号
    {
        int j;
        for (j = 0; j < 5; j++)
        {
            people[i].num[j] = '0';
        }
        if (shuzi < 10)people[i].num[j - 1] = '0' + shuzi;
        else {
            people[i].num[j - 2] = '0' + shuzi / 10;
            people[i].num[j - 1] = '0' + shuzi % 10;
        }
        shuzi++;
        people[i].num[6] = '\0';
    }
    //for (int i = 0; i < N; i++)
    //{
    //  cout << people[i].num << endl;
    //}
    int f = 1;
    cout << "输入信息请按1,修改信息请按2,显示工资请按3,存储信息请按4" << endl;
    cin >> f;
    while (f)
    {
        static int i2 = 0;
        int i = 0;//case 1中的输入定位
        int f1 = 1;//case 1中的
        int f2 = 1;//case2中的
        int f3 = 1;//case选择f3
        int xuhao = 0;//case3
        sale temppeople[N];//存放排序的数
        sale temp;//存放完全的临时数据
        switch (f)
        {
        case 1:
            for (i2; i2<20 && f1 != 0; i2++)
            {
                //cout << i2<<endl;
                cout << "请输入名字" << endl;
                cin >> people[i2].name;
                cout << "请输入工资" << endl;
                cin >> people[i2].gongzi;
                cout << "请输入奖金" << endl;
                cin >> people[i2].prize;
                people[i2].all = people[i2].gongzi + people[i2].prize;
                people[i2].flag = 1;
                cout << "输入下一个数据请按1,退出请按0;" << endl;
                cin >> f1;

            }
            break;
        case 2://修改信息
            while (f2)
            {

                cout << "现在的存储的信息是(按0退出1继续):" << endl;
                checkposition = people;

                for (int j = 0; j < i-1; j++)people[j].flag = 1;
                i = 0;
                cout << "\t\t" << people[i].name << "\t\t" << people[i].gongzi << "\t\t" << people[i].prize << "\t\t" << people[i].all << "\t\t" << people[i].flag << endl;///
                cout << "==========================================================================================" << endl;
                cout << "序号\t\t" << "工号\t\t" << "名字\t\t" << "工资\t\t" << "奖金\t\t" << "总工资" << endl;
                xuhao = 1;
                for (i = 0; i<N&&people[i].flag != 0; i++)//输出
                {//通过xuhao可以实现从上到下或者从下到上的排序。此次只固定排序。

                    cout << xuhao << "\t\t";
                    for (int j = 0; j<5; j++)
                        cout << people[i].num[j];

                    cout << "\t\t" << people[i].name << "\t\t" <<people[i].gongzi << "\t\t" << people[i].prize << "\t\t" << people[i].all << "\t\t"<<people[i].flag<<endl;
                    xuhao++;
                }
                cout << "==========================================================================================" << endl;
                cin >> f2; if (f2 == 0)break;
                cout << "选择删除按1,选择修改按2" << endl;
                int f2f = 0;
                int f3f = 1;
                cin >> f2f;
                int xuhao2;
                sale temp = people[0];//临时数据
                switch (f2f)
                {
                case 1://删除
                    cout << "根据序号删除按1,根据名字删除按2" << endl;
                    cin >> f3f;
                    if (f3f == 1) {
                        cout << "输入删除序号" << endl;
                        cin >> xuhao2;
                        int i;//判断位置
                        for (i = xuhao2 - 1; i < 20 && people[i].flag == 1; i++)
                        {
                            people[i] = people[i + 1];
                            //cout << i<<"\t\t" << people[i].name << "\t\t" << people[i].gongzi << "\t\t" << people[i].prize << "\t\t" << people[i].all<<"\t\t"<<people[i].flag << endl;
                        }
                    }
                    else {
                        cout << "输入删除的名字" << endl;
                        char tempname[10];
                        cin >> tempname;
                        int T;
                        for ( T = 0; T < 20 && people[T].flag != 0; T++)
                        {
                            if (strcmp(tempname, people[T].name) == 0)break;
                        }
                        if (T == 20) {
                            cout << "没找到" << endl; break;
                        }
                        for (i = T - 1; i < 20 && people[i].flag == 1; i++)
                        {
                            people[i] = people[i + 1];
                            //cout << i<<"\t\t" << people[i].name << "\t\t" << people[i].gongzi << "\t\t" << people[i].prize << "\t\t" << people[i].all<<"\t\t"<<people[i].flag << endl;
                        }
                    }
                    shuzi = 1;
                    i2 = i2 - 1;
                    for (int i = 0; i < N; i++)//重置工号
                    {
                        int j;

                        for (j = 0; j < 5; j++)
                        {
                            people[i].num[j] = '0';
                        }
                        if (shuzi < 10)people[i].num[j - 1] = '0' + shuzi;
                        else {
                            people[i].num[j - 2] = '0' + shuzi / 10;
                            people[i].num[j - 1] = '0' + shuzi % 10;
                        }
                        people[i].num[6] = '\0';
                        shuzi++;
                    }
                    break;
                case 2://修改
                    cout << "输入修改的序号:";
                    cin >> xuhao2;
                    cout << "之前的名字是"<<people[xuhao2-1].name<<"  "<<"输入修改后的名字" << endl;
                    cin >> people[xuhao2-1].name;
                    cout << "之前的工资是" << people[xuhao2 - 1].gongzi << "  " << "输入修改后的工资" << endl;
                    cin >> people[xuhao2-1].gongzi;
                    cout << "之前的工资是" << people[xuhao2 - 1].prize << "  " << "输入修改后的奖金" << endl;
                    cin >> people[xuhao2-1].prize;
                    people[xuhao2-1].all = people[xuhao2-1].gongzi + people[xuhao2-1].prize;
                    break;
                }

            }break;
        case 3://默认的排序,姓名的排序,工资总额的排序,职务工资的排序,奖金的排序。
            cout << "显示工资方式:\n工号顺序请按1\n工资总额请按2\n职务工资请按3\n奖金顺序请按4\n名字顺序请按5" << endl;
            for (int q = 0; q<N&&people[q].flag != 0; q++)
                temppeople[q] = people[q];
            cin >> f3;
            while (f3)
            {
                if (f3 == 1)
                {
                    cout << "===================================按工号顺序==================================================" << endl;
                    cout << "序号\t\t" << "工号\t\t" << "名字\t\t" << "工资\t\t" << "奖金\t\t" << "总工资" << endl;
                    //按工号顺序输出
                }
                else if (f3 == 2)
                {
                    cout << "===================================按总额顺序=================================================" << endl;
                    cout << "序号\t\t" << "工号\t\t" << "名字\t\t" << "工资\t\t" << "奖金\t\t" << "总工资" << endl;
                    for (int i = 0; i < N&&temppeople[i].flag != 0; i++)
                    {
                        int k = i;
                        for (int j = i; temppeople[j].flag != 0; j++)
                        {
                            if (temppeople[k].all < temppeople[j].all)k = j;
                        }
                        sale linshi;
                        linshi = temppeople[i];
                        temppeople[i] = temppeople[k];
                        temppeople[k] = linshi;
                    }
                }
                else if (f3 == 3)
                {
                    cout << "===================================按工资顺序=================================================" << endl;
                    cout << "序号\t\t" << "工号\t\t" << "名字\t\t" << "工资\t\t" << "奖金\t\t" << "总工资" << endl;
                    for (int i = 0; i < N&&temppeople[i].flag != 0; i++)
                    {
                        int k=i;
                        for (int j = i; temppeople[j].flag!=0; j++)
                        {
                            if (temppeople[k].gongzi < temppeople[j].gongzi)k=j;
                        }
                        sale linshi;
                        linshi = temppeople[i];
                        temppeople[i]=temppeople[k];
                        temppeople[k] =linshi;
                    }
                }
                else if (f3 == 4)
                {
                    cout << "===================================按奖金顺序=================================================" << endl;
                    cout << "序号\t\t" << "工号\t\t" << "名字\t\t" << "工资\t\t" << "奖金\t\t" << "总工资" << endl;
                    for (int i = 0; i < N&&temppeople[i].flag != 0; i++)
                    {
                        int k = i;
                        for (int j = i; temppeople[j].flag != 0; j++)
                        {
                            if (temppeople[k].prize < temppeople[j].prize)k = j;
                        }
                        sale linshi;
                        linshi = temppeople[i];
                        temppeople[i] = temppeople[k];
                        temppeople[k] = linshi;

                    }
                }
                else if (f3 == 5)
                {
                    cout << "===================================按名字顺序=================================================" << endl;
                    cout << "序号\t\t" << "工号\t\t" << "名字\t\t" << "工资\t\t" << "奖金\t\t" << "总工资" << endl;
                    for (int i = 0; i < N&&people[i].flag != 0; i++)
                    {
                        int k = i;
                        for (int j = i; temppeople[j].flag!=0; j++)
                        {
                            if (strcmp(people[k].name, people[j].name))k = j;
                        }
                        sale linshi;
                        linshi = temppeople[i];
                        temppeople[i] = temppeople[k];
                        temppeople[k] = linshi;
                    }
                }
                xuhao = 1;
                for(int i=0;i<N&&temppeople[i].flag!=0;i++)//输出
                {//通过xuhao可以实现从上到下或者从下到上的排序。此次只固定排序。

                    cout << xuhao << "\t\t"  ;
                    for(int j=0;j<5;j++)
                    cout << temppeople[i].num[j];

                    cout<< "\t\t" << temppeople[i].name << "\t\t" << temppeople[i].gongzi << "\t\t" << temppeople[i].prize << "\t\t" << temppeople[i].all << endl;
                    xuhao++;
                }
                cout << "==========================================================================================" << endl;
                cout << endl;
                checkposition = people;
                cout << "显示工资方式:\n工号顺序请按1\n工资总额请按2\n职务工资请按3\n奖金顺序请按4\n名字顺序请按5\n退出排序请按0\n" << endl;
                cin >> f3;
            }break;

        case 4: //存储信息并退出

            return 0;
        default:
            break;
        }
        cout << "输入信息请按1,修改信息请按2,显示工资请按3,存储信息请按4,退出循环请按0" << endl;
        cin >> f;
    }
    cout << "已自动保存" << endl;
    return 0;
}
int main()
{
    sale people[N];
    input_message(people);
    ofstream outfile_gongzi("gognzi.dat", ios::binary);
    if (!outfile_gongzi)
    {
        cerr << "open error!" << endl;
        abort();
    }
    for (int i = 0; i < 20 && people[i].flag != 0; i++)
    {
        outfile_gongzi.write((char *)&people[i], sizeof(sale));
    }
    outfile_gongzi.close();
    return 0;
}
工资管理系统主要用于企业员工的工资核算,实现对人员信息、薪资福利、员工社保信息的维护和查询,并能迅速准确地完成考勤的分类汇总,生成工资报表。系统主要功能如下: (1)人员信息管理:企业员工信息(包括员工基本信息、教育经历、个人简历、岗位变更、离职登记、离退休信息等)的维护和查询(包括精确查询与模糊查询)。查询方式包括单条件查询与组合查询。修改时不允许修改员工编号。 提示:员工基本信息表上某一行的“职称”字段更新后,可以通过触发器自动调整职工工资,或通过事务实现。 (2)考勤管理:管理员工的出勤情况(包括加班、请假、休假等),并提供查询和分类统 计功能。可根据日期、员工编号查询员工出勤情况:也可以按月份、季度、部门、姓名等统计员工出勤情况。 (3)薪资福利管理:管理员工的薪资和福利(包括当月工资、个人所得税、发放工资历 史、员工奖励、员工惩罚等)。 提示:通过存储过程实现当月工资计算和工资发放功能。 计算当月工资时,月工资信息表中的“奖金”、“罚款”字段,是通过计算员工奖励表的奖励金额总和、员工惩罚表的惩罚金额总和得到的。扣款合计、应发合计计算公式可参考实际业务。 个人所得税率是由国家相应法律法规规定的,除非条款变更,否则所得税的计算方法不发生改变。 工资发放时,将工资发放的记录转入工资发放历史记录中,同时将已经发放工资的员工从当月工资管理表中删除。 工资发放历史的作用是查询员工工资的历史记录,查询条件包括月份、职工编号等。 提示:为了保护员工隐私,应设置密码保护,使员工只能查询自己的过往历史信息,同时工资条的输出也应设置专门的权限,不能随意进行。下面的社会保障管理同此处理。 (4)社会保障管理:管理员工的社保信息(包括单位参保信息、养老保险、医疗保险、住房公积金等),生成社会保险台账。 社保基金由企业和员工按照一定的比率共同支付。其中支付的基数和比率根据企业的情况而有所不同,一般基数会和员工工资挂钩,可参考实际业务进行计算。 社会保险台账用于查询企业员工各种社会保险的支付历史和支付金额,其数据根据设定的企业支付比率、个人支付比率及“薪资福利管理”中工资发放时指定的信息自动计算生成。 (5)系统管理:包括操作员管理、参数设置、权限设置、更改密码等。
一、项目简介本课程演示的是一套基于SSM实现的工资管理系统,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的Java学习者。课程包含:1. 项目源码、项目文档、数据库脚本、软件工具等所有资料2. 带你从零开始部署运行本套系统3. 该项目附带的源码资料可作为毕设使用4. 提供技术答疑二、技术实现后台框架:Spring、SpringMVC、MyBatisUI界面:JSP、jQuery 、H-ui数据库:MySQL 三、系统功能该系统共包含两种角色:员工、管理员,主要分为前台和后台两大模块。1.前台模块 前台首页、新闻公告、员工活动、职位招聘、留言板、用户注册、用户登录、个人中心、我的考勤、我的奖惩、我的培训、我的薪资、修改密码等功能。2.后台模块 系统后台登陆、管理员管理、员工信息管理、部门管理、职务管理、考勤类别管理、员工考勤管理、员工奖惩管理、员工培训管理、员工薪资管理、网站栏目管理、网站内容管理、职位招聘管理、求职简历管理、留言交流管理、留言回复管理等功能。该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 四、项目截图1)前台首面2)个人信息页面3)员工信息管理4)考勤信息管理5)薪资信息管理6)添加员工薪资   更多Java毕设项目请关注【毕设系列课程】https://edu.csdn.net/lecturer/2104   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值