class AllDeliversWindow(QFrame):
	def __init__(self,mdi):
		QFrame.__init__(self)
		self.ui = Ui_all_delivers_form()
	
		self.ui.setupUi(self)
		self.delivers = query_session.query(Deliver).all()
		self.drawTable()
		self.mdi = mdi
		QObject.connect(self.ui.delivers_table, SIGNAL("cellDoubleClicked(int, int)"), self.showDeliverForm)
		QObject.connect(self.ui.close_btn, SIGNAL("clicked()"), self.closeme)
		self.setWindowTitle(QString.fromUtf8('Список приходных накладных'))
	def drawTable(self):
		#self.drugs = self.getDrugs(self.ui.filter_text.text())
		self.ui.delivers_table.clear()
		self.ui.delivers_table.setRowCount(1)
		self.ui.delivers_table.setColumnCount(5)
		self.ui.delivers_table.setHorizontalHeaderLabels([QString.fromUtf8('Номер'), QString.fromUtf8('Поставщик'), QString.fromUtf8('Дата'), QString.fromUtf8('Количество позиций'), QString.fromUtf8('Сумма')])
		self.ui.delivers_table.resizeColumnsToContents()
		
		for deliver in self.delivers:
			data = []
			data.append(str(deliver.id))
			data.append(deliver.distributor.name)
			data.append(str(deliver.create_date))
			data.append(str(len(deliver.maps)))
			summ = 0
			for m in deliver.maps:
				summ = summ + m.count*m.drug.price
			data.append(str(summ))
			for i in range(0,5):	
				tableitem = QTableWidgetItem()
				tableitem.setText(data[i])
				tableitem.font = QFont("Arial", 10)
				tableitem.font.setBold(True)
				tableitem.textcolor = QColor("black")
				if not deliver.accepted:
					tableitem.setBackgroundColor(QColor('Yellow'))
				self.ui.delivers_table.setItem(self.ui.delivers_table.rowCount() - 1,i,tableitem)
			self.ui.delivers_table.setRowCount(self.ui.delivers_table.rowCount()+1)
		self.ui.delivers_table.resizeColumnsToContents()
		
	def showDeliverForm(self, row, col):
		deliverId = int(self.ui.delivers_table.item(row, 0).text())
		deliver = query_session.query(Deliver).filter_by(id=deliverId).one()
		self.deliver_widget = DeliverWindow(deliver)
		self.deliver_widget = self.mdi.addSubWindow(self.deliver_widget)
		self.deliver_widget.showMaximized()
		self.mdi.setActiveSubWindow(self.deliver_widget)
	
	
	def closeme(self):
		self.parent().close()
Example #2
0
class MainWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.mdiArea.setOption(QMdiArea.DontMaximizeSubWindowOnActivation, True)

    @pyqtSlot(int)
    def show_child_window(self, widget_number):
        if widget_number == 0:
            self.deliver_widget = DeliverWindow()
            self.deliver_widget = self.ui.mdiArea.addSubWindow(self.deliver_widget)
            self.deliver_widget.showMaximized()
        elif widget_number == 1:
            self.sale_widget = SaleWindow()
            self.ui.mdiArea.addSubWindow(self.sale_widget)
            self.sale_widget.showMaximized()

        elif widget_number == 2:
            self.drugs_widget = AllDrugsWindow()
            self.ui.mdiArea.addSubWindow(self.drugs_widget)
            self.drugs_widget.showMaximized()

        elif widget_number == 3:
            self.delivers_widget = AllDeliversWindow(self.ui.mdiArea)
            self.ui.mdiArea.addSubWindow(self.delivers_widget)
            self.delivers_widget.showMaximized()
        elif widget_number == 4:
            self.sales_widget = AllSalesWindow(self.ui.mdiArea)
            self.ui.mdiArea.addSubWindow(self.sales_widget)
            self.sales_widget.showMaximized()
        elif widget_number == 5:
            self.patients_widget = AllPatientsWindow()
            self.ui.mdiArea.addSubWindow(self.patients_widget)
            self.patients_widget.showMaximized()
        elif widget_number == 6:
            self.distributors_widget = AllDistributorsWindow()
            self.ui.mdiArea.addSubWindow(self.distributors_widget)
            self.distributors_widget.showMaximized()
        elif widget_number == 7:
            self.medorg_widget = AllMedorgWindow()
            self.ui.mdiArea.addSubWindow(self.medorg_widget)
            self.medorg_widget.showMaximized()
        elif widget_number == 8:
            self.doctors_widget = AllDoctorsWindow()
            self.doctors_widget = self.ui.mdiArea.addSubWindow(self.doctors_widget)
            self.doctors_widget.showMaximized()
        elif widget_number == 9:
            self.manufacters_widget = AllManufactersWindow()
            self.manufacters_widget = self.ui.mdiArea.addSubWindow(self.manufacters_widget)
            self.manufacters_widget.showMaximized()
            # QObject.connect(self.manufacters_widget, SIGNAL("closed()"), self.ui.mdiArea.removeSubWindow)

        elif widget_number == 10:
            self.ills_widget = AllIllsWindow()
            self.ills_widget = self.ui.mdiArea.addSubWindow(self.ills_widget)
            self.ills_widget.showMaximized()
        elif widget_number == 11:
            self.recipes_widget = AllRecipesWindow()
            self.recipes_widget = self.ui.mdiArea.addSubWindow(self.recipes_widget)
            self.recipes_widget.showMaximized()