2013年11月1号写, 尚未完成

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

 

#define MAX 100

 

/*涉及数据结构*/

struct salary_Info

{

       int card_no;             //工作卡号

       char name[20];           //姓名

       int month;               //月份

       float init_salary;       //应发工资

       float water_rate;        //水费

       float electric_rate;     //电费

       float tax;               //税金

       float final_salary;      //实发工资

}SI[MAX];

/*1、主函数提供输入、处理和输出部分的函数调用,各功能模块采用菜单方式选择*/

 

static int g_nTotal = 0;

 

//输入部分

void input();

 

//输入部分选择菜单  包含保存选择菜单

int selectinput();

//顺序输入

void SysProductCardNo();

void inputCardName();

void inputCardMonth();

void inputCardSalary();

void inputCardWaterRate();

void inputCardElectricRate();

 

//保存选择菜单

int saveSelect();

void saveInputOK();

void saveInputCancel();

 

 

//处理部分

void handle();

int GetCardNoByName();

int GetCardNoByNo();

void modifyCardName();

void modifyCardMonth();

void modifyCardSalary();

void modifyCardWaterRate();

void modifyCardElectricRate();

void modify();

 

 

//输出部分

void display();

 

//主菜单选择

int selectmenu();

 

int selectmenu()

{

    char szSelect[20] = {0};

Label:   

    system("cls");

    printf("工资管理系统主菜单\n");

    printf("(i/I) 输入\n");

    printf("(h/H) 处理\n");

    printf("(d/D) 显示\n");

    printf("(e/E) 退出\n");

    printf("请选择以上选项 : ");

    scanf("%s",szSelect);

    if(szSelect[1] != '\0'){

           printf("输入错误! 请重新输入");

           goto Label;

    }

    if(szSelect[0] == 'i' || szSelect[0] == 'I')

        return 1;

    else if(szSelect[0] == 'h' || szSelect[0] == 'H')

        return 2;  

    else if(szSelect[0] == 'd' || szSelect[0] == 'D')

        return 3;

    else if(szSelect[0] == 'e' || szSelect[0] == 'E')

        return 0;

}

 

 

 

 

int selectinput()

{

    char szSelect[20] = {0};

Label:

    system("cls");

    printf("1、添加职工信息\n");

    printf("0、返回上一级..\n");

    printf("选择操作 (0 - 1) : "); 

    scanf("%s",szSelect);

    if(szSelect[0] == '1')

         return 1;

    else if(szSelect[0] == '0')

         return 0;

    else

    {

        printf("选择错误,请重新选择 \n");

        goto Label;

    }

}

 

int saveSelect()

{

    char szSelect[20] = {0};

Label:

    printf("选择是否保存 (yes y(Y),no n(N) :");

    scanf("%s",szSelect);

    if(szSelect[1] != '\0')

    {

           printf("输入错误,请重新输入");

           goto Label;

    }

    if(szSelect[0] == 'y' || szSelect[0] == 'Y')

            return 1;

    else if(szSelect[0] == 'n' || szSelect[0] == 'N')

            return 0;

}

void saveInputOK()

{

     printf("保存成功 !\n");

     system("pause");

}

void saveInputCancel()

{

     g_nTotal--;

     printf("保存失败 !\n");

     system("pause");

}

 

void ModifyEditOK()

{

     printf("保存成功 !\n");

     system("pause");

}

void ModifyEditCancel()

{

     g_nTotal--;

     printf("保存失败 !\n");

     system("pause");

}

//输入值

void SysProductCardNo()

{

     int nMember = 0;

     int nNo = 0;

     nMember = g_nTotal;

     nMember++;

     nNo = rand() % 100;

     printf("系统随机产生职员编号为 %d \n", nNo);

     SI[nMember].card_no = nNo;

     g_nTotal = nMember;

}

void inputCardName()

{

     int nMember = 0;

     printf("输入职员名称 : ");

     nMember = g_nTotal;

     scanf("%s",SI[nMember].name);

}

void inputCardMonth()

{

     int nMember = 0;

     printf("输入月份 : ");

     nMember = g_nTotal;

     scanf("%d",&SI[nMember].month);

}

void inputCardSalary()

{

     int nMember = 0;

     printf("输入应发薪水 : ");

     nMember = g_nTotal;

     scanf("%f",&SI[nMember].init_salary);

}

void inputCardWaterRate()

{

     int nMember = 0;

     printf("输入水费 : ");

     nMember = g_nTotal;

     scanf("%f",&SI[nMember].water_rate);

}

void inputCardElectricRate()

{

     int nMember = 0;

     printf("输入电费 : ");

     nMember = g_nTotal;

     scanf("%f",&SI[nMember].electric_rate);

}

 

 

void input()

{

     int nReturn = 1;

     while(nReturn)

     {

             switch(selectinput())

             {

             //继续添加

             case 1:

                  system("cls");

                  //生产系统编号

                  SysProductCardNo();

                  //姓名

                  inputCardName();

                  //月份

                  inputCardMonth();

                  //应发工资

                  inputCardSalary();

                  //水费

                  inputCardWaterRate();

                  //电费

                  inputCardElectricRate();

                  break;

             //不添加

             case 0:

                  nReturn = 0;

                  break;     

             }     

     }

     switch(saveSelect())

     {

             case 1:

                  saveInputOK();

                  break;

             case 0:

                  saveInputCancel();

                  break;      

             default:

                  break;    

     }

}

 

int GetCardNoByName()

{

    int nFlag = 0;

    int nCardNo = -1;

    int nMember = 0;

    char szName[20] = {0};

    system("cls");

    printf("请输入需要查找的姓名 : ");

    scanf("%s",szName);

    for(nMember = 0; nMember < g_nTotal; nMember++)

    {

         if(strcmp(szName,SI[nMember].name) == 0)

         {

                  nCardNo = SI[nMember].card_no;

                  nFlag = 1;                   

                  break;     

         }

    }

    if(0 == nFlag)

         printf("没有找到对应的用户 \n");

    return nCardNo;

}

int GetCardNoByNo()

{

    int nFlag = 0;

    int nCardNo = -1;

    int nMember = 0;

    int nInputNo = 0;

    system("cls");

    printf("请输入需要查找的卡号 : ");

    scanf("%d",&nInputNo);

    for(nMember = 0; nMember < g_nTotal; nMember++)

    {

         if(nInputNo == SI[nMember].card_no)

         {

                 nCardNo = SI[nMember].card_no;

                 nFlag = 1;

                 break;

         }

    }

    if(0 == nFlag)

         printf("没有找到对应的用户 \n");

    return nCardNo;

}

void modifyCardName()

{

     printf("修改员工姓名\n");

}

void modifyCardMonth()

{

}

void modifyCardSalary()

{

}

void modifyCardWaterRate()

{

}

void modifyCardElectricRate()

{

}

int modifyMenu()

{

   

}

void modify()

{

     int nReturn = 1;

  //   SysProductCardNo();

     while(nReturn)

     {

             switch(selectinput())

             {

             case 1:

                  //姓名

                  modifyCardName();

             break;

             case 2:

                  //月份

                  modifyCardMonth();

             break;

             case 3:

                  //应发工资

                  modifyCardSalary();

                  break;

             case 4:

                  //水费

                  modifyCardWaterRate();

                  break;

             case 5:

                  //电费

                  modifyCardElectricRate();

                  break;

             case 0:

                  nReturn = 0;

                  break;     

             default:

                  break;

             }     

     }

     switch(saveSelect())

     {

             case 1:

                  ModifyEditOK();

                  break;

             case 0:

                  ModifyEditCancel();

                  break;  

             default:

                  break;        

     }

}

void calCard()

{

}

void sortCard()

{

}

int handleMenu()

{

    int szSelect[20] = {0};

Label:

    system("cls");

    printf("1、修改职工信息 \n");

    printf("2、处理员工税金工资 \n");

    printf("3、重新排序处理 \n");

    printf("0、返回上一级 ... \n");

    printf("请选择操作 (0 - 3) : ");

    scanf("%s",szSelect);

    if(szSelect[0] == '1')

        return 1;

    else if(szSelect[0] == '2')

        return 2;

    else if(szSelect[0] == '3')

        return 3;

    else if(szSelect[0] == '0')

        return 0;

    else

    {

        printf("选择错误,请重新输入 \n");

        goto Label;

    }

}

void handle()

{

     int nFlag = 1;

     while(nFlag)

     {

          switch(handleMenu())

          {

          case 1:

               modify();

               break;

          case 2:

               calCard();

               break;

          case 3:

               sortCard();

               break;

          case 0:

               break;

          }

     }   

}

void displayCardNo()

{

    int nMember = 0;

    printf(" %d 员工的卡号", g_nTotal);

    for(nMember = 0; nMember < g_nTotal; nMember++)

    {

          printf("%d  ", SI[nMember].card_no);

         

    }

}

void displayCardName()

{

    int nMember = 0;

    printf(" %d 员工的姓名", g_nTotal);

    for(nMember = 0; nMember < g_nTotal; nMember++)

    {

          printf("%d  ", SI[nMember].name);

         

    }

}

int choiceMenu()

{

    int nChoice = 0;

Label:   

    system("cls");

    printf("选择菜单 \n");

    printf("1、只显示姓名 \n");

    printf("2、只显示卡号 \n");

    printf("3、显示选择列 \n");

    printf("0、返回上一级 .. \n");

    printf("请选择以上选项 : ");

    scanf("%d",&nChoice);

    if(nChoice > 3 && nChoice < 0)

    {

          printf("选择错误,请重新选择 \n");

          goto Label;

    }

    return nChoice;

}

void choiceDisplay()

{

    int nChoice = 1;

    while(nChoice)

    {

          switch(choiceMenu())

          {

          case 1:

               break;

          case 2:

               break;

          case 3:

               break;

          case 0:

               nChoice = 0;

               break;

          }

    }

}

int listMenu()

{

}

void listDisplay()

{

}

int sortMenu()

{

}

void SortDisplay()

{

}

int displayMenu()

{

    char szSelect[20] = {0};

Label:

    system("cls");

    printf("选择浏览方式 \n");

    printf("1、选择所有用户 \n");

    printf("2、分列显示用户 \n");

    printf("3、排序显示用户 \n");

    printf("0、返回上一级.. \n");

    printf("请选择以上选项 : ");

    scanf("%s",szSelect);

    if(szSelect[0] == '1')

         return 1;

    else if(szSelect[0] == '2')

         return 2;

    else if(szSelect[0] == '3')

         return 3;

    else if(szSelect[0] == '0')

         return 0;

    else{

         printf("选择错误,请重新选择 \n");

         goto Label;

    }

}

void display()

{

    int nDisplay = 1;

    while(nDisplay)

    {

           switch(displayMenu())

           {

           case 1:

                choiceDisplay();

                break;

           case 2:

                listDisplay();

                break;

           case 3:

                SortDisplay();

                break;

           case 0:

                nDisplay = 0;

                break;       

           }

    }

}

void ChangeDesktop()

{

    

//      system("mode con cols=30 lines=20");

//      system("color 14");

   //   system("title=工资管理系统");

}

/*主函数*/

int main(void)

{

 

    int nExit = 1;

    ChangeDesktop();

    while(nExit)

    {       

            switch(selectmenu())

            {

            case 1:

                 //1、输入

                 input();

                 break;

            case 2:

                 //2、处理

                 handle();

                 break;

            case 3:

                 //3、输出

                 display();

                 break;

            case 0:

                 //退出

                 nExit = 0;

                 break;

            }

    }

    //存盘处理

    return 0;

}

 

posted @ 2013-11-01 16:22  中国男孩  阅读(156)  评论(0编辑  收藏  举报