addadd函数是在窗口输入用户数据的
add()函数窗口的整体控制
为什么我刷新屏幕的时候窗口会自动落到电脑下面显示不到,必须用鼠标拖出来才可以看见
而且如果我addadd函数里面由InputBox的话,这时窗口根本无法拖上来 不知道为啥
void peoplelist:: addadd()
{
fstream in, out;
struct People m1;
in.open("staffs.dat", ios::binary | ios::app | ios::out);
out.open("staffs.dat", ios::binary | ios::in);
if (!in)
{
cout << "文件打开失败" << endl;
exit(0);
}
if (!out)
{
cout << "文件打开失败" << endl;
exit(0);
}
initgraph(1000, 620);
setfillcolor(WHITE);
setbkcolor(WHITE);
cleardevice();
setfillcolor(BLUE);
setbkcolor(RGB(176, 224, 230));
clearrectangle(0, 0, 300, 1000);
setbkcolor(RGB(25, 25, 112));
clearroundrect(50, 10, 250, 100, 50, 50);
clearroundrect(50, 110, 250, 200, 50, 50);
clearroundrect(50, 210, 250, 300, 50, 50);
clearroundrect(50, 310, 250, 400, 50, 50);
clearroundrect(50, 410, 250, 500, 50, 50);
clearroundrect(50, 510, 250, 600, 50, 50);
clearroundrect(750, 410, 950, 500, 50, 50);//退出添加
clearroundrect(750, 310, 950, 400, 50, 50);//继续添加
clearroundrect(750, 510, 950, 600, 50, 50);//退出系统
settextstyle(32, 15, _T("Consolas"));
outtextxy(90, 40, _T("增加员工"));
outtextxy(90, 140, _T("删除员工"));
outtextxy(90, 240, _T("修改员工"));
outtextxy(90, 340, _T("查找员工"));
outtextxy(65, 440, _T("显示所有员工"));
outtextxy(65, 540, _T("删除所有员工"));
outtextxy(790, 440, _T("退出添加"));
outtextxy(790, 340, _T("继续添加"));
outtextxy(790, 540, _T("退出系统"));
setbkmode(TRANSPARENT);
settextcolor(BLACK);
settextstyle(64, 40, _T("Consolas"));
outtextxy(400, 40, _T("添加员工信息"));
InputBox(m1.name, 10, "请输入姓 名");
InputBox(m1.sex, 5, "请输入性别");
InputBox(m1.id, 20, "请输入身份证号");
InputBox(m1.telephone, 15, "请输入电话号码");
InputBox(m1.birthday, 20, "请输入出生年份");
InputBox(m1.number, 20, "请输入工作证号");
InputBox(m1.address, 100, "请输入家庭地址");
InputBox(m1.salary, 10, "请输入薪水");
InputBox(m1.post, 20, "请输入职务");
InputBox(m1.department, 30, "请输入工作部门");
in.write((char*)&m1, sizeof(m1));
in.close();
struct People m2 = m1;
settextstyle(32, 15, _T("Consolas"));//32 gao 15chang
outtextxy(400, 200, _T("您所要添加的员工信息如下:"));
outtextxy(400, 232, _T("姓 名:"));
outtextxy(550, 232, _T(m2.name));
outtextxy(400, 264, _T("性 别:"));
outtextxy(550, 264, _T(m2.sex));
outtextxy(400, 292, _T("身份证号:"));
outtextxy(550, 292, _T(m2.id));
outtextxy(400, 328, _T("出生年份:"));
outtextxy(550, 328, _T(m2.birthday));
outtextxy(400, 360, _T("工作证号:"));
outtextxy(550, 360, _T(m2.number));
outtextxy(400, 392, _T("家庭住址:"));
outtextxy(550, 392, _T(m2.address));
outtextxy(400, 424, _T("薪 水:"));
outtextxy(550, 424, _T(m2.salary));
outtextxy(400, 456, _T("职 务:"));
outtextxy(550, 456, _T(m2.post));
outtextxy(400, 488, _T("工作部门:"));
outtextxy(550, 488, _T(m2.department));
outtextxy(400, 520, _T("该员工的信息存储成功"));
}
void peoplelist::add()
{
MOUSEMSG msg,msg1;
initgraph(1000, 620);
setbkcolor(WHITE);
cleardevice();
setfillcolor(BLUE);
setbkcolor(RGB(176, 224, 230));
clearrectangle(0, 0, 300, 1000);
setbkcolor(RGB(25, 25, 112));
clearroundrect(50, 10, 250, 100, 50, 50);
clearroundrect(50, 110, 250, 200, 50, 50);
clearroundrect(50, 210, 250, 300, 50, 50);
clearroundrect(50, 310, 250, 400, 50, 50);
clearroundrect(50, 410, 250, 500, 50, 50);
clearroundrect(50, 510, 250, 600, 50, 50);
clearroundrect(750, 510, 950, 600, 50, 50);
settextstyle(32, 15, _T("Consolas"));
outtextxy(90, 40, _T("增加员工"));
outtextxy(90, 140, _T("删除员工"));
outtextxy(90, 240, _T("修改员工"));
outtextxy(90, 340, _T("查找员工"));
outtextxy(65, 440, _T("显示所有员工"));
outtextxy(65, 540, _T("删除所有员工"));
outtextxy(790, 540, _T("退出系统"));
setbkmode(TRANSPARENT);
settextcolor(BLACK);
settextstyle(64, 40, _T("Consolas"));
outtextxy(400, 40, _T("人事管理系统"));
settextstyle(32, 15, _T("Consolas"));
outtextxy(400, 300, _T("欢迎来到人事管理系统"));
outtextxy(400, 332, _T("该系统目前有左侧六大功能"));
outtextxy(400, 364, _T("根据您的要求点击相应功能即可"));
outtextxy(400, 396, _T("希望您愉快使用该系统,谢谢配合!"));
while (1)
{
if (MouseHit())//有鼠标操作消息返回真
{
msg = GetMouseMsg();//获取鼠标信息
switch (msg.uMsg)//消息分发
{
case WM_LBUTTONDOWN:
if (msg.x >= 50 && msg.x <= 250 && msg.y >= 10 && msg.y <= 100)
{
addadd();
while (1)
{
if (MouseHit())
{
msg1 = GetMouseMsg();
switch (msg1.uMsg)
{
case WM_LBUTTONDOWN:
if (msg1.x >= 750 && msg1.x <= 950 && msg1.y >= 310 && msg1.y <= 400)
{
addadd();
}
if (msg1.x >= 750 && msg1.x <= 950 && msg1.y >= 410 && msg1.y <= 500)
{
add();
}
if (msg1.x >= 750 && msg1.x <= 950 && msg1.y >= 510 && msg1.y <= 600)
{
exit(0);
}break;
default:break;
}
}
}
}break;
default:break;
}
}
}
}