pihy6 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pihy6-0.2.0/PKG-INFO +5 -0
- pihy6-0.2.0/merged/auth/auth.py +48 -0
- pihy6-0.2.0/merged/database/db.py +259 -0
- pihy6-0.2.0/merged/database/db2.py +136 -0
- pihy6-0.2.0/merged/dialogs/item_form_dialog.py +53 -0
- pihy6-0.2.0/merged/dialogs/order_add.py +36 -0
- pihy6-0.2.0/merged/dialogs/order_form_dialog.py +50 -0
- pihy6-0.2.0/merged/main.py +21 -0
- pihy6-0.2.0/merged/ui/admin_win.py +126 -0
- pihy6-0.2.0/merged/ui/client_win.py +111 -0
- pihy6-0.2.0/merged/ui/gues_window.py +74 -0
- pihy6-0.2.0/merged/ui/item_form.py +78 -0
- pihy6-0.2.0/merged/ui/login_window.py +59 -0
- pihy6-0.2.0/merged/ui/manager_win.py +105 -0
- pihy6-0.2.0/merged/ui/order_client.py +49 -0
- pihy6-0.2.0/merged/ui/order_form.py +63 -0
- pihy6-0.2.0/merged/users/admin.py +137 -0
- pihy6-0.2.0/merged/users/card.py +72 -0
- pihy6-0.2.0/merged/users/client.py +83 -0
- pihy6-0.2.0/merged/users/ewiruht.py +205 -0
- pihy6-0.2.0/merged/users/gues.py +51 -0
- pihy6-0.2.0/merged/users/manager.py +104 -0
- pihy6-0.2.0/merged/users/oewfokewfkoew.py +55 -0
- pihy6-0.2.0/merged/users/xixixi.py +51 -0
- pihy6-0.2.0/merged/users/xlxlxllxlxlx.py +141 -0
- pihy6-0.2.0/pihy6.egg-info/PKG-INFO +5 -0
- pihy6-0.2.0/pihy6.egg-info/SOURCES.txt +29 -0
- pihy6-0.2.0/pihy6.egg-info/dependency_links.txt +1 -0
- pihy6-0.2.0/pihy6.egg-info/top_level.txt +1 -0
- pihy6-0.2.0/pyproject.toml +10 -0
- pihy6-0.2.0/setup.cfg +4 -0
pihy6-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from PyQt6.QtWidgets import QMainWindow, QMessageBox
|
|
2
|
+
from ui.login_window import Ui_login_window
|
|
3
|
+
from database.db import check_login
|
|
4
|
+
|
|
5
|
+
class login_window(QMainWindow, Ui_login_window):
|
|
6
|
+
def __init__(self):
|
|
7
|
+
super().__init__()
|
|
8
|
+
self.setupUi(self)
|
|
9
|
+
|
|
10
|
+
self.pushButton_guest.clicked.connect(self.open_guest)
|
|
11
|
+
self.pushButton_login.clicked.connect(self.login)
|
|
12
|
+
|
|
13
|
+
def login(self):
|
|
14
|
+
|
|
15
|
+
username = self.lineEditUsername.text().strip()
|
|
16
|
+
password = self.lineEditPassword.text().strip()
|
|
17
|
+
|
|
18
|
+
if not username or not password:
|
|
19
|
+
QMessageBox.warning(self, 'ошибка', 'введите логин или пароль')
|
|
20
|
+
return
|
|
21
|
+
|
|
22
|
+
user = check_login(username, password)
|
|
23
|
+
if not user:
|
|
24
|
+
QMessageBox.warning(self, 'ошибка', 'неверный логин или пароль')
|
|
25
|
+
return
|
|
26
|
+
|
|
27
|
+
name = user['full_name']
|
|
28
|
+
role = user['role']
|
|
29
|
+
user_id = user['user_id']
|
|
30
|
+
|
|
31
|
+
if role == 'client':
|
|
32
|
+
from users.client import client_window
|
|
33
|
+
self.win = client_window(name, user_id)
|
|
34
|
+
elif role == 'admin':
|
|
35
|
+
from users.admin import admin_window
|
|
36
|
+
self.win = admin_window(name, user_id)
|
|
37
|
+
elif role == 'manager':
|
|
38
|
+
from users.manager import manager_window
|
|
39
|
+
self.win = manager_window(name, user_id)
|
|
40
|
+
|
|
41
|
+
self.win.show()
|
|
42
|
+
self.close()
|
|
43
|
+
|
|
44
|
+
def open_guest(self):
|
|
45
|
+
from users.gues import guest_window
|
|
46
|
+
self.win = guest_window()
|
|
47
|
+
self.win.show()
|
|
48
|
+
self.close()
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import pymysql
|
|
2
|
+
from pymysql import MySQLError
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def db_connect():
|
|
6
|
+
try:
|
|
7
|
+
return pymysql.connect(
|
|
8
|
+
host='localhost',
|
|
9
|
+
user='root',
|
|
10
|
+
password='qwerty',
|
|
11
|
+
database='kvalik',
|
|
12
|
+
cursorclass=pymysql.cursors.DictCursor,
|
|
13
|
+
autocommit=True
|
|
14
|
+
)
|
|
15
|
+
except MySQLError as e:
|
|
16
|
+
print('Ошибка подключения', e)
|
|
17
|
+
return None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# ---------- авторизация ----------
|
|
21
|
+
|
|
22
|
+
def check_login(username, password):
|
|
23
|
+
db = db_connect()
|
|
24
|
+
try:
|
|
25
|
+
with db.cursor() as cursor:
|
|
26
|
+
cursor.execute("""
|
|
27
|
+
SELECT
|
|
28
|
+
users.user_id,
|
|
29
|
+
users.fullname AS full_name,
|
|
30
|
+
roles.name AS role
|
|
31
|
+
FROM users
|
|
32
|
+
JOIN roles ON roles.role_id = users.role_id
|
|
33
|
+
WHERE users.username = %s AND users.password = %s
|
|
34
|
+
""", (username, password))
|
|
35
|
+
return cursor.fetchone()
|
|
36
|
+
finally:
|
|
37
|
+
db.close()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# ---------- товары ----------
|
|
41
|
+
|
|
42
|
+
def all_menu_items():
|
|
43
|
+
db = db_connect()
|
|
44
|
+
try:
|
|
45
|
+
with db.cursor() as cursor:
|
|
46
|
+
cursor.execute("""
|
|
47
|
+
SELECT
|
|
48
|
+
item_id,
|
|
49
|
+
item_name AS name,
|
|
50
|
+
item_price AS price,
|
|
51
|
+
description,
|
|
52
|
+
image,
|
|
53
|
+
category,
|
|
54
|
+
discount
|
|
55
|
+
FROM items
|
|
56
|
+
""")
|
|
57
|
+
return cursor.fetchall()
|
|
58
|
+
finally:
|
|
59
|
+
db.close()
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def one_menu_items(item_id):
|
|
63
|
+
db = db_connect()
|
|
64
|
+
try:
|
|
65
|
+
with db.cursor() as cursor:
|
|
66
|
+
cursor.execute("""
|
|
67
|
+
SELECT
|
|
68
|
+
item_id,
|
|
69
|
+
item_name AS name,
|
|
70
|
+
item_price AS price,
|
|
71
|
+
description,
|
|
72
|
+
image,
|
|
73
|
+
category
|
|
74
|
+
FROM items
|
|
75
|
+
WHERE item_id = %s
|
|
76
|
+
""", (item_id,))
|
|
77
|
+
return cursor.fetchone()
|
|
78
|
+
finally:
|
|
79
|
+
db.close()
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def add_menu_item(name, category, description, price):
|
|
83
|
+
db = db_connect()
|
|
84
|
+
try:
|
|
85
|
+
with db.cursor() as cursor:
|
|
86
|
+
cursor.execute("""
|
|
87
|
+
INSERT INTO items (item_name, category, description, item_price)
|
|
88
|
+
VALUES (%s, %s, %s, %s)
|
|
89
|
+
""", (name, category, description, price))
|
|
90
|
+
return True
|
|
91
|
+
except Exception as e:
|
|
92
|
+
print('Ошибка добавления товара', e)
|
|
93
|
+
return False
|
|
94
|
+
finally:
|
|
95
|
+
db.close()
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def edit_menu_item(item_id, name, category, description, price):
|
|
99
|
+
db = db_connect()
|
|
100
|
+
try:
|
|
101
|
+
with db.cursor() as cursor:
|
|
102
|
+
cursor.execute("""
|
|
103
|
+
UPDATE items SET
|
|
104
|
+
item_name = %s,
|
|
105
|
+
category = %s,
|
|
106
|
+
description = %s,
|
|
107
|
+
item_price = %s
|
|
108
|
+
WHERE item_id = %s
|
|
109
|
+
""", (name, category, description, price, item_id))
|
|
110
|
+
return True
|
|
111
|
+
except Exception as e:
|
|
112
|
+
print('Ошибка изменения товара', e)
|
|
113
|
+
return False
|
|
114
|
+
finally:
|
|
115
|
+
db.close()
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def delete_menu_item(item_id):
|
|
119
|
+
db = db_connect()
|
|
120
|
+
try:
|
|
121
|
+
with db.cursor() as cursor:
|
|
122
|
+
cursor.execute(
|
|
123
|
+
"SELECT COUNT(*) FROM orders WHERE item_id = %s", (item_id,))
|
|
124
|
+
result = cursor.fetchone()
|
|
125
|
+
if list(result.values())[0]:
|
|
126
|
+
return False, 'Товар есть в заказах — удалить нельзя.'
|
|
127
|
+
cursor.execute("DELETE FROM items WHERE item_id = %s", (item_id,))
|
|
128
|
+
return True, ''
|
|
129
|
+
except Exception as e:
|
|
130
|
+
print('Ошибка удаления товара', e)
|
|
131
|
+
return False, str(e)
|
|
132
|
+
finally:
|
|
133
|
+
db.close()
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
# ---------- заказы ----------
|
|
137
|
+
|
|
138
|
+
def all_orders():
|
|
139
|
+
db = db_connect()
|
|
140
|
+
try:
|
|
141
|
+
with db.cursor() as cursor:
|
|
142
|
+
cursor.execute("""
|
|
143
|
+
SELECT
|
|
144
|
+
orders.order_id,
|
|
145
|
+
orders.order_place,
|
|
146
|
+
orders.status,
|
|
147
|
+
orders.order_date,
|
|
148
|
+
orders.total_amount,
|
|
149
|
+
users.fullname AS full_name,
|
|
150
|
+
items.item_name
|
|
151
|
+
FROM orders
|
|
152
|
+
LEFT JOIN users ON users.user_id = orders.user_id
|
|
153
|
+
LEFT JOIN items ON items.item_id = orders.item_id
|
|
154
|
+
ORDER BY orders.order_id DESC
|
|
155
|
+
""")
|
|
156
|
+
return cursor.fetchall()
|
|
157
|
+
finally:
|
|
158
|
+
db.close()
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def all_orders_by_client(user_id):
|
|
162
|
+
db = db_connect()
|
|
163
|
+
try:
|
|
164
|
+
with db.cursor() as cursor:
|
|
165
|
+
cursor.execute("""
|
|
166
|
+
SELECT
|
|
167
|
+
orders.order_id,
|
|
168
|
+
orders.order_place,
|
|
169
|
+
orders.status,
|
|
170
|
+
orders.order_date,
|
|
171
|
+
orders.total_amount,
|
|
172
|
+
items.item_name AS name
|
|
173
|
+
FROM orders
|
|
174
|
+
JOIN items ON items.item_id = orders.item_id
|
|
175
|
+
WHERE orders.user_id = %s
|
|
176
|
+
ORDER BY orders.order_id DESC
|
|
177
|
+
""", (user_id,))
|
|
178
|
+
return cursor.fetchall()
|
|
179
|
+
finally:
|
|
180
|
+
db.close()
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def one_order(order_id):
|
|
184
|
+
db = db_connect()
|
|
185
|
+
try:
|
|
186
|
+
with db.cursor() as cursor:
|
|
187
|
+
cursor.execute(
|
|
188
|
+
"SELECT * FROM orders WHERE order_id = %s", (order_id,))
|
|
189
|
+
return cursor.fetchone()
|
|
190
|
+
finally:
|
|
191
|
+
db.close()
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def add_order(order_place, status, order_date):
|
|
195
|
+
db = db_connect()
|
|
196
|
+
try:
|
|
197
|
+
with db.cursor() as cursor:
|
|
198
|
+
cursor.execute("""
|
|
199
|
+
INSERT INTO orders (order_place, status, order_date)
|
|
200
|
+
VALUES (%s, %s, %s)
|
|
201
|
+
""", (order_place, status, order_date))
|
|
202
|
+
return True
|
|
203
|
+
except Exception as e:
|
|
204
|
+
print('Ошибка добавления заказа', e)
|
|
205
|
+
return False
|
|
206
|
+
finally:
|
|
207
|
+
db.close()
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def edit_order(order_id, order_place, status, order_date):
|
|
211
|
+
db = db_connect()
|
|
212
|
+
try:
|
|
213
|
+
with db.cursor() as cursor:
|
|
214
|
+
cursor.execute("""
|
|
215
|
+
UPDATE orders SET
|
|
216
|
+
order_place = %s,
|
|
217
|
+
status = %s,
|
|
218
|
+
order_date = %s
|
|
219
|
+
WHERE order_id = %s
|
|
220
|
+
""", (order_place, status, order_date, order_id))
|
|
221
|
+
return True
|
|
222
|
+
except Exception as e:
|
|
223
|
+
print('Ошибка изменения заказа', e)
|
|
224
|
+
return False
|
|
225
|
+
finally:
|
|
226
|
+
db.close()
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def delete_order(order_id):
|
|
230
|
+
db = db_connect()
|
|
231
|
+
try:
|
|
232
|
+
with db.cursor() as cursor:
|
|
233
|
+
cursor.execute(
|
|
234
|
+
"DELETE FROM orders WHERE order_id = %s", (order_id,))
|
|
235
|
+
return True
|
|
236
|
+
except Exception as e:
|
|
237
|
+
print('Ошибка удаления заказа', e)
|
|
238
|
+
return False
|
|
239
|
+
finally:
|
|
240
|
+
db.close()
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
# ---------- совместимость со старым order_add.py ----------
|
|
244
|
+
|
|
245
|
+
def add_item(user_id, item_id, order_place, order_date, quantity, total_amount):
|
|
246
|
+
db = db_connect()
|
|
247
|
+
try:
|
|
248
|
+
with db.cursor() as cursor:
|
|
249
|
+
cursor.execute("""
|
|
250
|
+
INSERT INTO orders
|
|
251
|
+
(user_id, item_id, order_place, status, order_date, quantity, total_amount)
|
|
252
|
+
VALUES (%s, %s, %s, 'в обработке', %s, %s, %s)
|
|
253
|
+
""", (user_id, item_id, order_place, order_date, quantity, total_amount))
|
|
254
|
+
return True
|
|
255
|
+
except Exception as e:
|
|
256
|
+
print('Ошибка добавления заказа', e)
|
|
257
|
+
return False
|
|
258
|
+
finally:
|
|
259
|
+
db.close()
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# import pymysql
|
|
2
|
+
# from pymysql import MySQLError
|
|
3
|
+
|
|
4
|
+
# def db_connect():
|
|
5
|
+
# try:
|
|
6
|
+
# return pymysql.connect(
|
|
7
|
+
# host='localhost', user='root', password='qwerty',
|
|
8
|
+
# database='kvalik',
|
|
9
|
+
# cursorClass=pymysql.cursors.DictCursor,
|
|
10
|
+
# autocommit=True
|
|
11
|
+
# )
|
|
12
|
+
# except MySQLError as e:
|
|
13
|
+
# print('ошибка подключения к бд:', e)
|
|
14
|
+
|
|
15
|
+
# def check_login(username, password):
|
|
16
|
+
# db = db_connect()
|
|
17
|
+
# try:
|
|
18
|
+
# with db.cursor() as cur:
|
|
19
|
+
# cur.execute("""
|
|
20
|
+
# SELECT
|
|
21
|
+
# u.user_id,
|
|
22
|
+
# r.name as role,
|
|
23
|
+
# u.fullname as name
|
|
24
|
+
# from users u
|
|
25
|
+
# join roles r on r.role_id = u.role_id
|
|
26
|
+
# where u.username = %s and u.password = %s
|
|
27
|
+
# """(username, password))
|
|
28
|
+
# return cur.fetchone()
|
|
29
|
+
# finally:
|
|
30
|
+
# db.close
|
|
31
|
+
|
|
32
|
+
import pymysql
|
|
33
|
+
from pymysql import MySQLError
|
|
34
|
+
|
|
35
|
+
def db_connect():
|
|
36
|
+
try:
|
|
37
|
+
return pymysql.connect(
|
|
38
|
+
host='localhost', user='root', password='qwerty',
|
|
39
|
+
database='kvalik',
|
|
40
|
+
cursorclass = pymysql.cursors.DictCursor,
|
|
41
|
+
autocommit=True
|
|
42
|
+
)
|
|
43
|
+
except MySQLError as e:
|
|
44
|
+
print('ошибка подключения к бд:', e)
|
|
45
|
+
|
|
46
|
+
def check_login(username, password):
|
|
47
|
+
db = db_connect()
|
|
48
|
+
try:
|
|
49
|
+
with db.cursor() as cur:
|
|
50
|
+
cur.execute("""
|
|
51
|
+
SELECT
|
|
52
|
+
u.user_id,
|
|
53
|
+
r.name as role,
|
|
54
|
+
u.fullname as name
|
|
55
|
+
from users u
|
|
56
|
+
join roles r on r.role_id = u.user_id
|
|
57
|
+
where u.username = %s and u.password = %s
|
|
58
|
+
""",(username, password))
|
|
59
|
+
return cur.fetchone()
|
|
60
|
+
finally:
|
|
61
|
+
db.close
|
|
62
|
+
|
|
63
|
+
def all_menu_items():
|
|
64
|
+
db = db_connect()
|
|
65
|
+
try:
|
|
66
|
+
with db.cursor() as cur:
|
|
67
|
+
cur.execute("""
|
|
68
|
+
SELECT
|
|
69
|
+
i.item_id,
|
|
70
|
+
i.item_name as name,
|
|
71
|
+
i.item_price as prise,
|
|
72
|
+
i.description,
|
|
73
|
+
i.image,
|
|
74
|
+
i.category
|
|
75
|
+
from items i
|
|
76
|
+
""")
|
|
77
|
+
return cur.fetchall()
|
|
78
|
+
finally:
|
|
79
|
+
db.close
|
|
80
|
+
|
|
81
|
+
def one_menu_items(item_id):
|
|
82
|
+
db = db_connect()
|
|
83
|
+
try:
|
|
84
|
+
with db.cursor() as cur:
|
|
85
|
+
cur.execute("""
|
|
86
|
+
SELECT
|
|
87
|
+
i.item_id,
|
|
88
|
+
i.item_name as name,
|
|
89
|
+
i.item_price as prise,
|
|
90
|
+
i.description,
|
|
91
|
+
i.image,
|
|
92
|
+
i.category
|
|
93
|
+
from items i
|
|
94
|
+
where i.item_id = %s
|
|
95
|
+
""",(item_id))
|
|
96
|
+
return cur.fetchone()
|
|
97
|
+
finally:
|
|
98
|
+
db.close
|
|
99
|
+
|
|
100
|
+
def all_orders_by_client(user_id):
|
|
101
|
+
db = db_connect()
|
|
102
|
+
try:
|
|
103
|
+
with db.cursor() as cur:
|
|
104
|
+
cur.execute("""
|
|
105
|
+
SELECT
|
|
106
|
+
i.item_id,
|
|
107
|
+
o.order_id,
|
|
108
|
+
o.order_place,
|
|
109
|
+
o.status,
|
|
110
|
+
o.order_date,
|
|
111
|
+
o.quantity,
|
|
112
|
+
o.total_amount
|
|
113
|
+
from orders o
|
|
114
|
+
join items i on i.item_id = o.item_id
|
|
115
|
+
where o.user_id = %s
|
|
116
|
+
""",(user_id,))
|
|
117
|
+
return cur.fetchall()
|
|
118
|
+
finally:
|
|
119
|
+
db.close
|
|
120
|
+
|
|
121
|
+
def add_item(user_id, item_id,order_place, status,order_date,quantity,total_amount):
|
|
122
|
+
db = db_connect()
|
|
123
|
+
try:
|
|
124
|
+
with db.cursor() as cur:
|
|
125
|
+
cur.execute("""
|
|
126
|
+
INSERT INTO orders
|
|
127
|
+
(user_id,item_id, order_place,status, order_date,quantity,total_amount)
|
|
128
|
+
VALUES
|
|
129
|
+
(%s,%s,%s,'в обработке',%s,%s,%s)
|
|
130
|
+
""",(user_id, item_id,order_place, status,order_date,quantity,total_amount))
|
|
131
|
+
return True
|
|
132
|
+
except Exception as e:
|
|
133
|
+
print('ошибка', e)
|
|
134
|
+
return False
|
|
135
|
+
finally:
|
|
136
|
+
db.close
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from PyQt6.QtWidgets import QDialog, QMessageBox
|
|
2
|
+
from ui.item_form import Ui_ItemFormDialog
|
|
3
|
+
from database.db import one_menu_items, add_menu_item, edit_menu_item
|
|
4
|
+
|
|
5
|
+
class ItemFormDialog(QDialog, Ui_ItemFormDialog):
|
|
6
|
+
def __init__(self, item_id= None):
|
|
7
|
+
super().__init__()
|
|
8
|
+
self.setupUi(self)
|
|
9
|
+
self.item_id = item_id
|
|
10
|
+
|
|
11
|
+
self.setWindowTitle('добавление товара' if item_id is None else 'редактирование товара')
|
|
12
|
+
|
|
13
|
+
self.pushButtonCancel.clicked.connect(self.reject)
|
|
14
|
+
self.pushButtonSave.clicked.connect(self.save_data)
|
|
15
|
+
|
|
16
|
+
if item_id is None:
|
|
17
|
+
self.labelId.hide()
|
|
18
|
+
self.labelIdValue.hide()
|
|
19
|
+
else:
|
|
20
|
+
self.load_item_data()
|
|
21
|
+
|
|
22
|
+
def load_item_data(self):
|
|
23
|
+
item = one_menu_items(self.item_id)
|
|
24
|
+
if not item:
|
|
25
|
+
QMessageBox.warning(self, 'ошибка', 'не удалось загрузить товар')
|
|
26
|
+
self.reject()
|
|
27
|
+
return
|
|
28
|
+
|
|
29
|
+
self.labelIdValue.setText(str(item['item_id']))
|
|
30
|
+
self.lineEditName.setText(item.get('name') or '')
|
|
31
|
+
self.lineEditCategory.setText(item.get('category') or '')
|
|
32
|
+
self.lineEditDescription.setText(item.get('description') or '')
|
|
33
|
+
self.doubleSpinBoxPrice.setValue(float(item.get('price') or 0))
|
|
34
|
+
|
|
35
|
+
def save_data(self):
|
|
36
|
+
name = self.lineEditName.text().strip()
|
|
37
|
+
if not name:
|
|
38
|
+
QMessageBox.warning(self, 'ошибка', 'заполните имя товара')
|
|
39
|
+
return
|
|
40
|
+
if self.doubleSpinBoxPrice.value() < 0:
|
|
41
|
+
QMessageBox.warning(self, 'ошибка', 'цена не может быть отрицательной')
|
|
42
|
+
return
|
|
43
|
+
|
|
44
|
+
category = self.lineEditCategory.text().strip()
|
|
45
|
+
description = self.lineEditDescription.text().strip()
|
|
46
|
+
price = self.doubleSpinBoxPrice.value()
|
|
47
|
+
|
|
48
|
+
ok = edit_menu_item(self.item_id, name, category, description, price) if self.item_id else add_menu_item(name, category, description, price)
|
|
49
|
+
if ok:
|
|
50
|
+
self.accept()
|
|
51
|
+
else:
|
|
52
|
+
QMessageBox.warning(self, 'ошибка', 'ошибка сохранение товара')
|
|
53
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from PyQt6.QtWidgets import QDialog, QMessageBox
|
|
2
|
+
from PyQt6.QtCore import QDate
|
|
3
|
+
from ui.order_client import Ui_Dialog_order
|
|
4
|
+
from database.db import all_menu_items,add_item, one_menu_items
|
|
5
|
+
|
|
6
|
+
class order_item(QDialog, Ui_Dialog_order):
|
|
7
|
+
def __init__(self, user_id):
|
|
8
|
+
super().__init__()
|
|
9
|
+
self.setupUi(self)
|
|
10
|
+
self.date = QDate.currentDate().toPyDate()
|
|
11
|
+
self.user_id = user_id
|
|
12
|
+
|
|
13
|
+
self.pushButtonOrder.clicked.connect(self.order)
|
|
14
|
+
|
|
15
|
+
self.load_all()
|
|
16
|
+
|
|
17
|
+
def load_all(self):
|
|
18
|
+
items = all_menu_items()
|
|
19
|
+
|
|
20
|
+
for item in items:
|
|
21
|
+
self.comboBox.addItem(item.get('name'), item.get('item_id'))
|
|
22
|
+
|
|
23
|
+
def order(self):
|
|
24
|
+
item_id = self.comboBox.currentData()
|
|
25
|
+
itemm = one_menu_items(item_id)
|
|
26
|
+
prise = int(itemm['prise'])
|
|
27
|
+
adress = self.lineEditAdres.text()
|
|
28
|
+
quantity = self.spinBoxquantity.value()
|
|
29
|
+
total_amount = prise * quantity
|
|
30
|
+
|
|
31
|
+
print(f"заказ: item_id={item_id}, prise={prise}, quantity={quantity}, total_amount={total_amount}")
|
|
32
|
+
|
|
33
|
+
if add_item(self.user_id, item_id, adress, self.date, quantity, total_amount):
|
|
34
|
+
self.accept()
|
|
35
|
+
else:
|
|
36
|
+
QMessageBox.warning(self, 'ошибка', 'ошибка добавления')
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from PyQt6.QtWidgets import QDialog, QMessageBox
|
|
2
|
+
from PyQt6.QtCore import QDate
|
|
3
|
+
from ui.order_form import Ui_OrderFormDialog
|
|
4
|
+
from database.db import one_order, add_order, edit_order
|
|
5
|
+
|
|
6
|
+
STATUSES = ['в обработке', 'в доставке', 'доставлен']
|
|
7
|
+
|
|
8
|
+
class OrderFormDialog(QDialog, Ui_OrderFormDialog):
|
|
9
|
+
def __init__(self, order_id=None):
|
|
10
|
+
super().__init__()
|
|
11
|
+
self.setupUi(self)
|
|
12
|
+
self.order_id = order_id
|
|
13
|
+
|
|
14
|
+
self.setWindowTitle('добавление заказа' if order_id is None else 'редактирование заказа')
|
|
15
|
+
self.comboBoxStatus.addItems(STATUSES)
|
|
16
|
+
self.dateEditDate.setDate(QDate.currentDate())
|
|
17
|
+
self.pushButtonCancel.clicked.connect(self.reject)
|
|
18
|
+
self.pushButtonSave.clicked.connect(self.save_data)
|
|
19
|
+
|
|
20
|
+
if order_id:
|
|
21
|
+
self.load_order_data()
|
|
22
|
+
|
|
23
|
+
def load_order_data(self):
|
|
24
|
+
order = one_order(self.order_id)
|
|
25
|
+
if not order:
|
|
26
|
+
QMessageBox.warning(self, 'ошибка', 'заказ не найден')
|
|
27
|
+
self.reject()
|
|
28
|
+
return
|
|
29
|
+
|
|
30
|
+
self.lineEditPlace.setText(str(order.get('order_place') or ''))
|
|
31
|
+
idx = self.comboBoxStatus.findText(order.get('status') or '')
|
|
32
|
+
if idx >= 0:
|
|
33
|
+
self.comboBoxStatus.setCurrentIndex(idx)
|
|
34
|
+
if od := order.get('order_date'):
|
|
35
|
+
self.dateEditDate.setDate(QDate(od.year, od.month, od.day))
|
|
36
|
+
|
|
37
|
+
def save_data(self):
|
|
38
|
+
place = self.lineEditPlace.text().strip()
|
|
39
|
+
status = self.comboBoxStatus.currentText()
|
|
40
|
+
date = self.dateEditDate.date().toPyDate()
|
|
41
|
+
|
|
42
|
+
if not place:
|
|
43
|
+
QMessageBox.warning(self, 'ошибка', 'введите дату доставки')
|
|
44
|
+
return
|
|
45
|
+
|
|
46
|
+
ok = edit_order(self.order_id, place, status, date) if self.order_id else add_order(place, status, date)
|
|
47
|
+
if ok:
|
|
48
|
+
self.accept()
|
|
49
|
+
else:
|
|
50
|
+
QMessageBox.warning(self, 'ошибка', 'не удалось сохранить заказ')
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# import sys
|
|
2
|
+
# from PyQt6.QtWidgets import QApplication
|
|
3
|
+
# from auth.auth import login_window
|
|
4
|
+
|
|
5
|
+
# app = QApplication(sys.argv)
|
|
6
|
+
# win = login_window()
|
|
7
|
+
# win.show()
|
|
8
|
+
# sys.exit(app.exec())
|
|
9
|
+
|
|
10
|
+
import sys
|
|
11
|
+
from PyQt6.QtWidgets import QApplication
|
|
12
|
+
from auth.auth import login_window
|
|
13
|
+
|
|
14
|
+
app = QApplication(sys.argv)
|
|
15
|
+
app.setStyleSheet("""
|
|
16
|
+
QMainWindow, QDialog { background-color: #4caf50; }
|
|
17
|
+
QPushButton { background-color: #1565c0; color: white; border: none; padding: 5px 14px; }
|
|
18
|
+
""")
|
|
19
|
+
win = login_window()
|
|
20
|
+
win.show()
|
|
21
|
+
sys.exit(app.exec())
|