| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 551 人关注过本帖
标题:求救啊!!跪求高手帮忙看下代码啊
只看楼主 加入收藏
xuyiming1987
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-12-26
收藏
 问题点数:0 回复次数:3 
求救啊!!跪求高手帮忙看下代码啊
#include<iostream>
#include<string>
#include<fstream>
using namespace std;

const N=20;  //部门最大数值

string Dname[N];
long Dnum[N];
string Djob[N];
string Dupname[N];

class department
{public:
string departmentname;
long departmentnum;
string departmentjob;
string departmentupname;
static long departmentMaxNum;

void Dadd();
void Dchange();
void Ddelete();
void Dshow();
void Dshownum(long number);
static int MaxNum();

};

class DBOperate
{
public:
string departmentname;
long departmentnum;
string departmentjob;
string departmentupname;
static long departmentMaxNum;

void WriteIn(int iflag);
void ReadOut();
void RefreshMaxNum(int iflag); //i=1 or -1 or 0
};

long department::departmentMaxNum = 1000; //部门编号由1000起


int department::MaxNum() //返回系统已经存储的人数
{
int MN = 0;
ifstream myf;
myf.open("departmentMaxNum.txt");
myf>>MN;
cout<<MN<<endl;
myf.close();
return MN;
}

void department::Dadd()
{cout<<"请输入部门名称: ";
cin>>department::departmentname;

cout<<"请输入部门职能: ";
cin>>department::departmentjob;

cout<<"请输入部门的上级部门: ";
cin>>department::departmentupname;

DBOperate dbo;
dbo.ReadOut();

int MaxNum = department::MaxNum();

Dnum[MaxNum]=department::departmentnum;
Dname[MaxNum]=department::departmentname;
Djob[MaxNum]=department::departmentjob;
Dupname[MaxNum]=department::departmentupname;


dbo.WriteIn(1);
cout<<" 添加新成员成功!"<<endl;

return;
}


void department::Dshow()
{ int i;
long number;
for(i=0;i<department::MaxNum();i++)
{
number = Dnum[i];
Dshownum(number);
} }

void department::Dshownum(long number) //按员工编号输出函数
{
int i;
for(i=0;i<department::MaxNum();i++)
{
if(Dnum[i] == number)
{cout<<"**********************************"<<endl;
cout<<"部门编号 >"<<Dnum[i]<<endl;
cout<<"部门名 >"<<Dname[i]<<endl;
cout<<"部门职能 >"<<Djob[i]<<endl;
cout<<"部门的上级部门 >"<<Dupname<<endl;
cout<<"**********************************"<<endl;
}
else continue;
}
}

void department::Dchange()
{int cNum = 1000;
DBOperate dbo;
dbo.ReadOut();
void department::Dshownum(long number);

cout<<"请输入您要修改的部门编号: >";
cin>>cNum;
int MN;
MN=department::MaxNum();

for(int i=0;i<MN;i++) //遍历数据文件,查找要修改的部门数据
{
if(Dnum[i] == cNum)
{
department::Dshownum(cNum);

cout<<"请输入该员工的新信息: "<<endl;
cout<<"新部门名: "; //录入部门新的数据,部门编号保持不变
cin>>department::departmentname;
Dname[i] = department::departmentname;

cout<<"请输入新的部门职能: ";
cin>>department::departmentjob;
Djob[i] = department::departmentjob;

cout<<"请输入新的部门的上级部门: ";
cin>>department::departmentupname;
Dupname[i] = department::departmentupname;
break;
}
}

dbo.WriteIn(0);
}

void department::Ddelete()
{{ char tmp;
int cNum = 1000;
DBOperate dbo;
dbo.ReadOut();
void department::Dshownum(long number);

cout<<"请输入您要删除的部门编号>: ";
cin>>cNum;
int MN;
MN = department::MaxNum();

for(int i=0;i<MN;i++) //遍历数据文件,查找要删除的部门
{
if(Dnum[i] == cNum)
department::Dshownum(cNum);
}

cout<<"确认要删除该部门信息?(Y为确认 N为放弃): ";
cin>>tmp;
if(tmp=='Y')
{
if(i==MN-1)
dbo.WriteIn(-1);
else
{
for(int j=i;j<MN-1;j++)
{ Dnum[j] = Dnum[j+1]; }
dbo.WriteIn(-1);
}

cout<<" 删除操作成功 ! "<<endl;
} }


void DBOperate::WriteIn(int iflag) //数据操作函数 写入
{DBOperate::RefreshMaxNum(iflag);
ofstream myf("department.txt");
department e;
int MN;
MN = e.MaxNum();
for(int i=0;i<MN;i++)
{
myf<<Dnum[i]<<'\n'<<Dname[i]<<'\n'<<Djob[i]<<'\n'<<Dupname[i]<<'\n';
}
myf.close();

}

void DBOperate::ReadOut() //数据操作函数 读出
{ifstream myf("department.txt");

department e;
int MN;
MN = e.MaxNum();
for(int i=0 ;i<MN;i++)
{
myf>>DBOperate::departmentnum>>DBOperate::departmentname>>DBOperate::departmentjob>>DBOperate::departmentupname;

Dnum[i] = DBOperate::departmentnum;
Dname[i] = DBOperate::departmentname;
Djob[i] = DBOperate::departmentjob;
Dupname[i] = DBOperate::departmentupname;
}
myf.close();
}



void DBOperate::RefreshMaxNum(int iflag) //更新系统中员工计数文件的函数
{
int MaxNum = 0;
ifstream myif("departmentMaxNum.txt");
myif>>MaxNum;
myif.close();
MaxNum = MaxNum+iflag;
ofstream myof("departmentMaxNum.txt");
myof<<MaxNum;
myof.close();
}


int main() //主函数
{
system("color 05f");

int select=0;
while(select!=8)
{

cout<<" ╭————————————《主菜单》———————————╮"<<endl;
cout<<" ∣ 请选择功能 ∣"<<endl;
cout<<" ├————————————————————————————┤"<<endl;
cout<<" ∣ 1.部门信息管理功能 ∣"<<endl;
cout<<" ∣ 2.员工基本信息管理功能 ∣"<<endl;
cout<<" ∣ 3.员工主要学习与工作经历管理功能 ∣"<<endl;
cout<<" ∣ 4.员工考勤管理功能 ∣"<<endl;
cout<<" ∣ 5.员工工作考评管理功能 ∣"<<endl;
cout<<" ∣ 6.员工工资管理功能  ∣"<<endl;
cout<<" ∣ 7.系统用户管理功能 ∣"<<endl;
cout<<" ∣ 8.退出 ∣"<<endl;
cout<<" ╰————————————————————————————╯"<<endl;
cout<<" ——————————————————————————————"<<endl;
cout<<" 请选择您要服务的类别: " ;
cin>>select;

switch(select)
{
case 1:
{int select1 = 0;
while(select1!=5)
{

cout<<" ╭————————————《部门菜单》———————————╮"<<endl;
cout<<" ∣ 请选择功能 ∣"<<endl;
cout<<" ├————————————————————————————┤"<<endl;
cout<<" ∣ 1.新建并输入部门数据 ∣"<<endl;
cout<<" ∣ 2.修改指定部门数据 ∣"<<endl;
cout<<" ∣ 3.删除指定部门的数据 ∣"<<endl;
cout<<" ∣ 4.查询指定部门数据 ∣"<<endl;
cout<<" ∣ 5.退出 ∣"<<endl;
cout<<" ╰————————————————————————————╯"<<endl;
cout<<" ——————————————————————————————"<<endl;
cout<<" 请选择您要服务的类别: " ;
cin>>select1;

department e;
DBOperate dbo;

switch(select1)
{
case 1:
e.Dadd(); break;
case 2:
dbo.ReadOut();
e.Dchange(); break;
case 3:
e.Ddelete(); break;
case 4:
e.Dshow(); break;
case 5: break;
default:
cout<<"命令错误!"<<endl;
}

if(select == 5)
break;
}

exit(1);
return 0;
}}; break;


case 2: break;
case 3:  break;
case 4: break;
case 5: break;
case 6:break;
case 7:break;
default:
cout<<"命令错误!"<<endl;
}

if(select == 8)
break;
} }




----------------------------------------------------------------------------------
怎么总说我RefreshMaxNum  ReadOut   WriteIn三个函数有问题啊
搜索更多相关主题的帖子: 代码 
2007-12-26 17:37
随风逐流
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:passerby
等 级:版主
威 望:8
帖 子:4054
专家分:271
注 册:2007-6-13
收藏
得分:0 
发错地方了,转移.

[url=http://www./html/6/6694/]极道金丹[/url][url=http://www./html/2/2849/]九阴九阳[/url][url=http://www./html/2/2596/]凡人修仙传[/url]
2007-12-26 17:40
随风逐流
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:passerby
等 级:版主
威 望:8
帖 子:4054
专家分:271
注 册:2007-6-13
收藏
得分:0 
这是C#还是C++?

[url=http://www./html/6/6694/]极道金丹[/url][url=http://www./html/2/2849/]九阴九阳[/url][url=http://www./html/2/2596/]凡人修仙传[/url]
2007-12-26 17:46
andey
Rank: 2
等 级:新手上路
威 望:4
帖 子:938
专家分:0
注 册:2007-7-18
收藏
得分:0 
貌似不是C#

msdn == 葵花宝典!!!
QQ:122768959
2007-12-26 17:54
快速回复:求救啊!!跪求高手帮忙看下代码啊
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016914 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved