#include "mainwindow.h"
void MainWindow::setMyLineEdit()
{
ui->stuNumber -> setMaxLength( 11 ); //学号限制为11位
ui->classLevel -> setMaxLength( 4 ); //年级限制为两位
ui->stuPhone -> setMaxLength( 11 ); //手机号13位
QRegExp regExp("[0-9]+$");
QRegExp dor("^((0([1-9]{1}))|(1[1|2]))/(([0-2]([1-9]{1}))|(3[0|1]))/(d{2}|d{4})$");
QRegExpValidator *pattern= new QRegExpValidator(regExp, this);//创建了一个表达式
// QRegExpValidator *pat= new QRegExpValidator(dor, this);//创建了一个表达式
//交付使用
ui->stuNumber ->setValidator(pattern); //学号限输入制为数字
ui->classLevel ->setValidator(pattern); //班级限输入制为数字
ui->stuPhone ->setValidator(pattern); //学生
//设置提示内容
ui->stuName ->setPlaceholderText("示例:张三");
ui->stuNumber ->setPlaceholderText("11位学号");
ui->stuPhone ->setPlaceholderText("请输入手机号");
ui->className ->setPlaceholderText("示例:软件1班");
ui->classLevel ->setPlaceholderText("示例:2018");
ui->headTeacher ->setPlaceholderText("班主任名字");
ui->instructor ->setPlaceholderText("辅导员名字");
QStringList qstr_campus;
QStringList qstr_department;
QStringList qstr_sex;
QStringList qstr_buildingno;
QStringList qstr_floor;
QStringList qstr_dormitoryno;
QStringList qstr_dormitorylevel;
qstr_department << "计算机工程系" << "土木工程系" << "机电信息系" << "化学工程系" << "经济管理系";
qstr_campus << "请选择" << "北校区" << "南校区";
qstr_sex << "请选择" << "男" << "女";
qstr_buildingno << "请选择" << "1栋" << "2栋" << "3栋" << "4栋" << "5栋" << "6栋" << "7栋" << "8栋" << "9栋" << "10栋" << "11栋" << "12栋" << "13栋" << "14栋";
qstr_floor << "请选择" << "一层" << "二层" << "三层" << "四层" << "五层" << "六层" << "七层";
qstr_dormitorylevel << "请选择" << "一级宿舍" << "二级宿舍";
// qstr_dormitoryno << ;
ui->department ->addItems (qstr_department );
ui->campus ->addItems (qstr_campus );
ui->sex ->addItems (qstr_sex );
ui->buildingno ->addItems (qstr_buildingno );
ui->floor ->addItems (qstr_floor );
ui->dormitorylevel ->addItems (qstr_dormitorylevel );
}
void MainWindow::setAddTableWidget()
{
QTableWidgetItem *headerItem;
QStringList headerText;
headerText << "系别" << "校区" << "性别" << "楼号" << "楼层"<< "宿舍号"<< "床位号" << "宿舍级别" << "学 号" << "姓 名" << "学生手机号" << "年级";
ui->addTableWidget->setColumnCount(headerText.count());//列数设置为与 headerText的行数相等
for (int i = 0; i < ui->addTableWidget->columnCount(); i++)
{
headerItem = new QTableWidgetItem(headerText.at(i));//新建一个QTableWidgetItem, headerText.at(i)获取headerText的i行字符串
QFont font = headerItem->font();//获取原有字体设置
font.setBold(true);//设置为粗体
font.setPixelSize(12);//字体大小
headerItem->setTextColor("#2E8B57");//字体颜色
ui->addTableWidget->setHorizontalHeaderItem(i,headerItem);//设置表头单元格的Item
}
selectDormitoryno();
}
void MainWindow::selectDormitoryno()
{
ui->addTableWidget->clearContents();
QSqlDatabase db = star_mysql();
QSqlQuery *query = new QSqlQuery;
QString first = "SELECT * FROM test_db.dorm where ";
QString strdepartment = " department = '" + ui->department->currentText () + "'";
first += strdepartment;
QString campus = ui->campus ->currentText ();
QString strsex = QString::number(ui->sex ->currentIndex());
QString strbuildingno = QString::number(ui->buildingno ->currentIndex());
QString strfloor = QString::number(ui->floor ->currentIndex());
QString strdormitorylevel = QString::number(ui->dormitorylevel ->currentIndex());
if (campus != "请选择" ) first += (campus = " and campus = '" + campus + "'" );
if (strsex != "0") first += (strsex = " and sex = " + strsex );
if (strbuildingno != "0") first += (strbuildingno = " and buildingno = " + strbuildingno );
if (strfloor != "0") first += (strfloor = " and floor = " + strfloor );
if (strdormitorylevel != "0") first += (strdormitorylevel = " and dormitorylevel = " + strdormitorylevel);
query->prepare(first);
if(!query->exec()) qDebug() << "insert fail of selectDormitoryno";
QSqlRecord rec = query->record();
query->next();
//=================================================================================
QSqlQuery *querylist = new QSqlQuery;
QString str1;
QString str2;
// str1 = "SELECT * FROM test_db.stulist where stunumber = ";
// str2 = query->value(rec.indexOf("stunameber")).toString();
// str1 += str2;
// qDebug() << str1;
// querylist->prepare(str1);
// querylist->exec();
// QSqlRecord reclist = querylist->record();
// querylist->next();
// qDebug() << querylist->value(reclist.indexOf("stuname"));
// str2 = querylist->value(reclist.indexOf("stuname")).toString();
//=================================================================================
do{
// query->record();
//=================================================================================
str1 = "SELECT * FROM test_db.stulist where stunumber = ";
str2 = query->value(rec.indexOf("stunameber")).toString();
str1 += str2;
querylist->prepare(str1);
querylist->exec();
QSqlRecord reclist = querylist->record();
querylist->next();
//=================================================================================
ui->addTableWidget->setItem(g_rowCountForAddTableWidget, 0, new QTableWidgetItem( query->value(rec.indexOf("department" )).toString()));
ui->addTableWidget->setItem(g_rowCountForAddTableWidget, 1, new QTableWidgetItem( query->value(rec.indexOf("campus" )).toString()));
ui->addTableWidget->setItem(g_rowCountForAddTableWidget, 2, new QTableWidgetItem(g_CHSex [query->value(rec.indexOf("sex" )).toInt ()]));
ui->addTableWidget->setItem(g_rowCountForAddTableWidget, 3, new QTableWidgetItem(g_CHBuildingno [query->value(rec.indexOf("buildingno" )).toInt ()]));
ui->addTableWidget->setItem(g_rowCountForAddTableWidget, 4, new QTableWidgetItem(g_CHFloor [query->value(rec.indexOf("floor" )).toInt ()]));
ui->addTableWidget->setItem(g_rowCountForAddTableWidget, 5, new QTableWidgetItem( query->value(rec.indexOf("dormitoryno" )).toString()));
ui->addTableWidget->setItem(g_rowCountForAddTableWidget, 6, new QTableWidgetItem(g_CHBedno [query->value(rec.indexOf("bedno" )).toInt ()]));
ui->addTableWidget->setItem(g_rowCountForAddTableWidget, 7, new QTableWidgetItem(g_CHDormitorylevel [query->value(rec.indexOf("dormitorylevel")).toInt ()]));
ui->addTableWidget->setItem(g_rowCountForAddTableWidget, 8, new QTableWidgetItem(query->value(rec.indexOf( "stunameber" )).toString()));
//学生表的内容
ui->addTableWidget->setItem(g_rowCountForAddTableWidget, 9, new QTableWidgetItem(querylist->value(reclist.indexOf("stuname")).toString()));
毕业小助手
- 粉丝: 2765
- 资源: 5583
最新资源
- 流媒体服务zlm,支持天地伟业设备接入版本
- 三菱FX系列PLC温度PID控制程序(含注释和IO图、三菱触摸屏程序),程序已经应用于设备上,成熟可靠,有程序注释,触摸屏有注释值得参考和借鉴.
- 欧姆龙NJ的控制程序,里面功能齐全,相机,机器人,RFID,转盘,检测传感器,伺服等,里面模板程序大部分都是LAD写的,方便宜读,对于新手上手块,里面很多功能块都可以直接套用,程序里写的逻辑思维程序也
- 流媒体服务zlm,支持天地伟业设备接入版本
- 单相逆变变频器,双闭环控制策略,电压环和电流环均采用Pi控制,输出电压稳定 0~0.5S输出电压频率20HZ 0.5~1S输出电压频率50HZ 1~1.5S输出电压频率100HZ 也可以直接设置输出
- 2KW移相全桥整机Matlab Simulink仿真模型电源学习资料,报告mathcad参数设计,模型搭建过程,参考资料,仿真模型等,很全面的移相全桥学习资料
- CRUISE纯电动车仿真模型,simulink DLL联合仿真,实现电制动优先能量回收策略 关于模型:策略是用64位软件编译的,如果模型运行不了请将软件切成64位 切位置在启动界面platform
- 可以切割提取多页PDF集合中指定页码间的页
- 车辆紧急防避撞AEB控制,模型包含建立驾驶员制动模型来模拟制动过程,同时加入模糊控制实现期望减速度的计算,加入纵向发动机逆动力学模型实时求解期望节气门开度,驱动与制动的切控制,以及制动压力与减速度之间
- 遥感场景图像分类数据集【已标注,约15000张数据】
- 驾校模拟考试软件,理论考试练习软件
- 增加HID服务20250108-173901.7z
- 四轮独立驱动横摆角速度控制,LQR 基于LQR算法的 基于二自由度动力学方程,通过主动转向afs和直接横摆力矩dyc实现的横摆角速度跟踪 ,模型包括期望横摆角速度,质心侧偏角,稳定性因素,lqr模块等
- YS9082HP-MPToolV8.00.00.00.012-FW210520-release-B37&B47.rar
- YS9082HP-MPToolV8.00.00.01.025-HPS2704M-release-N38B.rar
- MATLAB环境下一种基于深度学习的NASA涡扇发动机 化仿真数据集剩余使用寿命预测方法 算法运行环境为matlab r2018a,执行基于深度学习的NASA涡扇发动机 化仿真数据集剩余使用寿命预测
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈