修复全名重复

master
Mike Solar 2023-08-29 11:45:11 +08:00
parent fd525fb8d1
commit a96f802b85
5 changed files with 27 additions and 5 deletions

View File

@ -119,13 +119,15 @@ void ApplicationManager::onclick1(QString op, QString func, QString path, QStrin
add_app.exec();
if(add_app.changed)
{
bool ok = sqlite_helper.insert_software(add_app.get_name(), add_app.get_orig_name(), add_app.get_exe_path(),
int ok = sqlite_helper.insert_software(add_app.get_name(), add_app.get_orig_name(), add_app.get_exe_path(),
add_app.get_sort(), add_app.get_categories());
if (!ok)
{
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("插入失败,全名是否重名?"));
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("插入失败。"));
}else if(ok==FIND)
{
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("已存在。"));
}
emit refresh_tab();
}
}

View File

@ -43,4 +43,6 @@
#define CUSTOM_2 7
#define OTHERS 8
#define CATEGORIES_NUM 8
#define FIND 2
#endif //OFFICEASSISTANT_CONFIG_H

View File

@ -139,4 +139,11 @@ public:
OpenWeChatRequest():RequestBodyBase(){}
QString sendRequest(bool notuse=false/*为了构成函数重载,凑数的*/);
};
class OpenAppRequest:public RequestBodyBase
{
public:
OpenAppRequest():RequestBodyBase(){}
QString sendRequest(QString app_name);
};
#endif //OFFICEASSISTANT_NETIO_H

View File

@ -1340,10 +1340,21 @@ bool SQLiteHelper::insert_software(QString name, QString orig_name, QString path
return true;
}
bool SQLiteHelper::insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories) {
int SQLiteHelper::insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories) {
QSqlQuery begin(db);
begin.exec("BEGIN;");
QSqlQuery select;
QSqlQuery query(db);
QSqlQuery query_sel(db);
QString sql_sel = "select id from kmd_menu where orig_name = :orig_name;";
query_sel.prepare(sql_sel);
query_sel.bindValue(":orig_name", orig_name);
if(query_sel.exec())
{
if(query_sel.next()){
return FIND;
}
}
QString categories_str = "";
categories[ALL - 1] = true;
QString sql = "insert into kmd_menu "

View File

@ -52,7 +52,7 @@ public:
SQLiteHelper(QObject *parent = nullptr);
bool update_software();
bool insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories, QString logo, QString img,QString type,bool locked,QString op,QString func,QString url,bool is_navbar,bool is_elite,QString dev);
bool insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories);
int insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories);
bool edit_software(QString name, QString orig_name, QString path, QString sort, bool* categories,QString type="");
bool get_software(QList<ButtonStruct>* buttons, ConfigResponse* config_response);
bool get_software(QList<ButtonStruct>* button_structs,QString background_color , QString title_color, QString title_cover_color);