83 lines
1.8 KiB
C++
83 lines
1.8 KiB
C++
![]() |
#include "addshu.h"
|
|||
|
#include "ui_addshu.h"
|
|||
|
QString id3;
|
|||
|
addshu::addshu(QWidget *parent) :
|
|||
|
QWidget(parent),
|
|||
|
ui(new Ui::addshu)
|
|||
|
{
|
|||
|
ui->setupUi(this);
|
|||
|
setWindowTitle("新增菌属");
|
|||
|
|
|||
|
this->setFixedSize(423,244);
|
|||
|
ui->widget->setFixedHeight(55);
|
|||
|
ui->lineEdit->setFixedSize(301,32);
|
|||
|
ui->lineEdit_2->setFixedSize(301,32);
|
|||
|
ui->pushButton->setFixedSize(76,37);
|
|||
|
ui->pushButton_2->setFixedSize(76,37);
|
|||
|
this->setWindowFlags(Qt::FramelessWindowHint); // 隐藏标题<E6A087><E9A298>?
|
|||
|
this->setFixedSize(437,244);
|
|||
|
this->setWindowFlags(Qt::FramelessWindowHint);//ȥ<><C8A5><EFBFBD><EFBFBD><EFBFBD>ڱ߿<DAB1>
|
|||
|
setAttribute(Qt::WA_TranslucentBackground);
|
|||
|
}
|
|||
|
|
|||
|
addshu::~addshu()
|
|||
|
{
|
|||
|
delete ui;
|
|||
|
}
|
|||
|
|
|||
|
void addshu::on_pushButton_clicked()
|
|||
|
{
|
|||
|
if(!ui->lineEdit->text().isEmpty()&&!ui->lineEdit_2->text().isEmpty()){QString sql=QString("INSERT INTO junshu (id,name,time,ren) VALUES ('%1','%2','%3','%4')")
|
|||
|
.arg(ui->lineEdit->text()).arg(ui->lineEdit_2->text()).arg(gettime()).arg(id3);
|
|||
|
qDebug()<<sql;
|
|||
|
QSqlQuery query;
|
|||
|
|
|||
|
if(query.exec(sql))
|
|||
|
{
|
|||
|
|
|||
|
qDebug()<<"插入成功";
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else{
|
|||
|
|
|||
|
}
|
|||
|
emit xinzeng();
|
|||
|
this->close();
|
|||
|
}
|
|||
|
QString addshu::getname()
|
|||
|
{
|
|||
|
QString sql=QString("select usersname from users where id='%1'").arg(id3);
|
|||
|
qDebug()<<sql;
|
|||
|
QSqlQuery query;
|
|||
|
|
|||
|
if(query.exec(sql))
|
|||
|
{
|
|||
|
if(query.first()){
|
|||
|
|
|||
|
QString str1=query.value(0).toString();
|
|||
|
qDebug()<<str1;
|
|||
|
return str1;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
qDebug()<<"没查到名<EFBFBD><EFBFBD>?";
|
|||
|
}
|
|||
|
}
|
|||
|
QString addshu::gettime()
|
|||
|
{
|
|||
|
QDateTime dateTime= QDateTime::currentDateTime();//获取系统当前的时<E79A84><E697B6>?
|
|||
|
QString str = dateTime .toString("yyyy-MM-dd hh:mm:ss");//格式化时<E58C96><E697B6>?
|
|||
|
|
|||
|
return str;
|
|||
|
}
|
|||
|
|
|||
|
void addshu::on_pushButton_2_clicked()
|
|||
|
{
|
|||
|
this->close();
|
|||
|
emit xinzeng();
|
|||
|
}
|
|||
|
|