Skip to content

Commit

Permalink
更新1.9.7版
Browse files Browse the repository at this point in the history
  • Loading branch information
qqqck18 committed Jun 1, 2022
1 parent 4038df3 commit 82218e6
Show file tree
Hide file tree
Showing 21 changed files with 769 additions and 396 deletions.
6 changes: 6 additions & 0 deletions source_code/32位_win7及以上打包/打包说明.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set CONDA_FORCE_32BIT=1
conda activate py37_win32
pip install openpyxl==2.3.5 -i https://pypi.douban.com/simple/
pip install pyinstaller -i https://pypi.douban.com/simple/
pip install pyqt5 -i https://pypi.douban.com/simple/
在目录下:pyinstaller -w -i images/image.ico main.py
299 changes: 299 additions & 0 deletions source_code/ctrl_lots_in_out.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
import ctypes
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("myappid")
import resources_rc
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QStandardItemModel, QStandardItem, QIcon
from PyQt5.QtWidgets import QMainWindow, QMessageBox, QButtonGroup
import datetime
from lots_in_out import Ui_lots_in_out
import sqlite3


class lots_in_out_window(QMainWindow, Ui_lots_in_out):
def __init__(self):
QMainWindow.__init__(self)
self.setupUi(self)
self.main_window = self
self.setWindowIcon(QIcon(":/images/image.ico"))
QBG = QButtonGroup()
QBG.addButton(self.in_radioButton)
QBG.addButton(self.out_radioButton)
self.generate_pushButton.clicked.connect(self.on_generate_btn_clicked)
self.clear_lists_pushButton.clicked.connect(self.on_clear_btn_clicked)
self.cancel_pushButton.clicked.connect(self.on_cancel_btn_clicked)
self.confirm_pushButton.clicked.connect(self.on_confirm_btn_clicked)
self.fill_table([])
self.generate_pushButton.setStyleSheet("background:#BFCAE6")
self.confirm_pushButton.setStyleSheet("background:#BFCAE6")
self.in_radioButton.setStyleSheet("color:red")
self.out_radioButton.setStyleSheet("color:green")
self.in_radioButton.clicked.connect(self.on_in_radiobtn_clicked)
self.out_radioButton.clicked.connect(self.on_out_radiobtn_clicked)

def on_in_radiobtn_clicked(self):
self.confirm_label.setText("入库操作")
self.confirm_label.setStyleSheet("color:red")

def on_out_radiobtn_clicked(self):
self.confirm_label.setText("出库操作")
self.confirm_label.setStyleSheet("color:green")

def on_cancel_btn_clicked(self):
self.close()

def on_confirm_btn_clicked(self):
if self.export_data == []:
QMessageBox.question(self, '操作失败!', '出/入库详单中没有数据!', QMessageBox.Yes)
return
today_date = datetime.date.today()
date_str = str(today_date.year * 10000 + today_date.month * 100 + today_date.day)
# sql
if self.in_radioButton.isChecked(): # 入库
sql="insert into in_log values "
else:
sql="insert into out_log values "

# sql = "insert into in_log values(" + self.date_time + ",'" + self.material_id + "','" + self.material_name + "','" + self.spec + "'," + self.in_num + ","+self.per_price+",'"+self.position+"',"+self.total_price+",'" + self.user_man + "','" + self.agree_man + "', null);"

for i in range(0,len(self.export_data)):
sql+=f"({date_str}, '{self.export_data[i][0]}','{self.export_data[i][1]}', '{self.export_data[i][2]}', {self.export_data[i][8]}, {self.export_data[i][6]}, '{self.export_data[i][4]}', {self.export_data[i][9]}, '{self.export_data[i][10]}','{self.export_data[i][11]}', null)"
if i<len(self.export_data)-1:
sql+=','
else:
sql+=';'

conn = sqlite3.connect("material_management.db")
conn.text_factory = str
cur = conn.cursor()
cur.execute(sql)
conn.commit()
# 更新物料表结存数量
#构建临时表
sql="create temporary table tmp(material_id varchar(32) primary key,now_num float);"
cur.execute(sql)
conn.commit()
#临时表插入新数据
sql=f"insert into tmp values "

if self.in_radioButton.isChecked(): # 入库
for i in range(len(self.export_data)):
new_now_num=str(float(self.export_data[i][5]) + float(self.export_data[i][8]))
sql+=f"('{self.export_data[i][0]}', {new_now_num})"
if i<len(self.export_data)-1:
sql+=','
else:
sql+=';'
else:#出库
for i in range(len(self.export_data)):
new_now_num=str(float(self.export_data[i][5]) - float(self.export_data[i][8]))
sql+=f"('{self.export_data[i][0]}', {new_now_num})"
if i<len(self.export_data)-1:
sql+=','
else:
sql+=';'

cur.execute(sql)
conn.commit()

#更新material表
sql="update material set now_num= (select now_num from tmp where tmp.material_id=material.material_id) where material.material_id in (select material_id from tmp)"
cur.execute(sql)
conn.commit()

#临时表会自动删除
cur.close()
conn.close()

QMessageBox.question(self, '入库成功!' if self.in_radioButton.isChecked() else '出库成功!', '批量操作完成!', QMessageBox.Yes)
self.on_clear_btn_clicked()



def fill_table(self, datas): # datas为列表
self.export_data = datas
self.model = QStandardItemModel(len(datas), 11)
self.model.setHorizontalHeaderLabels(
['存货编码', '存货名称', '规格型号', '计量单位', '库存位置', '结存数量', '单价(元)', '操作类型', '操作数量', '总价(元)', '使用人', "令号"])
if datas != []:
for i in range(0, len(datas)):
item = QStandardItem(datas[i][0])
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
self.model.setItem(i, 0, item)

item = QStandardItem(datas[i][1])
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
self.model.setItem(i, 1, item)

item = QStandardItem(datas[i][2])
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
self.model.setItem(i, 2, item)

item = QStandardItem(datas[i][3])
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
self.model.setItem(i, 3, item)

item = QStandardItem(datas[i][4])
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
self.model.setItem(i, 4, item)

item = QStandardItem(format(float(datas[i][5]), '.4f'))
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
self.model.setItem(i, 5, item)

item = QStandardItem(format(float(datas[i][6]), '.4f'))
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
self.model.setItem(i, 6, item)

item = QStandardItem(datas[i][7])
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
self.model.setItem(i, 7, item)

item = QStandardItem(format(float(datas[i][8]), '.4f'))
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
self.model.setItem(i, 8, item)

item = QStandardItem(format(float(datas[i][9]), '.4f'))
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
self.model.setItem(i, 9, item)

item = QStandardItem(datas[i][10])
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
self.model.setItem(i, 10, item)

item = QStandardItem(datas[i][11])
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
self.model.setItem(i, 11, item)

self.tableView.setModel(self.model)
self.tableView.resizeColumnsToContents()
self.tableView.resizeRowsToContents()
self.tableView.horizontalHeader().setStretchLastSection(True)

def on_clear_btn_clicked(self):
self.id_textEdit.setPlainText("")
self.num_textEdit.setPlainText("")
self.user_textEdit.setPlainText("")
self.code_textEdit.setPlainText("")
self.in_radioButton.setChecked(False)
self.out_radioButton.setChecked(False)
self.fill_table([])

def on_generate_btn_clicked(self):
if self.in_radioButton.isChecked():
all_in_flag = 1
elif self.out_radioButton.isChecked():
all_in_flag = 0
else:
QMessageBox.question(self, '生成失败!', '请选择入库还是出库!', QMessageBox.Yes)
return
id_str = self.id_textEdit.toPlainText()
id_str = id_str.strip('\n\t ')
if id_str == "":
QMessageBox.question(self, '生成失败!', '存货编码不可为空!', QMessageBox.Yes)
return

id_ll = id_str.split('\n')
id_len = len(id_ll)
for i in range(0, id_len):
id_ll[i] = id_ll[i].strip('\n\t ')
# 判断重复
for i in range(0, id_len):
for j in range(i + 1, id_len):
if id_ll[i] == id_ll[j]:
QMessageBox.question(self, '生成失败!', '存货编码列表第' + str(i + 1) + "行与第" + str(j + 1) + "行重复!\n请自行合并!",
QMessageBox.Yes)
return

num_str = self.num_textEdit.toPlainText()
if num_str == "":
QMessageBox.question(self, '生成失败!', '操作数量不可为空!', QMessageBox.Yes)
return
else:
num_str = num_str.strip('\n\t ')
num_ll = num_str.split('\n')

if len(num_ll) != id_len:
QMessageBox.question(self, '生成失败!', '操作数量列表条数与存货编码列表不一致!', QMessageBox.Yes)
return
for i in range(0, id_len):
num_ll[i] = num_ll[i].strip('\n\t ')

user_str = self.user_textEdit.toPlainText()
if user_str == "":
QMessageBox.question(self, '生成失败!', '使用人不可为空!', QMessageBox.Yes)
return
else:
user_str = user_str.strip('\n\t ')
user_ll = user_str.split('\n')
if len(user_ll) != id_len:
QMessageBox.question(self, '生成失败!', '使用人列表条数与存货编码列表不一致!', QMessageBox.Yes)
return
for i in range(0, id_len):
user_ll[i] = user_ll[i].strip('\n\t ')

code_str = self.code_textEdit.toPlainText()
if code_str == "":
QMessageBox.question(self, '生成失败!', '令号不可为空!', QMessageBox.Yes)
return
else:
code_str = code_str.strip('\n\t ')
code_ll = code_str.split('\n')
if len(code_ll) != id_len:
QMessageBox.question(self, '生成失败!', '令号列表条数与存货编码列表不一致!', QMessageBox.Yes)
return
for i in range(0, id_len):
code_ll[i] = code_ll[i].strip('\n\t ')

conn = sqlite3.connect("material_management.db")
conn.text_factory = str
cur = conn.cursor()
table_data = []
for i in range(0, id_len):
sql = "select material_name,spec,unit,pos,now_num,per_price from material where material_id='" + id_ll[
i] + "'"
try:
cur.execute(sql)
except:
QMessageBox.question(self, '生成失败!', '第' + str(i + 1) + "条存货编码不存在!\n所有存货均未进行出、入库操作!", QMessageBox.Yes)
cur.close()
conn.close()
return
res = cur.fetchone()
if res is None:
QMessageBox.question(self, '生成失败!', '第' + str(i + 1) + "条存货编码不存在!\n所有存货均未进行出、入库操作!", QMessageBox.Yes)
cur.close()
conn.close()
return
tmp = []
tmp.append(id_ll[i])
tmp.append(res[0])
tmp.append(res[1])
tmp.append(res[2])
tmp.append(res[3])
tmp.append(str(res[4]))
tmp.append(str(res[5]))
if all_in_flag:
tmp.append('入库')
else:
tmp.append('出库')
try:
tt = float(num_ll[i])
except:
QMessageBox.question(self, '生成失败!', '第' + str(i + 1) + "条操作数量不是实数!\n所有存货均未进行出、入库操作!", QMessageBox.Yes)
cur.close()
conn.close()
return
if all_in_flag == 0 and tt > res[4]:
QMessageBox.question(self, '生成失败!', '第' + str(i + 1) + "条存货的出库数量大于现有库存!\n所有存货均未进行出、入库操作!", QMessageBox.Yes)
cur.close()
conn.close()
return
tmp.append(num_ll[i])
tmp.append(str(res[5] * tt)) # 总价
tmp.append(user_ll[i])
tmp.append(code_ll[i])
table_data.append(tmp)
cur.close()
conn.close()
self.fill_table(table_data)
QMessageBox.question(self, '生成成功!', "详单已填充至下方表格,请仔细核查!", QMessageBox.Yes)
4 changes: 1 addition & 3 deletions source_code/ctrl_lots_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import resources_rc
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QStandardItemModel, QStandardItem, QIcon
from PyQt5.QtWidgets import QMainWindow, QMessageBox, QButtonGroup
import datetime
from PyQt5.QtWidgets import QMainWindow, QMessageBox
from lots_new import Ui_lots_new
from objects import In_Log, Out_Log
import sqlite3


Expand Down
22 changes: 11 additions & 11 deletions source_code/ctrl_material_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,18 @@ def my_query(self):
sql += ")"

if self.position_lineEdit.text() != "":
spec_ll = self.position_lineEdit.text()
spec_ll = spec_ll.strip('%\n\t ')
spec_ll = spec_ll.split('%')
spec_ll1 = []
spec_ll2 = []
for tspec in spec_ll:
spec_ll1.append("%" + tspec + "%")
spec_ll2.append("%%" + tspec + "%%")
pos_ll = self.position_lineEdit.text()
pos_ll = pos_ll.strip('%\n\t ')
pos_ll = pos_ll.split('%')
pos_ll1 = []
pos_ll2 = []
for tpos in pos_ll:
pos_ll1.append("%" + tpos + "%")
pos_ll2.append("%%" + tpos + "%%")
sql += " and ("
for i in range(len(spec_ll)):
sql += "spec like '" + spec_ll1[i] + "' or spec like '" + spec_ll2[i] + "'"
if i < len(spec_ll) - 1:
for i in range(len(pos_ll)):
sql += "pos like '" + pos_ll1[i] + "' or pos like '" + pos_ll2[i] + "'"
if i < len(pos_ll) - 1:
sql += " or "
sql += ")"

Expand Down
4 changes: 2 additions & 2 deletions source_code/ctrl_new_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def on_confirm_btn_clicked(self):
str(now_num))
try:
tmp_material.insert_new_material()
QMessageBox.question(self, '新增成功!', '新物料信息已录入!', QMessageBox.Yes)
QMessageBox.question(self, '新增成功!', '新存货信息已录入!', QMessageBox.Yes)
self.material_name_lineEdit.setText("")
self.material_id_lineEdit.setText("")
self.spec_lineEdit.setText("")
Expand All @@ -65,7 +65,7 @@ def on_confirm_btn_clicked(self):
self.position_lineEdit.setText("")
self.ori_num_lineEdit.setText("")
except:
QMessageBox.question(self, '新增失败!', '物料编码不可重复!', QMessageBox.Yes)
QMessageBox.question(self, '新增失败!', '重复,库中已存在该存货编码!', QMessageBox.Yes)

def on_cancel_btn_clicked(self):
self.close()
Expand Down
2 changes: 1 addition & 1 deletion source_code/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def setupUi(self, home):

def retranslateUi(self, home):
_translate = QtCore.QCoreApplication.translate
home.setWindowTitle(_translate("home", "库房存货管理系统V1.9.5"))
home.setWindowTitle(_translate("home", "库房存货管理系统V1.9.7"))
self.groupBox.setTitle(_translate("home", "存货操作"))
self.new_material_pushButton.setText(_translate("home", "单件新增"))
self.in_material_pushButton.setText(_translate("home", "入库/出库"))
Expand Down
2 changes: 1 addition & 1 deletion source_code/home.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>库房存货管理系统V1.9.5</string>
<string>库房存货管理系统V1.9.7</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
Expand Down
Binary file modified source_code/images/image.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion source_code/lots_in_out.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def retranslateUi(self, lots_in_out):
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'SimSun\';\"><br /></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'SimSun\'; color:#000000;\">3.通过一组单选按钮设定批量入库/批量出库;</span></p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'SimSun\'; color:#000000;\"><br /></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'SimSun\'; color:#000000;\">4.填充列表后,按</span><span style=\" font-family:\'SimSun\'; color:#0000ff;\">“生成”按钮</span><span style=\" font-family:\'SimSun\'; color:#000000;\">,自动生成“出/入库详单”;</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'SimSun\'; color:#000000;\">4.填充列表后,按</span><span style=\" font-family:\'SimSun\'; color:#0000ff;\">“生成详单”按钮</span><span style=\" font-family:\'SimSun\'; color:#000000;\">,自动生成“出/入库详单”;</span></p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'SimSun\'; color:#000000;\"><br /></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'SimSun\'; color:#000000;\">5.核查后,点击确定,完成批量出/入库操作。</span></p></body></html>"))
self.confirm_pushButton.setText(_translate("lots_in_out", "确认"))
Expand Down
Loading

0 comments on commit 82218e6

Please sign in to comment.