📄 possystem.c
字号:
wclear(numberInputWin);
wrefresh(numberInputWin);
goto numberInputWin;
}
}
DestroyWindow(win);
DestroyWindow(BarCodeInputWin);
DestroyWindow(numberInputWin);
scr_restore("save.scr");
refresh();
return result;//返回选择的值,如确定就是0,返回就是1
}
//结帐窗口
int Reckoning_Window(int startY,int startX,float totalmoney)
{
scr_dump("save1.scr");
int ReckoningWindowHight=11;
int ReckoningWindowWidth=25;
int ch,result;
char moneyStr[10]={'\0'};
float money;
WINDOW *win=CreateWindow(ReckoningWindowHight,ReckoningWindowWidth,startY,startX,Yes,RED_BLACK);
StringCenterPrint(win,1,"结帐");
printhline(win,2,1,ReckoningWindowWidth-2);//画水平线
mvwprintw(win,3,5,"应收:");
// 应收窗口
WINDOW * ReceivablesWin=CreateWindow(1,10,startY+3,startX+10,No,WHITE_BLACK);
wclear(ReceivablesWin);
mvwprintw(ReceivablesWin,0,0,"%.2f",totalmoney); //打印出要收的钱
wrefresh(ReceivablesWin);
printhline(win,4,1,ReckoningWindowWidth-2);//画水平线
mvwprintw(win,5,5,"实收:");
//实收窗口
WINDOW * RealIncomeWin=CreateWindow(1,10,startY+5,startX+10,No,WHITE_BLACK);
printhline(win,6,1,ReckoningWindowWidth-2);//画水平线
mvwprintw(win,7,5,"找零:");
//零钱窗口
WINDOW * ShoestringWin=CreateWindow(1,10,startY+7,startX+10,No,WHITE_BLACK);
wrefresh(win);
WINDOW * YesButton=CreateButtonWindow(startY+ReckoningWindowHight-2,startX+ReckoningWindowWidth/2-9,No,RED_BLACK,"是");
WINDOW * NoButton=CreateButtonWindow(startY+ReckoningWindowHight-2,startX+ReckoningWindowWidth/2+2,No,RED_BLACK,"否");
while(1)
{
ReceivablesWin:
while(1)
{
ch=GetFloat(RealIncomeWin,0,0,moneyStr,9);
switch(ch)
{
case '\e':
result=1;//选择NO是选加1
goto exit;
case KEY_DOWN:
case '\n':
{
money=atof(moneyStr);
//mvwprintw(win,1,1,moneyStr);
//mvwprintw(win,1,6,"%f",money);
//wrefresh(win);
if(isNull(moneyStr))
{
Message_Box(10,30,10,10,RED_BLACK,"警告","实收金额不能为空");
goto ReceivablesWin;
break;
}
//判断一个浮点型输入是否符合大于min,小于max,格式是否正确,正确返回1,格式错或为空返回0,太小返回-1,太大返回-2
int err;
err=Float_Input_Validate(moneyStr,totalmoney,99999.99f);
// mvwprintw(win,1,1,"%s,%f",moneyStr,totalmoney);
// wrefresh(win);
switch(err)
{
case 0:
Message_Box(10,30,10,10,RED_BLACK,"警告","输入金额格式错误");
goto ReceivablesWin;
break;
case -1:
Message_Box(10,40,10,10,RED_BLACK,"警告","实收金额不能小于应收金额");
goto ReceivablesWin;
break;
case 1:
break;
}
if(money<totalmoney)
{
Message_Box(10,40,10,10,RED_BLACK,"警告","实收金额不能小于应收金额");
goto ReceivablesWin;
break;
}
mvwprintw(ShoestringWin,0,0,"%.2f",money-totalmoney);
wrefresh(ShoestringWin);
goto YesButton;
break;
}
}
}
YesButton:
while(1)
{
IntoButtonWindow(YesButton,WHITE_RED);
ch=wgetch(YesButton);
switch(ch)
{
case KEY_UP:
LeaveButtonWindow(YesButton,RED_BLACK);
goto ReceivablesWin;
break;
case KEY_DOWN:
case KEY_RIGHT:
LeaveButtonWindow(YesButton,RED_BLACK);
goto NoButton;
break;
case '\n':
{
LeaveButtonWindow(YesButton,RED_BLACK);
result=0;//选择yes的时候返回0
goto exit;
}
}
}
NoButton:
while(1)
{
IntoButtonWindow(NoButton,WHITE_RED);
ch=wgetch(NoButton);
switch(ch)
{
case KEY_LEFT:
case KEY_UP:
LeaveButtonWindow(NoButton,RED_BLACK);
//IntoButtonWindow(okButton,WHITE_RED);
goto YesButton;
break;
case '\n':
LeaveButtonWindow(NoButton,RED_BLACK);
result=1;//选择NO是选加1
goto exit;
break;
}
}
}
exit:
//StringCenterPrint(win,9,"请按任意键继续收银...");
wrefresh(win);
DestroyWindow(win);
DestroyWindow(ReceivablesWin);
DestroyWindow(RealIncomeWin);
DestroyWindow(ShoestringWin);
DestroyWindow(YesButton);
DestroyWindow(NoButton);
scr_restore("save1.scr");
refresh();
return result;//返回选择的值,如确定就是0,返回就是1
}
//输入管理员密码窗口
int InputAdminPwdWin(int startY,int startX)
{
scr_dump("save1.scr");
int InputAdminPwdWinHight=9;
int InputAdminPwdWinWidth=30;
int ch,result,userType;
userType=0;//退货管理员的类型为0
char account[16]={'\0'};
char password[16]={'\0'};
WINDOW *win=CreateWindow(InputAdminPwdWinHight,InputAdminPwdWinWidth,startY,startX,Yes,RED_BLACK);
StringCenterPrint(win,1,"输入管理员密码");
printhline(win,2,1,InputAdminPwdWinWidth-2);//画水平线
mvwprintw(win,3,2,"管理员帐户:");
// 输入密码窗口
WINDOW * InputAccWin=CreateWindow(1,15,startY+3,startX+13,No,WHITE_BLACK);
mvwprintw(win,5,2,"管理员密码:");
// 输入密码窗口
WINDOW * InputPwdWin=CreateWindow(1,15,startY+5,startX+13,No,WHITE_BLACK);
wrefresh(win);
WINDOW * YesButton=CreateButtonWindow(startY+InputAdminPwdWinHight-2,startX+InputAdminPwdWinWidth/2-9,No,RED_BLACK,"是");
WINDOW * NoButton=CreateButtonWindow(startY+InputAdminPwdWinHight-2,startX+InputAdminPwdWinWidth/2+2,No,RED_BLACK,"否");
while(1)
{
InputAccWin:
while(1)
{
ch=GetNumber(InputAccWin,0,0,account,6);
switch(ch)
{
case KEY_DOWN:
case '\n':
goto InputPwdWin;
break;
}
}
InputPwdWin:
while(1)
{
ch=GetPasswordString(InputPwdWin,0,0,password,15);
switch(ch)
{
case KEY_UP:
goto InputAccWin;
break;
case KEY_DOWN:
case '\n':
goto YesButton;
break;
}
}
YesButton:
while(1)
{
IntoButtonWindow(YesButton,WHITE_RED);
ch=wgetch(YesButton);
switch(ch)
{
case KEY_UP:
LeaveButtonWindow(YesButton,RED_BLACK);
goto InputPwdWin;
break;
case KEY_DOWN:
case KEY_RIGHT:
LeaveButtonWindow(YesButton,RED_BLACK);
goto NoButton;
break;
case '\n':
{
int idlength;
Trim(account);
idlength=strlen(account);
if(isNull(account))
{
Message_Box(10,30,10,10,RED_BLACK,"提示","输入的帐户ID不能为空");
LeaveButtonWindow(YesButton,RED_BLACK);
goto InputAccWin;
}
if(idlength<6)
{
Message_Box(10,30,10,10,RED_BLACK,"提示","输入的帐户ID太短");
wclear(InputAccWin);
wrefresh(InputAccWin);
wclear(InputPwdWin);
wrefresh(InputPwdWin);
LeaveButtonWindow(YesButton,RED_BLACK);
goto InputAccWin;
}
if(isNull(password))
{
Message_Box(10,30,10,10,RED_BLACK,"提示","输入的密码不能为空");
wclear(InputAccWin);
wrefresh(InputAccWin);
wclear(InputPwdWin);
wrefresh(InputPwdWin);
LeaveButtonWindow(YesButton,RED_BLACK);
goto InputPwdWin;
}
int checkResult;
checkResult=check_login(account,password,&userType);
if(checkResult==0 && userType==0)
{
LeaveButtonWindow(YesButton,RED_BLACK);
result=0;//选择yes的时候返回0
goto exit;
}
else
{
Message_Box(10,30,10,10,RED_BLACK,"提示","权限不够");
wclear(InputAccWin);
wrefresh(InputAccWin);
wclear(InputPwdWin);
wrefresh(InputPwdWin);
LeaveButtonWindow(YesButton,RED_BLACK);
break;
}
}
}
}
NoButton:
while(1)
{
IntoButtonWindow(NoButton,WHITE_RED);
ch=wgetch(NoButton);
switch(ch)
{
case KEY_LEFT:
case KEY_UP:
LeaveButtonWindow(NoButton,RED_BLACK);
//IntoButtonWindow(okButton,WHITE_RED);
goto YesButton;
break;
case '\n':
LeaveButtonWindow(NoButton,RED_BLACK);
result=1;//选择NO是选加1
goto exit;
break;
}
}
}
exit:
DestroyWindow(win);
DestroyWindow(InputAccWin);//删掉帐户输入窗口
DestroyWindow(InputPwdWin);//删掉密码输入窗口
DestroyWindow(YesButton);
DestroyWindow(NoButton);
scr_restore("save.scr");
refresh();
scr_restore("save1.scr");
refresh();
return result;//返回选择的值,如确定就是0,返回就是1
}
//退货窗口
int ReturningAProductWin(int startY,int startX)
{
scr_dump("save1.scr");
int ReckoningWindowHight=11;
int ReckoningWindowWidth=52;
int ch,result;
char sellNumber[20]={'\0'};//销售单号
char barcode[10]="CN";//条形码
char amounts[5]={'\0'};//数量
WINDOW *win=CreateWindow(ReckoningWindowHight,ReckoningWindowWidth,startY,startX,Yes,RED_BLACK);
StringCenterPrint(win,1,"退货");
printhline(win,2,1,ReckoningWindowWidth-2);//画水平线
mvwprintw(win,3,2,"销售单号:");
// 销售单号窗口
WINDOW * Sell_Odd_NumbersWin=CreateWindow(1,30,startY+3,startX+11,No,WHITE_BLACK);
printhline(win,4,1,ReckoningWindowWidth-2);//画水平线
mvwprintw(win,5,4,"条形码:");
//条形码窗口
WINDOW * BarCodeWin=CreateWindow(1,30,startY+5,startX+11,No,WHITE_BLACK);
mvwprintw(BarCodeWin,0,0,barcode);
wrefresh(BarCodeWin);
wrefresh(win);
WINDOW * YesButton=CreateButtonWindow(startY+ReckoningWindowHight-2,startX+ReckoningWindowWidth/2-9,No,RED_BLACK,"是");
WINDOW * NoButton=CreateButtonWindow(startY+ReckoningWindowHight-2,startX+ReckoningWindowWidth/2+2,No,RED_BLACK,"否");
while(1)
{
Sell_Odd_NumbersWin:
while(1)
{
ch=GetString(Sell_Odd_NumbersWin,0,0,sellNumber,19);
switch (ch)
{
case KEY_DOWN:
case '\n':
goto BarCodeWin;
break;
}
}
BarCodeWin:
while(1)
{
ch=GetString(BarCodeWin,0,2,&barcode[2],6);
switch (ch)
{
case KEY_UP:
goto Sell_Odd_NumbersWin;
break;
case KEY_DOWN:
case '\n':
goto YesButton;
break;
}
}
YesButton:
while(1)
{
IntoButtonWindow(YesButton,WHITE_RED);
ch=wgetch(YesButton);
switch(ch)
{
case KEY_UP:
LeaveButtonWindow(YesButton,RED_BLACK);
goto BarCodeWin;
break;
case KEY_DOWN:
case KEY_RIGHT:
LeaveButtonWindow(YesButton,RED_BLACK);
goto NoButton;
break;
case '\n':
{
int count;
float sale_price;
int returnResult;
float totoalmoney=0.0f;
returnResult=Get_Sale_Detail(sellNumber,barcode,&count,&sale_price);
// mvwprintw(win,1,5,"count:%d sale_price:%f",count,sale_price);
// wrefresh(win);
// wgetch(win);
if(returnResult!=0) //没有查找到相关的退货信息
{
Message_Box(10,30,10,10,RED_BLACK,"提示","没有查找到相关的信息");
break;
}
else //查找到相关的退货信息
{
totoalmoney=count*sale_price;
Modify_Sale_Detail_State(sellNumber,barcode);//修改商品状态
Modify_Sale_Money(sellNumber,count*sale_price);//修改商品总金额
ReduceStock(barcode,-count);//修改库存
char message[50];
sprintf(message,"退钱 %f",totoalmoney);
Message_Box(10,30,10,10,RED_BLACK,"提示",message);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -