#include "mema.h"
#include "ui_mema.h"
#include "QDebug"
#include "QMessageBox"
#include "kdatabase.h"
#include "QToolBox"
#include "QtSql/QSqlDatabase"
#include <QSqlQuery>
#include <QSqlError>
#include "QPushButton"
#include "QDateTime"
MeMa::MeMa(QDialog *parent) :
QDialog(parent),
ui(new Ui::MeMa)
{
ui->setupUi(this);
connect(ui->pushButton_into,SIGNAL(clicked()),this,SLOT(into()));
connect(ui->pushButton_clear,SIGNAL(clicked()),this,SLOT(clear()));
connect(ui->sell_2,SIGNAL(clicked()),this,SLOT(sell_2()));
connect(ui->order,SIGNAL(clicked()),this,SLOT(order()));
connect(ui->styp_2,SIGNAL(on_styp_2_activated(int index)),this,SLOT(on_styp_2_activated(const QString &arg1)));
connect(ui->name_2,SIGNAL(on_name_2_activated(int index)),this,SLOT(on_name_2_activated(const QString &arg1)));
connect(ui->count_2,SIGNAL(on_count_2_valueChanged(int arg1)),this,SLOT());
}
MeMa::~MeMa()
{
delete ui;
}
void MeMa::initMeMa()
{
/*步骤
* 1、先将所有的仓库当中的商品陈列出来
* 2、可以选择入库操作,通过输入的信息商品入库‘
* 3、清仓,将数据库当中的所有数据输出,将所有的记录删除,留表
*
* 4、预售功能,没点击一次按钮,要将数据库当中的数据更改一次
* 5、将更改的数据,在页面打印出来
*
* / //先将
*/
m_product = new kproduct;
ui->tableView->setModel(m_product->getSqlModel());
ui->order->setEnabled(false);//设置下单按键不可用
on_styp_2_activated();
on_count_2_valueChanged();
}
void MeMa::print()//将商品在展示出来
{
}
void MeMa::into()
{
QString type=ui->type_1->currentText();//获得商品类型
QString name=ui->name_1->text();//获得商品名称
QString into_price=ui->price_1->text();//获得进价
QString sell_price=ui->sell_1->text();//获得售价
QString num=ui->count_1->text();//获得数目
if(name==nullptr)
{
QMessageBox::information(NULL, "提示信息", "商品名称不能为空", QMessageBox::Yes);
return ;
}
if(into_price==nullptr)
{
QMessageBox::information(NULL, "提示信息", "进价不能为空", QMessageBox::Yes);
return ;
}
if(sell_price==nullptr)
{
QMessageBox::information(NULL, "提示信息", "售价不能为空", QMessageBox::Yes);
return ;
}
if(num=="0")
{
QMessageBox::information(NULL, "提示信息", "数目不能为0", QMessageBox::Yes);
return ;
}
if(into_price.toDouble()>sell_price.toDouble())
{
QMessageBox::information(NULL, "提示信息", "奸细,进价怎么能比卖价高呢,举报你", QMessageBox::Yes);
return;
}
Kdatabase k;
if(k.addproduct(type,name,into_price.toDouble(), sell_price.toDouble(),num.toInt()))
{
initMeMa();//重新载入数据库数据
}
else
{
QMessageBox::information(NULL, "提示信息", "录入失败", QMessageBox::Yes);
}
}
void MeMa::clear()
{
Kdatabase k;
k.clear();
initMeMa();//重新载入数据库数据
}
void MeMa::sell_2()//点击出售
{
//第一个,先选择一个属性,属性出来之后,将商品展出来
//第二个,才是参数的变化
QString numbers=ui->count_2->text();
if(numbers=="0")
{
QMessageBox::information(NULL, "提示信息", "数量不能为0", QMessageBox::Yes);
return;
}
QString name=ui->name_2->currentText();
QString price=ui->label_10->text();
QString sumPri=ui->label_19->text();
QDateTime curDateTime=QDateTime::currentDateTime();
ui->textBrowser->append("--------------------------------------------------------");
ui->textBrowser->append(curDateTime.toString ("hh:mm: ss11")+"售出: "+name);
ui->textBrowser->append(" 数量:"+numbers+" 单价: "+price +" ¥ 总价: "+sumPri +"¥");
ui->textBrowser->append("--------------------------------------------------------");
sumOrders++;//订单数加一
sumPrice+=sumPri.toDouble();//价格加上
ui->order->setEnabled(true);
//将数据库当中的数据更新
int n=ui->label_17->text().toInt()-ui->count_2->text().toInt();
QString tpye=ui->name_2->currentText();
QSqlQuery query;
QString sql="UPDATE commodities numbers=? Where type=? and name=?";
query.prepare(sql);
query.bindValue(0,n);
query.bindValue(1,tpye);
query.bindValue(2,name);
if(query.exec())
{
qDebug() << query.lastError();
return ;
}
else
{
QMessageBox::information(NULL, "提示信息", "出售成功", QMessageBox::Yes);
on_styp_2_activated();
}
}
void MeMa::order()//点击下单
{
if(sumOrders==0)
{
QMessageBox::information(NULL, "提示信息", "还没有订单", QMessageBox::Yes);
return ;
}
QMessageBox::information(NULL, "提示信息", "下单成功", QMessageBox::Yes);
QDateTime curDateTime=QDateTime::currentDateTime();
ui->textBrowser->append("日期:"+curDateTime.toString ("yyyy-MM-dd hh:mm: ss11") );
ui->textBrowser->append(" 订 单 号:"+QString::number(sumOrders));
ui->textBrowser->append( "应付款总额: " + QString::number(sumPrice) +"¥");
ui->textBrowser->append("下单成功");
sumOrders=0;
sumPrice=0.0;
ui->order->setEnabled(false);
}
void MeMa::styp_2change()
{
}
void MeMa::on_styp_2_activated()//预售订单的下拉框
{
Kdatabase k;
k.initdatabase();
QString str = ui->styp_2->currentText();
QString tpye=ui->styp_2->currentText();//获得当前的商品类别,将该商品类别的商品展示出来
QSqlQuery query;
QString sql="select name, sell, numbers from commodities Where type=?";
query.prepare(sql);
query.bindValue(0,str);
if(!query.exec())
{
qDebug() << query.lastError();
return ;
}
QStringList list;
while(query.next())
{
qDebug()<<query.value(0).toString();
list.append(query.value(0).toString());
}
ui->name_2->clear();
ui->name_2->insertItems(1,list);
on_name_2_activated();
}
void MeMa::on_name_2_activated()//商品名下拉框
{
Kdatabase k;
k.initdatabase();
QString str = ui->name_2->currentText();//获得商品名
QString tpye=ui->styp_2->currentText();//获得当前的商品类别,将该商品类别的商品展示出来
QSqlQuery query;
QString sql="select sell, numbers from commodities Where type=? and name=?";
query.prepare(sql);
query.bindValue(0,tpye);
query.bindValue(1,str);
if(!query.exec())
{
qDebug() << query.lastError();
return ;
}
else
{
qDebug()<< query.size();
while(query.next())
{
ui->label_10->setText(query.value(0).toString());//单价
ui->label_17->setText(query.value(1).toString());//库存
}
}
}
void MeMa::on_count_2_valueChanged(const QString &arg1)
{
}
void MeMa::on_count_2_valueChanged()//数目下拉框
{
QString sell=ui->label_10->text();//获得单价
QString count=ui->label_17->text();//获得库存数目
ui->count_2->setRange(1,count.toInt());
double allPrice=ui->count_2->text().toDouble()*sell.toDouble();
ui->label_19->setText(QString::number(allPrice));
}
没有合适的资源?快使用搜索试试~ 我知道了~
基于qt,数据库使用的是SQLite的一个酒店管理系统.zip
共57个文件
cpp:17个
o:16个
h:11个
需积分: 1 3 下载量 84 浏览量
2024-03-21
23:20:47
上传
评论 1
收藏 3.23MB ZIP 举报
温馨提示
基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一个酒店管理系统.zip 基于qt,数据库使用的是SQLite的一
资源推荐
资源详情
资源评论
收起资源包目录
基于qt,数据库使用的是SQLite的一个酒店管理系统.zip (57个子文件)
code_30312
build-eShopSystem-Desktop_Qt_5_9_3_MinGW_32bit-Debug
object_script.eShopSystem.Release 277B
Makefile 24KB
eShop.db 16KB
debug
kdatabase.o 467KB
moc_kdatabase.o 553B
moc_mainwindow.cpp 4KB
k_mpop.o 284KB
moc_login.o 411KB
moc_registdialog.cpp 3KB
moc_mainwindow.o 412KB
regist.o 274KB
mainwindow.o 546KB
registdialog.o 539KB
moc_k_mpop.o 411KB
login.o 332KB
moc_login.cpp 2KB
moc_kproduct.cpp 3KB
moc_registdialog.o 412KB
main.o 494KB
kproduct.o 411KB
moc_mema.cpp 7KB
moc_kproduct.o 298KB
moc_mema.o 477KB
eShopSystem.exe 4.84MB
moc_k_mpop.cpp 2KB
mema.o 783KB
moc_predefs.h 9KB
moc_kdatabase.cpp 0B
Makefile.Release 103KB
object_script.eShopSystem.Debug 253B
ui_mainwindow.h 5KB
Makefile.Debug 103KB
.qmake.stash 1KB
ui_mema.h 16KB
ui_registdialog.h 5KB
eShopSystem
kdatabase.cpp 3KB
login.cpp 1KB
mainwindow.h 382B
kproduct.h 563B
kdatabase.h 571B
mainwindow.cpp 964B
kpopup.h 0B
eShopSystem.pro 1KB
kproduct.cpp 1KB
kpopup.cpp 19B
main.cpp 210B
eShopSystem.pro.user 42KB
source.cpp 0B
registdialog.ui 4KB
mema.ui 19KB
mainwindow.ui 4KB
registdialog.h 353B
mema.cpp 7KB
registdialog.cpp 2KB
mema.h 1KB
sorce.cpp 0B
login.h 385B
共 57 条
- 1
资源评论
龙年行大运
- 粉丝: 996
- 资源: 3859
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功