|
|
@@ -14,6 +14,8 @@
|
|
14
|
14
|
#
|
|
15
|
15
|
# ///////////////////////////////////////////////////////////////
|
|
16
|
16
|
from PySide6.QtWidgets import QMessageBox
|
|
|
17
|
+
|
|
|
18
|
+from Front.back.Program_Run.utils import resource_path
|
|
17
|
19
|
# MAIN FILE
|
|
18
|
20
|
# ///////////////////////////////////////////////////////////////
|
|
19
|
21
|
|
|
|
@@ -307,12 +309,14 @@ class UIFunctions(MainWindow):
|
|
307
|
309
|
current_text = self.ui.comboBox_2.currentText()
|
|
308
|
310
|
# db_path = r"D:/Code/ControlNetwork/UI/SQL/DataBase.db"
|
|
309
|
311
|
# 获取当前脚本所在的目录
|
|
310
|
|
- current_dir = os.getcwd()
|
|
311
|
|
- # 构建 SQL 文件夹的相对路径(上一级的上一级中的 SQL 文件夹)
|
|
312
|
|
- sql_folder = os.path.join(current_dir, '..', '..', 'SQL')
|
|
313
|
|
- # 将相对路径转换为绝对路径
|
|
314
|
|
- sql_folder = os.path.abspath(sql_folder)
|
|
315
|
|
- db_path = os.path.join(sql_folder, f"{self.ui.comboBox.currentText()}.db")
|
|
|
312
|
+ # current_dir = os.getcwd()
|
|
|
313
|
+ # # 构建 SQL 文件夹的相对路径(上一级的上一级中的 SQL 文件夹)
|
|
|
314
|
+ # sql_folder = os.path.join(current_dir, '..', '..', 'SQL')
|
|
|
315
|
+ # # 将相对路径转换为绝对路径
|
|
|
316
|
+ # sql_folder = os.path.abspath(sql_folder)
|
|
|
317
|
+ # db_path = os.path.join(resource_path(sql_folder), f"{self.ui.comboBox.currentText()}.db")
|
|
|
318
|
+ db_path = os.path.join(resource_path('SQL'), f"{self.ui.comboBox.currentText()}.db")
|
|
|
319
|
+ print(db_path)
|
|
316
|
320
|
file_path = file_path
|
|
317
|
321
|
if current_text == "水准测段高差稳定计算":
|
|
318
|
322
|
GC.main_function(file_path, db_path)
|
|
|
@@ -327,13 +331,14 @@ class UIFunctions(MainWindow):
|
|
327
|
331
|
# 计算与展示文件的方法
|
|
328
|
332
|
def compute_show_process_excel_file(self, file_path):
|
|
329
|
333
|
current_text = self.ui.comboBox_2.currentText()
|
|
330
|
|
- # 获取当前脚本所在的目录
|
|
331
|
|
- current_dir = os.getcwd()
|
|
332
|
|
- # 构建 SQL 文件夹的相对路径(上一级的上一级中的 SQL 文件夹)
|
|
333
|
|
- sql_folder = os.path.join(current_dir, '..', '..', 'SQL')
|
|
334
|
|
- # 将相对路径转换为绝对路径
|
|
335
|
|
- sql_folder = os.path.abspath(sql_folder)
|
|
336
|
|
- db_path = os.path.join(sql_folder, f"{self.ui.comboBox.currentText()}.db")
|
|
|
334
|
+ # # 获取当前脚本所在的目录
|
|
|
335
|
+ # current_dir = os.getcwd()
|
|
|
336
|
+ # # 构建 SQL 文件夹的相对路径(上一级的上一级中的 SQL 文件夹)
|
|
|
337
|
+ # sql_folder = os.path.join(current_dir, '..', '..', 'SQL')
|
|
|
338
|
+ # # 将相对路径转换为绝对路径
|
|
|
339
|
+ # sql_folder = os.path.abspath(sql_folder)
|
|
|
340
|
+ # db_path = os.path.join(sql_folder, f"{self.ui.comboBox.currentText()}.db")
|
|
|
341
|
+ db_path = os.path.join(resource_path('SQL'), f"{self.ui.comboBox.currentText()}.db")
|
|
337
|
342
|
# 转换为utf-8
|
|
338
|
343
|
excelname = os.path.basename(file_path) # 文件名
|
|
339
|
344
|
utf_en = excelname.encode('utf-8') # 转换文件名为utf-8编码形式
|
|
|
@@ -350,13 +355,14 @@ class UIFunctions(MainWindow):
|
|
350
|
355
|
# 文件导出的方法
|
|
351
|
356
|
def export_database_to_excel(self, file_path):
|
|
352
|
357
|
current_text = self.ui.comboBox_2.currentText()
|
|
353
|
|
- # 获取当前脚本所在的目录
|
|
354
|
|
- current_dir = os.getcwd()
|
|
355
|
|
- # 构建 SQL 文件夹的相对路径(上一级的上一级中的 SQL 文件夹)
|
|
356
|
|
- sql_folder = os.path.join(current_dir, '..', '..', 'SQL')
|
|
357
|
|
- # 将相对路径转换为绝对路径
|
|
358
|
|
- sql_folder = os.path.abspath(sql_folder)
|
|
359
|
|
- db_path = os.path.join(sql_folder, f"{self.ui.comboBox.currentText()}.db")
|
|
|
358
|
+ # # 获取当前脚本所在的目录
|
|
|
359
|
+ # current_dir = os.getcwd()
|
|
|
360
|
+ # # 构建 SQL 文件夹的相对路径(上一级的上一级中的 SQL 文件夹)
|
|
|
361
|
+ # sql_folder = os.path.join(current_dir, '..', '..', 'SQL')
|
|
|
362
|
+ # # 将相对路径转换为绝对路径
|
|
|
363
|
+ # sql_folder = os.path.abspath(sql_folder)
|
|
|
364
|
+ # db_path = os.path.join(sql_folder, f"{self.ui.comboBox.currentText()}.db")
|
|
|
365
|
+ db_path = os.path.join(resource_path('SQL'), f"{self.ui.comboBox.currentText()}.db")
|
|
360
|
366
|
# 转换为utf-8
|
|
361
|
367
|
excelname = os.path.basename(file_path) # 文件名
|
|
362
|
368
|
utf_en = excelname.encode('utf-8') # 转换文件名为utf-8编码形式
|
|
|
@@ -470,6 +476,7 @@ class UIFunctions(MainWindow):
|
|
470
|
476
|
#编辑完后的数据更新
|
|
471
|
477
|
#输入模型,方法,表名utf8,数据库
|
|
472
|
478
|
def update_to_db(self,model1,methodName, tableName_utf8, dbPath):
|
|
|
479
|
+ print(dbPath)
|
|
473
|
480
|
db1 = sqlite3.connect(dbPath)
|
|
474
|
481
|
cursor1 = db1.cursor()
|
|
475
|
482
|
# 通过行锁定对应的字段
|