Example #1
0
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;
//    }

}
Example #2
0
bool Cms::delete_operator(const QString &operatorID)
{
    TSqlQuery query;
    if( query.exec("DELETE FROM connection WHERE operatorID = '"+operatorID+"'") )
    {
      if( query.exec("DELETE FROM operators WHERE operatorID = '"+operatorID+"'") )
      {
          return true;
      }else{
          return false;
      }
    }else{
        return false;
    }
}
Example #3
0
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();
}
Example #4
0
bool Cms::remove_connection(const QString &adminID, const QString &operatorID)
{
    TSqlQuery query;
    bool result = query.exec("DELETE FROM connection WHERE adminID = '"+adminID+"' AND operatorID = '"+operatorID+"'");
    return result;

}
Example #5
0
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;

}
Example #6
0
bool Cms::insert_connection(const QString &adminID, const QString &operatorID)
{
    TSqlQuery query;
    query.prepare("INSERT INTO connection (adminID,operatorID)  VALUE (:adminID, :operatorID)");
    query.bindValue(":adminID",adminID);
    query.bindValue(":operatorID",operatorID);
    if(query.exec())
        return true;
    else
        return false;
}
Example #7
0
bool Cms::checkoperatorID(const QString &operatorID)
{
    TSqlQuery query;
    query.exec("SELEXT operatorID FROM operators where operatorID = '"+operatorID+"'");
    if(query.next()){
        return false;
    }else{
        return true;
    }

}
Example #8
0
bool Cms::operatorlogin(const QVariantMap &values)
{
    QString t = values["numberID"].toString();
    QString b = values["password"].toString();
    TSqlQuery query;
    query.exec("SELECT * FROM operators WHERE operatorID = '"+t+"' AND operatorPassword = '******' ");
   if(query.next()){
       return true;
    }
    return false;
}
Example #9
0
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;
    }
}
Example #10
0
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();
    }
}
Example #11
0
void MarketingunitController::index()
{
    QString hpage = httpRequest().formItemValue("page");
    int tpage=0,trec=0,spage,epage,page;
    QString spage1,epage1,warning;
    TSqlQuery query;
    query.exec("SELECT * FROM CMS.marketingunit;");
    while(query.next()) {
        trec=trec+1;
    }
    tpage=trec/5;
    if(tpage*5<trec)tpage=tpage+1;
    if(hpage.isNull()) {
        page=1;
    } else {
        page=hpage.toInt();
    }
    if(page<1) {
        page=1;
        warning="当前为最前页";
    } else if(page>tpage) {
        page=tpage;
        warning="当前为最后页";
    }

    epage=page*5;
    spage=epage-5;
    spage1=QString::number(spage);
    epage1=QString::number(epage);
    QList<Marketingunit> marketingunitList;
    TSqlQuery query2;
    query2.exec("SELECT * FROM CMS.marketingunit  LIMIT "+spage1+","+epage1+";");
    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());
        marketingunitList.append(b);
    }
    texport(warning);
    texport(page);
    texport(tpage);
    texport(marketingunitList);
    render();
}
Example #12
0
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;
}