forked from sanketsbhosale/Q-LOOP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalibration1.py
365 lines (308 loc) · 15 KB
/
Calibration1.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
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
import sqlite3
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Calibration(object):
def CalDB(self):
GaugeName=str(self.lineEdit.text())
ReportDate=str(self.lineEdit_2.text())
ReminderDate=str(self.lineEdit_7.text())
if(len(GaugeName) == 0 and \
len(ReportDate) == 0 and \
len(ReminderDate) == 0):
self.showCWMessageBox("Calibration","Please Enter Details!")
print("Please Enter Details!")
elif(len(GaugeName) == 0 and \
len(ReportDate) == 0 ):
self.showCWMessageBox("Calibration","Please Enter all Details!")
print("Please Enter all Details!")
elif(len(ReportDate) == 0 and \
len(ReminderDate) == 0 ):
self.showCWMessageBox("Calibration","Please Enter all Details!")
print("Please Enter all Details!")
elif(len(GaugeName) == 0 and \
len(ReminderDate) == 0 ):
self.showCWMessageBox("Calibration","Please Enter all Details!")
print("Please Enter all Details!")
elif(len(GaugeName) == 0):
self.showCWMessageBox("Calibration","Please Enter all Details!")
print("Please Enter all Details!")
elif(len(ReportDate) == 0):
self.showCWMessageBox("Calibration","Please Enter all Details!")
print("Please Enter all Details!")
elif(len(ReminderDate) == 0):
self.showCWMessageBox("Calibration","Please Enter all Details!")
print("Please Enter all Details!")
else:
connection=sqlite3.connect("PYDB.db")
c=connection.cursor()
c.execute("CREATE TABLE IF NOT EXISTS CalibrationTable(GAUGE_NAME TEXT PRIMARY KEY,REPORT_DATE TEXT NOT NULL,REMINDER_DATE TEXT NOT NULL)")
c.execute("INSERT INTO CalibrationTable VALUES(?,?,?)",(GaugeName,ReportDate,ReminderDate))
connection.commit()
result=connection.execute("SELECT * FROM CalibrationTable WHERE GAUGE_NAME = ? AND REPORT_DATE = ?",(GaugeName,ReportDate))
if (len(result.fetchone()) > 0):
print("Details are added successfully!")
self.showCMessageBox("Calibration","Details are Added successfully")
c.close()
def onClickCalDB(self):
try:
self.CalDB()
except sqlite3.IntegrityError:
self.showCWMessageBox("MSA","Details Exists !")
def CalDBUpdate(self):
GaugeName_1=str(self.lineEdit_3.text())
GaugeName_2=str(self.lineEdit_4.text())
ReportDate_1=str(self.lineEdit_5.text())
ReminderDate_1=str(self.lineEdit_6.text())
connection=sqlite3.connect("PYDB.db")
c=connection.cursor()
c.execute("UPDATE CalibrationTable SET REMINDER_DATE = ? , REPORT_DATE = ? , GAUGE_NAME = ? WHERE GAUGE_NAME = ?",(ReminderDate_1,ReportDate_1,GaugeName_2,GaugeName_1))
connection.commit()
result=connection.execute("SELECT * FROM CalibrationTable WHERE GAUGE_NAME = ?",(GaugeName_2,))
if (len(result.fetchone()) > 0):
print("Details are Updated successfully!")
self.showCMessageBox("Calibration","Details are Updated successfully")
c.close()
def onClickCalDBUpdate(self):
try:
self.CalDBUpdate()
except :
print("Please re-enter Details")
self.showCWMessageBox("Calibration","Please Re-Enter Details")
def showCMessageBox(self,title,message):
msgBox=QtWidgets.QMessageBox()
msgBox.setWindowTitle(title)
msgBox.setIcon(QtWidgets.QMessageBox.Information)
msgBox.setText(message)
msgBox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgBox.exec_()
def showCWMessageBox(self,title,message):
msgBox=QtWidgets.QMessageBox()
msgBox.setWindowTitle(title)
msgBox.setIcon(QtWidgets.QMessageBox.Warning)
msgBox.setText(message)
msgBox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgBox.exec_()
def setupUi(self, Calibration):
Calibration.setObjectName("Calibration")
Calibration.resize(1070, 572)
Calibration.setMinimumSize(QtCore.QSize(1070, 572))
Calibration.setMaximumSize(QtCore.QSize(1070, 572))
Calibration.setStatusTip("")
Calibration.setWhatsThis("")
Calibration.setAccessibleName("")
Calibration.setAccessibleDescription("")
self.centralwidget = QtWidgets.QWidget(Calibration)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout_2 = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout_2.setObjectName("gridLayout_2")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("Resource/logo2.bmp"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
Calibration.setWindowIcon(icon)
font = QtGui.QFont()
font.setFamily("Segoe UI")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.tabWidget.setFont(font)
self.tabWidget.setTabPosition(QtWidgets.QTabWidget.North)
self.tabWidget.setTabShape(QtWidgets.QTabWidget.Rounded)
self.tabWidget.setElideMode(QtCore.Qt.ElideNone)
self.tabWidget.setObjectName("tabWidget")
self.tab = QtWidgets.QWidget()
self.tab.setObjectName("tab")
self.groupBox = QtWidgets.QGroupBox(self.tab)
self.groupBox.setGeometry(QtCore.QRect(10, 10, 1011, 221))
self.groupBox.setObjectName("groupBox")
####################### NAME OF GAUGE ###################################
self.label = QtWidgets.QLabel(self.groupBox)
self.label.setGeometry(QtCore.QRect(20, 40, 291, 31))
font = QtGui.QFont()
font.setFamily("Segoe UI")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.label.setFont(font)
self.label.setObjectName("label")
self.lineEdit = QtWidgets.QLineEdit(self.groupBox)
self.lineEdit.setGeometry(QtCore.QRect(350, 40, 631, 31))
self.lineEdit.setObjectName("lineEdit")
########################### DATE OF GAUGE ###############################
self.label_2 = QtWidgets.QLabel(self.groupBox)
self.label_2.setGeometry(QtCore.QRect(20, 80, 291, 31))
font = QtGui.QFont()
font.setFamily("Segoe UI")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.lineEdit_2 = QtWidgets.QLineEdit(self.groupBox)
self.lineEdit_2.setGeometry(QtCore.QRect(350, 80, 631, 31))
self.lineEdit_2.setObjectName("lineEdit_2")
######################## DATE OF REMAINDER ##################################
self.lineEdit_7 = QtWidgets.QLineEdit(self.groupBox)
self.lineEdit_7.setGeometry(QtCore.QRect(350, 120, 631, 31))
self.lineEdit_7.setObjectName("lineEdit_7")
self.label_7 = QtWidgets.QLabel(self.groupBox)
self.label_7.setGeometry(QtCore.QRect(20, 120, 291, 31))
font = QtGui.QFont()
font.setFamily("Segoe UI")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.label_7.setFont(font)
self.label_7.setObjectName("label_7")
########################### BUTTON ##########################################
self.pushButton = QtWidgets.QPushButton(self.groupBox)
self.pushButton.setGeometry(QtCore.QRect(650, 170, 121, 31))
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(self.onClickCalDB)
self.groupBox_2 = QtWidgets.QGroupBox(self.tab)
self.groupBox_2.setGeometry(QtCore.QRect(10, 240, 1011, 261))
self.groupBox_2.setObjectName("groupBox_2")
self.label_3 = QtWidgets.QLabel(self.groupBox_2)
self.label_3.setGeometry(QtCore.QRect(20, 50, 291, 31))
font = QtGui.QFont()
font.setFamily("Segoe UI")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.lineEdit_3 = QtWidgets.QLineEdit(self.groupBox_2)
self.lineEdit_3.setGeometry(QtCore.QRect(350, 50, 631, 31))
self.lineEdit_3.setObjectName("lineEdit_3")
self.label_4 = QtWidgets.QLabel(self.groupBox_2)
self.label_4.setGeometry(QtCore.QRect(20, 90, 291, 31))
font = QtGui.QFont()
font.setFamily("Segoe UI")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.lineEdit_4 = QtWidgets.QLineEdit(self.groupBox_2)
self.lineEdit_4.setGeometry(QtCore.QRect(350, 90, 631, 31))
self.lineEdit_4.setObjectName("lineEdit_4")
self.label_5 = QtWidgets.QLabel(self.groupBox_2)
self.label_5.setGeometry(QtCore.QRect(20, 130, 291, 31))
font = QtGui.QFont()
font.setFamily("Segoe UI")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.lineEdit_5 = QtWidgets.QLineEdit(self.groupBox_2)
self.lineEdit_5.setGeometry(QtCore.QRect(350, 130, 631, 31))
self.lineEdit_5.setObjectName("lineEdit_5")
self.label_6 = QtWidgets.QLabel(self.groupBox_2)
self.label_6.setGeometry(QtCore.QRect(20, 170, 321, 31))
font = QtGui.QFont()
font.setFamily("Segoe UI")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.label_6.setFont(font)
self.label_6.setObjectName("label_6")
self.lineEdit_6 = QtWidgets.QLineEdit(self.groupBox_2)
self.lineEdit_6.setGeometry(QtCore.QRect(350, 170, 631, 31))
self.lineEdit_6.setText("")
self.lineEdit_6.setObjectName("lineEdit_6")
self.pushButton_2 = QtWidgets.QPushButton(self.groupBox_2)
self.pushButton_2.setGeometry(QtCore.QRect(650, 220, 121, 31))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_2.clicked.connect(self.onClickCalDBUpdate)
############################# TAB 2 ##########################################
self.tabWidget.addTab(self.tab, "")
self.tab_2 = QtWidgets.QWidget()
self.tab_2.setObjectName("tab_2")
self.label_8 = QtWidgets.QLabel(self.tab_2)
self.label_8.setGeometry(QtCore.QRect(20, 30, 151, 31))
font = QtGui.QFont()
font.setFamily("Segoe UI")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.label_8.setFont(font)
self.label_8.setObjectName("label_8")
self.lineEdit_8 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_8.setGeometry(QtCore.QRect(340, 30, 561, 31))
self.lineEdit_8.setObjectName("lineEdit_8")
self.pushButton_3 = QtWidgets.QPushButton(self.tab_2)
self.pushButton_3.setGeometry(QtCore.QRect(920, 31, 101, 28))
self.pushButton_3.setObjectName("pushButton_3")
self.lineEdit_9 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_9.setGeometry(QtCore.QRect(340, 90, 681, 31))
self.lineEdit_9.setObjectName("lineEdit_9")
self.label_9 = QtWidgets.QLabel(self.tab_2)
self.label_9.setGeometry(QtCore.QRect(20, 90, 301, 31))
font = QtGui.QFont()
font.setFamily("Segoe UI")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.label_9.setFont(font)
self.label_9.setObjectName("label_9")
self.lineEdit_10 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_10.setGeometry(QtCore.QRect(340, 150, 681, 31))
self.lineEdit_10.setObjectName("lineEdit_10")
self.label_10 = QtWidgets.QLabel(self.tab_2)
self.label_10.setGeometry(QtCore.QRect(20, 150, 301, 31))
font = QtGui.QFont()
font.setFamily("Segoe UI")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.label_10.setFont(font)
self.label_10.setObjectName("label_10")
self.line = QtWidgets.QFrame(self.tab_2)
self.line.setGeometry(QtCore.QRect(0, -30, 1041, 541))
self.line.setFrameShape(QtWidgets.QFrame.HLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
self.line.raise_()
self.label_8.raise_()
self.lineEdit_8.raise_()
self.pushButton_3.raise_()
self.lineEdit_9.raise_()
self.label_9.raise_()
self.lineEdit_10.raise_()
self.label_10.raise_()
self.tabWidget.addTab(self.tab_2, "")
self.verticalLayout.addWidget(self.tabWidget)
self.gridLayout_2.addLayout(self.verticalLayout, 0, 0, 1, 1)
Calibration.setCentralWidget(self.centralwidget)
self.retranslateUi(Calibration)
self.tabWidget.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(Calibration)
def retranslateUi(self, Calibration):
_translate = QtCore.QCoreApplication.translate
Calibration.setWindowTitle(_translate("Calibration", "Calibration"))
self.groupBox.setTitle(_translate("Calibration", "Insert Calibration Details"))
self.label.setText(_translate("Calibration", "Name of Gauge :"))
self.label_2.setText(_translate("Calibration", "Date of gauge Calibration Report :"))
self.label_7.setText(_translate("Calibration", "Date of Calibration Remainder :"))
self.pushButton.setText(_translate("Calibration", "SUBMIT"))
self.groupBox_2.setTitle(_translate("Calibration", "Edit Calibration Details"))
self.label_3.setText(_translate("Calibration", "Name of Gauge :"))
self.label_5.setText(_translate("Calibration", "New Date of gauge Calibration Report :"))
self.label_4.setText(_translate("Calibration", "New Name of Gauge :"))
self.label_6.setText(_translate("Calibration", "New Date of gauge Calibration Report :"))
self.pushButton_2.setText(_translate("Calibration", "SUBMIT"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("Calibration", "Insert and Edit Calibration Details"))
self.label_8.setText(_translate("Calibration", "Name of Gauge :"))
self.pushButton_3.setText(_translate("Calibration", "Search"))
self.label_9.setText(_translate("Calibration", "Date of gauge Calibration Report :"))
self.label_10.setText(_translate("Calibration", "Date of Calibration Remainder :"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("Calibration", "Show Calibration Date"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Calibration = QtWidgets.QMainWindow()
ui = Ui_Calibration()
ui.setupUi(Calibration)
Calibration.show()
sys.exit(app.exec_())