-
Notifications
You must be signed in to change notification settings - Fork 0
/
percentageLonen.py
140 lines (114 loc) · 5.36 KB
/
percentageLonen.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
import datetime
from login import hoofdMenu
from PyQt5.QtWidgets import QLabel, QLineEdit, QGridLayout, QPushButton,\
QDialog, QMessageBox
from PyQt5.QtGui import QFont, QIcon, QRegExpValidator, QPixmap
from PyQt5.QtCore import Qt, QRegExp
from sqlalchemy import (Table, Column, Integer, String, Float, Boolean,\
MetaData, create_engine)
from sqlalchemy.sql import select, update
def eindModule(self,m_email):
msg = QMessageBox()
msg.setStyleSheet("color: black; background-color: gainsboro")
msg.setWindowIcon(QIcon('./images/logos/logo.jpg'))
msg.setIcon(QMessageBox.Information)
msg.setText('Input aborted.')
msg.setWindowTitle('Wages')
msg.exec_()
self.close()
hoofdMenu(m_email)
def invoerOK(m_email):
msg = QMessageBox()
msg.setStyleSheet("color: black; background-color: gainsboro")
msg.setIcon(QMessageBox.Information)
msg.setText('Input successful!')
msg.setWindowTitle('Wages')
msg.exec_()
hoofdMenu(m_email)
def invoerVerpl():
msg = QMessageBox()
msg.setStyleSheet("color: black; background-color: gainsboro")
msg.setIcon(QMessageBox.Warning)
msg.setText('Input required\nor close the program!')
msg.setWindowTitle('Wage table')
msg.exec_()
def percLoonschaal(m_email):
class Widget(QDialog):
def __init__(self):
QDialog.__init__(self)
grid = QGridLayout()
grid.setSpacing(12)
self.setWindowTitle("Percentage adjustment of wages")
self.setWindowIcon(QIcon('./images/logos/logo.jpg'))
self.setFont(QFont('Arial', 10))
self.lbl = QLabel()
self.pixmap = QPixmap('./images/logos/verbinding.jpg')
self.lbl.setPixmap(self.pixmap)
grid.addWidget(self.lbl , 0, 0)
self.logo = QLabel()
self.pixmap = QPixmap('./images/logos/logo.jpg')
self.logo.setPixmap(self.pixmap)
grid.addWidget(self.logo , 0, 1, 1, 2, Qt.AlignRight)
grid.addWidget(QLabel(' Adjust wages in percentage terms'), 1, 0, 1, 3, Qt.AlignCenter)
self.Percentage = QLabel()
q1Edit = QLineEdit()
q1Edit.setFixedWidth(100)
q1Edit.setFont(QFont("Arial",10))
q1Edit.textChanged.connect(self.q1Changed)
reg_ex = QRegExp("^[-+]?[0-9]*\.?[0-9]+$")
input_validator = QRegExpValidator(reg_ex, q1Edit)
q1Edit.setValidator(input_validator)
lbl1 = QLabel('Percentage increase')
grid.addWidget(lbl1, 2, 0, 1, 2, Qt.AlignRight)
grid.addWidget(q1Edit, 2, 2)
wijzig = QPushButton('Modify')
wijzig.clicked.connect(self.accept)
grid.addWidget(wijzig, 3, 1, 1 , 2, Qt.AlignRight)
wijzig.setFont(QFont("Arial",10))
wijzig.setStyleSheet("color: black; background-color: gainsboro; selection-background-color: gainsboro; selection-color: black")
wijzig.setFixedWidth(100)
sluit = QPushButton('Close')
sluit.clicked.connect(lambda: eindModule(self, m_email))
grid.addWidget(sluit, 3, 0, 1 , 2, Qt.AlignRight)
sluit.setFont(QFont("Arial",10))
sluit.setStyleSheet("color: black; background-color: gainsboro; selection-background-color: gainsboro; selection-color: black")
sluit.setFixedWidth(100)
grid.addWidget(QLabel('\u00A9 2017 all rights reserved [email protected]'), 4, 0, 1, 3, Qt.AlignCenter)
self.setLayout(grid)
self.setGeometry(100, 50, 150, 150)
def q1Changed(self,text):
self.Percentage.setText(text)
def returnq1(self):
return self.Percentage.text()
@staticmethod
def getData(parent=None):
dialog = Widget()
dialog.exec_()
return [dialog.returnq1()]
window = Widget()
data = window.getData()
if data[0]:
mperc = float(data[0])
else:
invoerVerpl()
return
metadata = MetaData()
lonen = Table('lonen', metadata,
Column('loonID', Integer(), primary_key=True),
Column('tabelloon', Float),
Column('werkuur',Float),
Column('reisuur', Float),
Column('direct', Boolean),
Column('maandloon', Float),
Column('functieomschr', String),
Column('boekdatum', String))
engine = create_engine('postgresql+psycopg2://postgres@localhost/bisystem')
con = engine.connect()
sellon = select([lonen])
rplon = con.execute(sellon)
mboekd = str(datetime.datetime.now())[0:10]
for row in rplon:
updlon = update(lonen).where(lonen.c.loonID==row[0]).values(maandloon = row[5]*1+mperc/100, tabelloon = row[1]*1+mperc/100,\
werkuur =row[2]*1+mperc/100, reisuur = row[3]*1+mperc/100, boekdatum = mboekd)
con.execute(updlon)
invoerOK(m_email)