本文整理汇总了C++中ADB::sumFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ ADB::sumFloat方法的具体用法?C++ ADB::sumFloat怎么用?C++ ADB::sumFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ADB
的用法示例。
在下文中一共展示了ADB::sumFloat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printReport
void CollReport::printReport(long CustID)
{
QDate theDate;
QPrinter prn(QPrinter::PrinterResolution);
QPainter p;
QRect rect;
ADBTable cust;
ADBTable cont;
ADB DB;
QString tmpSt;
QDate tmpDate1;
char tmpStr[1024];
char tStr[1024];
int yPos;
int pageNo = 1;
float Balance = 0.00;
float EndingBalance;
CustomersDB CDB;
AddressesDB addrDB;
char transFont[1024];
strcpy(transFont, "b&h lucida");
CDB.get(CustID);
addrDB.get(REF_CUSTOMER, CustID, "Billing");
theDate = QDate::currentDate();
sprintf(tStr, "/tmp/collreport-%09ld.ps", CustID);
// prn.setPrintProgram("ghostview");
//prn.setPrinterName("PostScript");
//prn.setOutputFileName(tStr);
prn.setOutputToFile(false);
prn.setPageSize(QPrinter::Letter);
prn.setFullPage(true);
prn.setDocName("Collections Report");
prn.setCreator("Total Accountability");
p.begin(&prn);
EndingBalance = DB.sumFloat("select SUM(Amount) from AcctsRecv where CustomerID = %ld", CustID);
// Put the Blarg header and contact information on the page.
printHeader(&p, &CDB, &addrDB, EndingBalance);
// Put the register header on the page.
registerHeader(&p);
// Now, get the register information from the database.
DB.query("select TransDate, DueDate, LoginID, Memo, Amount from AcctsRecv where CustomerID = %ld order by TransDate, LoginID", CustID);
yPos = 165;
p.setFont(QFont(transFont, 8, QFont::Normal));
QFontMetrics fm(p.fontMetrics());
while (DB.getrow()) {
//int Lines = (int) (strlen(DB.curRow["Memo"]) / 52) + 1;
//int RowHeight = 15 * Lines;
int Lines = (int) (fm.width(DB.curRow["Memo"]) / (descriptionX2 - descriptionX1 - 2)) + 1;
int RowHeight = (fm.height()+2) * Lines;
// Check to see if we have enough room on the page left for this
// line.
if (yPos+RowHeight >= 740) {
printFooter(&p, pageNo++);
prn.newPage();
printHeader(&p, &CDB, &addrDB, EndingBalance);
registerHeader(&p);
yPos = 165;
p.setFont(QFont(transFont, 8, QFont::Normal));
}
// The transaction date.
myDatetoQDate(DB.curRow["TransDate"], &tmpDate1);
sprintf(tmpStr, "%02d/%02d/%02d", tmpDate1.month(), tmpDate1.day(), tmpDate1.year()%100);
rect.setCoords(transDateX1, yPos, transDateX2, yPos + RowHeight-1);
p.drawRect(rect);
p.drawText(rect, Qt::AlignVCenter|Qt::AlignHCenter, tmpStr);
// The Due Date
myDatetoQDate(DB.curRow["DueDate"], &tmpDate1);
sprintf(tmpStr, "%02d/%02d/%02d", tmpDate1.month(), tmpDate1.day(), tmpDate1.year()%100);
rect.setCoords(dueDateX1, yPos, dueDateX2, yPos + RowHeight-1);
p.drawRect(rect);
p.drawText(rect, Qt::AlignVCenter|Qt::AlignHCenter, tmpStr);
// The Login ID
/*
rect.setCoords(140, yPos, 199, yPos + RowHeight);
p.drawRect(rect);
p.drawText(rect, Qt::AlignVCenter|Qt::AlignHCenter, DB.curRow["LoginID"]);
*/
// The description...
//fprintf(stderr, "descriptionX1 = %d, descriptionX2 = %d\n", descriptionX1, descriptionX2);
//fprintf(stderr, "description = '%s'\n", DB.curRow["Memo"]);
rect.setCoords(descriptionX1, yPos, descriptionX2, yPos + RowHeight-1);
p.drawRect(rect);
rect.setCoords(descriptionX1+1, yPos, descriptionX2, yPos + RowHeight);
p.drawText(rect, Qt::WordBreak|Qt::AlignLeft|Qt::AlignVCenter, DB.curRow["Memo"]);
// The amount.
//.........这里部分代码省略.........
示例2: printRegister
void CustRegister::printRegister()
{
QDate theDate;
QPrinter prn;
QPainter p;
QRect rect;
ADBTable cust;
ADBTable cont;
ADB DB;
QString tmpSt;
char tStr[1024];
int yPos;
int pageNo = 1;
float Balance = 0.00;
float EndingBalance;
CustomersDB CDB;
AddressesDB addrDB;
CDB.get(myCustID);
addrDB.get(REF_CUSTOMER, myCustID, "Billing");
theDate = QDate::currentDate();
// prn.setPrintProgram("ghostview");
prn.setPrinterName("PostScript");
// prn.setOutputFileName("/home/marc/test.ps");
// prn.setOutputToFile(TRUE);
prn.setPageSize(QPrinter::Letter);
prn.setDocName("Register Listing");
prn.setCreator("Blarg! Online Services, Inc.");
if (!prn.setup()) return;
p.begin(&prn);
EndingBalance = DB.sumFloat("select SUM(Amount) from AcctsRecv where CustomerID = %ld", myCustID);
// Put the Blarg header and contact information on the page.
printHeader(&p, &CDB, &addrDB, EndingBalance);
// Put the register header on the page.
registerHeader(&p);
// Now, get the register information from the database.
DB.query("select TransDate, DueDate, LoginID, Memo, Amount from AcctsRecv where CustomerID = %ld order by TransDate, LoginID", myCustID);
yPos = 165;
p.setFont(QFont("courier", 8, QFont::Normal));
while (DB.getrow()) {
int Lines = (int) (strlen(DB.curRow["Memo"]) / 52) + 1;
int RowHeight = 15 * Lines;
// Check to see if we have enough room on the page left for this
// line.
if (yPos+RowHeight >= 740) {
printFooter(&p, pageNo++);
prn.newPage();
printHeader(&p, &CDB, &addrDB, EndingBalance);
registerHeader(&p);
yPos = 165;
p.setFont(QFont("courier", 8, QFont::Normal));
}
// The transaction date.
rect.setCoords(20, yPos, 79, yPos + RowHeight);
p.drawRect(rect);
p.drawText(rect, AlignVCenter|AlignHCenter, DB.curRow["TransDate"]);
// The Due Date
rect.setCoords(80, yPos, 139, yPos + RowHeight);
p.drawRect(rect);
p.drawText(rect, AlignVCenter|AlignHCenter, DB.curRow["DueDate"]);
// The Login ID
rect.setCoords(140, yPos, 199, yPos + RowHeight);
p.drawRect(rect);
p.drawText(rect, AlignVCenter|AlignHCenter, DB.curRow["LoginID"]);
// The description...
rect.setCoords(200, yPos, 419, yPos + RowHeight);
p.drawRect(rect);
rect.setCoords(203, yPos, 419, yPos + RowHeight);
p.drawText(rect, WordBreak|AlignLeft|AlignVCenter, DB.curRow["Memo"]);
// The amount.
rect.setCoords(420, yPos, 479, yPos + RowHeight);
p.drawRect(rect);
p.drawText(rect, AlignRight|AlignVCenter, DB.curRow["Amount"]);
// The balance.
Balance += atof(DB.curRow["Amount"]);
sprintf(tStr, "%.2f", Balance);
if (Balance == 0.0) strcpy(tStr, "0.00");
rect.setCoords(480, yPos, 539, yPos + RowHeight);
p.drawRect(rect);
p.drawText(rect, AlignRight|AlignVCenter, tStr);
yPos += RowHeight;
}
//.........这里部分代码省略.........