/
count_form.py
45 lines (37 loc) · 1.37 KB
/
count_form.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
# -*- coding: utf-8 -*-
import os,sys
# Import Qt modules
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from model import *
from utils import _date_from_str
# Import the compiled UI module
sys.path.append("ui")
from count_form_ui import Ui_count_form
class CountForm(QFrame):
def __init__(self, parent):
QFrame.__init__(self)
self.ui = Ui_count_form()
self.ui.setupUi(self)
self.parent = parent
if hasattr(parent.parent, 'deliver'):
QObject.connect(self.ui.ok_btn, SIGNAL("clicked()"), self.sendCountForDeliver)
else:
QObject.connect(self.ui.ok_btn, SIGNAL("clicked()"), self.sendCountForSale)
def sendCountForDeliver(self):
self.parent.m.count = int(self.ui.lineEdit.text())
self.parent.parent.deliver.maps.append(self.parent.m)
#session.add(self.parent.parent.drug_deliver_map)
#session.commit()
self.emit(SIGNAL("drugAdded()"))
self.close()
def sendCountForSale(self):
if (int(self.ui.lineEdit.text()) > self.parent.m.drug.count()):
QMessageBox.information(self, QString.fromUtf8('Внимание'), QString.fromUtf8("На складе доступно %d" % self.parent.m.drug.count()), QMessageBox.Ok)
else:
self.parent.m.count = int(self.ui.lineEdit.text())
self.parent.parent.sale.maps.append(self.parent.m)
#session.add(self.parent.parent.drug_deliver_map)
#session.commit()
self.emit(SIGNAL("drugAdded()"))
self.close()