UINT8 IfInvSumRoll()
{
	CInvSum curInvSum;
	UINT8 ret = SUCCESS;
	UINT32 nSumDelDate = 0;

	TDateTime lastDate(g_globalArg->m_startDecDate, 000001);
	lastDate--;
	UINT32 nRefDate = lastDate.FormatInt(YYYYMMDD);//上次申报的截止日期

	ret = curInvSum.CheckRoll(g_globalArg->m_invSumCount, nRefDate,nSumDelDate);
	if (ret!=SUCCESS)
	{
		CaMsgBox::ShowMsg("单卷汇总滚动判断失败!");
		DBG_RETURN(FAILURE);
	}

	if (nSumDelDate>0)
	{
		DBG_PRINT(("nSumDelDate = %u", nSumDelDate));
		CaMsgBox::ShowMsg("单卷汇总要滚动!");		
	}
	
	DBG_RETURN(SUCCESS);

}
UINT8 IfInvHeadRoll()
{
	CInvHead curInvHead;
	UINT8 ret = SUCCESS;
	UINT32 nInvDelDate = 0;
	
//	ret = CheckIfFull(g_globalArg->m_invCount, g_globalArg->m_invSumCount);
//	if (ret==SUCCESS) 
//	{
//		DBG_RETURN(DB_FULL);		
//	}

	TDateTime lastDate(g_globalArg->m_startDecDate, 000001);
	lastDate--;
	UINT32 nRefDate = lastDate.FormatInt(YYYYMMDD);//上次申报的截止日期

	//判断是否需要滚动,并计算需滚动的记录数量
	ret = curInvHead.CheckRoll(g_globalArg->m_invCount, nRefDate,nInvDelDate);
	if (ret!=SUCCESS)
	{
		CaMsgBox::ShowMsg("发票张数滚动判断失败!");
		DBG_RETURN(FAILURE);
	}

	//滚动
	if (nInvDelDate>0)
	{
		DBG_PRINT(("nInvDelDate = %u", nInvDelDate));
		CaMsgBox::ShowMsg("发票张数要滚动!");
	}
	DBG_RETURN(SUCCESS);
}
Exemple #3
0
void TimetableWarning::toParametersMap(
    ParametersMap& pm,
    bool withDates
) const	{

    pm.insert(DATA_NUMBER, getNumber());
    pm.insert(DATA_TEXT, getText());

    // Active days
    const Calendar& calendar(getCalendar());
    date firstDate(calendar.getFirstActiveDate());
    date lastDate(calendar.getLastActiveDate());
    if(withDates)
    {
        for(date day(firstDate); day <lastDate; day += days(1))
        {
            // Jump over inactive days
            if(!calendar.isActive(day))
            {
                continue;
            }

            // Writing the active date to a sub map
            boost::shared_ptr<ParametersMap> datePM(new ParametersMap);
            datePM->insert(ATTR_DATE, day);
            pm.insert(TAG_DAY, datePM);
        }
    }

    // Active days bounds
    pm.insert(DATA_FIRST_DATE, firstDate);
    pm.insert(DATA_LAST_DATE, firstDate);

    // Active days bounds (old schema - deprecated)
    pm.insert(DATA_FIRST_DAY, firstDate.day());
    pm.insert(DATA_FIRST_MONTH, firstDate.month());
    pm.insert(DATA_FIRST_YEAR, firstDate.year());
    pm.insert(DATA_LAST_DAY, lastDate.day());
    pm.insert(DATA_LAST_MONTH, lastDate.month());
    pm.insert(DATA_LAST_YEAR, lastDate.year());

    // Calendar template
    if(_calendarTemplate)
    {
        boost::shared_ptr<ParametersMap> calendarPM(new ParametersMap);
        _calendarTemplate->toParametersMap(*calendarPM, true);
        pm.insert(TAG_CALENDAR, calendarPM);
    }
}
Exemple #4
0
void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
{
    QDateTime now = historyBaselineDate.addMSecs(-1);

    if (since > now)
        return;

    if (!earliestMessage.isNull())
    {
        if (earliestMessage < since)
            return;

        if (earliestMessage < now)
        {
            now = earliestMessage;
            now = now.addMSecs(-1);
        }
    }

    auto msgs = HistoryKeeper::getInstance()->getChatHistory(HistoryKeeper::ctSingle, f->getToxID().publicKey, since, now);

    ToxId storedPrevId = previousId;
    ToxId prevId;

    QList<ChatLine::Ptr> historyMessages;

    QDate lastDate(1,0,0);
    for (const auto &it : msgs)
    {
        // Show the date every new day
        QDateTime msgDateTime = it.timestamp.toLocalTime();
        QDate msgDate = msgDateTime.date();

        if (msgDate > lastDate)
        {
            lastDate = msgDate;
            historyMessages.append(ChatMessage::createChatInfoMessage(msgDate.toString(Settings::getInstance().getDateFormat()), ChatMessage::INFO, QDateTime()));
        }

        // Show each messages
        ToxId authorId = ToxId(it.sender);
        QString authorStr = authorId.isActiveProfile() ? Core::getInstance()->getUsername() : resolveToxID(authorId);
        bool isAction = it.message.startsWith("/me ", Qt::CaseInsensitive);

        ChatMessage::Ptr msg = ChatMessage::createChatMessage(authorStr,
                                                              isAction ? it.message.right(it.message.length() - 4) : it.message,
                                                              isAction ? ChatMessage::ACTION : ChatMessage::NORMAL,
                                                              authorId.isActiveProfile(),
                                                              QDateTime());

        if (!isAction && (prevId == authorId) && (prevMsgDateTime.secsTo(msgDateTime) < getChatLog()->repNameAfter) )
            msg->hideSender();

        prevId = authorId;
        prevMsgDateTime = msgDateTime;

        if (it.isSent || !authorId.isActiveProfile())
        {
            msg->markAsSent(msgDateTime);
        }
        else
        {
            if (processUndelivered)
            {
                int rec;
                if (!isAction)
                    rec = Core::getInstance()->sendMessage(f->getFriendID(), msg->toString());
                else
                    rec = Core::getInstance()->sendAction(f->getFriendID(), msg->toString());

                getOfflineMsgEngine()->registerReceipt(rec, it.id, msg);
            }
        }
        historyMessages.append(msg);
    }

    previousId = storedPrevId;
    int savedSliderPos = chatWidget->verticalScrollBar()->maximum() - chatWidget->verticalScrollBar()->value();

    earliestMessage = since;

    chatWidget->insertChatlineOnTop(historyMessages);

    savedSliderPos = chatWidget->verticalScrollBar()->maximum() - savedSliderPos;
    chatWidget->verticalScrollBar()->setValue(savedSliderPos);
}
Exemple #5
0
void NotifyWindow::updateNotifyDisplay() {
	if (!item) return;

	int32 w = st::notifyWidth, h = st::notifyHeight;
	QImage img(w * cIntRetinaFactor(), h * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
	if (cRetina()) img.setDevicePixelRatio(cRetinaFactor());
	img.fill(st::notifyBG->c);

	{
		QPainter p(&img);
		p.fillRect(0, 0, w - st::notifyBorderWidth, st::notifyBorderWidth, st::notifyBorder->b);
		p.fillRect(w - st::notifyBorderWidth, 0, st::notifyBorderWidth, h - st::notifyBorderWidth, st::notifyBorder->b);
		p.fillRect(st::notifyBorderWidth, h - st::notifyBorderWidth, w - st::notifyBorderWidth, st::notifyBorderWidth, st::notifyBorder->b);
		p.fillRect(0, st::notifyBorderWidth, st::notifyBorderWidth, h - st::notifyBorderWidth, st::notifyBorder->b);

		if (cNotifyView() <= dbinvShowName) {
			if (history->peer->photo->loaded()) {
				p.drawPixmap(st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), history->peer->photo->pix(st::notifyPhotoSize));
			} else {
				MTP::clearLoaderPriorities();
				peerPhoto = history->peer->photo;
				peerPhoto->load(true, true);
			}
		} else {
			static QPixmap icon = QPixmap::fromImage(App::wnd()->iconLarge().scaled(st::notifyPhotoSize, st::notifyPhotoSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
			p.drawPixmap(st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), icon);
		}

		int32 itemWidth = w - st::notifyPhotoPos.x() - st::notifyPhotoSize - st::notifyTextLeft - st::notifyClosePos.x() - st::notifyClose.width;

		QRect rectForName(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyTextTop, itemWidth, st::msgNameFont->height);
		if (cNotifyView() <= dbinvShowName) {
			if (history->peer->chat) {
				p.drawPixmap(QPoint(rectForName.left() + st::dlgChatImgLeft, rectForName.top() + st::dlgChatImgTop), App::sprite(), st::dlgChatImg);
				rectForName.setLeft(rectForName.left() + st::dlgChatImgSkip);
			}
		}

		QDateTime now(QDateTime::currentDateTime()), lastTime(item->date);
		QDate nowDate(now.date()), lastDate(lastTime.date());
		QString dt = lastTime.toString(qsl("hh:mm"));
		int32 dtWidth = st::dlgHistFont->m.width(dt);
		rectForName.setWidth(rectForName.width() - dtWidth - st::dlgDateSkip);
		p.setFont(st::dlgDateFont->f);
		p.setPen(st::dlgDateColor->p);
		p.drawText(rectForName.left() + rectForName.width() + st::dlgDateSkip, rectForName.top() + st::dlgHistFont->ascent, dt);

		if (cNotifyView() <= dbinvShowPreview) {
			const HistoryItem *textCachedFor = 0;
			Text itemTextCache(itemWidth);
			bool active = false;
			item->drawInDialog(p, QRect(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyItemTop + st::msgNameFont->height, itemWidth, 2 * st::dlgFont->height), active, textCachedFor, itemTextCache);
		} else {
			static QString notifyText = st::dlgHistFont->m.elidedText(lang(lng_notification_preview), Qt::ElideRight, itemWidth);
			p.setPen(st::dlgSystemColor->p);
			p.drawText(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyItemTop + st::msgNameFont->height + st::dlgHistFont->ascent, notifyText);
		}

		p.setPen(st::dlgNameColor->p);
		if (cNotifyView() <= dbinvShowName) {
			history->nameText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
		} else {
			p.setFont(st::msgNameFont->f);
			static QString notifyTitle = st::msgNameFont->m.elidedText(lang(lng_notification_title), Qt::ElideRight, rectForName.width());
			p.drawText(rectForName.left(), rectForName.top() + st::msgNameFont->ascent, notifyTitle);
		}
	}

	pm = QPixmap::fromImage(img);
	update();
}
Exemple #6
0
void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
{
    QDateTime now = QDateTime::currentDateTime();

    if (since > now)
        return;

    if (earliestMessage)
    {
        if (*earliestMessage < since)
            return;
        if (*earliestMessage < now)
        {
            now = *earliestMessage;
            now = now.addMSecs(-1);
        }
    }

    auto msgs = HistoryKeeper::getInstance()->getChatHistory(HistoryKeeper::ctSingle, f->getToxID().publicKey, since, now);

    ToxID storedPrevId;
    std::swap(storedPrevId, previousId);
    QList<ChatActionPtr> historyMessages;

    QDate lastDate(1,0,0);
    for (const auto &it : msgs)
    {
        // Show the date every new day
        QDateTime msgDateTime = it.timestamp.toLocalTime();
        QDate msgDate = msgDateTime.date();
        if (msgDate > lastDate)
        {
            lastDate = msgDate;
            historyMessages.append(genSystemInfoAction(msgDate.toString(),"",QDateTime()));
        }

        // Show each messages
        ToxID msgSender = ToxID::fromString(it.sender);
        MessageActionPtr ca = genMessageActionAction(msgSender, it.message, false, msgDateTime);
        if (it.isSent || !msgSender.isMine())
        {
            ca->markAsSent();
        } else {
            if (processUndelivered)
            {
                int rec;
                if (ca->isAction())
                    rec = Core::getInstance()->sendAction(f->getFriendID(), ca->getRawMessage());
                else
                    rec = Core::getInstance()->sendMessage(f->getFriendID(), ca->getRawMessage());
                registerReceipt(rec, it.id, ca);
            }
        }
        historyMessages.append(ca);
    }
    std::swap(storedPrevId, previousId);

    int savedSliderPos = chatWidget->verticalScrollBar()->maximum() - chatWidget->verticalScrollBar()->value();

    if (earliestMessage != nullptr)
        *earliestMessage = since;

    chatWidget->insertMessagesTop(historyMessages);

    savedSliderPos = chatWidget->verticalScrollBar()->maximum() - savedSliderPos;
    chatWidget->verticalScrollBar()->setValue(savedSliderPos);
}
int main(void)
{
    //宣告與定義(Declaration & Definition)
    short int scanfTriggered = 0;
    short int year, startWkDay;
    short int month;

//標題
//版本:1.00(3)
    printf("程式名稱(Program Name):C Programming Practice 7-2[Basic] Printing a Calendar for a Year 。\n");
    printf("程式敘述(Program Description):\nWrite a program that prints a one-year calendar.\nThe user enters which year's calendar he wants, and specifies the day of the week on which the year begins.。\n");
    printf("程式版本(Program Version):1.00(0)\n");
    printf("Build by Vdragon@2010\nAll rights RESERVED\n");
    printf("---------------------------------\n");


//詢問year年 startWkday星期幾代表的位置
    printf("請問要印哪一年的月曆:");
    scanfTriggered = 1;
    scanf("%hd", &year);
    printf("2000 年 1 月 1 日是星期幾(0 表示星期天、1 表示星期一,依此類推)?");
    scanfTriggered = 1;
    scanf("%hd", &startWkDay);

//output 上方的文字
    printf("\n%d 年月曆\n\n", year);


//調動輸出日曆模塊
//從一月到12月
    for(month = 1 ; month <= 12 ; month++ )
    {
        //輸出標頭 參數 月名
        const char * monthName[12] = {"一","二","三","四", "五", "六", "七", "八", "九", "十", "十一", "十二"};
        printf("【%s月】\n日 一 二 三 四 五 六\n", monthName[month - 1]);
        //模塊*12
        //接收新位置
        startWkDay = printMonthCaldr(lastDate(year, month), startWkDay);
    }






//-----------------------------------------
//使程式暫停運行
//版本:1.00(14)
    //方法一︰執行系統指令(部份系統有效、需#include <stdlib.h>)
    //printf("\n---------------------------------\n顯示運行結果,程式暫停運行\n");
    //system("pause");
    //方法二:運用輸入function(需#include <stdio.h>)
    printf("\n---------------------------------\n顯示運行結果,程式暫停運行\n請按Enter繼續");
    //先清除imput buffer
    //方法一
    /*
       int ch;
       while ((ch = getchar()) != EOF && ch != '\n');
    */
    //方法二
    //需全域定義int scanfTriggered = 0;

    if (scanfTriggered ==1)
    {
        scanf("%*[^\n]");
        scanf("%*c");
    }


    fgetc(stdin); //參數stdin表鍵盤(stream來源)輸入(有scanf()就會無效,須清除inputbuffer)



    //傳回數字0(表程式運行成功)
    //版本:1.00(1)
    //return後面不可加註解!
    return 0;
}
Exemple #8
0
void SessionsBox::gotAuthorizations(const MTPaccount_Authorizations &result) {
	_shortPollRequest = 0;
	setLoading(false);

	auto availCurrent = st::boxWideWidth - st::sessionPadding.left() - st::sessionTerminateSkip;
	auto availOther = availCurrent - st::sessionTerminate.iconPosition.x();// -st::sessionTerminate.width - st::sessionTerminateSkip;

	_list.clear();
	if (result.type() != mtpc_account_authorizations) {
		return;
	}
	auto &v = result.c_account_authorizations().vauthorizations.c_vector().v;
	_list.reserve(v.size());

	const CountriesByISO2 &countries(countriesByISO2());

	for_const (auto &auth, v) {
		if (auth.type() != mtpc_authorization) {
			continue;
		}
		auto &d = auth.c_authorization();
		Data data;
		data.hash = d.vhash.v;

		QString appName, appVer = qs(d.vapp_version), systemVer = qs(d.vsystem_version), deviceModel = qs(d.vdevice_model);
		if (d.vapi_id.v == 2040 || d.vapi_id.v == 17349) {
			appName = (d.vapi_id.v == 2040) ? qstr("Telegram Desktop") : qstr("Telegram Desktop (GitHub)");
		//	if (systemVer == qstr("windows")) {
		//		deviceModel = qsl("Windows");
		//	} else if (systemVer == qstr("os x")) {
		//		deviceModel = qsl("OS X");
		//	} else if (systemVer == qstr("linux")) {
		//		deviceModel = qsl("Linux");
		//	}
			if (appVer == QString::number(appVer.toInt())) {
				int32 ver = appVer.toInt();
				appVer = QString("%1.%2").arg(ver / 1000000).arg((ver % 1000000) / 1000) + ((ver % 1000) ? ('.' + QString::number(ver % 1000)) : QString());
			} else {
				appVer = QString();
			}
		} else {
			appName = qs(d.vapp_name);// +qsl(" for ") + qs(d.vplatform);
			if (appVer.indexOf('(') >= 0) appVer = appVer.mid(appVer.indexOf('('));
		}
		data.name = appName;
		if (!appVer.isEmpty()) data.name += ' ' + appVer;
		data.nameWidth = st::sessionNameFont->width(data.name);

		QString country = qs(d.vcountry), platform = qs(d.vplatform);
		//CountriesByISO2::const_iterator j = countries.constFind(country);
		//if (j != countries.cend()) country = QString::fromUtf8(j.value()->name);

		MTPint active = d.vdate_active.v ? d.vdate_active : d.vdate_created;
		data.activeTime = active.v;

		data.info = qs(d.vdevice_model) + qstr(", ") + (platform.isEmpty() ? QString() : platform + ' ') + qs(d.vsystem_version);
		data.ip = qs(d.vip) + (country.isEmpty() ? QString() : QString::fromUtf8(" \xe2\x80\x93 ") + country);
		if (!data.hash || (d.vflags.v & 1)) {
			data.active = lang(lng_sessions_header);
			data.activeWidth = st::sessionWhenFont->width(lang(lng_sessions_header));
			int32 availForName = availCurrent - st::sessionPadding.right() - data.activeWidth;
			if (data.nameWidth > availForName) {
				data.name = st::sessionNameFont->elided(data.name, availForName);
				data.nameWidth = st::sessionNameFont->width(data.name);
			}
			data.infoWidth = st::sessionInfoFont->width(data.info);
			if (data.infoWidth > availCurrent) {
				data.info = st::sessionInfoFont->elided(data.info, availCurrent);
				data.infoWidth = st::sessionInfoFont->width(data.info);
			}
			data.ipWidth = st::sessionInfoFont->width(data.ip);
			if (data.ipWidth > availCurrent) {
				data.ip = st::sessionInfoFont->elided(data.ip, availCurrent);
				data.ipWidth = st::sessionInfoFont->width(data.ip);
			}
			_current = data;
		} else {
			QDateTime now(QDateTime::currentDateTime()), lastTime(date(active));
			QDate nowDate(now.date()), lastDate(lastTime.date());
			QString dt;
			if (lastDate == nowDate) {
				data.active = lastTime.toString(cTimeFormat());
			} else if (lastDate.year() == nowDate.year() && lastDate.weekNumber() == nowDate.weekNumber()) {
				data.active = langDayOfWeek(lastDate);
			} else {
				data.active = lastDate.toString(qsl("d.MM.yy"));
			}
			data.activeWidth = st::sessionWhenFont->width(data.active);
			int32 availForName = availOther - st::sessionPadding.right() - data.activeWidth;
			if (data.nameWidth > availForName) {
				data.name = st::sessionNameFont->elided(data.name, availForName);
				data.nameWidth = st::sessionNameFont->width(data.name);
			}
			data.infoWidth = st::sessionInfoFont->width(data.info);
			if (data.infoWidth > availOther) {
				data.info = st::sessionInfoFont->elided(data.info, availOther);
				data.infoWidth = st::sessionInfoFont->width(data.info);
			}
			data.ipWidth = st::sessionInfoFont->width(data.ip);
			if (data.ipWidth > availOther) {
				data.ip = st::sessionInfoFont->elided(data.ip, availOther);
				data.ipWidth = st::sessionInfoFont->width(data.ip);
			}

			_list.push_back(data);
			for (int32 i = _list.size(); i > 1;) {
				--i;
				if (_list.at(i).activeTime > _list.at(i - 1).activeTime) {
					qSwap(_list[i], _list[i - 1]);
				}
			}
		}
	}
	_inner->listUpdated();

	update();

	_shortPollTimer->start(SessionsShortPollTimeout);
}