예제 #1
0
const char *StrToDate(const char *fmt, Date& d, const char *s, Date def)
{
	if(*s == 0) {
		d = Null;
		return s;
	}
	d = Nvl(def, GetSysDate());
	while(*fmt) {
		while(*s && !IsDigit(*s) && !IsAlpha(*s) && (byte)*s < 128)
			s++;
		int n;
		if(IsDigit(*s)) {
			char *q;
			n = strtoul(s, &q, 10);
			s = q;
		}
		else
		if(IsAlpha(*s) || (byte)*s >= 128) {
			if(*fmt != 'm')
				return NULL;
			String m;
			while(IsAlpha(*s) || (byte)*s >= 128)
				m.Cat(*s++);
			m = ToUpper(m);
			for(int i = 0; i < 12; i++)
				if(m == ToUpper(MonthName(i)) || m == ToUpper(MonName(i))) {
					n = i + 1;
					goto found;
				}
			return NULL;
		found:
			;
		}
		else
			break;

		switch(*fmt) {
		case 'd':
			if(n < 1 || n > 31)
				return NULL;
			d.day = n;
			break;
		case 'm':
			if(n < 1 || n > 12)
				return NULL;
			d.month = n;
			break;
		case 'y':
			d.year = n;
			if(d.year < 25) d.year += 2000; // Check again in 2020.... // TODO: Make this automatic
			else
			if(d.year < 100) d.year += 1900;
			break;
		default:
			NEVER();
		}
		fmt++;
	}
	return d.IsValid() ? s : NULL;
}
예제 #2
0
DateFmtCtrl::DateFmtCtrl()
{
	CtrlLayout(*this, "Window title");
	lang.Add(LNG_('E','N','U','S'), "ENUS");
	lang.Add(LNG_('C','S','C','Z'), "CSCZ");
	date <<= THISBACK(Print);
	lang <<= THISBACK(Language);
	date = GetSysDate();
	Print();
}
예제 #3
0
//задание цвета строки
void AnimeList::RowColor(int row)
{
	Date release;
	Array<CellSeries> array;
	Date today = GetSysDate();
	String xml = listName.Get(row, SeriesRelease);
	String number, date;
	int ep = listName.Get(row, Episodes);
	int ser;
	if(xml.GetCount() > 0)
	{
		int pos;
		while(xml.GetCount() > 0){ 
			pos = xml.Find("-");
			if(pos > 0)
			{
				number = String(xml, pos);
				xml.Remove(0, pos + 1);
				date = String(xml, 10);
				xml.Remove(0, 11);
				series.number = StrInt(number);
				StrToDate(series.release, date);
				array.Add(series);
			}
		}
		release = array[array.GetCount()-1].release;
		if((ep == array[array.GetCount()-1].number) & (today < release))
			ser = array[array.GetCount()-1].number - 1;
		else
			ser = ((today - release) / 7) + array[array.GetCount()-1].number;
	} else
	{
		release = listName.Get(row, Release);
		ser = ((today - release) / 7) + 1;
	}
	int views = listName.Get(row, Views);
	if(views == ep) //полностью просмотрено
		for(int i=0;i<listName.GetColumnCount();i++)
			listName.SetDisplay(row, i, Single<ColumnBlue>());
	else
		if((views < ep) & (views != 0) & (views == ser)) //нет новых серий, в просмотре
			for(int i=0;i<listName.GetColumnCount();i++)
				listName.SetDisplay(row, i, Single<ColumnGreen>());
		else
			if((views < ep) & (views != 0) & (views < ser)) //есть новые серии, в просмотре
				for(int i=0;i<listName.GetColumnCount();i++)
					listName.SetDisplay(row, i, Single<ColumnRed>());
			else
				if(views == 0) //нет просмотренных серий
					for(int i=0;i<listName.GetColumnCount();i++)
						listName.SetDisplay(row, i, Single<ColumnDefault>());
}
예제 #4
0
String  DocReport::HFormat(const char *s) {
	String result;
	while(*s) {
		if(s[0] == '$' && s[1] == '$') {
			if(s[2] == 'P')
				result.Cat(Format("%d", pageno));
			if(s[2] == 'D')
				result.Cat(Format(GetSysDate()));
			s += 3;
		}
		result.Cat(*s++);
	}
	return result;
}
예제 #5
0
ComplexStatsWin::ComplexStatsWin()
{
	CtrlLayoutOK(*this, t_("Complex statistics"));
	
	interval.Add(siDay, t_("Day"));
	interval.Add(siMonth,t_("Month"));
	interval.Add(siDateRange,t_("Date range"));
	interval.SetData(siDay);
	interval.WhenAction = THISBACK(when_interval_changes);
	
	day_date.SetData(GetSysDate());
	day_date.WhenAction = THISBACK(refresh); 
	
	month_date.SetData(GetSysDate());
	month_date.Enable(false);
	month_date.WhenAction = THISBACK(refresh);
	
	date_from.SetData(GetSysDate());
	date_from.Enable(false);
	date_from.WhenAction = THISBACK(refresh);
	
	date_to.SetData(GetSysDate());
	date_to.Enable(false);
	date_to.WhenAction = THISBACK(refresh);
	
	products.AddColumn(NAME, t_("Product"));
	products.AddColumn(NAME, t_("Count"));
	
	clients.AddColumn(NAME, t_("Title"));
	clients.AddColumn(FIRST_NAME, t_("FName"));
	clients.AddColumn(LAST_NAME, t_("Surname"));
	
	tablist.Add(products.SizePos(), t_("Sold"));
	tablist.Add(clients.SizePos(), t_("Clients"));
	
	refresh();
}
예제 #6
0
void Ide::Statistics()
{
	Vector< ArrayMap<String, FileStat> > stat;
	Progress pi;
	const Workspace& wspc = IdeWorkspace();
	pi.SetTotal(wspc.GetCount());
	Date now = GetSysDate();
	for(int i = 0; i < wspc.GetCount(); i++) {
		const Package& pk = wspc.GetPackage(i);
		String n = wspc[i];
		pi.SetText(n);
		if(pi.StepCanceled()) return;
		ArrayMap<String, FileStat>& pfs = stat.Add();
		for(int i = 0; i < pk.GetCount(); i++)
			if(!pk[i].separator) {
				String file = SourcePath(n, pk[i]);
				if(FileExists(file)) {
					FileStat& fs = pfs.GetAdd(GetFileExt(file));
					int d = minmax(now - FileGetTime(file), 0, 9999);
					fs.oldest = max(d, fs.oldest);
					fs.newest = min(d, fs.newest);
					String data = LoadFile(file);
					for(const char *s = data; *s; s++)
						if(*s == '\n')
							fs.lines++;
					fs.len += data.GetCount();
					fs.days += d;
					fs.count++;
				}
			}
	}
	String qtf = "[1 ";
	ArrayMap<String, FileStat> all;
	String tab = "{{45:20:25:20:35:30:30:30:30@L [* ";
	String hdr = "]:: [= Files:: Lines:: - avg.:: Length:: - avg.:: Oldest:: Newest:: Avg. age]";
	for(int i = 0; i < wspc.GetCount(); i++) {
		qtf << tab << DeQtf(wspc[i]) << hdr;
		sPut(qtf, stat[i], all);
	}

	qtf << tab << "All packages" << hdr;
	sPut(qtf, all, all);

	WithStatLayout<TopWindow> dlg;
	CtrlLayoutOK(dlg, "Statistics");
	dlg.stat = qtf;
	dlg.Sizeable().Zoomable();
	dlg.Run();
}
예제 #7
0
//составление списка выходов серий
void AnimeList::AnimeSeries()
{
	int episodes;
	Date release, today;
	today = GetSysDate();
	if(listName.IsCursor()){
		seriesDate.Clear();
		episodes = listName.Get(Episodes);
		release = listName.Get(Release);
		int i = 0;
		int j = 1;
		int series = 0;
		
		if(seriesArray.GetCount() > 0)
			while(i == 0) {
				if( j == seriesArray[series].number)
				{
					seriesDate.Add(seriesArray[series].number, seriesArray[series].release);
					release = seriesArray[series].release;
					operator+=(release, 7);
					if(series < seriesArray.GetCount()-1)
						series++;
				}
				else
				{
					seriesDate.Add(j, release);
					operator+=(release, 7);
				}
				j++;
				if(j > episodes)
					i++;
			}
		else
			while(i == 0) { 
				seriesDate.Add(j, release);
				operator+=(release, 7);
				j++;
				if( j  > episodes)
					i = 1;
			}
			
		for(int i=0;i<seriesArray.GetCount();i++)
			test.testList.Add(seriesArray[i].number, seriesArray[i].release);
	}
}
예제 #8
0
파일: UrpTime.cpp 프로젝트: radtek/lister
//==============================================================================================
void LoadHolidays() {
	Date curDate = GetSysDate();
	int y = curDate.year;
	Vector<Date> us;
	us.Add(GetDateByMonthWeekWeekday(y, JANUARY, THIRDWEEK, MONDAY));         // Martin Luther King's Birthday
	us.Add(GetDateByMonthWeekWeekday(y, FEBRUARY, THIRDWEEK, MONDAY));        // President's Day
	us.Add(GetDateByMonthWeekWeekday(y, MAY, LASTWEEK, MONDAY));              // Memorial Day
	us.Add(Date(y, JULY, 4));                                                 // Independence Day
	us.Add(GetDateByMonthWeekWeekday(y, SEPTEMBER, FIRSTWEEK, MONDAY));       // Labor Day
	us.Add(GetDateByMonthWeekWeekday(y, OCTOBER, SECONDWEEK, MONDAY));        // Columbus Day
	us.Add(Date(y, NOVEMBER, 11));                                            // Veteran's Day
	us.Add(GetDateByMonthWeekWeekday(y, NOVEMBER, FOURTHWEEK, THURSDAY));     // Thanksgiving Day
	us.Add(Date(y, DECEMBER, 25));                                            // Christmas Day
	// Inauguration Day, every 4 years starting 1940, January 20th
	// Good Friday
	holidays.Add(us);
	
}
예제 #9
0
String  Report::FormatHF(const char *s, int pageno)
{
	String result;
	while(*s) {
		if(s[0] == '$' && s[1] == '$') {
			if(s[2] == 'P') {
				result << pageno + 1;
				s += 3;
			}
			else
			if(s[2] == 'D') {
				result.Cat(Format(GetSysDate()));
				s += 3;
			}
		}
		result.Cat(*s++);
	}
	return result;
}
예제 #10
0
파일: ApFilePage.cpp 프로젝트: 25311753/asi
//---------------------------------------------------------------------------
//新增时自动产生递增的档号
AnsiString TApFilePageForm::GenerateID()
{ //编号格式:GR-S-XXXXXX

	int nYear,nMonth,nDay,nFlow;
  char strID[80],chMon,strSQL[1024],strKey[80];

  if(!dm1->OpenDatabase())	return "";
	GetSysDate(nYear,nMonth,nDay,false);

	if(nMonth<10)	chMon=(char)('0'+nMonth);
  else chMon=(char)('A'-10+nMonth);

  //查看该月是否已经有流水号
  sprintf(strKey,"FilePage_%04d%02d",nYear,nMonth);
  sprintf(strSQL,"select * from RuntimeData where rd_key='%s'",strKey);
	RunSQL(strSQL,true);
  if(dm1->Query1->Eof)
  { //该月还没有流水号,初始化该月流水号
  	sprintf(strSQL,"insert into RuntimeData values('%s',1,NULL,'档案页码%d年%d月流水号')",
    	strKey,nYear,nMonth);
    RunSQL(strSQL);
    nFlow=1;
  }

  else
  {
  	nFlow=dm1->Query1->FieldByName("rd_int")->AsInteger;
  }

  while(1)
  {
    sprintf(strID,"A%02d%02d%03d",nYear%10,nMonth,nFlow);                       //自动生成的档号默认以A开头
    sprintf(strSQL,"select * from FilePage where fp_fno='%s'",strID);
    RunSQL(strSQL,true);
    if(dm1->Query1->Eof)	break;
		nFlow++;
  }
  sprintf(strSQL,"update RuntimeData set rd_int=%d where rd_key='%s'",nFlow,strKey);
  RunSQL(strSQL);

  return AnsiString(strID);

}
예제 #11
0
void OtherChecks()
{
    Value c;

    ASSERT(c.IsVoid());
    RDUMP(c.IsVoid());

    Value x = "Ahoj";
    String xx = x;
    RDUMP(xx);
    ASSERT(xx == "Ahoj");

    Value xw = WString("Ahoj");
    RDUMP(xw);
    RDUMP(xw == x);

    Value xc = x;
    RDUMP(xc);
    c = xc;
    RDUMP(c);

    Value y = 123;
    int yy = y;
    RDUMP(yy);

    Value xn = (int)Null;
    RDUMP(IsNull(xn));
    RDUMP(IsNull(yy));

    Value yc = y;
    RDUMP(y);

    c = y;
    RDUMP(c);

    Value v2 = 123.0;
    Value v3 = 123;
    Value v4 = 125;

    RDUMP(v2 == y);
    RDUMP(v3 == y);
    RDUMP(v4 == y);
    RDUMP(v4 == v2);

    ASSERT(v2 == v3);
    ASSERT(v2 != v4);
    ASSERT(v4 != x);

    Value uu = Uuid::Create();
    RDUMP(uu);
    Value uuc = uu;
    RDUMP(uuc);

    {
        Color c = Blue;
        Value v = c;
        RDUMP(v);
        Value v2 = v;
        c = v2;
        RDUMP(c);
    }

    Value txt = "text";
    ASSERT(txt.GetCount() == 0);
    ASSERT(txt["hhh"].IsError());
    ASSERT(txt[3].IsError());

    ASSERT(txt != GetSysDate());
    ASSERT(txt == "text");
    ASSERT(txt == WString("text"));
    ASSERT(txt != 123);
    ASSERT(txt == String("text"));

    Value n = 123;
    ASSERT(n != "ahoj");
    ASSERT(n == 123);
    ASSERT(n == 123.0);

    Value d = 123.0;
    ASSERT(d != "ahoj");
    ASSERT(d == 123);
    ASSERT(d == 123.0);

    Value cc = Blue();
    ASSERT(cc != 123);
    ASSERT(cc == Blue());
    ASSERT(cc != "Blue");
}
예제 #12
0
int	doreq(Recv *R, Send *S, void *dbcon)
{
    struct 	water 	winfo	= { "", 0.0, 0, Calloc(MONTHNUM,sizeof(struct bill) )} ;			//水费账户/
    struct 	bank 	binfo	= { "", 0.0, Calloc(1,sizeof(struct pay))};					//银行账户
    struct 	user 	person 	= { "", "", &winfo, &binfo };							//用户信息
    char 	*pbrecv;
    char 	buf[ HEADLEN_30 +1];

    sscanf(R->buffer, RECVHEAD, &(R->len), &(R->code), &(R->filelen));	//填充报文头结构
    pbrecv = R->buffer + 30;
    switch(R->code) {
    case	UQUERY:
        S->len = SLEN7000;
        sscanf(pbrecv, RFORMAT7000, person.pwater->account );	//获取用户编号
        do7000(S, &person, R, dbcon);
        break;
    case	SIGN:
        sscanf(pbrecv, RFORMAT7001,
               person.pwater->account,
               person.name,
               person.addr,
               person.pbank->account );
        do7001(S, &person, R, dbcon);
        break;
    case	MODIFY:
        sscanf(pbrecv, RFORMAT7002,
               person.pwater->account,
               person.name,
               person.addr,
               person.pbank->account );
        do7002(S, &person, R, dbcon);
        break;
    case	DELETE:
        sscanf(pbrecv, RFORMAT7003,
               person.pwater->account,
               person.name,
               person.addr,
               person.pbank->account );
        do7003(S, &person, R, dbcon);
        break;
    case	BQUERY:
        sscanf(pbrecv, RFORMAT7004 , person.pwater->account);
        do7004(S, &person, R, dbcon);
        S->len = HEADLEN_26 + BODYLEN7004 + person.pwater->months*30;		 // 30 = 2(月份) + 12(金额) + 12(滞纳金)
        break;
    case	BPAY:
        sscanf(pbrecv, RFORMAT7005,
               person.pwater->account,
               person.name,
               person.addr,
               &(person.pbank->table->money),
               person.pbank->table->order,
               person.pbank->table->date);
        do7005(S, &person, R, dbcon);
        break;
    case	BREDO:
        sscanf(pbrecv, RFORMAT7006,
               person.pwater->account,
               person.name,
               person.addr,
               &person.pbank->table->money,
               person.pbank->table->order,
               person.pbank->table->date);
        do7006(S, &person, R, dbcon);
        break;
    case	BDAILY:
    {
        char	date[9] = {""};
        int	count	= 0;
        float	sum	= 0;
        FILE 	*fp;
        char 	file[30] = {""};
        char 	usrbuf[110] = {""};	//110为一条记录的长度,包含\n + \0
        int 	num = R->filelen / 109;

        sscanf(pbrecv, RFORMAT7007, date,  &count, &sum);
        do7007(S, date, count, sum, R, dbcon);
        //接受银行详细对账账单,并写入文本


        sprintf(file,"./7-%s.txt", GetSysDate(1));
        if((fp = fopen(file, "w")) == NULL)
        {
            S->result = ERRORFILE;
            break;

        }


        while(num > 0 )
        {
            num--;
            //printf("server receive %d bytes %s\n",n,usrbuf);
            //Rio_writen(fileno(fp), usrbuf, Rio_readn(conn, usrbuf, sizeof(usrbuf)));
            Rio_readn(R->conn, usrbuf, sizeof(usrbuf)-1);
            fputs(usrbuf,fp);
        }
        fclose(fp);
    }
    break;
    case	BMONTHQ:
        do7008(S, R, dbcon);
        break;
    case	BMONTHP:
    {
        char 	line[115];
        int	res = 0;			//00代表银行扣款成功,99代码扣款失败
        //读取每一行记录,如扣款成功,则将欠款表记录移至缴费表
        while(Rio_readn(R->conn, line, sizeof(line)))
        {
            sscanf(line, "%12s%60s%20s%12f%8s%2d",
                   person.pwater->account,
                   person.name,
                   person.pbank->account,
                   &person.pbank->table->money,
                   person.pbank->table->date,
                   &res);

            do7009(&person, res, dbcon);
            memset(line, 0 , sizeof(line));
        }
    }
    break;

    default:
        app_error("No this Code ,Please check");
        break;
    }

    //sprintf会在结尾+NULL, 故使用memcpy将报文头拷贝至Buffer中
    //PS sprintf函数不安全,可能发生缓冲区溢出,建议选用snprintf

    sprintf(buf,SENDHEAD, S->len , R->code, S->result, S->filelen);
    memcpy(S->buffer, buf, HEADLEN_30);

    Free(person.pbank->table);
    Free(person.pwater->table);
}
예제 #13
0
/****************************************************************
** 功    能:冲正拆包
** 输入参数:
**        ptMsgRule       报文规则
**        ptData          ISO结构指针
** 输出参数:
**        ptApp           app结构
** 返 回 值:
**        SUCC            处理成功
**        FAIL            处理失败
** 作    者:
**        fengwei
** 日    期:
**        2013/06/13
** 调用说明:
**
** 修改日志:
****************************************************************/
int AutovoidUnpack(MsgRule *ptMsgRule, T_App *ptApp, ISO_data *ptData)
{
	char    szTmpBuf[512+1];
    char    szTmpBuf2[512+1];
	int     iRet;

	/* 2域 主账号 */
	memset(szTmpBuf, 0, sizeof(szTmpBuf));
	iRet = GetBit(ptMsgRule, ptData, PAN, szTmpBuf);
	if(iRet < 0 || iRet > 19)
	{
        WriteLog(ERROR, "交易类型[%d]应到报文第[%d]域拆解失败iRet:[%d]!",
                 ptApp->iTransType, PAN, iRet);

		strcpy(ptApp->szRetCode, ERR_DATA_FORMAT);

		return FAIL;
	}
	strcpy(ptApp->szPan, szTmpBuf);

    /* 4域 交易金额 */
	memset(szTmpBuf, 0, sizeof(szTmpBuf));
	iRet = GetBit(ptMsgRule, ptData, AMOUNT, szTmpBuf);
	if(iRet != 12)
	{
        WriteLog(ERROR, "交易类型[%d]应到报文第[%d]域拆解失败iRet:[%d]!",
                 ptApp->iTransType, AMOUNT, iRet);

		strcpy(ptApp->szRetCode, ERR_DATA_FORMAT);

		return FAIL;
	}
    strcpy(ptApp->szAmount, szTmpBuf);

	/* 11域 流水号 */
	memset(szTmpBuf, 0, sizeof(szTmpBuf));
	iRet = GetBit(ptMsgRule, ptData, POS_TRACE, szTmpBuf);
	if(iRet != 6)
	{
        WriteLog(ERROR, "交易类型[%d]应到报文第[%d]域拆解失败iRet:[%d]!",
                 ptApp->iTransType, POS_TRACE, iRet);

		strcpy(ptApp->szRetCode, ERR_DATA_FORMAT);

		return FAIL;
	}
	ptApp->lSysTrace = atol(szTmpBuf);

	/* 12域 交易时间 */
	memset(szTmpBuf, 0, sizeof(szTmpBuf));
	iRet = GetBit(ptMsgRule, ptData, LOCAL_TIME, szTmpBuf);
	if(iRet == 6)
	{
		strcpy(ptApp->szHostTime, szTmpBuf);
	}
	else
	{
       	GetSysTime(ptApp->szHostTime);
   	}

	/* 13域 交易日期 */
	memset(szTmpBuf, 0, sizeof(szTmpBuf));
    GetSysDate(ptApp->szHostDate);
	iRet = GetBit(ptMsgRule, ptData, LOCAL_DATE, szTmpBuf);
	if(iRet == 4)
	{
	    strcpy(ptApp->szHostDate+4, szTmpBuf);
    }
	
	/* 14域 有效期 */
	memset(szTmpBuf, 0, sizeof(szTmpBuf));
	iRet = GetBit(ptMsgRule, ptData, EXPIRY, szTmpBuf);
	if(iRet == 4)
	{
		strcpy(ptApp->szExpireDate, szTmpBuf);
	}

    /* 15域 清算日期 */
	memset(szTmpBuf, 0, sizeof(szTmpBuf));
	iRet = GetBit(ptMsgRule, ptData, SETTLE_DATE, szTmpBuf);
	if(iRet != 4)
	{
        WriteLog(ERROR, "交易类型[%d]应到报文第[%d]域拆解失败iRet:[%d]!",
                 ptApp->iTransType, SETTLE_DATE, iRet);

		strcpy(ptApp->szRetCode, ERR_DATA_FORMAT);

		return FAIL;
	}
	strcpy(ptApp->szSettleDate, szTmpBuf);

	/* 25域 服务点条件码 */
	/* 已解析 */

	/* 32域 受理方标识码 */
	memset(szTmpBuf, 0, sizeof(szTmpBuf));
	iRet = GetBit(ptMsgRule, ptData, ACQUIRER_ID, szTmpBuf);
    if(iRet > 11 || iRet < 1)
	{
        WriteLog(ERROR, "交易类型[%d]应到报文第[%d]域拆解失败iRet:[%d]!",
                 ptApp->iTransType, ACQUIRER_ID, iRet);

		strcpy(ptApp->szRetCode, ERR_DATA_FORMAT);

		return FAIL;
	}

	/* 37域 检索参考号 后六位是凭证号 */
	memset(szTmpBuf, 0, sizeof(szTmpBuf));
	iRet = GetBit(ptMsgRule, ptData, RETR_NUM, szTmpBuf);
	if(iRet != 12)
	{
        WriteLog(ERROR, "交易类型[%d]应到报文第[%d]域拆解失败iRet:[%d]!",
                 ptApp->iTransType, RETR_NUM, iRet);

		strcpy(ptApp->szRetCode, ERR_DATA_FORMAT);

		return FAIL;
	}
    sprintf(ptApp->szRetriRefNum, "%12.12s", szTmpBuf);

    /* 39域 响应码 */
    memset(szTmpBuf, 0, sizeof(szTmpBuf));
    iRet = GetBit(ptMsgRule, ptData, RET_CODE, szTmpBuf);
	if(iRet != 2)
	{
        WriteLog(ERROR, "交易类型[%d]应到报文第[%d]域拆解失败iRet:[%d]!",
                 ptApp->iTransType, RET_CODE, iRet);

		strcpy(ptApp->szRetCode, ERR_DATA_FORMAT);

		return FAIL;
	}
	strcpy(ptApp->szHostRetCode, szTmpBuf);

	/* 41域 终端号 */
    memset(szTmpBuf, 0, sizeof(szTmpBuf));
	iRet = GetBit(ptMsgRule, ptData, POS_ID, szTmpBuf);
	if(iRet != 8)
	{
        WriteLog(ERROR, "交易类型[%d]应到报文第[%d]域拆解失败iRet:[%d]!",
                 ptApp->iTransType, POS_ID, iRet);

		strcpy(ptApp->szRetCode, ERR_DATA_FORMAT);

		return FAIL;
	}
    strcpy(ptApp->szPosNo, szTmpBuf);

	/* 42域 商户号 */
    memset(szTmpBuf, 0, sizeof(szTmpBuf));
	iRet = GetBit(ptMsgRule, ptData, CUSTOM_ID, szTmpBuf);
	if(iRet != 15)
	{
        WriteLog(ERROR, "交易类型[%d]应到报文第[%d]域拆解失败iRet:[%d]!",
                 ptApp->iTransType, CUSTOM_ID, iRet);

		strcpy(ptApp->szRetCode, ERR_DATA_FORMAT);

		return FAIL;
	}
    strcpy(ptApp->szShopNo, szTmpBuf);

	/* 44域 FIELD44 */
    memset(szTmpBuf, 0, sizeof(szTmpBuf));
	iRet = GetBit(ptMsgRule, ptData,FIELD44, szTmpBuf);
    /*
	if(iRet != 15)
	{
        WriteLog(ERROR, "交易类型[%d]应到报文第[%d]域拆解失败iRet:[%d]!",
                 ptApp->iTransType, CUSTOM_ID, iRet);

		strcpy(ptApp->szRetCode, ERR_DATA_FORMAT);

		return FAIL;
	}
    */

	/* 60.2域 批次号 */
	memset(szTmpBuf, 0, sizeof(szTmpBuf));
	iRet = GetBit(ptMsgRule, ptData, FIELD60, szTmpBuf);
    if(iRet < 1 || iRet > 11)
	{
        WriteLog(ERROR, "交易类型[%d]应到报文第[%d]域拆解失败iRet:[%d]!",
                 ptApp->iTransType, FIELD60, iRet);

        strcpy(ptApp->szRetCode, ERR_DATA_FORMAT);

        return FAIL;
	}
	memset(szTmpBuf2, 0, sizeof(szTmpBuf2));
	memcpy(szTmpBuf2, szTmpBuf+2, 6);
	ptApp->lBatchNo = atol(szTmpBuf2);

	return SUCC;
}
예제 #14
0
void __fastcall TBookNotAcceptListForm::btnQueryClick(TObject *Sender)
{
	int nDays,nYear,nMonth,nDay;
	CString szSQL;
	TListItem *pItem;
	char strTemp[256];
	int nSel,i;
        char strDate0[80],strDate1[80];
        unsigned short year0,month0,day0,year1,month1,day1;

	GetSysDate(nYear,nMonth,nDay,false);
	lstView->Items->Clear();

	edtDays->Text=edtDays->Text.Trim();
	if(edtDays->Text.IsEmpty())
	{
		ShowMessage("请输入宽放天数");
		if(edtDays->CanFocus())	edtDays->SetFocus();
		return;
	}
	if(!StringIsInt(edtDays->Text.c_str()) || (nDays=atoi(edtDays->Text.c_str()))<0)
	{
		ShowMessage("请输入整数");
		if(edtDays->CanFocus())	edtDays->SetFocus();
		return;
	}

	szSQL.Format("select * from BookFactory,PurchaseDetail,materialno,AskPurchase,Manufactur,StockHandleman"
		" where pd_code=bf_apcode"
		" and substring(pd_mncode,2,1)<>'M'"
		" and mn_code=pd_mncode"
    " and pd_endflag is null"
    " and ap_shcode=sh_code"
		" and ap_code=substring(pd_code,1,7)"
    " and bf_mfcode*=mf_code"
		" and bf_bookdate+bf_deliverdays+%d<'%04d-%02d-%02d'",nDays,nYear,nMonth,nDay);
        DateTimePicker1->DateTime.DecodeDate(&year0,&month0,&day0);
        sprintf(strDate0,"%04d-%02d-%02d",year0,month0,day0);
        DateTimePicker2->DateTime.DecodeDate(&year1,&month1,&day1);
        sprintf(strDate1,"%04d-%02d-%02d",year1,month1,day1);
        sprintf(strTemp," and bf_bookdate between '%s' and '%s'",strDate0,strDate1);
        szSQL+=strTemp;
	if((nSel=lstCorp->ItemIndex)>0 && nSel<m_lstCorpID.GetSize())
	{
		sprintf(strTemp," and substring(ap_reqdepart,1,2)='%s'",m_lstCorpID[nSel]);
		szSQL+=strTemp;
	}
	if((nSel=lstAskDep->ItemIndex)>0 && nSel<m_lstAskDepID.GetSize())
	{
		sprintf(strTemp," and ap_reqdepart='%s'",m_lstAskDepID[nSel]);
		szSQL+=strTemp;
	}
	if((nSel=lstDepart->ItemIndex)>0 && nSel<m_lstDepartID.GetSize())
	{
		sprintf(strTemp," and ap_sdcode='%s'",m_lstDepartID[nSel]);
		szSQL+=strTemp;
	}

	if((nSel=lstFact->ItemIndex)>0 && nSel<m_lstFactID.GetSize())
	{
		sprintf(strTemp," and bf_mfcode='%s'",m_lstFactID[nSel]);
		szSQL+=strTemp;
	}

	szSQL+=" and  bf_code not in"
		"("
		"select distinct(am_bfcode) from acceptmate"
		")"
		" order by bf_bookdate";
    RunSQL(dm1->Query1,szSQL,true);
	while(!dm1->Query1->Eof)
	{
		pItem=lstView->Items->Add();
		assert(pItem!=NULL);
		pItem->Caption=dm1->Query1->FieldByName("bf_code")->AsString;
		pItem->SubItems->Add(DateField2Text(dm1->Query1->FieldByName("bf_bookdate")));
		pItem->SubItems->Add(IntField2Text(dm1->Query1->FieldByName("bf_deliverdays")));
		pItem->SubItems->Add(dm1->Query1->FieldByName("mn_code")->AsString);
		pItem->SubItems->Add(dm1->Query1->FieldByName("mn_name")->AsString);
		strcpy(strTemp,dm1->Query1->FieldByName("ap_reqdepart")->AsString.c_str());
		strTemp[2]='\0';
		for(i=1;i<m_lstCorpID.GetSize();i++)
		{
			if(m_lstCorpID[i]==strTemp)
			{
				pItem->SubItems->Add(lstCorp->Items->Strings[i]);
				break;
			}
		}
		if(i==m_lstCorpID.GetSize())	pItem->SubItems->Add("");

		for(i=1;i<m_lstAskDepID.GetSize();i++)
		{
			if(m_lstAskDepID[i]==dm1->Query1->FieldByName("ap_reqdepart")->AsString.c_str())
			{
				pItem->SubItems->Add(lstAskDep->Items->Strings[i]);
				break;
			}
		}
		if(i==m_lstAskDepID.GetSize())	pItem->SubItems->Add("");

		for(i=1;i<m_lstDepartID.GetSize();i++)
		{
			if(m_lstDepartID[i]==dm1->Query1->FieldByName("ap_sdcode")->AsString.c_str())
			{
				pItem->SubItems->Add(lstDepart->Items->Strings[i]);
				break;
			}
		}
		if(i==m_lstDepartID.GetSize())	pItem->SubItems->Add("");

    pItem->SubItems->Add(FloatField2String(dm1->Query1->FieldByName("bf_count"),2));
    pItem->SubItems->Add(dm1->Query1->FieldByName("mf_shortname")->AsString);
    pItem->SubItems->Add(dm1->Query1->FieldByName("pd_code")->AsString);
    pItem->SubItems->Add(dm1->Query1->FieldByName("sh_name")->AsString);

		dm1->Query1->Next();
	}
// ShowMessage(szSQL.s)
}
예제 #15
0
/****************************************************************
** 功    能:请求报文拆包
** 输入参数:
**        szReqBuf              交易请求报文
**        iLen                  报文长度
** 输出参数:
**        ptApp                 app结构指针
** 返 回 值:
**        SUCC                  成功
**        FAIL                  失败
** 作    者:
**        fengwei
** 日    期:
**        2012/12/18
** 调用说明:
**
** 修改日志:
****************************************************************/
int UnpackWebReq(T_App *ptApp, char *szReqBuf, int iLen)
{
    int     iIndex;                 /* buf索引 */
    int     iMsgCount;              /* 短信记录数 */

    iIndex = 0;

    /* 交易代码 */
    memcpy(ptApp->szTransCode, szReqBuf+iIndex, 8);
    iIndex += 8;

    /* 根据交易代码获取交易定义 */
    if(GetTranInfo(ptApp) != SUCC)
    {
        return FAIL;
    }

    /* 更新方式 */
    giDownType = szReqBuf[iIndex] - '0';
    iIndex += 1;

    switch(giDownType)
    {
    /* 更新指定终端 */
    case DOWN_SPECIFY_POS:
        memcpy(ptApp->szShopNo, szReqBuf+iIndex, 15);
        iIndex += 15;
        DelTailSpace(ptApp->szShopNo);

        memcpy(ptApp->szPosNo, szReqBuf+iIndex, 15);
        iIndex += 15;
        DelTailSpace(ptApp->szPosNo);

        iIndex += 40;

        break;
    /* 更新指定商户终端 */
    case DOWN_SPECIFY_SHOP:
        memcpy(ptApp->szShopNo, szReqBuf+iIndex, 15);
        iIndex += 15;
        DelTailSpace(ptApp->szShopNo);

        iIndex += 55;

        break;
    /* 更新所有终端 */
    case DOWN_ALL:
        iIndex += 70;

        break;
    /* 更新指定应用类型终端 */
    case DOWN_SPECIFY_TYPE:
        memcpy(ptApp->szShopNo, szReqBuf+iIndex, 10);
        iIndex += 10;

        iIndex += 60;

        break;
    /* 更新指定机构下终端 */
    case DOWN_SPECIFY_DEPT:
        memcpy(ptApp->szDeptDetail, szReqBuf+iIndex, 70);
        iIndex += 70;
        DelTailSpace(ptApp->szDeptDetail);

        break;
    default:
        strcpy(ptApp->szRetCode, ERR_UNDEF_DOWNTYPE);

        WriteLog(ERROR, "更新类型:[%d]未定义!", giDownType);

        return FAIL;
    }

    /* 下载模式 */
    giDownMode = szReqBuf[iIndex] - '0';
    iIndex += 1;

    /* 根据交易拆解报文 */
    switch(ptApp->iTransType)
    {
    case CENDOWN_TERM_PARA:             /* 更新终端参数模板 */
    case CENDOWN_PSAM_PARA:             /* 更新安全参数模板 */
        /* 更新位图 */
        memcpy(gszBitmap, szReqBuf+iIndex, 32);
        iIndex += 32;

        break;
    case CENDOWN_MENU:                  /* 更新菜单 */
    case CENDOWN_ALL_OPERATION:         /* 更新应用 */
    case CENDOWN_PAYLIST:               /* 更新账单 */
    /*
    case CENDOWN_COMM_PARA:             更新通讯参数
        break;
    */
    case CENDOWN_OPERATION_INFO:        /* 更新操作提示 */
    case CENDOWN_FUNCTION_INFO:         /* 更新功能提示 */
    case CENDOWN_PRINT_INFO:            /* 更新打印记录 */
        /* 更新位图 */
        memcpy(gszBitmap, szReqBuf+iIndex, 256);
        iIndex += 256;

        break;
    case CENDOWN_MSG:                   /* 更新短信 */
        /* 短信记录数 */
        iMsgCount = szReqBuf[iIndex] - '0';

        memcpy(gszBitmap, szReqBuf+iIndex, 1+6*iMsgCount);
        iIndex += 1+6*iMsgCount;

        break;
    case CENDOWN_FIRST_PAGE:            /* 更新首页信息 */
        /* 更新记录号 */
        memcpy(gszBitmap, szReqBuf+iIndex, 6);
        iIndex += 6;

        break;
    default:
        strcpy(ptApp->szRetCode, ERR_INVALID_TRANS);

        WriteLog(ERROR, "未定义交易类型[%d]请求报文接口!", ptApp->iTransType);

        return FAIL;
    }

    /* POS交易日期、时间 */
    GetSysDate(ptApp->szPosDate);
    GetSysTime(ptApp->szPosTime);

    /* 响应码 */
    strcpy(ptApp->szRetCode, "NN");
    strcpy(ptApp->szHostRetCode, "NN");

    /* 呼叫类型 */
    ptApp->iCallType = CALLTYPE_CENTER;

    return SUCC;
}
예제 #16
0
EditTimeDlg::EditTimeDlg()
{
	a <<= GetSysDate();
	CtrlLayoutOK(*this, "Window title");
}
예제 #17
0
void Ide::SetupFormat() {
	FormatDlg dlg;
	dlg.Title("Format setup");
	WithSetupFontLayout<ParentCtrl> fnt;
	WithSetupHlLayout<ParentCtrl> hlt;
	WithSetupEditorLayout<ParentCtrl> edt;
	WithSetupIdeLayout<ParentCtrl> ide;
	WithSetupAssistLayout<ParentCtrl> assist;
	WithSetupMobilePlatformsLayout<ParentCtrl> mobile;
	AStyleSetupDialog ast(this);
#ifdef PLATFORM_WIN32
	ide.console_txt.Hide();
	ide.console.Hide();
	ide.kde.Hide();
	ide.gnome.Hide();
	ide.xterm.Hide();
	ide.mate.Hide();
	
#endif
	ide.kde <<= callback2(SetConsole, &ide.console, "/usr/bin/konsole -e");
	ide.gnome <<= callback2(SetConsole, &ide.console, "/usr/bin/gnome-terminal -x");
	ide.mate <<= callback2(SetConsole, &ide.console, "/usr/bin/mate-terminal -x");
	ide.xterm <<= callback2(SetConsole, &ide.console, "/usr/bin/xterm -e");
	
	edt.lineends
		.Add(LF, "LF")
		.Add(CRLF, "CRLF")
		.Add(DETECT_LF, "Detect with default LF")
		.Add(DETECT_CRLF, "Detect with default CRLF");
	
	edt.filetabs
		.Add(AlignedFrame::LEFT, "Left")
		.Add(AlignedFrame::TOP, "Top")
		.Add(AlignedFrame::RIGHT, "Right")
		.Add(AlignedFrame::BOTTOM, "Bottom")
		.Add(-1, "Off");
		
	edt.tabs_crosses
		.Add(AlignedFrame::LEFT, "Left")
		.Add(AlignedFrame::RIGHT, "Right")
		.Add(-1, "Off");
	
	dlg.Add(fnt, "Fonts");
	dlg.Add(hlt, "Syntax highlighting");
	dlg.Add(edt, "Editor");
	dlg.Add(assist, "Assist");
	dlg.Add(ide, "IDE");
	dlg.Add(ast, "Code formatting");
	dlg.Add(mobile, "Mobile platforms");
	dlg.WhenClose = dlg.Acceptor(IDEXIT);
	FontSelectManager ed, vf, con, f1, f2, tf;
	ed.Set(fnt.face, fnt.height, fnt.bold, fnt.italic, fnt.naa);
	vf.Set(fnt.vface, fnt.vheight, fnt.vbold, fnt.vitalic, fnt.vnaa);
	con.Set(fnt.cface, fnt.cheight, fnt.cbold, fnt.citalic, fnt.cnaa);
	tf.Set(fnt.tface, fnt.theight, fnt.tbold, fnt.titalic, fnt.tnaa);
	f1.Set(fnt.face1, fnt.height1, fnt.bold1, fnt.italic1, fnt.naa1);
	f2.Set(fnt.face2, fnt.height2, fnt.bold2, fnt.italic2, fnt.naa2);
	ed.Set(editorfont);
	vf.Set(veditorfont);
	con.Set(consolefont);
	tf.Set(tfont);
	f1.Set(font1);
	f2.Set(font2);
	DlCharset(edt.charset);
	edt.tabsize.MinMax(1, 100).NotNull();
	edt.tabsize <<= editortabsize;
	edt.indent_amount.MinMax(1, 100).NotNull();
	edt.indent_amount <<= indent_spaces ? indent_amount : editortabsize;
	edt.indent_amount.Enable(indent_spaces);
	CtrlRetriever rtvr;
	int hs = hilite_scope;
	rtvr
		(hlt.hilite_scope, hs)
		(hlt.hilite_bracket, hilite_bracket)
		(hlt.hilite_ifdef, hilite_ifdef)
		(hlt.hilite_if_endif, hilite_if_endif)
		(hlt.thousands_separator, thousands_separator)
		(hlt.hline, hline)

		(edt.indent_spaces, indent_spaces)
		(edt.no_parenthesis_indent, no_parenthesis_indent)
		(edt.showtabs, show_tabs)
		(edt.warnwhitespace, warnwhitespace)
		(edt.lineends, line_endings)
		(edt.numbers, line_numbers)
		(edt.bookmark_pos, bookmark_pos)
		(edt.bordercolumn, bordercolumn)
		(edt.bordercolor, bordercolor)
		(edt.findpicksel, find_pick_sel)
		(edt.findpicktext, find_pick_text)
		(edt.deactivate_save, deactivate_save)
		(edt.filetabs, filetabs)
		(edt.tabs_icons, tabs_icons)
		(edt.tabs_crosses, tabs_crosses)
		(edt.tabs_grouping, tabs_grouping)
		(edt.tabs_stacking, tabs_stacking)
		(edt.tabs_serialize, tabs_serialize)
		(edt.persistent_find_replace, persistent_find_replace)
		(edt.find_replace_restore_pos, find_replace_restore_pos)

		(assist.barline, barline)
		(assist.auto_enclose, auto_enclose)
		(assist.commentdp, editor.commentdp)
		(assist.header_guards, header_guards)
		(assist.insert_include, insert_include)
		(assist.mark_lines, mark_lines)
		(assist.qtfsel, qtfsel)
		(assist.assist, editor.auto_assist)

		(ide.showtime, showtime)
		(ide.show_status_bar, show_status_bar)
		(ide.toolbar_in_row, toolbar_in_row)
		(ide.splash_screen, splash_screen)
		(ide.sort, sort)
		(ide.mute_sounds, mute_sounds)
		(ide.wrap_console_text, wrap_console_text)
		(ide.hydra1_threads, hydra1_threads)
		(ide.gdbSelector, gdbSelector)
		(ide.chstyle, chstyle)
		(ide.console, LinuxHostConsole)
		(ide.output_per_assembly, output_per_assembly)

		(ast.BracketIndent,					astyle_BracketIndent)
		(ast.NamespaceIndent,               astyle_NamespaceIndent)
		(ast.BlockIndent,                   astyle_BlockIndent)
		(ast.CaseIndent,                    astyle_CaseIndent)
		(ast.ClassIndent,                   astyle_ClassIndent)
		(ast.LabelIndent,                   astyle_LabelIndent)
		(ast.SwitchIndent,                  astyle_SwitchIndent)
		(ast.PreprocessorIndent,            astyle_PreprocessorIndent)
		(ast.MinInStatementIndentLength,    astyle_MinInStatementIndentLength)
		(ast.MaxInStatementIndentLength,    astyle_MaxInStatementIndentLength)
		(ast.BreakClosingHeaderBracketsMode,astyle_BreakClosingHeaderBracketsMode)
		(ast.BreakElseIfsMode,              astyle_BreakElseIfsMode)
		(ast.BreakOneLineBlocksMode,        astyle_BreakOneLineBlocksMode)
		(ast.SingleStatementsMode,          astyle_SingleStatementsMode)
		(ast.BreakBlocksMode,               astyle_BreakBlocksMode)
		(ast.BreakClosingHeaderBlocksMode,  astyle_BreakClosingHeaderBlocksMode)
		(ast.BracketFormatMode,             astyle_BracketFormatMode)
		(ast.ParensPaddingMode,             astyle_ParensPaddingMode)
		(ast.ParensUnPaddingMode,           astyle_ParensUnPaddingMode)
		(ast.OperatorPaddingMode,           astyle_OperatorPaddingMode)
		(ast.EmptyLineFill,                 astyle_EmptyLineFill)
		(ast.TabSpaceConversionMode,        astyle_TabSpaceConversionMode)
		(ast.TestBox,						astyle_TestBox)
		
		(mobile.AndroidSDKPath, androidSDKPath)
	;
	hlt.hlstyle.AddColumn("Style");
	hlt.hlstyle.AddColumn("Color").Ctrls(HlPusherFactory);
	hlt.hlstyle.AddColumn("Bold").Ctrls<Option>();
	hlt.hlstyle.AddColumn("Italic").Ctrls<Option>();
	hlt.hlstyle.AddColumn("Underline").Ctrls<Option>();
	hlt.hlstyle.ColumnWidths("211 80 45 45 80");
	hlt.hlstyle.EvenRowColor().NoHorzGrid().SetLineCy(EditField::GetStdHeight() + 2);
	ReadHlStyles(hlt.hlstyle);
	edt.charset <<= (int)default_charset;
	edt.tabsize <<= rtvr <<=
		hlt.hlstyle.WhenCtrlsAction = ed.WhenAction = tf.WhenAction =
		con.WhenAction = f1.WhenAction = f2.WhenAction = dlg.Breaker(222);
	ide.showtimeafter <<= Nvl((Date)FileGetTime(ConfigFile("version")), GetSysDate() - 1);
	hlt.hl_restore <<= dlg.Breaker(333);
	ide.chstyle.Add(0, "Host platform");
	ide.chstyle.Add(1, "Standard");
	ide.chstyle.Add(2, "Classic");
	ide.chstyle.Add(3, "Host platform, blue bars");
	ide.chstyle.Add(4, "Standard, blue bars");

	FrameRight<Button> uscBrowse;
	uscBrowse.SetImage(CtrlImg::right_arrow());
	uscBrowse <<= callback1(AddPath, &ide.uscpath);
	ide.uscpath.AddFrame(uscBrowse);
	ide.uscpath <<= LoadFile(GetHomeDirFile("usc.path"));
	
	FrameRight<Button> androidSDKDownload;
	androidSDKDownload.SetImage(IdeImg::DownloadBlack());
	androidSDKDownload.Tip("Download");
	androidSDKDownload <<= callback1(LaunchWebBrowser, AndroidSDK::GetDownloadUrl());
	mobile.AndroidSDKPath.AddFrame(androidSDKDownload);
	
	FrameRight<Button> androidSDKBrowse;
	androidSDKBrowse.SetImage(CtrlImg::right_arrow());
	androidSDKBrowse.Tip("Select directory");
	androidSDKBrowse <<= callback1(InsertPath, &mobile.AndroidSDKPath);
	mobile.AndroidSDKPath.AddFrame(androidSDKBrowse);
	mobile.AndroidSDKPath <<= androidSDKPath;
	
	for(;;) {
		int c = dlg.Run();
		Upp::SaveFile(GetHomeDirFile("usc.path"), ~ide.uscpath);
		editorfont = ed.Get();
		tfont = tf.Get();
		veditorfont = vf.Get();
		consolefont = con.Get();
		font1 = f1.Get();
		font2 = f2.Get();
		editortabsize = Nvl((int)~edt.tabsize, 4);
		rtvr.Retrieve();
		console.SetSlots(minmax(hydra1_threads, 1, 256));
		hilite_scope = hs;
		if(indent_spaces)
			indent_amount = ~edt.indent_amount;
		else {
			indent_amount = editortabsize;
			edt.indent_amount <<= editortabsize;
		}
		edt.indent_amount.Enable(indent_spaces);
		default_charset = (byte)(int)~edt.charset;
		for(int i = 0; i < CodeEditor::HL_COUNT; i++)
			editor.SetHlStyle(i, hlt.hlstyle.Get(i, 1), hlt.hlstyle.Get(i, 2),
			                     hlt.hlstyle.Get(i, 3), hlt.hlstyle.Get(i, 4));
		UpdateFormat();
		if(c == IDEXIT)
			break;
		if(c == 333 && PromptYesNo("Restore default highlighting colors?")) {
			editor.DefaultHlStyles();
			ReadHlStyles(hlt.hlstyle);
		}
	}
	FileSetTime(ConfigFile("version"), ToTime(~ide.showtimeafter));
	FinishConfig();
	SaveConfig();
}