-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdd.py
More file actions
250 lines (202 loc) · 7.37 KB
/
Copy pathAdd.py
File metadata and controls
250 lines (202 loc) · 7.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
from PyQt5 import QtWidgets, uic
from PyQt5.QtWidgets import QMessageBox
from PyQt5.QtGui import QStandardItemModel, QStandardItem
import sys
import Dataset as ds
from PyQt5.QtWidgets import (QDialog)
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QMessageBox
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import pyqtSlot
# import main as Pack
# import py3dbp as py3d
# from py3dbp import visualize
# from py3dbp import test as test
container = []
boxes = []
Multiboxes = []
class AddBox(QtWidgets.QDialog):
def __init__(self, model):
super(AddBox, self).__init__()
self.w = uic.loadUi('UI/add.ui', self)
print('add.ui')
self.model = model
self.w.show()
self.w.buttonBox.accepted.connect(self.addBox)
def addBox(self):
SerialNumber = 0
Quantity = 0
print('add')
SerialNumber = self.w.LineSerialNum.text()
Quantity = self.w.LineQuantity.text()
# email = self.w.lineEditEmail.text()
i = 0
# print(SerialNumber,Quantity)
# exit(0)
# result = dataset.select_data_serial(conn,SerialNumber)
result = ds.select_Box_serial(conn, SerialNumber)
# print(result)
# exit(0)
for row in result:
id = '{}'.format(row['Id'])
TableRow = (
QStandardItem('{}'.format(row['Id'])), QStandardItem(row['SerialNumber']), QStandardItem(row['Length']),
QStandardItem(row['Width']), QStandardItem(row['Height']), QStandardItem(Quantity))
self.model.appendRow(TableRow)
# print(Quantity)
Multiboxes.append([row['Id'], Quantity])
for i in range(0, int(Quantity)):
boxes.append([row['Id']])
print(i)
i += 1
class AddCrate(QtWidgets.QDialog):
def __init__(self, model):
super(AddCrate, self).__init__()
self.w = uic.loadUi('UI/addCrate.ui', self)
print('add.ui')
self.model = model
self.w.show()
self.w.buttonBox.accepted.connect(self.AddCrate)
def AddCrate(self):
SerialNumber = 0
Quantity = 1
print('add')
SerialNumber = self.w.LineSerialNum.text()
# Quantity = self.w.LineQuantity.text()
# email = self.w.lineEditEmail.text()
# print(SerialNumber,Quantity)
# exit(0)
# result = dataset.select_data_serial(conn,SerialNumber)
result = ds.select_Crate_serial(conn, SerialNumber)
# print(result)
# exit(0)
for row in result:
id = '{}'.format(row['Id'])
TableRow = (
QStandardItem('{}'.format(row['Id'])), QStandardItem(row['SerialNumber']), QStandardItem(row['Length']),
QStandardItem(row['Width']), QStandardItem(row['Height']), QStandardItem('1'))
self.model.appendRow(TableRow)
container.append(row['Id'])
def RunPacking():
print("Run packing")
# add = RunPacking()
dataset = {}
print(container, boxes)
print(len(container), len(boxes))
if len(container) == 0 or len(boxes) < 1:
alert = CrateAlert1()
else:
dataset = ds.Packing_Prepare(conn, container, boxes)
print(dataset)
Pack.start()
# Pack.start(dataset)
def RunMulPacking():
print("Run Mul packing")
# add = RunPacking()
dataset = {}
# print(container, boxes)
print(len(container), len(boxes))
if len(container) == 0 or len(boxes) < 1:
alert = CrateAlert1()
else:
print(container, Multiboxes)
dataset = ds.Multi_Packing_Prepare(conn, container, Multiboxes)
print(dataset)
# # Pack.start()
# test.Mul_packing()
# Pack.start(dataset)
def BoxesList():
print("Run Boxes List")
class CrateAlert1(QWidget):
def __init__(self):
super().__init__()
self.title = 'Crate Alert'
self.left = 10
self.top = 10
self.width = 320
self.height = 200
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
buttonReply = QMessageBox.question(self, 'Alert ', "Please add more boxes",
QMessageBox.Yes | QMessageBox.Cancel,
QMessageBox.Cancel)
print(int(buttonReply))
if buttonReply == QMessageBox.Yes:
print('Yes clicked.')
if buttonReply == QMessageBox.No:
print('No clicked.')
if buttonReply == QMessageBox.Cancel:
print('Cancel')
self.show()
class CrateAlert(QWidget):
def __init__(self):
super().__init__()
self.title = 'Crate Alert'
self.left = 10
self.top = 10
self.width = 320
self.height = 200
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
buttonReply = QMessageBox.question(self, 'Alert ', "Only one carte per time",
QMessageBox.YesToAll | QMessageBox.Cancel,
QMessageBox.Cancel)
print(int(buttonReply))
if buttonReply == QMessageBox.Yes:
print('Yes clicked.')
if buttonReply == QMessageBox.No:
print('No clicked.')
if buttonReply == QMessageBox.Cancel:
print('Cancel')
self.show()
class Example(QtWidgets.QMainWindow):
def __init__(self):
super(Example, self).__init__()
uic.loadUi('UI/window.ui', self)
# result = Database.select_data(conn)
# for row in result:
# print("{SerialNumber}, {Length}, {Width}, {Height}, {Weight}".format(**row))
self.model1 = QStandardItemModel()
self.model1.setHorizontalHeaderLabels(['Id', 'Serial Number', 'Length', 'Width', 'Height', 'Quantity'])
self.tableView2.setModel(self.model1)
self.tableView2.horizontalHeader().setSectionResizeMode(1)
self.model = QStandardItemModel()
self.model.setHorizontalHeaderLabels(['Id', 'Serial Number', 'Length', 'Width', 'Height', 'Quantity'])
self.tableView.setModel(self.model)
self.tableView.horizontalHeader().setSectionResizeMode(1)
# row = (QStandardItem('Alice'), QStandardItem('Alison'), QStandardItem('alice@alison.com'))
# self.model.appendRow(row)
self.actionNewCrate.triggered.connect(self.addCrate)
self.actionNewBox.triggered.connect(self.addBox)
self.actionExit.triggered.connect(self.Close)
self.actionRun.triggered.connect(RunPacking)
self.actionRunMul.triggered.connect(RunMulPacking)
self.actionShow.triggered.connect(BoxesList)
def Close(self):
self.close()
def addBox(self):
print('add box')
add = AddBox(self.model)
def addCrate(self):
print('Add crate')
if self.model1.rowCount() < 1:
print(self.model1.rowCount())
add = AddCrate(self.model1)
else:
print("have container already")
ex = CrateAlert()
def start():
app = QtWidgets.QApplication([])
win = Example()
win.setFixedSize(1280, 720)
win.show()
sys.exit(app.exec())
# conn.close()
if __name__ == "__main__":
conn = ds.connect_database()
start()
conn.close()