C语言课程设计 Win32应用程序
问题描述:
请设计一个职工信息管理程序,以方便人事部门对本单位职工的管理,该程序应该具有以下功
能:
(1)能从键盘输入职工的信息 。
(2)给定职工号,显示职工的信息。
(3)给定工作部门,显示该部门的职工信息。
(4)给定职工号,修改职工的信息。
(5)给定职工号,删除职工信息。
题目要求:
(1)按照分析、设计、编码、调试、测试的软件过程完成这个应用程序。
(2)职工信息应该包含职工号、姓名、工作部门、职称、入厂时间、工资。
(3)为程序设计windows 窗口,在该窗口上以按钮的形式为用户提供“菜单”,通过点击各个功
能项对应的按钮完成操作。
输入要求:
(1)用户可以根据需求,选定相应的操作项目。进入每个操作后,通过窗口的文本框,从键盘输
入相应的信息。程序根据用户输入的信息完成相应的处理,实现要求的功能。
(2)能对输入的数据进行简单的校验,例如,入厂时间必须是合法的日期格式,职工号是唯一的
(一个职工号对应一个职工的职工信息)。
输出要求:
(1)应用程序运行后,要在屏幕上显示一个按钮形式的“菜单”。
(2)要求用户输入数据时,给出清晰、明确的提示信息,包括输入的数据内容、格式以及结束方
式等。
(3)在程序完成处理后,要清楚地给出程序的处理结果。例如,在给定职工号删除职工信息时,
如果该职工不存在,要提示没能删除,如果删除成功要提示删除成功。
实现要求:
(1)在程序中使用链表存储职工信息。
(2)采用模块化程序设计的方法,将程序中的各项功能用函数实现。
提示:
(1)使用结构体表示职工信息,一个结点保存一条职工信息。
扩展功能:
(1)提供一些统计功能。例如统计每个部门的人数,统计平均工资、统计各职称的人数。
(2)职工信息从文件读入。
(3)将职工信息保存到文件中。
代码如下:
- #include <windows.h>
- #include<string.h>
- #include<stdio.h>
- #include"resource.h"
- LRESULT WINAPI WinProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam);//函数声明
- /* 基本功能 */
- void initWorker();
- void addWorker();
- void showAllInfo();
- void clearText();
- void clearCache();
- void deleteWorker();
- void searchWorker();
- void modifyWorker();
- void searchDepartmentWorker();
- void showFormat(struct worker *p);
- void saveLocalFile();
- void readLocalFile();
- void statisticsInfo();
- struct inputhwnd
- {
- int x1;
- int x2;
- int x3;
- int x4;
- int menu_name;
- }hwndArray[]= {{, , , ,NUM_INPUT},{, , , ,NAME_INPUT},{, , , ,DEPART_INPUT},
- {, , , ,JOBTITLE_INPUT},{, , , ,YEAR_INPUT},{, , , ,WAGE_INPUT},
- {, , , ,MONTH_INPUT},{, , , ,DATE_INPUT},{, , , ,BIGTEXTBOX}};
- /* 按钮 结构体 */
- struct inputhwndbutton
- {
- char buttonName[];
- int x1;
- int x2;
- int x3;
- int x4;
- int buttonNum;
- }buttonArray[]={{"添加职工",,,,,ADD_BUTTON},{"按职工号查询",,,,,SEARCHNUM_BUTTON},{"修改信息",,,,,MODIFY_BUTTON},
- {"删除职工",,,,,DELETE_BUTTON},{"显示所有职工信息",,,,,SHOWINFO_BUTTON},{"按部门查询",,,,,SEARCHDEPART_BUTTON},
- {"清空显示",,,,,CLEARTEXT_BUTTON},{"版权声明",,,,,COPYRIGHT_BUTTON},{"退出程序",,,,,EXIT_BUTTON},
- {"保存到本地",,,,,SAVELOCALFILE_BUTTON},{"从本地读",,,,,READLOCALFILE_BUTTON},{"统计",,,,,STATISTICS_BUTTON}};
- /* 矩形框 结构体 */
- struct showrect
- {
- char rectName[];
- int top;
- int right;
- int bottom;
- int left;
- }rectArray[]={{"[ 职工信息输入框 ]",,,,},{"职工号:",,,,},{"姓名:",,,,},
- {"工作部门:",,,,},{"职称:",,,,},{"入厂时间:",,,,},
- {"工资:",,,,},{"年",,,,},{"月",,,,},{"日",,,,}};
- RECT rect[];
- HDC hDC;
- HWND hWnd;
- PAINTSTRUCT paint;
- static char str_num[],str_name[],str_depart[],str_jobTitle[],str_year[],str_month[],str_date[],str_wage[],str_showAll[];
- char title[]={"职工号\t\t姓名\t\t工作部门\t\t\t职称\t\t入厂时间\t\t工资\r\n\r\n"};
- struct worker
- {
- long num; //职工号
- char name[]; //姓名
- char department[];//工作部门
- char jobTitle[]; //职称
- int year;
- int month;
- int date;
- long wage; //工资
- worker *next;
- };
- struct worker *headp;
- void initWorker()
- {
- headp = new worker;
- headp->next=NULL;
- }
- int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
- {
- char *cName = "myWindow";//定义个字符指针表示窗口类的名字
- WNDCLASS wc;//定义变量
- MSG Msg;
- wc.cbClsExtra = ;
- wc.cbWndExtra = ;
- wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);;//设置窗口背景为白色
- wc.hCursor = NULL;//窗口的光标不设置
- wc.hIcon = NULL;
- wc.hInstance = hInstance;//当前程序的句柄,hInstance是由主函数传递
- wc.lpfnWndProc = WinProc;//窗口处理过程的窗口函数。
- wc.lpszClassName =(LPSTR)cName;//窗口类的名字。
- wc.lpszMenuName = NULL;//目录名,不设置
- wc.style = CS_HREDRAW | CS_VREDRAW; //窗口类的风格
- RegisterClass(&wc);//在系统中注册窗口
- hWnd = CreateWindow(cName,TEXT("职工管理程序"),WS_OVERLAPPEDWINDOW,, , , ,NULL, NULL, hInstance, NULL) ;
- ShowWindow(hWnd,nShowCmd);//显示窗口
- UpdateWindow(hWnd);//更新窗口
- initWorker();
- while(GetMessage(&Msg,NULL,,))
- {
- TranslateMessage(&Msg);//翻译消息
- DispatchMessage(&Msg);//分派消息
- }
- return Msg.message;//程序结束后返回消息
- }
- LRESULT WINAPI WinProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
- {//处理消息过程
- static HWND btnHwnd;
- static HWND inputHwnd[];
- static HWND hwndbutton[];
- switch(Msg)//对消息进行判断
- {
- case WM_PAINT:
- hDC=BeginPaint(hWnd,&paint);//获取设备上下文
- for(int i =;i<;i++)
- {
- rect[i].top = rectArray[i].top;
- rect[i].right = rectArray[i].right;
- rect[i].bottom = rectArray[i].bottom;
- rect[i].left = rectArray[i].left;
- DrawText(hDC,rectArray[i].rectName,-,&rect[i],DT_SINGLELINE|DT_LEFT|DT_VCENTER);
- }
- EndPaint(hWnd,&paint);
- return ;
- case WM_CREATE: //响应窗口的创建事件
- //gg(((LPCREATESTRUCT) lParam) -> hInstance);
- for(int i = ;i<;i++)
- {
- inputHwnd[i]=CreateWindow(TEXT("edit"),NULL,WS_CHILD |WS_VISIBLE|WS_BORDER|ES_LEFT|ES_MULTILINE,hwndArray[i].x1,hwndArray[i].x2,hwndArray[i].x3,hwndArray[i].x4,hWnd,(HMENU)hwndArray[i].menu_name,((LPCREATESTRUCT) lParam)->hInstance,NULL);
- }
- for(int i = ;i<;i++)
- {
- hwndbutton[i]=CreateWindow(TEXT("BUTTON"),buttonArray[i].buttonName,WS_CHILD|WS_VISIBLE,buttonArray[i].x1,buttonArray[i].x2,buttonArray[i].x3,buttonArray[i].x4,hWnd,(HMENU)buttonArray[i].buttonNum,((LPCREATESTRUCT) lParam) -> hInstance,NULL);
- }
- return ;
- case WM_COMMAND://响应命令
- {
- switch(LOWORD(wParam))
- {
- case ADD_BUTTON:
- {
- clearCache();
- addWorker();
- return ;
- }
- case SEARCHNUM_BUTTON:
- {
- clearCache();
- searchWorker();
- return ;
- }
- case MODIFY_BUTTON:
- {
- clearCache();
- modifyWorker();
- return ;
- }
- case DELETE_BUTTON:
- {
- clearCache();
- deleteWorker();
- return ;
- }
- case SHOWINFO_BUTTON:
- {
- clearCache();
- showAllInfo();
- return ;
- }
- case SEARCHDEPART_BUTTON:
- {
- clearCache();
- searchDepartmentWorker();
- return ;
- }
- case CLEARTEXT_BUTTON:
- {
- clearCache();
- clearText();
- return ;
- }
- case COPYRIGHT_BUTTON:
- {
- MessageBox(NULL,TEXT("本程序归属CCSoft所有,并保留一切权力,任何\n个人或者单位必须经过CCSoft的个人授权、不限\n于书面形式。如有侵权行为,必当追究。"),TEXT("版权声明"),MB_OK);
- return ;
- }
- case EXIT_BUTTON:
- {
- PostQuitMessage();//退出消息队列
- return ;//返回0,结束函数
- }
- /* 扩展功能:保存在本地 */
- case SAVELOCALFILE_BUTTON:
- {
- clearCache();
- saveLocalFile();
- return ;
- }
- /* 扩展功能:写在本地 */
- /**fun()[];*/
- case READLOCALFILE_BUTTON:
- {
- clearCache();
- readLocalFile();
- /* 用函数指针的方式 */
- /*fun()[3]*/
- return ;
- }
- /* 扩展功能:简单的统计 */
- case STATISTICS_BUTTON:
- {
- clearCache();
- statisticsInfo();
- return ;
- }
- }
- return ;
- }
- case WM_DESTROY://如果是点击关闭窗口时的消息
- PostQuitMessage();//退出消息队列
- return ;//返回0,结束函数
- }
- //如果是其余的消息,调用默认消息处理函数,将消息该函数处理并将返回值返回
- return DefWindowProc(hWnd,Msg,wParam,lParam);
- }
- void clearText()
- {
- SetDlgItemText(hWnd,NUM_INPUT,str_num);
- SetDlgItemText(hWnd,NAME_INPUT,str_name);
- SetDlgItemText(hWnd,DEPART_INPUT,str_depart);
- SetDlgItemText(hWnd,JOBTITLE_INPUT,str_jobTitle);
- SetDlgItemText(hWnd,YEAR_INPUT,str_year);
- SetDlgItemText(hWnd,MONTH_INPUT,str_month);
- SetDlgItemText(hWnd,DATE_INPUT,str_date);
- SetDlgItemText(hWnd,WAGE_INPUT,str_wage);
- SetDlgItemText(hWnd,BIGTEXTBOX,str_showAll);
- }
- void gg( HINSTANCE hInstance)
- {
- }
- void clearCache()
- {
- ZeroMemory(str_num,sizeof(str_num));
- ZeroMemory(str_name,sizeof(str_name));
- ZeroMemory(str_depart,sizeof(str_depart));
- ZeroMemory(str_jobTitle,sizeof(str_jobTitle));
- ZeroMemory(str_year,sizeof(str_year));
- ZeroMemory(str_month,sizeof(str_month));
- ZeroMemory(str_date,sizeof(str_date));
- ZeroMemory(str_wage,sizeof(str_wage));
- ZeroMemory(str_showAll,sizeof(str_showAll));
- }
- void addWorker()
- {
- char str_temp[];
- ZeroMemory(str_temp,sizeof(str_temp));
- struct worker *newworker;
- struct worker *assistp,*followp;
- followp=headp;
- assistp=headp->next;
- newworker = new worker;
- GetDlgItemText(hWnd,NUM_INPUT,str_num,sizeof(str_num)/sizeof(char));
- newworker->num = atol(str_num);
- if(newworker->num == || newworker->num<)
- {
- MessageBox(NULL,TEXT("保存失败!输入职工号不合法!请检查输入信息"),TEXT("系统提示"),MB_OK);
- delete newworker;
- }
- else
- {
- while(assistp!=NULL && assistp->num!=newworker->num)
- {
- assistp=assistp->next;
- followp=followp->next;
- }
- if(assistp==NULL)
- {
- GetDlgItemText(hWnd,NAME_INPUT,newworker->name,sizeof(str_num)/sizeof(char));
- GetDlgItemText(hWnd,DEPART_INPUT,newworker->department,sizeof(str_num)/sizeof(char));
- GetDlgItemText(hWnd,JOBTITLE_INPUT,newworker->jobTitle,sizeof(str_num)/sizeof(char));
- GetDlgItemText(hWnd,YEAR_INPUT,str_year,sizeof(str_num)/sizeof(char));
- GetDlgItemText(hWnd,MONTH_INPUT,str_month,sizeof(str_num)/sizeof(char));
- GetDlgItemText(hWnd,DATE_INPUT,str_date,sizeof(str_num)/sizeof(char));
- GetDlgItemText(hWnd,WAGE_INPUT,str_wage,sizeof(str_num)/sizeof(char));
- newworker->wage=atoi(str_wage);
- newworker->year=atoi(str_year);
- newworker->month=atoi(str_month);
- newworker->date=atoi(str_date);
- newworker->next = NULL;
- if(newworker->year< || newworker->year> || newworker->month< || newworker->month > || newworker->date < ||newworker->date>)
- {
- MessageBox(NULL,TEXT("保存失败!您输入的日期不合法,请检查职工信息,并重试!"),("系统提示"),MB_OK);
- delete newworker;
- }
- else if(newworker->wage< | newworker->wage > )
- {
- MessageBox(NULL,TEXT("保存失败!您输入的工资不合法,请检查职工信息,并重试!"),TEXT("系统提示"),MB_OK);
- delete newworker;
- }
- else
- {
- /* 理清楚概念不要挂错了地方。 */
- followp->next=newworker;//将指向首节点的指针,向右移动
- followp=followp->next;
- MessageBox(NULL,TEXT("保存成功!"),TEXT("系统提示"),MB_OK);
- }
- }
- else
- {
- strcat(str_temp,"保存失败!职工号为");
- ltoa(newworker->num,str_num,);
- strcat(str_temp,str_num);
- strcat(str_temp,"的职工已存在,请勿重复保存!");
- MessageBox(NULL,str_temp,"系统提示",MB_OK);
- delete newworker;
- }
- }
- }
- void showAllInfo()
- {
- int flag = ;
- worker *searchp;
- searchp=headp->next;
- if(searchp==NULL)
- {
- MessageBox(NULL,TEXT("请先输入职工信息!"),TEXT("系统提示"),MB_OK);
- }
- strcat(str_showAll,title);
- while(searchp!=NULL)
- {
- flag = ;
- showFormat(searchp);
- searchp=searchp->next;
- }
- if(flag==)
- {
- SetDlgItemText(hWnd,,str_showAll);
- }
- }
- /* 函数名:showFormat(struct worker *p)
- * 用来统一文本输出格式
- 为什么当初用那种显示方式 主要是因为简单,但是对于用户来说 可能影响了用户的使用体验。
- */
- void showFormat(struct worker *p)
- {
- ltoa(p->num,str_num,);
- strcat(str_showAll,str_num);
- /* 该判断 用来对齐 字符串 */
- if(strlen(str_num)<)
- {
- //MessageBox(NULL,TEXT("测试判断"),TEXT("提示"),MB_OK);
- strcat(str_showAll,"\t");
- }
- strcat(str_showAll,"\t");
- strcat(str_showAll,p->name);
- strcat(str_showAll,"\t\t");
- strcat(str_showAll,p->department);
- if(strlen(p->department)<)
- {
- strcat(str_showAll,"\t\t\t");
- }
- else
- {
- strcat(str_showAll,"\t\t");
- }
- //strcat(str_showAll,"\t");
- strcat(str_showAll,p->jobTitle);
- strcat(str_showAll,"\t\t");
- ltoa(p->year,str_year,);
- strcat(str_showAll,str_year);
- strcat(str_showAll,"年");
- ltoa(p->month,str_month,);
- strcat(str_showAll,str_month);
- strcat(str_showAll,"月");
- ltoa(p->date,str_date,);
- strcat(str_showAll,str_date);
- strcat(str_showAll,"日");
- strcat(str_showAll,"\t");
- ltoa(p->wage,str_wage,);
- strcat(str_showAll,str_wage);
- strcat(str_showAll,"\r\n");
- strcat(str_showAll,"\r\n");
- }
- void deleteWorker()
- {
- char str_temp[];
- ZeroMemory(str_temp,sizeof(str_temp));
- long s;
- worker *deletep,*shadowp;
- shadowp=headp;
- deletep=headp->next;
- GetDlgItemText(hWnd,NUM_INPUT,str_num,sizeof(str_num)/sizeof(char));
- s=atol(str_num);
- if(s== || s<)
- {
- MessageBox(NULL,TEXT("请输入正确的职工号再删除!"),TEXT("系统提示"),MB_OK);
- }
- else
- {
- while(deletep!=NULL && deletep->num!=s)
- {
- deletep=deletep->next;
- shadowp=shadowp->next;
- }
- if(deletep!=NULL)
- {
- if(deletep->next==NULL)
- {
- shadowp->next =NULL;
- delete deletep;;
- MessageBox(NULL,TEXT("删除成功"),TEXT("系统提示"),MB_OK);
- }
- else
- {
- shadowp->next=deletep->next;
- delete deletep;
- MessageBox(NULL,TEXT("删除成功"),TEXT("系统提示"),MB_OK);
- }
- }
- else
- {
- strcat(str_temp,"职工号为:");
- strcat(str_temp,str_num);
- strcat(str_temp,"的职工不存在,无法删除!");
- MessageBox(NULL,str_temp,TEXT("系统提示"),MB_OK);
- }
- }
- }
- void searchWorker()
- {
- long s;
- char str_temp[];
- ZeroMemory(str_temp,sizeof(str_temp));
- struct worker *assistp;
- assistp=headp->next;
- GetDlgItemText(hWnd,NUM_INPUT,str_num,sizeof(str_num)/sizeof(char));
- s=atol(str_num);
- if(s== || s<)
- {
- MessageBox(NULL,TEXT("请输入正确的职工号!"),TEXT("系统提示"),MB_OK);
- }
- else
- {
- /* long s = atol(str1); 直接用!=进行比较 没毛病 */
- while(assistp!=NULL && assistp->num!=s)
- {
- assistp=assistp->next;
- }
- if(assistp!=NULL)
- {
- strcat(str_showAll,title);
- showFormat(assistp);
- SetDlgItemText(hWnd,,str_showAll);
- }
- else
- {
- strcat(str_temp,"职工号为:");
- strcat(str_temp,str_num);
- strcat(str_temp,"的职工不存在!");
- MessageBox(NULL,str_temp,TEXT("系统提示"),MB_OK);
- }
- }
- }
- void modifyWorker()
- {
- struct worker *assistp;
- assistp=headp->next;
- char str_temp[];
- long s;
- GetDlgItemText(hWnd,NUM_INPUT,str_num,sizeof(str_num)/sizeof(char));
- s=atol(str_num);
- if(s== || s<)
- {
- MessageBox(NULL,TEXT("请输入正确的职工号!"),TEXT("系统提示"),MB_OK);
- }
- else
- {
- while(assistp!=NULL && assistp->num!=s)
- {
- assistp=assistp->next;
- }
- if(assistp!=NULL)
- {
- GetDlgItemText(hWnd,NAME_INPUT,assistp->name,sizeof(str_num)/sizeof(char));
- GetDlgItemText(hWnd,DEPART_INPUT,assistp->department,sizeof(str_num)/sizeof(char));
- GetDlgItemText(hWnd,JOBTITLE_INPUT,assistp->jobTitle,sizeof(str_num)/sizeof(char));
- //GetDlgItemText(hWnd,5,newworker->date,sizeof(str1)/sizeof(char));
- GetDlgItemText(hWnd,YEAR_INPUT,str_year,sizeof(str_num)/sizeof(char));
- GetDlgItemText(hWnd,WAGE_INPUT,str_wage,sizeof(str_num)/sizeof(char));
- GetDlgItemText(hWnd,MONTH_INPUT,str_month,sizeof(str_num)/sizeof(char));
- GetDlgItemText(hWnd,DATE_INPUT,str_date,sizeof(str_num)/sizeof(char));
- assistp->wage = atoi(str_wage);
- assistp->year = atoi(str_month);
- assistp->month = atoi(str_month);
- assistp->date = atoi(str_date);
- MessageBox(NULL,TEXT("修改成功!"),TEXT("系统提示"),MB_OK);
- }
- else
- {
- strcat(str_temp,"职工号为:");
- strcat(str_temp,str_num);
- strcat(str_temp,"的职工不存在,无法修改其信息!");
- MessageBox(NULL,str_temp,TEXT("系统提示"),MB_OK);
- }
- }
- assistp=headp->next;
- }
- void searchDepartmentWorker()
- {
- int flag= ;
- worker *searchp;
- searchp=headp->next;
- GetDlgItemText(hWnd,DEPART_INPUT,str_depart,sizeof(str_num)/sizeof(char));
- if(str_depart=="\0")
- {
- MessageBox(NULL,TEXT("请输入正确的部门!"),TEXT("系统提示"),MB_OK);
- }
- else
- {
- strcat(str_showAll,title);
- while(searchp!=NULL)
- {
- if(strcmp((searchp->department),str_depart)==)
- {
- flag =;
- showFormat(searchp);
- /* 如果 和比对的 字符串 相等的话 , 向前移动一个在进行比较 */
- searchp=searchp->next;
- }
- else
- {
- /* 如果 和比对的 字符串 不相等的话 , 向前移动一个在进行比较 */
- /* 注意这个不能漏,必定出错。 */
- searchp=searchp->next;
- }
- }
- SetDlgItemText(hWnd,,str_showAll);
- //searchp=headp->next;
- if(flag == )
- {
- MessageBox(NULL,TEXT("没有找到该部门的职工!"),TEXT("系统提示"),MB_OK);
- }
- }
- }
- /* 扩展功能 */
- void saveLocalFile()
- {
- int flag = ;
- FILE *fp;
- fp=fopen("C:\\workerDatabase.txt","w");
- if(fp==NULL)
- {
- MessageBox(NULL,TEXT("无法保存在本地!"),TEXT("系统警告"),MB_OK);
- exit();
- }
- worker *searchp;
- searchp=headp->next;
- if(searchp==NULL)
- {
- MessageBox(NULL,TEXT("职工信息为空!请先录入职工信息!"),TEXT("系统警告"),MB_OK);
- exit();
- }
- while(searchp!=NULL)
- {
- fprintf(fp,"%ld %s %s %s %d %d %d %ld\n",searchp->num,searchp->name,searchp->department,searchp->jobTitle,searchp->year,searchp->month,searchp->date,searchp->wage);
- searchp=searchp->next;
- flag = ;
- }
- fclose(fp);
- if(flag == )
- {
- MessageBox(NULL,TEXT("写入本地成功!"),TEXT("系统提示"),MB_OK);
- }
- else
- {
- MessageBox(NULL,TEXT("写入本地失败!"),TEXT("系统提示"),MB_OK);
- }
- }
- void readLocalFile()
- {
- FILE *p;
- int flag = ;
- struct worker *newworker;//用来保存读入的新职员
- struct worker *followp;//用来移动指针
- followp=headp;
- worker *shadowp;//定义一个影子指针 用来指向 倒数第二个节点。因为从文本读入的时候最后一行是空行,要丢弃。
- if((p=fopen("C:\\workerDatabase.txt","r"))==NULL)
- {
- MessageBox(NULL,TEXT("打开本地数据文件失败!"),TEXT("系统警告"),MB_OK);
- exit();
- }
- while(!feof(p))
- {
- newworker = (struct worker*)malloc(sizeof(struct worker ));
- fscanf(p,"%ld %s %s %s %d %d %d %ld",&newworker->num,newworker->name,newworker->department,newworker->jobTitle,&newworker->year,&newworker->month,&newworker->date,&newworker->wage);
- newworker->next = NULL;
- followp->next = newworker;
- shadowp = followp;
- followp = newworker;
- /* 在这里-842156451是用来标记一个未赋值的变量。利用这一点,来判断读取是否成功*/
- if(newworker->wage != -)
- {
- flag = ;
- }
- }
- /* 删除最后一个节点*/
- delete newworker;
- followp = shadowp;
- shadowp->next = NULL;
- if(flag == )
- {
- MessageBox(NULL,TEXT("从本地读取到程序成功!"),TEXT("系统提示"),MB_OK);
- }
- else
- {
- MessageBox(NULL,TEXT("从本地读取到程序失败"),TEXT("系统提示"),MB_OK);
- }
- fclose(p);
- }
- void statisticsInfo()
- {
- char temp1[],temp2[];
- int NumOfPeoCount=;
- double sumWage = ;
- double averageWage=;
- worker *searchp;
- searchp=headp->next;
- if(headp->next==NULL)
- {
- MessageBox(NULL,TEXT("请先输入职工信息!"),TEXT("系统提示"),MB_OK);
- }
- else
- {
- while(searchp!=NULL)
- {
- NumOfPeoCount++;
- sumWage += searchp->wage;
- searchp=searchp->next;
- }
- averageWage = sumWage/(double)NumOfPeoCount;
- ltoa(NumOfPeoCount,temp1,);
- ltoa(averageWage,temp2,);
- strcat(str_showAll,"总计有:");
- strcat(str_showAll,temp1);
- strcat(str_showAll,"人\t");
- strcat(str_showAll,"平均工资为:");
- strcat(str_showAll,temp2);
- strcat(str_showAll,"\t\n");
- SetDlgItemText(hWnd,,str_showAll);
- }
- }
resource.h头文件如下:
- /* INPUT NUMBER */
- #define NUM_INPUT 1
- #define NAME_INPUT 2
- #define DEPART_INPUT 3
- #define JOBTITLE_INPUT 4
- #define YEAR_INPUT 5
- #define WAGE_INPUT 6
- #define MONTH_INPUT 7
- #define DATE_INPUT 8
- #define BIGTEXTBOX 10
- /* BUTTON NUMBER */
- #define ADD_BUTTON 13
- #define SEARCHNUM_BUTTON 14
- #define MODIFY_BUTTON 15
- #define DELETE_BUTTON 16
- #define SHOWINFO_BUTTON 17
- #define SEARCHDEPART_BUTTON 18
- #define CLEARTEXT_BUTTON 19
- #define COPYRIGHT_BUTTON 20
- #define EXIT_BUTTON 21
- #define SAVELOCALFILE_BUTTON 100
- #define READLOCALFILE_BUTTON 101
- #define STATISTICS_BUTTON 111
C语言课程设计 Win32应用程序的更多相关文章
- C语言课程设计
目录 实现目的 游戏玩法介绍 实现流程与作品架构 任务列表及贡献度 总结感想 作品源码与仓库地址(附页) 资料引用与出处(附页) 实现目的 2048,作为一款极其经典的游戏,从发行到现在,已经有了极多 ...
- 学生管理系统-火车订票系统 c语言课程设计
概要: C 语言课程设计一---学生管理系统 使使用 C 语言实现学生管理系统.系统实现对学生的基本信息和考试成绩的 管理.采用终端命令界面,作为系统的输入输出界面.采用文件作为信息存储介质. 功能描 ...
- C语言课程设计—图书管理系统
这是本人大一第二学期初C语言课程设计的作品,嘿嘿,本来以为已经找不到原稿了,今天无意中居然在QQ网络硬盘中找到了当初的teta版,公布于此,以作纪念. C源码例如以下: #include<std ...
- Java语言课程设计——博客作业教学数据分析系统(201521123107 张翔)
#Java语言课程设计--博客作业教学数据分析系统(个人博客) 1.团队课程设计博客链接 [博客作业教学数据分析系统(From:网络五条狗)](http://www.cnblogs.com/fanta ...
- C语言课程设计(成绩管理系统)
C语言课程设计(成绩管理系统) 翻到了大学写的C语言课程设计,缅怀一下 内容: 增加学生成绩 查询学生成绩 删除 按照学生成绩进行排序 等 #include <stdio.h> #incl ...
- C语言课程设计大整数运算
该大整数运算系统用于对有符号的位数不超过500位的大整数进行加.减.乘.除四则运算和计算N(0<=N<=10000)的阶乘.注意事项 : 1.操作期间,进行四则运算时若大整数为正数请 ...
- 大一C语言课程设计——班级档案管理系统
记录我在大一第二学期期末做的C语言课程毕业设计 1. 班级档案管理系统运用到的主要结构体 typedef struct birthday //出生日期{int year;int month;int d ...
- C语言课程设计——电影院订票系统
1. 课题简介 大家都爱看电影,现请参考一个熟悉电影票预订系统,实现C语言版的订票系统.了解订票如何实现的.系统主要有2类用户:管理员用户和顾客用户. 管理员用户登录系统后,实现电影放映厅信息管理和电 ...
- 第一次 C语言课程设计
小学生测验 最近比较忙,就拿前几天做的课设项目水一水. 内容 面向小学1~2年级学生,随机选择两个整数和加减法形成算式要求学生解答. 功能要求: (1)电脑随机出10道题,每题10分,程序结束时显示学 ...
随机推荐
- Android服务开发经验——优雅地活着
大多数的Android应用开发都会将注意力集中在界面功能上,只有少数应用会需要一个Service,尤其是一个长期运行的Service,去进行后台联网.环境检测.媒体播放等功能.Android环境下的S ...
- WebActivator的实现原理详解
WebActivator的实现原理详解 文章内容 上篇文章,我们分析如何动态注册HttpModule的实现,本篇我们来分析一下通过上篇代码原理实现的WebActivator类库,WebActivato ...
- 在线试听功能(前端直接略过吧,适合javaEE后台开发的)
应用场景:录音试听,MP3试听... 比如为客户提供录音功能时.客户希望录音完成试听录音,然后下载等功能.直接上代码:关键是取得录音的在服务器的地址,如:url='http://localhost:8 ...
- Java中的嵌套类和内部类
以前看<Java编程思想>的时候,看到过嵌套类跟内部类的区别,不过后来就把它们的概念给忘了吧.昨天在看<数据结构与算法分析(Java语言版)>的时候,又遇到了这个概念,当时就很 ...
- c#二进制、十进制、16进制之间的转换
//十进制转二进制 Console.WriteLine(Convert.ToString(69, 2)); //十进制转八进制 Console.WriteLine(Convert.ToString(6 ...
- Memcached缓存入门篇
Asp.Net中使用Couchbase——Memcached缓存入门篇 前言 本文的主要目的就是简单的进行使用Memcached.这是Memchahed的官网http://memcached.org/ ...
- Microsoft Push Notification Service(MPNS)的最佳体验
如何获得 Microsoft Push Notification Service(MPNS)的最佳体验 有很多同学抱怨MPNS的各种问题,其中包括服务超时.返回各种错误代码不知如何处理等等..今天我用 ...
- Html Agility Pack解析HTML页
文章来源:Html Agility Pack解析HTML页 现在,在不少应用场合中都希望做到数据抓取,特别是基于网页部分的抓取.其实网页抓取的过程实际上是通过编程的方法,去抓取不同网站网页后,再进行分 ...
- C#程序调用cmd.exe执行命令
代码部分 using System.Diagnostics; public class CmdHelper { private static string CmdPath = @"C:\Wi ...
- MSSQL数据库迁移到Oracle
MSSQL数据库迁移到Oracle 最近要把一个MSSQL数据库迁移到Oracle上面,打算借助PowerDesigner这个软件来实现;今天简单研究一下这个软件的运用;把一步简单的操作步骤记录下来: ...