bool Cms::cgstatus(const QString &managerID) { QString status = ""; TSqlQuery query; query.exec("SELECT managerState FROM assetsunitmanager WHERE managerID = '"+managerID+"'"); if(query.next()){ status = query.value(0).toString(); if(status.compare("可用") == 0){ status = "冻结"; }else{ status = "可用"; } if( query.exec("UPDATE assetsunitmanager set managerState = '"+status+"' WHERE managerID = '"+managerID+"'") ) { return true; }else{ return false; } }else{ return false; } // QString name = "可用"; // QString sn = "er"; // TSqlQuery query; // if(query.exec("UPDATE assetsunitmanager set managerState = '"+name+"' WHERE managerID = '1'")) // { // return true; // }else{ // return false; // } }
QList<Operators> Operators::list_operator(const QString &adminID) { QList<Operators> operator_list; TSqlQuery query; query.exec("SELECT * FROM operators join connection on operators.operatorID = connection.operatorID WHERE connection.adminID = '"+adminID+"'"); while(query.next()){ Operators a; //建立一个对象a a.setOperatorID(query.value(0).toString()); a.setOperatorName(query.value(1).toString()); a.setOperatorNickname(query.value(2).toString()); a.setOperatorPassword(query.value(3).toString()); // a.setOperatorNumber(query.value(4).toString()); a.setOperatorPhone(query.value(4).toString()); a.setId(query.value(5).toString()); a.setOperatorRole(query.value(6).toString()); a.setOperatorStatus(query.value(7).toString()); //设置对象a中的相关值 operator_list.append(a); //将a插入链表中 } return operator_list; }
void MarketingunitController::searching() { QString val = httpRequest().formItemValue("search"); QString error; if(val.isEmpty()) { error="请输入查询关键字"; tflash(error); redirect(urla("index")); return; } QList<Marketingunit> list1; TSqlQuery query; query.exec("SELECT * FROM CMS.marketingunit WHERE MUid LIKE '%"+val+"%';"); while(query.next()) { Marketingunit a; a.setMuid(query.value(0).toInt()); a.setMuname(query.value(1).toString()); a.setMusname(query.value(2).toString()); a.setMuvalue(query.value(3).toInt()); a.setMudate(query.value(4).toDate()); a.setSrcUnitID(query.value(5).toInt()); a.setDestUnitID(query.value(6).toInt()); a.setOperatorID(query.value(7).toString()); list1.append(a); } QList<Marketingunit> list2; TSqlQuery query2; query2.exec("SELECT * FROM CMS.marketingunit WHERE MUsname LIKE '%"+val+"%';"); while(query2.next()) { Marketingunit b; b.setMuid(query2.value(0).toInt()); b.setMuname(query2.value(1).toString()); b.setMusname(query2.value(2).toString()); b.setMuvalue(query2.value(3).toInt()); b.setMudate(query2.value(4).toDate()); b.setSrcUnitID(query2.value(5).toInt()); b.setDestUnitID(query2.value(6).toInt()); b.setOperatorID(query2.value(7).toString()); list2.append(b); } if(list1.isEmpty()&&list2.isEmpty()) { error="无对应记录"; tflash(error); redirect(urla("index")); return; } else { texport(list1); texport(list2); render(); } }
void MarketingunitController::showform() { QString start = httpRequest().formItemValue("start"); QString end = httpRequest().formItemValue("end"); QString error; QList<Marketingunit> list; TSqlQuery query; int c=0; if(start.isEmpty()&&end.isEmpty()) { query.exec("SELECT * FROM CMS.marketingunit ORDER BY MUdate;"); } else if(start.isEmpty()||end.isEmpty()) { error="请输入日期"; tflash(error); redirect(urla("reportform")); return; } else if(start>end) { error="起始日期应小于截止日期"; tflash(error); redirect(urla("reportform")); return; } else { query.exec("SELECT * FROM CMS.marketingunit WHERE MUdate BETWEEN '"+start+"' AND '"+end+"' ORDER BY MUdate;"); } while(query.next()) { Marketingunit a; a.setMuid(query.value(0).toInt()); a.setMuvalue(query.value(1).toInt()); a.setMusname(query.value(2).toString()); a.setMuname(query.value(3).toString()); a.setMudate(query.value(4).toDate()); a.setSrcUnitID(query.value(5).toInt()); a.setDestUnitID(query.value(6).toInt()); a.setOperatorID(query.value(7).toString()); c=a.muvalue()+c; list.append(a); } if(list.isEmpty()) { error="所选日期内无记录"; tflash(error); redirect(urla("reportform")); return; } texport(list); texport(c); render(); }
bool Cms::change_status(const QString &operatorID) { QString status = ""; TSqlQuery query; query.exec("SELECT operatorStatus FROM operators WHERE operatorID = '"+operatorID+"'"); if(query.next()){ status = query.value(0).toString(); if(status.compare("正常") == 0){ status = "冻结"; }else{ status = "正常"; } if( query.exec("UPDATE operators set operatorStatus = '"+status+"' WHERE operatorID = '"+operatorID+"'") ) { return true; }else{ return false; } }else{ return false; } }
QList<Operators> Operators::search_operator(const QString &operatorID, const QString &adminID) { QList<Operators> operator_list; TSqlQuery query; query.exec("SELECT * FROM operators join connection on operators.operatorID = connection.operatorID WHERE connection.adminID = '"+adminID+"' AND connection.operatorID LIKE '%"+operatorID+"%'"); while(query.next()){ Operators a; //建立一个对象a a.setOperatorID(query.value(0).toString()); a.setOperatorName(query.value(1).toString()); a.setOperatorNickname(query.value(2).toString()); a.setOperatorPassword(query.value(3).toString()); // a.setOperatorNumber(query.value(4).toString()); a.setOperatorPhone(query.value(4).toString()); a.setId(query.value(5).toString()); a.setOperatorRole(query.value(6).toString()); a.setOperatorStatus(query.value(7).toString()); //设置对象a中的相关值 operator_list.append(a); //将a插入链表中 } query.exec("SELECT * FROM operators join connection on operators.operatorID = connection.operatorID WHERE connection.adminID = '"+adminID+"' AND operators.operatorNickname LIKE '%"+operatorID+"%'"); while(query.next()){ Operators a; //建立一个对象a a.setOperatorID(query.value(0).toString()); a.setOperatorName(query.value(1).toString()); a.setOperatorNickname(query.value(2).toString()); a.setOperatorPassword(query.value(3).toString()); a.setOperatorPhone(query.value(4).toString()); a.setId(query.value(5).toString()); a.setOperatorRole(query.value(6).toString()); a.setOperatorStatus(query.value(7).toString()); //设置对象a中的相关值 int j = 0; for(const auto &i : operator_list){ if(i.operatorID() == a.operatorID()){ break; }else{ j = j +1; } } if(j == operator_list.length()){ operator_list.append(a); //将a插入链表中 }//遍历链表,查找该对象是否已经存在,如果存在则不再插入链表,否则插入 } query.exec("SELECT * FROM operators join connection on operators.operatorID = connection.operatorID WHERE connection.adminID = '"+adminID+"' AND operators.operatorStatus LIKE '%"+operatorID+"%'"); while(query.next()){ Operators a; //建立一个对象a a.setOperatorID(query.value(0).toString()); a.setOperatorName(query.value(1).toString()); a.setOperatorNickname(query.value(2).toString()); a.setOperatorPassword(query.value(3).toString()); a.setOperatorPhone(query.value(4).toString()); a.setId(query.value(5).toString()); a.setOperatorRole(query.value(6).toString()); a.setOperatorStatus(query.value(7).toString()); //设置对象a中的相关值 int j = 0; for(const auto &i : operator_list){ if(i.operatorID() == a.operatorID()){ break; }else{ j = j +1; } } if(j == operator_list.length()){ operator_list.append(a); //将a插入链表中 } } return operator_list; }