图书管理系统

1.概述

1.1 设计内容

本设计是用VS环境完成的一个书店管理系统,运用所学C++语言知识,通过对菜单项中2功能键的调用,输入密码登录系统开始,不仅实现了对书本管理,销售管理,退货管理,用户管理和收入统计等基本要求,同时增加了登录系统设置,权限管理,密码修改和订单管理及GDI+等创新亮点,以便于整个书店管理系统功能更加完善,使得本次程序设计更丰富。

1.2 问题分析

1.2.1 主要要求:

  1. 书店管理:实现书本信息数据的录入、修改、查询,可以实现多种查询方式,如按类型查询,按名称查询,按价格查询等。

(2)销售管理:书本信息查询以及实现书本销售,库存动态变化,顾客根据vip等级享受折扣。

(3)退货管理:根据顾客姓名或者订单等查询,并实现退货。

(4)收入统计:统计可以实现按日、月统计收入信息。

(5)用户管理:增加、注销顾客信息,增加或修改管理员信息。

1.2.2 需求分析

根据书店的需求,书店的日常,主要分为5种情况:

进货:每一本图书,都有着图书类型,图书价格,图书出版商,图书的版本等图书的信息,筛选好图书然后整理好图书信息,才能进货。

入库:将图书进货后,需要确定图书是否在库中已有,如果没有此类的图书信息,需要将图书的基本信息存入库中,并且添加入库的图书的数量;如果有相同的图书信息,则不需要录入图书信息,而直接更新图书的现有数量。

销售:销售出去的书也要记录书的信息,确定好书籍的信息才能记录并售出。

出库:对于销售出去的书籍要及时更新数据,对现有的书籍数量进行更新检查,并且记录销售记录,以便为以后的进货作参考,如果书籍售空,这可以提醒操作员进货

退货:对于销售出去的书籍,可以实现退货。

表1 管理员

属性

字段名

数据类型

主键、非空说明

用户名

uname

varchar

主键且非空

密码

pas

varchar

表2 书本信息

属性

字段名

数据类型

主键、非空说明

ISBN

bookIsbn

varchar

主键且非空

书名

bookName

varchar

非空

作者

bookAuthor

varchar

种类

bookType

varchar

进价

bookinPrice

float

零售价

bookPrice

float

出版社

bookPublisher

varchar

库存

bookCount

int

表3 销售信息

属性

字段名

数据类型

主键、非空说明

序号

num

int

主键且非空

销售单号

saleId

varchar

非空

销售日期

saleDate

varchar

ISBN

bookIsbn

varchar

非空

书名

bookName

varchar

非空

销售量

booksaleCount

int

零售价

salePrice

float

折后价

countprice

float

顾客姓名

VipName

varchar

表4 顾客信息

属性

字段名

数据类型

主键、非空说明

编号

vipId

varchar

主键且非空

等级

vipLevel

int

非空

姓名

vipName

varchar

非空

性别

vipSex

varchar

年龄

vipAge

varchar

电话

vipTel

varchar

1.3 系统功能及要求

1.3.1 主要功能:

(1)系统有登录界面。

(2)能够进行入库,退货等功能。

(3)能查看,修改及删除订单。

(4)能实现书本信息数据的录入、修改、查询,查看和删除,并满足多种查询方式。

(5)能多种方式进行查看、统计销售情况,并导出到文件。

(6)能实现修改登录密码。

1.3.2 程序要求:

(1)能够实现任务书中的功能;

(2)尽可能使界面友好,直观,易操作,没有bug;

(3)源程序要有适当的注释,使程序容易阅读。

2.总体设计

2.1 系统功能

书店管理系统,主要为商家提供完整的系统来管理日常流水,设置管理员和顾客信息的添加和修改;本系统主要包括六方面,分别是登录界面,书本管理,销售管理,退货管理,用户管理以及退出系统。

2.2 系统模块

根据设计需求系统包括四个大模块:登录界面,页面操作,用户管理以及退出系统。

3.详细设计

3.1 登录系统

3.1.1 原始函数

afx_msg void OnBnClickedOk();

bool bpassflag;

virtual BOOL OnInitDialog();

3.1.2 功能

登入书店系统,输入密码以管理员身份登录,操作所有功能。从数据库查询用户名与密码,若存在,则登录成功。若错误三次,自动退出登录界面。

3.1.3 说明

void LoginDlg::OnBnClickedOk()

{

CString strname,strpsw,strsql;

GetDlgItem(IDC_EDIT1)->GetWindowTextA(strname);

GetDlgItem(IDC_EDIT2)->GetWindowTextA(strpsw);

if(strname.TrimRight()=="")

{

AfxMessageBox("请输入用户名");

return ;

}

if(strpsw.TrimRight()=="")

{

AfxMessageBox("请输入密码");

return;

}

strsql.Format("select * from usert where uname='%s' and pas='%s'",strname,strpsw);

vector< vector<string> >AllInfo;

if(!theApp.smysql.Select(strsql.GetBuffer(),AllInfo))

AfxMessageBox(theApp.smysql.ErrorInfo);//失败的提示信息

if(AllInfo.size()!=0)

bpassflag=true;

CDialogEx::OnOK();

}

3.2 书店管理

3.2.1 原始函数

afx_msg void OnBnClickedButton1();

afx_msg void OnBnClickedButton2();

afx_msg void OnBnClickedButton3();

CListCtrl m_comb;

virtual BOOL OnInitDialog();

void showdata();

void showlist();

CComboBox m_con;

afx_msg void OnBnClickedButton4();

afx_msg void OnBnClickedButton7();

afx_msg void OnClickList2(NMHDR *pNMHDR, LRESULT *pResult);

3.2.2 功能

实现书本信息的添加,删除,修改以及多个数据的模糊查询等。

3.2.4 说明

void DBDlg::OnBnClickedButton1()//查询

{

// TODO: 在此添加控件通知处理程序代码

CString strc,strtext,strsql,strs[8]={"bookIsbn","bookName","bookAuthor","bookType",

"bookinPrice","bookPrice","bookPublisher","bookCount"};

m_con.GetWindowTextA(strc);

GetDlgItem(IDC_EDIT1)->GetWindowTextA(strtext);

strtext.TrimLeft();

if(strtext=="")

strsql.Format("select * from book");

else

{

if(strc=="无")

strsql.Format("select * from book where bookIsbn like '%%%s%%' or bookName like '%%%s%%' or bookAuthor like '%%%s%%' or bookType like '%%%s%%' or bookinPrice= %f or bookPrice= %f or bookPublisher like '%%%s%%' or bookCount = %d",strtext,strtext,strtext,strtext,atof(strtext),atof(strtext),strtext,atoi(strtext));//省略

3.3 销售管理

3.3.1 原始函数

virtual BOOL OnInitDialog();

afx_msg void OnBnClickedButton4();

afx_msg void OnBnClickedButton1();

afx_msg void OnBnClickedButton2();

afx_msg void OnBnClickedButton3();

void showdata();

void showlist();

void showshop();

afx_msg void OnClickList4(NMHDR *pNMHDR, LRESULT *pResult);

afx_msg void OnChangeEdit8();

afx_msg void OnKillfocusEdit10();

afx_msg void OnBnClickedButton7();

afx_msg void OnBnClickedButton8();

afx_msg void OnBnClickedButton9();

3.3.2 功能

实现书本销售的查询,销售量自由加减,销售金额计算,销售信息录入,实现库存动态改变。

3.3.4 说明

void Shopdlg::OnBnClickedButton8()//确认

{

// TODO: 在此添加控件通知处理程序代码

CString sql,name,id,str,level,str5,c;

float price=0;

CString row="SELECT COUNT(*) FROM sale";

theApp.smysql.Select(row.GetBuffer(),rowInfo);

c=rowInfo[0][0].c_str();

count=atoi(c);

CTime tm;

m_date.GetTime(tm);

CString strDate=tm.Format("%Y-%m-%d");//CTime->CString

GetDlgItem(IDC_EDIT11)->GetWindowTextA(name);

GetDlgItem(IDC_EDIT12)->GetWindowTextA(level);

int ncount = m_list.GetItemCount();

str.Format(_T("%d"),m);

id=strDate+str;

//遍历每一行

for (int i = 0; i <ncount; i++)

{

CString str1 = m_list.GetItemText(i, 0);

CString str2 = m_list.GetItemText(i, 1);

CString str3 = m_list.GetItemText(i, 6);

CString str4 = m_list.GetItemText(i, 7);

if(atoi(level)==1)

price=atof(str4)*0.7;

else if(atoi(level)==2)

price=atof(str4)*0.8;

else if(atoi(level)==3)

price=atof(str4)*0.9;

str5.Format(_T("%.2f"),price);

sql.Format("insert into sale values('%d','%s','%s','%s','%s','%d','%.2f','%.2f','%s')",++count,id,strDate,str1,str2,atoi(str3),atof(str4),atof(str5),name);//省略

3.4 退货管理

3.4.1 原始函数

void showdata();

void showlist();

void SetTitle();

afx_msg void OnBnClickedButton1();

afx_msg void OnBnClickedButton4();

afx_msg void OnBnClickedButton2();

afx_msg void OnBnClickedButton3();

afx_msg void OnBnClickedButton7();

afx_msg void OnBnClickedButton10();

afx_msg void OnClickList4(NMHDR *pNMHDR, LRESULT *pResult);

CSpinButtonCtrl m_spin;

afx_msg void OnChangeEdit8();

3.4.2 功能

实现书本根据购买人或者书本名称等模糊查询,进行退货管理,可决定退货量,实现库存动态改变。

3.4.4 说明

void InfoDlg::OnBnClickedButton10()//确认

{

// TODO: 在此添加控件通知处理程序代码

CString sql;

int ncount = m_list.GetItemCount();

//遍历每一行

for (int i = 0; i <ncount; i++)

{

CString str1 = m_list.GetItemText(i, 0);

CString str2 = m_list.GetItemText(i, 1);

CString str3 = m_list.GetItemText(i, 3);

CString str4 = m_list.GetItemText(i, 6);

if(atoi(str3)==atoi(str4))

sql.Format("delete from sale where bookIsbn='%s' and saleId='%s'",str2,str1);

else

sql.Format("update sale set bookSaleCount='%d' where bookIsbn='%s' and saleId='%s'",atoi(str3)-atoi(str4),str2,str1);

theApp.smysql.Query(sql.GetBuffer());

}

theApp.smysql.Query(sql.GetBuffer());

AfxMessageBox("退货成功!");

sql.Format("select * from sale");

AllInfo.clear();

theApp.smysql.Select(sql.GetBuffer(),AllInfo);

showlist();

m_list.DeleteAllItems();

}//省略

3.5 统计管理

3.5.1 原始函数

afx_msg void OnBnClickedButton1();

afx_msg void OnBnClickedButton2();

afx_msg void OnBnClickedButton3();

virtual BOOL OnInitDialog();

void SetTitle();

void showdata();

void showlist();

void AutoAdjustColumnWidth(CListCtrl *pListCtrl);

BOOL ExportAsCSV(CString& fileName);

CListCtrl m_list;

CStatic day;

afx_msg void OnClickedCheck1();

afx_msg void OnBnClickedButton4();

3.5.2 功能

实现统计根据日期和书名等的查询,以及把数据导入到CSV文件。

3.5.4 说明

void Filedlg::OnBnClickedButton1()//统计

{

// TODO: 在此添加控件通知处理程序代码

CString strc,month,day,strsql,text,date;

int state =((CButton *)GetDlgItem(IDC_CHECK1))->GetCheck();

m_mon.GetWindowTextA(month);

m_day.GetWindowTextA(day);

if(atoi(month)<10)

month='0'+month;

if(atoi(day)<10)

day='0'+day;

GetDlgItem(IDC_BUTTON2)->GetWindowTextA(text);

if(text=="切换到日统计" && state==1)

{

date="2023-"+month;

m_com.GetWindowTextA(strc);

strsql.Format("select * from sale where saleDate like '%%%s%%' and bookName like '%%%s%%'",date,strc);

}

else if(text=="切换到日统计" && state==0)

{

date="2023-"+month;

strsql.Format("select * from sale where saleDate like '%%%s%%'",date);

}//省略

3.6 用户管理

3.6.1 原始函数

afx_msg void OnBnClickedButton1();

afx_msg void OnBnClickedButton2();

afx_msg void OnBnClickedButton3();

afx_msg void OnBnClickedButton4();

virtual BOOL OnInitDialog();

afx_msg void OnKillfocusEdit5();

3.6.2 功能

实现管理员修改密码,添加,以及对顾客信息的录入以及注销。

3.6.4 说明

int rowc;

void Userdlg::OnBnClickedButton1()//添加

{

// TODO: 在此添加控件通知处理程序代码

CString sql,name,id,str,level,c,sex,tel,age;

CString row="SELECT COUNT(*) FROM vip";

theApp.smysql.Select(row.GetBuffer(),AllInfo);

c=AllInfo[0][0].c_str();

rowc=atoi(c);

id.Format("%d",++rowc);

GetDlgItem(IDC_EDIT1)->GetWindowTextA(name);

GetDlgItem(IDC_EDIT2)->GetWindowTextA(age);

GetDlgItem(IDC_EDIT3)->GetWindowTextA(tel);

GetDlgItem(IDC_EDIT4)->GetWindowTextA(level);

if(((CButton *)GetDlgItem(IDC_RADIO1))->GetCheck()==1)

sex="男";

else

sex="女";

sql.Format("insert into vip values('%s','%d','%s','%s','%s','%s')",id,atoi(level),name,sex,age,tel);

if(theApp.smysql.Query(sql.GetBuffer()))

MessageBox("添加成功,您的ID号为:"+id);

else

MessageBox("添加失败");

}//省略

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ଲଇଉକ ଲ ̊ଳ

多谢大哥赏赐

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值