second version
This commit is contained in:
parent
95602e82ce
commit
48bf45d4fe
3 changed files with 41 additions and 20 deletions
|
@ -110,6 +110,7 @@ class AccountTab(TabPage):
|
|||
descriptionLabel = QLabel("Description:")
|
||||
descriptionLine = QLineEdit()
|
||||
descriptionLine.setText(data[0][2])
|
||||
# descriptionLine.setText(self.transData[self.rows[0].row()][6])
|
||||
|
||||
button1 = QPushButton("Confirm")
|
||||
button3 = QPushButton("Delete")
|
||||
|
@ -251,15 +252,30 @@ class AccountTab(TabPage):
|
|||
print(e)
|
||||
QMessageBox.critical(self, 'Error', str(e))
|
||||
|
||||
self.pg.execute("SELECT c_id, meta ->> 'name' FROM category ORDER BY c_id")
|
||||
self.pg.execute("SELECT t_id, a_id, c_id, s_id, time, translate(amount::varchar,'$','¥'), meta->>'description' FROM transaction ORDER BY time DESC")
|
||||
self.transData = self.pg.fetchall()
|
||||
self.pg.execute("SELECT a_id, meta ->> 'name' FROM account ORDER BY a_id")
|
||||
self.accountData = self.pg.fetchall()
|
||||
self.pg.execute("SELECT c_id, meta ->> 'name' FROM category ORDER BY c_id")
|
||||
self.categoryData = self.pg.fetchall()
|
||||
|
||||
print(self.accountData)
|
||||
|
||||
# 初始化表格
|
||||
self.accountTable.clear()
|
||||
self.accountTable.setRowCount(len(self.accountData))
|
||||
self.accountTable.setColumnCount(5) # 时间 账户 类别 金额 描述
|
||||
self.accountTable.setHorizontalHeaderLabels(['Time', 'Account', 'Category', 'Amount', 'Description'])
|
||||
self.accountTable.setRowCount(len(self.transData))
|
||||
self.accountTable.setColumnCount(3) # 账户名 账户平衡 备注
|
||||
self.accountTable.setHorizontalHeaderLabels(['Account Name', 'Account Balance', 'Description'])
|
||||
# 设置自动调整列宽
|
||||
self.accountTable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
|
||||
self.accountTable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
|
||||
|
||||
# 填充表格
|
||||
for i in range(len(self.transData)):
|
||||
#self.accountTable.setItem(i, 0, QTableWidgetItem(self.transData[i][4].strftime("%Y-%m-%d %H:%M:%S")))
|
||||
self.accountTable.setItem(i, 0, QTableWidgetItem(self.accountData[self.transData[i][1]-1][1]))
|
||||
# if self.transData[i][2] is None:
|
||||
# self.accountTable.setItem(i, 1, QTableWidgetItem("None"))
|
||||
# else:
|
||||
# self.accountTable.setItem(i, 1, QTableWidgetItem(self.categoryData[self.transData[i][2]-1][1]))
|
||||
self.accountTable.setItem(i, 1, QTableWidgetItem(str(self.transData[i][5])))
|
||||
self.accountTable.setItem(i, 2, QTableWidgetItem(self.transData[i][6]))
|
||||
|
|
|
@ -215,6 +215,12 @@ class CategoryTab(TabPage):
|
|||
print(e)
|
||||
QMessageBox.critical(self, 'Error', str(e))
|
||||
|
||||
# self.pg.execute("SELECT c_id, meta ->> 'name' FROM category ORDER BY c_id")
|
||||
# self.categoryData = self.pg.fetchall()
|
||||
self.pg.execute("SELECT t_id, a_id, c_id, s_id, time, translate(amount::varchar,'$','¥'), meta->>'description' FROM transaction ORDER BY time DESC")
|
||||
self.transData = self.pg.fetchall()
|
||||
self.pg.execute("SELECT a_id, meta ->> 'name' FROM account ORDER BY a_id")
|
||||
self.accountData = self.pg.fetchall()
|
||||
self.pg.execute("SELECT c_id, meta ->> 'name' FROM category ORDER BY c_id")
|
||||
self.categoryData = self.pg.fetchall()
|
||||
|
||||
|
@ -222,8 +228,18 @@ class CategoryTab(TabPage):
|
|||
|
||||
# 初始化表格
|
||||
self.categoryTable.clear()
|
||||
self.categoryTable.setRowCount(len(self.categoryData))
|
||||
self.categoryTable.setColumnCount(5) # 时间 账户 类别 金额 描述
|
||||
self.categoryTable.setHorizontalHeaderLabels(['Time', 'Account', 'Category', 'Amount', 'Description'])
|
||||
self.categoryTable.setRowCount(len(self.transData))
|
||||
self.categoryTable.setColumnCount(3) # 类别名称 类别 描述
|
||||
self.categoryTable.setHorizontalHeaderLabels(['Category Name', 'Category Type','Description'])
|
||||
# 设置自动调整列宽
|
||||
self.categoryTable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
|
||||
self.categoryTable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
|
||||
|
||||
# 填充表格
|
||||
for i in range(len(self.categoryData)):
|
||||
# self.categoryTable.setItem(i, 2, QTableWidgetItem(self.accountData[self.transData[i][1]-1][1]))
|
||||
if self.transData[i][2] is None:
|
||||
self.categoryTable.setItem(i, 0, QTableWidgetItem("None"))
|
||||
else:
|
||||
self.categoryTable.setItem(i, 0, QTableWidgetItem(self.categoryData[self.transData[i][2]-1][1]))
|
||||
self.categoryTable.setItem(i, 1, QTableWidgetItem(str(self.transData[i][5])))
|
||||
self.categoryTable.setItem(i, 2, QTableWidgetItem(self.transData[i][6]))
|
||||
|
|
|
@ -213,17 +213,6 @@ class TransTab(TabPage):
|
|||
else:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def onDialogTypeChanged(self, index):
|
||||
# 获取当前选择的类型
|
||||
type = self.dialogLayout.itemAt(1).widget().currentText()
|
||||
|
|
Loading…
Reference in a new issue