固定资产管理系统

公司固定资产管理系统,实现固定资产的增删改查

/* demo.cpp */
/* 主函数所在的源文件 */
#include"Asset.h"
#include"AssetList.h"
#include<windows.h>

AssetList al;
void showMain()
{
	cout<<"********************"<<endl;
	cout<<"固定资产管理系统"<<endl;
	cout<<"1---增加"<<endl;
	cout<<"2---删除"<<endl;
	cout<<"3---修改"<<endl;
	cout<<"4---查询"<<endl;
	cout<<"0---退出"<<endl;
	cout<<"********************"<<endl;
}
int FindPos(int id)
{
	int j;
	for(j=0;j<al.getListCnt();j++)
	{
		if(al.getListId(j) == id)
		{
			break;
		}
	}
	return j;
}
void Add()
{
	Asset a;
	a.InitAsset();
	al.AddList(a);
}
void Dele()
{
	int id;
	cout<<"请输入要删除的用户的编号!"<<endl;
	cin>>id;
	int j = FindPos(id);
	al.DeleList(j);
}
void Revise()
{
	int id;
	cout<<"请输入要修改的用户的编号!"<<endl;
	cin>>id;
	int j = FindPos(id);
	al.ReviseList(j);
}
void choice()
{
	int choose = 1;
	while(choose)
	{
		system("cls");
		showMain();
		cin>>choose;
		switch(choose)
		{
		case 1:Add();break;
		case 2:Dele();break;
		case 3:Revise();break;
		case 4:al.ShowList();break;
		case 0:break;
		default:break;
		}
		system("pause");
	}
}
int main()
{
	choice();
	return 0;
}

/* Asset.h */
/* Asset 头文件 */
#pragma once
#include<iostream>
#include<string>
using namespace std;

class Asset
{
private:
	int id;
	int number;
	string name;
	string owner;
	string user;
	string position;
	float price;
	static int cnt;
public:
	Asset();
	int getAssetId();
	void InitAsset();
	void ShowAsset();
};

/* AssetList.h */
/* AssetList 头文件 */
#pragma once
#include"Asset.h"

class AssetList
{
private:
	Asset list[100];
	static int cnt;
public:
	AssetList();
	int getListId(int j);
	int getListCnt();
	void AddList(Asset a);
	void DeleList(int j);
	void ReviseList(int j);
	void ShowList();
};


/* Asset.cpp */
/* Asset 的源文件 */

#include "Asset.h"

Asset::Asset()
{
	this -> id = 0;
	this -> number = 0;
	this -> price = 0;
}

int Asset::getAssetId()
{
	return id;
}

void Asset::InitAsset()
{
	cout<<"请输入编号:";
	cin>>this->id;
	cout<<"请输入名称:";
	cin>>this->name;
	cout<<"请输入位置:";
	cin>>this->position;
	cout<<"请输入所有者:";
	cin>>this->owner;
	cout<<"请输如使用者:";
	cin>>this->user;
	cout<<"请输入价值:";
	cin>>this->price;
	cout<<"请输入数量:";
	cin>>this->number;
}

void Asset::ShowAsset()
{
	cout<<this->id;
	cout<<"\t"<<this->name;
	cout<<"\t\t"<<this->position;
	cout<<"\t\t"<<this->owner;
	cout<<"\t"<<this->user;
	cout<<"\t"<<this->price; 
	cout<<"\t"<<this->number<<endl;
}
/* AssetList.cpp */
/* AssetList 的头文件 */

#include "AssetList.h"

int AssetList::cnt = 0;

AssetList::AssetList()
{
}

int AssetList::getListId(int j)
{
	return list[j].getAssetId();
}

int AssetList::getListCnt()
{
	return cnt;
}

void AssetList::AddList(Asset a)
{
	if(cnt>=100)
	{
		cout<<"列表已满!"<<endl;
	}
	else
	{
		list[cnt++] = a;
		cout<<"增加用户信息成功!"<<endl;
	}
}

void AssetList::DeleList(int j)
{
	if(cnt==0)
	{
		cout<<"列表为空!"<<endl;
	}
	else
	{
		for(int i=j;i<cnt;i++)
		{
			list[i] = list[i+1];
		}
		cnt--;
		cout<<"删除用户信息成功!"<<endl;
	}
}

void AssetList::ReviseList(int j)
{
	cout<<"请修改该用户的信息:"<<endl;
	list[j].InitAsset();
	cout<<"修改用户信息成功"<<endl;
}

void AssetList::ShowList()
{
	cout<<"编号\t名称\t\t位置\t\t所有者\t使用者\t价格\t数量"<<endl;
	for(int i=0;i<cnt;i++)
	{
		list[i].ShowAsset();
	}
	cout<<"查询用户信息成功!"<<endl;
}




展开阅读全文

没有更多推荐了,返回首页