📄 saleform.ui.h
字号:
/****************************************************************************** ui.h extension file, included from the uic-generated form implementation.**** If you wish to add, delete or rename functions or slots use** Qt Designer which will update this file, preserving your code. Create an** init() function in place of a constructor, and a destroy() function in** place of a destructor.*****************************************************************************/#include <qsqlcursor.h>#include <qtable.h>#include <qmessagebox.h>#include <.ui/saleform.h>#include <qdatetime.h>#include <qnamespace.h>#include <qvariant.h>#include "XmlWriter.h"#include ".ui/cash.h"#include "driver.h"#include <fcntl.h>void saleForm::lineEdit1_returnPressed(){ static double sum=0; static int row=0; textLabel3->setText("200501180001"); textLabel16->setText(tr("操作人员: tom")); QSqlCursor cur( "product" ); if (lineEdit1->text() != "") { QSqlQuery q( "select code, name, saleprice, discount from product where code='"+lineEdit1->text()+"';" ); if ( q.next() ) { table1->insertRows(row); table1->setText(row, 0, q.value(0).toString()); table1->setText(row, 1, q.value(1).toString()); table1->setText(row, 2, "1"); table1->setText(row, 3, q.value(2).toString()); table1->setText(row, 4, q.value(3).toString()); table1->setText(row++, 5, q.value(2).toString()); textLabel8->setText(q.value(1).toString()); textLabel9->setText(q.value(2).toString()/*q.value(1).toString()*/); textLabel11->setText("1"); textLabel13->setText(q.value(2).toString()); sum += q.value(2).toDouble(); QVariant var(sum); textLabel5->setText(var.toString()); if (row == 1) { PalPrnStr(fd, " 某某大型超市", 20); PalPrnStr(fd, "流水号:200501180001\n", 20); PalPrnStr(fd, "编码 商品名 单价 数量", 30); } QString info(q.value(0).toString()+" "+q.value(1).toString()+" "+q.value(2).toString()+" 1"); PalPrnStr(fd, info.ascii(), info.length()); iopl(3); //进入内核模式 QString price(q.value(2).toString()); int pos = price.find("."); if (pos == -1) { price.append(".00"); // printf("price.append('.00') = %s\n", price); } else if ((price.length()-pos)==2) { price.append("0"); // printf("price.append('0') = %s\n", price); } else { // printf("price.append('') = %s\n", price); } CD109_Trans(5,1,1,price.ascii()); iopl(0); //返回用户模式 // table1->setText(0,0,"test"); } else { QMessageBox::warning( this, "Error!", tr("没有此商品") ); } } else { int rows = table1->numRows(); int i; if (rows > 0) { PalPrnStr(fd, "\n\n\n\n", 4); cashForm *fm = new cashForm(this, 0, 1, WDestructiveClose, sum); fm->exec(); QSqlCursor cur1( "sales" ); QDateTime dt = QDateTime::currentDateTime(); Qt::DateFormat f = Qt::ISODate; for (i=0;i<rows;i++) { QSqlRecord *buffer = cur1.primeInsert(); buffer->setValue( "flowno", "200501180001" ); buffer->setValue( "date", dt.toString(f) ); buffer->setValue( "code", table1->text(i, 0) ); buffer->setValue( "name", table1->text(i, 1) ); buffer->setValue( "price", table1->text(i, 2).toDouble() ); buffer->setValue( "count", table1->text(i, 3).toInt() ); buffer->setValue( "discount", table1->text(i, 4).toInt() ); buffer->setValue( "total", table1->text(i, 5).toDouble() ); buffer->setValue( "saler", "tom" ); cur1.insert(); } XmlWriter w; char *ns1[] = {"ns", "http://www.newstar.com/embedded/"}; char *attr1[2] = {"id", "0"}; char id[6]; w = XmlWriterCreate(); WriteStartDocument(w); WriteComment(w, "Test XML!"); WriteStartElement(w, "SaleTable", ns1); WriteNamespaces(w, ns1); WriteStartElement(w, "Order", ns1); WriteStartElement(w, "flowno", ns1); WriteValue(w, "200501180001"); WriteEndElement(w, "flowno", ns1); WriteStartElement(w, "date", ns1); WriteValue(w, dt.toString(f)); WriteEndElement(w, "date", ns1); for (i=0;i<rows;i++) { itoa(i+1, id, 0); attr1[1] = id; WriteStartElement(w, "Item", ns1); WriteAttributeString(w, attr1, NONAMESPACE); WriteStartElement(w, "code", NONAMESPACE); WriteValue(w, table1->text(i, 0)); WriteEndElement(w, "code", NONAMESPACE); WriteStartElement(w, "name", NONAMESPACE); WriteValue(w, table1->text(i, 1)); WriteEndElement(w, "name", NONAMESPACE); WriteStartElement(w, "price", NONAMESPACE); WriteValue(w, table1->text(i, 2)); WriteEndElement(w, "price", NONAMESPACE); WriteStartElement(w, "count", NONAMESPACE); WriteValue(w, table1->text(i, 3)); WriteEndElement(w, "count", NONAMESPACE); WriteStartElement(w, "discount", NONAMESPACE); WriteValue(w, table1->text(i, 4)); WriteEndElement(w, "discount", NONAMESPACE); WriteStartElement(w, "total", NONAMESPACE); WriteValue(w, table1->text(i, 5)); WriteEndElement(w, "total", NONAMESPACE); WriteEndElement(w, "Item", ns1); } WriteStartElement(w, "saler", ns1); WriteValue(w, "tom"); WriteEndElement(w, "saler", ns1); WriteEndElement(w, "Order", ns1); WriteEndElement(w, "SaleTable", ns1); WriteEndDocument(w);// printf("%s", w->buf_start); QMessageBox::warning( this, "XML Test!", w->buf_start ); PalPrnStr(fd, w->buf_start, _GetLength(w)); XmlWriterFree(w); } } lineEdit1->setText(""); lineEdit1->setFocus();}void saleForm::displayDateTime(){ QDateTime dt = QDateTime::currentDateTime(); Qt::DateFormat f = Qt::ISODate; textLabel15->setText(tr("当前时间:") + dt.toString(f)); timer->start( 1000, TRUE ); // 1 seconds single-shot timer}void saleForm::itoa(int in, char *buf, int len){ int _in = in; int tmp1, i, m; int j=0; if (_in > 10000) { i=4; m=10000; } else if (_in >1000) { i=3; m=1000; } else if (_in >100) { i=2; m=100; } else if (_in >10) { i=1; m=10; } else { i=0; m=1; } for (;i>=0;i--) { tmp1 = _in/m; buf[j++] = (char)(tmp1 + 48); _in = _in%m; m = m/10; } buf[j] = '\0';}void saleForm::saleForm_destroyed(){ CloseDev(fd);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -