📄 functionlib.c
字号:
// 0. 返回后台管理界面
}
break;
}
if(BUTTONID==res)
{
break;
}
}
while (1);
DelMyWindow(pAccountMgr);
scr_restore("SaveScr.scr");
}
/**********************************************************
Function:销售记录管理模块
Param:无
return :无
***********************************************************/
void SellRecord() // 销售记录管理模块
{
scr_dump("SaveScr.scr");
MyWindow * pSellRecord=NULL;
pSellRecord=MakeMyWindow(pSellRecord);
pSellRecord->m_color=WHITE_BLUE;
pSellRecord->m_sizex=78; // 30
pSellRecord->m_sizey=25; // 12
pSellRecord->m_px=1;
pSellRecord->m_py=1;
int sizex=pSellRecord->m_sizex;
int sizey=pSellRecord->m_sizey;
ChangeMyWindow(&pSellRecord);
DrawWords(pSellRecord,2,(sizex-strlen("销售管理"))/2,"销售管理");
Button * pItem1=NULL;
pItem1=MakeButton(pItem1);
strcpy(pItem1->m_name,"1. 按销售日期查询");
pItem1->m_kind=YESBUTTON;
pItem1->m_isbox=FALSE;
pItem1->m_buttonid=BUTTONID+1;
pItem1->m_sizex=20;
pItem1->m_sizey=1;
pItem1->m_color_foot=WHITE_BLUE;
pItem1->ChangeButton(&pItem1);
Button * pItem2=NULL;
pItem2=MakeButton(pItem2);
strcpy(pItem2->m_name,"2. 按员工ID查询");
pItem2->m_kind=YESBUTTON;
pItem2->m_isbox=FALSE;
pItem2->m_buttonid=BUTTONID+2;
pItem2->m_sizex=20;
pItem2->m_sizey=1;
pItem2->m_color_foot=WHITE_BLUE;
pItem2->ChangeButton(&pItem2);
Button * pItem0=NULL;
pItem0=MakeButton(pItem0);
strcpy(pItem0->m_name,"0. 返回后台管理界面");
pItem0->m_kind=YESBUTTON;
pItem0->m_isbox=FALSE;
pItem0->m_buttonid=BUTTONID;
pItem0->m_sizex=20;
pItem0->m_sizey=1;
pItem0->m_color_foot=WHITE_BLUE;
pItem0->ChangeButton(&pItem0);
AddActiveElement(pSellRecord,pItem1,ISBUTTON,5,30);
AddActiveElement(pSellRecord,pItem2,ISBUTTON,8,30);
AddActiveElement(pSellRecord,pItem0,ISBUTTON,11,30);
int res=0;
do
{
res=0;
ShowMyWindow(pSellRecord);
res=RunMyWindow(pSellRecord);
switch(res)
{
case BUTTONID+1:
{
// 按销售日期查询
SearchByData();
}
break;
case BUTTONID+2:
{
// 按员工ID查询
SearchByAccId();
}
break;
case BUTTONID:
{
// 0. 返回后台管理界面
}
break;
}
if(BUTTONID==res)
{
break;
}
}
while (1);
DelMyWindow(pSellRecord);
scr_restore("SaveScr.scr");
}
/**********************************************************
Function:查询商品
Param:无
return :无
***********************************************************/
void SearchCommodity() // 查询商品
{
scr_dump("SaveScr3.scr");
werase(stdscr);
refresh();
int y=0,x=0;
getmaxyx(stdscr,y,x);
box(stdscr,0,0);
mvprintw(0,32,"欢迎光临xxx超市");
mvprintw(2,36,"查询商品");
mvhline(3,1,ACS_S3,78);
mvprintw(4,1,"序列");
mvprintw(4,7,"条形码");
mvprintw(4,17,"商品名");
mvprintw(4,34,"单位");
mvprintw(4,40,"规格");
mvprintw(4,46,"销售价格");
mvprintw(4,57,"进货价格");
mvprintw(4,66,"数量");
mvprintw(4,72,"折扣");
mvhline(5,1,ACS_S3,78);
WINDOW * pnewin=newwin(15,78,6,1);
mvhline(21,1,ACS_S3,78);
mvprintw(22,6,"第一页[Home]");
mvprintw(22,21,"上一页[PageUp]");
mvprintw(22,39,"下一页[PageDown]");
mvprintw(22,60,"最后一页[END]");
mvprintw(24,6,"当前页[%d]",1);
mvprintw(24,25,"跳转到第[ ]页");
mvprintw(24,59,"退出 [ F2 ]");
refresh();
C_CLASS LINKLIST link;
link_init(&link);
SelectGoods(&link);
TextBox * pRealText=NULL;
pRealText=MakeTextBox(pRealText);
pRealText->m_strmaxlen=2;
strcpy(pRealText->m_str,"1");
pRealText->m_spc.s_sizex=2;
pRealText->m_spc.s_px=34;
pRealText->m_spc.s_py=24;
pRealText->m_isInteger=TRUE;
pRealText->m_isPasswd=FALSE;
pRealText->m_isFn2_9=TRUE;
ChangeTextBox(&pRealText);
ShowTextBox(pRealText);
int total=link.count;
int totalpage=(link.count%15)?(link.count/15+1):(link.count/15);
int begin=1;
int current=1;
int key;
int choicepage=1;
int flag=0;
do
{
flag=0;
werase(pnewin);
PrintOneView(&link,pnewin,begin,current,PrintProcutInfo);
key=InputString(pRealText);
switch(key)
{
case 10:
{
choicepage=atoi(pRealText->m_str);
if (choicepage>totalpage || choicepage<=0)
{
char temp[20];
sprintf(temp,"请输入[1-%d]范围",totalpage);
MessageBox("提示",temp,NOBTN);
}
else
{
begin=(choicepage-1)*15+1;
current=(choicepage-1)*15+1;
werase(pnewin);
wrefresh(pnewin);
}
}
break;
case KEY_UP:
case KEY_PPAGE:
{
begin=begin-15;
if(begin<=0)
{
begin=1;
}
current=begin;
}
break;
case KEY_DOWN:
case KEY_NPAGE:
{
if (link.count<=15)
{
}
else
{
begin=begin+15;
if(begin>(link.count))
{
begin=link.count-14;
}
current=begin;
}
}
break;
case KEY_HOME:
{
begin=1;
current=1;
}
break;
case KEY_END:
{
begin=link.count-14;
current=begin;
}
break;
case KEY_F(2):
{
flag=1;
}
}
if (1==flag)
{
break;
}
}while (1);
scr_restore("SaveScr3.scr");
}
/*******************************************
Function:添加商品模块
PRARM:无
return:无
*******************************************/
void AddCommodity() // 添加商品
{
scr_dump("SaveScr2.scr");
MyWindow * pAddCommodity=NULL;
pAddCommodity=MakeMyWindow(pAddCommodity);
pAddCommodity->m_color=WHITE_BLUE;
pAddCommodity->m_sizex=78; // 30
pAddCommodity->m_sizey=25; // 12
pAddCommodity->m_px=1;
pAddCommodity->m_py=1;
int sizex=pAddCommodity->m_sizex;
int sizey=pAddCommodity->m_sizey;
ChangeMyWindow(&pAddCommodity);
DrawWords(pAddCommodity,0,(sizex-strlen("欢迎光临XXX超市"))/2,"欢迎光临XXX超市");
DrawWords(pAddCommodity,2,(sizex-strlen("添加商品"))/2,"添加商品");
DrawWords(pAddCommodity,4,10,"条形码:");
DrawWords(pAddCommodity,6,12,"名称:");
DrawWords(pAddCommodity,8,12,"单位:");
DrawWords(pAddCommodity,10,12,"规格:");
DrawWords(pAddCommodity,12,12,"售价:");
DrawWords(pAddCommodity,14,8,"进货进价:");
DrawWords(pAddCommodity,16,12,"折扣:");
DrawWords(pAddCommodity,18,12,"数量:");
// 条形码
TextBox * pBarCodeText=NULL;
pBarCodeText=MakeTextBox(pBarCodeText);
pBarCodeText->m_spc.s_py=21;
pBarCodeText->m_spc.s_px=9;
pBarCodeText->m_spc.s_sizex=30;
strcpy(pBarCodeText->m_title,"CN");
pBarCodeText->m_strmaxlen=6;
pBarCodeText->m_isInteger=TRUE;
pBarCodeText->m_isPasswd=FALSE;
pBarCodeText->m_isFn2_9=FALSE;
ChangeTextBox(&pBarCodeText);
// 名称
TextBox * pNameText=NULL;
pNameText=MakeTextBox(pNameText);
pNameText->m_spc.s_py=21;
pNameText->m_spc.s_px=9;
pNameText->m_spc.s_sizex=30;
pNameText->m_strmaxlen=29;
pNameText->m_isInteger=FALSE;
pNameText->m_isPasswd=FALSE;
pNameText->m_isFn2_9=FALSE;
ChangeTextBox(&pNameText);
// 单位
TextBox * pUnitText=NULL;
pUnitText=MakeTextBox(pUnitText);
pUnitText->m_spc.s_py=21;
pUnitText->m_spc.s_px=9;
pUnitText->m_spc.s_sizex=30;
pUnitText->m_strmaxlen=8;
pUnitText->m_isInteger=FALSE;
pUnitText->m_isPasswd=FALSE;
pUnitText->m_isFn2_9=FALSE;
ChangeTextBox(&pUnitText);
// 规格
TextBox * pSpecText=NULL;
pSpecText=MakeTextBox(pSpecText);
pSpecText->m_spc.s_py=21;
pSpecText->m_spc.s_px=9;
pSpecText->m_spc.s_sizex=30;
pSpecText->m_strmaxlen=8;
pSpecText->m_isInteger=FALSE;
pSpecText->m_isPasswd=FALSE;
pSpecText->m_isFn2_9=FALSE;
ChangeTextBox(&pSpecText);
// 售价
TextBox * pSellPriceText=NULL;
pSellPriceText=MakeTextBox(pSellPriceText);
pSellPriceText->m_spc.s_py=21;
pSellPriceText->m_spc.s_px=9;
pSellPriceText->m_spc.s_sizex=30;
pSellPriceText->m_strmaxlen=6;
pSellPriceText->m_isInteger=TRUE;
pSellPriceText->m_isPasswd=FALSE;
pSellPriceText->m_isFn2_9=FALSE;
ChangeTextBox(&pSellPriceText);
// 进货价格
TextBox * pPriceText=NULL;
pPriceText=MakeTextBox(pPriceText);
pPriceText->m_spc.s_py=21;
pPriceText->m_spc.s_px=9;
pPriceText->m_spc.s_sizex=30;
pPriceText->m_strmaxlen=6;
pPriceText->m_isInteger=TRUE;
pPriceText->m_isPasswd=FALSE;
pPriceText->m_isFn2_9=FALSE;
ChangeTextBox(&pPriceText);
// 折扣
TextBox * pDiscountText=NULL;
pDiscountText=MakeTextBox(pDiscountText);
pDiscountText->m_spc.s_py=21;
pDiscountText->m_spc.s_px=9;
pDiscountText->m_spc.s_sizex=30;
pDiscountText->m_strmaxlen=3;
pDiscountText->m_isInteger=TRUE;
pDiscountText->m_isPasswd=FALSE;
pDiscountText->m_isFn2_9=FALSE;
ChangeTextBox(&pDiscountText);
// 数量
TextBox * pCountText=NULL;
pCountText=MakeTextBox(pCountText);
pCountText->m_spc.s_py=21;
pCountText->m_spc.s_px=9;
pCountText->m_spc.s_sizex=30;
pCountText->m_strmaxlen=6;
pCountText->m_isInteger=TRUE;
pCountText->m_isPasswd=FALSE;
pCountText->m_isFn2_9=FALSE;
ChangeTextBox(&pCountText);
// 确定按钮
Button * pButton1=NULL;
pButton1=MakeButton(pButton1);
strcpy(pButton1->m_name,"正确");
pButton1->m_kind=YESBUTTON;
pButton1->m_buttonid=BUTTONID+1;
pButton1->m_sizey=3;
pButton1->m_color_foot=WHITE_BLUE;
pButton1->ChangeButton(&pButton1);
// 取消按妞
Button * pButton2=NULL;
pButton2=MakeButton(pButton2);
strcpy(pButton2->m_name,"退出");
pButton2->m_buttonid=BUTTONID+2;
pButton2->m_kind=NOBUTTON;
pButton2->m_color_foot=WHITE_BLUE;
pButton2->m_sizey=3;
pButton2->ChangeButton(&pButton2);
// 加入对象
AddActiveElement(pAddCommodity,pBarCodeText,ISTEXT,4,18);
AddActiveElement(pAddCommodity,pNameText,ISTEXT,6,18);
AddActiveElement(pAddCommodity,pUnitText,ISTEXT,8,18);
AddActiveElement(pAddCommodity,pSpecText,ISTEXT,10,18);
AddActiveElement(pAddCommodity,pSellPriceText,ISTEXT,12,18);
AddActiveElement(pAddCommodity,pPriceText,ISTEXT,14,18);
AddActiveElement(pAddCommodity,pDiscountText,ISTEXT,16,18);
AddActiveElement(pAddCommodity,pCountText,ISTEXT,18,18);
AddActiveElement(pAddCommodity,pButton1,ISBUTTON,20,20);
AddActiveElement(pAddCommodity,pButton2,ISBUTTON,20,50);
int res=0;
do
{
ShowMyWindow(pAddCommodity);
res=RunMyWindow(pAddCommodity);
if (BUTTONID+1==res)
{
// 确定按钮.提取信息,插入数据库
if (strlen(pBarCodeText->m_str)==0)
{
MessageBox("请输条形码及相关信息","任意键返回",NOBTN);
continue;
}
Goods goods; // 提取条形码
goods.bar_code[0]='C';
goods.bar_code[1]='N';
strcpy(&goods.bar_code[2],pBarCodeText->m_str); // 提取名称
strcpy(goods.product_name,pNameText->m_str);
strcpy(goods.unit,pUnitText->m_str); // 提取单位
strcpy(goods.spec,pSpecText->m_str); // 提取规格
goods.sale_price=atof(pSellPriceText->m_str);// 售价
goods.purchase_price=atof(pPriceText->m_str); // 进货价格
goods.count=atoi(pCountText->m_str); // 数量
MoveRightSpace(pDiscountText->m_str);
goods.discount=atof(pDiscountText->m_str); // 折扣
MoveRightSpace(goods.bar_code);
MoveRightSpace(goods.product_name);
MoveRightSpace(goods.unit);
MoveRightSpace(goods.spec);
// 插入数据库
int k=InsertProduct(&goods);
if (1!=k)
{
MessageBox("添加失败","请检查条形码唯一性",NOBTN);
pBarCodeText->m_str[0]='\0';
}else
{
MessageBox("添加成功","确定继续添加,返回退出添加",NOBTN);
pBarCodeText->m_str[0]='\0';
pNameText->m_str[0]='\0';
pUnitText->m_str[0]='\0';
pSpecText->m_str[0]='\0';
pSellPriceText->m_str[0]='\0';
pPriceText->m_str[0]='\0';
pDiscountText->m_str[0]='\0';
pCountText->m_str[0]='\0';
}
}
else
{
break;
}
}while (1);
DelMyWindow(pAddCommodity);
scr_restore("SaveScr2.scr");
}
/*******************************************
Function:修改商品明细模块
PRARM:无
return:无
*******************************************/
// 修改商品明细
void ModifyComDetail(Goods * good)
{
scr_dump("SaveScr3.scr");
MyWindow * pAddCommodity=NULL;
pAddCommodity=MakeMyWindow(pAddCommodity);
pAddCommodity->m_color=WHITE_BLUE;
pAddCommodity->m_sizex=78; // 30
pAddCommodity->m_sizey=25; // 12
pAddCommodity->m_px=1;
pAddCommodity->m_py=1;
int sizex=pAddCommodity->m_sizex;
int sizey=pAddCommodity->m_sizey;
ChangeMyWindow(&pAddCommodity);
DrawWords(pAddCommodity,0,(sizex-strlen("欢迎光临XXX超市"))/2,"欢迎光临XXX超市");
DrawWords(pAddCommodity,2,(sizex-strlen("修改商品"))/2,"修改商品");
DrawWords(pAddCommodity,4,10,"条形码:");
DrawWords(pAddCommodity,6,12,"名称:");
DrawWords(pAddCommodity,8,12,"单位:");
DrawWords(pAddCommodity,10,12,"规格:");
DrawWords(pAddCommodity,12,12,"售价:");
DrawWords(pAddCommodity,14,8,"进货进价:");
DrawWords(pAddCommodity,16,12,"折扣:");
DrawWords(pAddCommodity,18,12,"数量:");
// 条形码
TextBox * pBarCodeText=NULL;
pBarCodeText=MakeTextBox(pBarCodeText);
pBarCodeText->m_spc.s_py=21;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -