⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 salewin5.cpp

📁 金融pos机前台源码
💻 CPP
字号:
#include <dos.h>
#include <math.h>
#include <string.h>
#include "box.h"
#include "sysinfo.h"
#include "submenu.h"
#include "salewin.h"

void
SaleWin::DoMulPay()
						 {
	char *sname0[5]={"购物金卡","金 穗 卡","牡 丹 卡","长 城 卡"};
	int eid0[5]={101,102,103,104};
	struct RECT rect={260,160,120,148};
	unsigned int Event;

	SubMenu *smenu= new SubMenu(sname0, eid0, rect, 4);
run:
	smenu->Run();
	GetEvent(Event);
	switch(Event)
	{
		case EV_QUIT:
			delete smenu;
			return;
		case 101:
			delete smenu;
			GoldCard();
			return;
		case 102:
			delete smenu;
			return;
		case 103:
			delete smenu;
			return;
		case 104:
			delete smenu;
			return;
		case 105:
			delete smenu;
			return;
		default:
			goto run;
	};
}

//运行购物金卡模块.
void
SaleWin::GoldCard()
						 {
	char temp[20], temp1[20], temp2[20];
	unsigned int Event;

	InputBox *msg = new InputBox("请确定刷卡金额:");
	msg->SetText(Trim(ShouldPay->Text()));
	msg->Run();
	GetEvent(Event);
	if(Event == CMD_YES)//如果不退出。
	{
		//判断金额是否合法。
		if(atof(msg->Text()) <= 0 || atof(msg->Text()) > atof(ShouldPay->Text()) )
		{
			printf("\007");
			delete msg;
			return;
		}
		strcpy(temp1, ShouldPay->Text());
		strcpy(temp2, msg->Text());
		sprintf(temp, "%0.2f", atof(ShouldPay->Text()) - atof(msg->Text()));
		ShouldPay->SetText(temp);
		delete msg;
		InputBox *msg = new InputBox("请刷储值金卡:");
		msg->InputLine->IsPassword = L_YES;//将文本框设置为密码方式。
		msg->Run();
		GetEvent(Event);
		if(Event == CMD_YES)//如果不退出。
		{
			//卡号为:msg->Text();
			int answer;//将刷卡结果给它,1表示成功,0表示失败。
			//调用刷卡处理程序。
			answer = GoldCard_Apply1(temp2, msg->Text());
			if(answer == 2)
			{
				//此处记帐。
				WriteMulpay("1", msg->Text(), "", temp2);
				delete msg;
				return;
			}
			ShouldPay->SetText(temp1);
			delete msg;
		}
		ShouldPay->SetText(temp1);
		delete msg;
		return;
	}
	delete msg;

}

//1.产生请求文件发生错误.
//2.该卡正常,同时“卡剩余金额”为该卡剩余金额.
//3.该卡非法.
//4.该卡未生效.
//5.该卡被止付.
//6.超时.
int
SaleWin::GoldCard_Apply1(char *Money, char *CardID)
{
	char Temp[100];
	char Temp1[100];
	char Str1[20];

	char TempPath[64];
	FILE *fp;

	//收款台号.
	strcpy(Temp, "");
	strcat(Temp, sys->TermID);
	strcat(Temp, ",");
	//流水号.
	strcat(Temp, SeqNumber->Text());
	strcat(Temp, ",");
	//收款员号.
	strcat(Temp, OpCode->Text());
	strcat(Temp, ",");
	//卡号.
	sprintf(Str1, "%15s", Trim(CardID));
	strcat(Temp, Str1);
	strcat(Temp, ",");
	//申请金额.	//多卡标志.	//标志位. //卡剩余金额.
	sprintf(Str1, "%12.2f", atof(Money));
	strcat(Temp, Str1);
	strcat(Temp, ",n,axxx,        0.00");

	//创建请求文件.
	strcpy(TempPath, "");
	strcat(TempPath, sys->StaRPath);
	strcat(TempPath, "\\gwk.dat");
	if ((fp = fopen(TempPath, "wt")) == NULL)
	{
		MsgBox *Error = new MsgBox("产生请求文件发生错误.");
		Error->Run();
		delete Error;
		return 1;
	}
	fwrite(Temp, strlen(Temp)+1, 1, fp);
	fclose(fp);
	for(int i=0; i<5; i++)
	{
		delay(1000);
		if ((fp = fopen(TempPath, "rt")) != NULL)
		{
			fread(Temp1, 65, 1, fp);
			fclose(fp);
			strncpy(Str1, Temp1 + 48, 4);
			Str1[4] = 0;
			if(strcmp(Str1, "axxx")!=0)
			{
				if(strcmp(Str1, "abxx"))
				{
					char S[60];
					strncpy(Str1, Temp1 + 53, 12);
					strcpy(S, "该卡剩余金额为:");
					strcat(S, Trim(Str1));
					MsgBox *Error = new MsgBox(S);
					Error->Run();
					delete Error;
						return 2;
				}
				if(strcmp(Str1, "xxxx"))
				{
					MsgBox *Error = new MsgBox("该卡非法.");
					Error->Run();
					delete Error;
					return 3;
				}
				if(strcmp(Str1, "anxx"))
				{
					MsgBox *Error = new MsgBox("该卡未生效.");
					Error->Run();
					delete Error;
					return 4;
				}
				if(strcmp(Str1, "asxx"))
				{
					MsgBox *Error = new MsgBox("该卡被止付.");
					Error->Run();
					delete Error;
					return 5;
				}
			}
		}
	}
	MsgBox *Error = new MsgBox("请求超时.");
	Error->Run();
	delete Error;
	return 6;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -