• mugua
    了解作者
  • QT
    开发工具
  • 15KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 8
    下载次数
  • 2017-05-15 15:16
    上传日期
模拟银行的小程序,qt界面,登录,注册,存款取款,sqllite数据库
bank10.zip
  • bank10
  • mainpage.cpp
    1.8KB
  • connection.h
    931B
  • bank10.pro
    728B
  • server.ui
    358B
  • register.cpp
    1.4KB
  • bankg.h
    1.1KB
  • mainwindow.cpp
    1.4KB
  • shoppay.cpp
    2.4KB
  • cpw.h
    296B
  • cpw.ui
    2.1KB
  • cpw.cpp
    1.4KB
  • register.ui
    4.4KB
  • bank10.pro.user
    18.2KB
  • server.h
    603B
  • main.cpp
    410B
  • shoppay.ui
    360B
  • mainpage.h
    488B
  • mainwindow.ui
    3.1KB
  • mainpage.ui
    4.5KB
  • shoppay.h
    447B
  • server.cpp
    1.6KB
  • register.h
    334B
  • mainwindow.h
    398B
  • bankg.cpp
    562B
内容介绍
#include "shoppay.h" #include "ui_shoppay.h" #include <QtNetwork/QUdpSocket> #include <QMessageBox> #include <QString> #include "mainwindow.h" #include <QSqlQuery> #include "mainpage.h" #include "bankg.h" #include <QTextStream> #include <QSqlQuery> #include <QDebug> extern Bankg *guest; Shoppay::Shoppay(QWidget *parent) : QDialog(parent), ui(new Ui::Shoppay) { ui->setupUi(this); udpSocket1 = new QUdpSocket(this); udpSocket2 = new QUdpSocket(this); bool conn = udpSocket1->bind(QHostAddress::LocalHost,6663,QUdpSocket::ShareAddress); if(!conn){ QMessageBox::information(this,"",tr("连接错误")); } else{ connect(udpSocket1,SIGNAL(readyRead()),this,SLOT(receive())); } } Shoppay::~Shoppay() { delete ui; } void Shoppay::receive(){ while(udpSocket1->hasPendingDatagrams()){ QByteArray data; data.resize(udpSocket1->pendingDatagramSize()); udpSocket1->readDatagram(data.data(),data.size()); //QString str1,str2; QString str = data.data(); QString str1,str2,str3; QStringList strlist= str.split(","); str1 = strlist.at(0); str2 = strlist.at(1); str3 = strlist.at(2); QSqlQuery query,query2; qDebug()<<"第一步"; if(query.exec("select *from bankguest where name = '"+str1+"'")){ //qDebug()<<"!!!"+query.value(3).toString(); query.next(); if(query.value(3).toString() == str2){ bool ok; double d; qDebug()<<"第2步"; d = QString(str3).toDouble(&ok); if(query.value(5).toDouble() >= d){ udpSocket2->writeDatagram("ok",2,QHostAddress::LocalHost,6664); double s = query.value(5).toDouble() - d; qDebug()<<"111"+query.value(5).toString(); qDebug()<<"111"+QString::number(d,'f',2); query2.exec("update bankguest set money ="+QString::number(s)+" where name = '"+str1+"'"); } else{ udpSocket2->writeDatagram("no",2,QHostAddress::LocalHost,6664); } } else{ udpSocket2->writeDatagram("no",2,QHostAddress::LocalHost,6664); } } else{ udpSocket2->writeDatagram("no",2,QHostAddress::LocalHost,6664); } } }
评论
    相关推荐