forked from gsriram24/ic-log
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapprove_comp.py
222 lines (210 loc) · 8.7 KB
/
approve_comp.py
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
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'approve_comp.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_approveComp(object):
def setupUi(self, approveComp):
approveComp.setObjectName("approveComp")
approveComp.resize(650, 670)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/admin/admin.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
approveComp.setWindowIcon(icon)
sizePolicy.setHeightForWidth(approveComp.sizePolicy().hasHeightForWidth())
approveComp.setSizePolicy(sizePolicy)
approveComp.setMinimumSize(QtCore.QSize(650, 670))
approveComp.setMaximumSize(QtCore.QSize(650, 670))
self.closeButton = QtWidgets.QPushButton(approveComp)
self.closeButton.setGeometry(QtCore.QRect(280, 620, 93, 41))
self.closeButton.setStyleSheet("#closeButton{\n"
" font: 57 8pt \"Slate For OnePlus Medium\";\n"
"background-color:#0277BD;\n"
" color: white;\n"
" padding: 5px;\n"
" text-align: center;\n"
" font-size: 16px;\n"
" margin: 4px 2px;\n"
"border-radius: 15px;\n"
"}\n"
"#closeButton:hover{\n"
"background-color:#01579B;\n"
"\n"
"}\n"
"#closeButton:pressed{\n"
"background-color:#1A237E;\n"
"}")
self.closeButton.setObjectName("closeButton")
self.label = QtWidgets.QLabel(approveComp)
self.label.setGeometry(QtCore.QRect(100, 10, 451, 40))
self.label.setMinimumSize(QtCore.QSize(0, 40))
font = QtGui.QFont()
font.setFamily("Slate For OnePlus Medium")
font.setPointSize(18)
font.setBold(False)
font.setItalic(False)
font.setWeight(7)
self.label.setFont(font)
self.label.setStyleSheet("color: rgb(255, 255, 255);\n"
"font: 57 18pt \"Slate For OnePlus Medium\";")
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(approveComp)
self.label_2.setGeometry(QtCore.QRect(-60, -80, 821, 781))
self.label_2.setStyleSheet("\n"
"background-color:qlineargradient(spread:pad, x1:0.492, y1:0, x2:0.501925, y2:0.796, stop:0 rgba(40, 53, 147, 255), stop:1 rgba( 131, 185, 255, 255))\n"
"")
self.label_2.setText("")
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(approveComp)
self.label_3.setGeometry(QtCore.QRect(10, 80, 181, 16))
font = QtGui.QFont()
font.setFamily("Slate For OnePlus Medium")
font.setPointSize(10)
font.setBold(False)
font.setItalic(False)
font.setWeight(7)
self.label_3.setFont(font)
self.label_3.setStyleSheet("font: 57 10pt \"Slate For OnePlus Medium\";\n"
"color: white;")
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(approveComp)
self.label_4.setGeometry(QtCore.QRect(330, 80, 151, 16))
font = QtGui.QFont()
font.setFamily("Slate For OnePlus Medium")
font.setPointSize(10)
font.setBold(False)
font.setItalic(False)
font.setWeight(7)
self.label_4.setFont(font)
self.label_4.setStyleSheet("font: 57 10pt \"Slate For OnePlus Medium\";\n"
"color: white;")
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(approveComp)
self.label_5.setGeometry(QtCore.QRect(10, 570, 251, 31))
self.label_5.setStyleSheet("\n"
" font: 57 8pt \"Slate For OnePlus Medium\";\n"
"\n"
" color: white;\n"
"")
self.label_5.setWordWrap(True)
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(approveComp)
self.label_6.setGeometry(QtCore.QRect(330, 570, 311, 31))
self.label_6.setStyleSheet("\n"
" font: 57 8pt \"Slate For OnePlus Medium\";\n"
"\n"
" color: white;\n"
"")
self.label_6.setWordWrap(True)
self.label_6.setObjectName("label_6")
self.rejectButton = QtWidgets.QPushButton(approveComp)
self.rejectButton.setGeometry(QtCore.QRect(570, 70, 71, 41))
self.rejectButton.setStyleSheet("#rejectButton{\n"
" font: 57 8pt \"Slate For OnePlus Medium\";\n"
"background-color:#ff867c;\n"
" color: white;\n"
" padding: 5px;\n"
" text-align: center;\n"
" font-size: 16px;\n"
" margin: 4px 2px;\n"
"border-radius: 5px;\n"
"}\n"
"#rejectButton:hover{\n"
"background-color:#ef5350;\n"
"\n"
"}\n"
"#rejectButton:pressed{\n"
"background-color:#9a0007;\n"
"}")
self.rejectButton.setObjectName("rejectButton")
self.dueList = QtWidgets.QListWidget(approveComp)
self.dueList.setGeometry(QtCore.QRect(330, 110, 311, 451))
self.dueList.setStyleSheet("#dueList{font: 57 9pt \"Slate For OnePlus Medium\";\n"
"border: 2px solid #002171;\n"
"border-style: outset;\n"
"}\n"
"#dueList:hover{font: 57 9pt \"Slate For OnePlus Medium\";\n"
"border: 3px solid #002171;\n"
"}\n"
"")
self.dueList.setObjectName("dueList")
self.nameList = QtWidgets.QListWidget(approveComp)
self.nameList.setGeometry(QtCore.QRect(10, 110, 311, 451))
self.nameList.setStyleSheet("#nameList{font: 57 9pt \"Slate For OnePlus Medium\";\n"
"border: 1px solid #002171;\n"
"border-style: outset;\n"
"}\n"
"#nameList:hover{font: 57 9pt \"Slate For OnePlus Medium\";\n"
"border: 3px solid #002171;\n"
"}\n"
"")
self.nameList.setObjectName("nameList")
self.label_2.raise_()
self.closeButton.raise_()
self.label.raise_()
self.label_3.raise_()
self.label_4.raise_()
self.label_5.raise_()
self.label_6.raise_()
self.rejectButton.raise_()
self.dueList.raise_()
self.nameList.raise_()
self.nameList.itemClicked.connect(lambda: self.getReqList())
self.dueList.itemDoubleClicked.connect(lambda: self.approveComponent(approveComp))
self.rejectButton.clicked.connect(lambda: self.rejectComponent(approveComp))
self.closeButton.clicked.connect(approveComp.close)
self.retranslateUi(approveComp)
QtCore.QMetaObject.connectSlotsByName(approveComp)
def rejectComponent(self, approveComp):
import db
x=db.fetchCompID(self.dueList.currentItem().text())
reg_no=db.fetchStudentReg(self.nameList.currentItem().text())
db.rejectComponent(x, reg_no, lab)
QtWidgets.QMessageBox.about(approveComp, 'Succesfully Rejected!', "Component Successfully Rejected!")
self.dueList.takeItem(self.dueList.currentRow())
def setLab(self,text):
global lab
lab=text
def approveComponent(self,approveComp):
import db
x=db.fetchCompID(self.dueList.currentItem().text())
s=db.getComponentStock(x,lab)
if(int(s)<=0):
QtWidgets.QMessageBox.about(approveComp, 'Error!', "Component out of stock!")
else:
reg_no=db.fetchStudentReg(self.nameList.currentItem().text())
db.issueComponent(x, reg_no, lab)
QtWidgets.QMessageBox.about(approveComp, 'Succesfully Issued!', "Component Successfully Issued!")
self.dueList.takeItem(self.dueList.currentRow())
def getReqList(self):
import db
self.dueList.clear()
a=db.getRequestedComponentsLab(db.fetchStudentReg(self.nameList.currentItem().text()),lab)
self.dueList.addItems(a)
def setList(self,a):
self.nameList.addItems(a)
def retranslateUi(self, approveComp):
_translate = QtCore.QCoreApplication.translate
approveComp.setWindowTitle(_translate("approveComp", "Approve Components"))
self.closeButton.setText(_translate("approveComp", "× Close"))
self.closeButton.setShortcut(_translate("approveComp", "Esc"))
self.label.setText(_translate("approveComp", "APPROVE COMPONENTS"))
self.label_3.setText(_translate("approveComp", "Student Name"))
self.label_4.setText(_translate("approveComp", "Requested List"))
self.label_5.setText(_translate("approveComp", "Click the student\'s name to check components requested."))
self.label_6.setText(_translate("approveComp", "Double Click the component names to issue them. Select and Click on the \'-\' to reject."))
self.rejectButton.setText(_translate("approveComp", "REJECT"))
import icons_rc
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
approveComp = QtWidgets.QWidget()
ui = Ui_approveComp()
ui.setupUi(approveComp)
approveComp.show()
sys.exit(app.exec_())