Пример #1
0
 def __init__(self, parent=None):
     """
     Constructor
     
     @param parent reference to the parent widget
     @type QWidget
     """
     super(Dialog_loadtemplate, self).__init__(parent)
     self.setupUi(self)
     self.curIndexData=None
     gtreeView(self.treeView, 'pricetemplateh')
Пример #2
0
 def deleteCurItem(self):
     deletestr=u'您将永久删除类别'+' '+self.curEditData[0]+' ,'+u'请确认是否执行.'
     if QMessageBox.question(self, u'删除提醒', deletestr, QMessageBox.Ok, QMessageBox.Cancel)==QMessageBox.Ok:
         if self.curEditData[2]-self.curEditData[1]>1:
             QMessageBox.warning(self, u'警告', u'请删除所有当前类别的子类别后,再删除本类别')
             return
         query=QSqlQuery()
         query.prepare(u"select count(*) from routingtemplate where `产品系列名`=:seriesname")
         query.bindValue(":seriesname", self.curIndexData[0])
         query.exec_()
         while query.next():
             print('test', query.value(0))
             if query.value(0)>0:
                 QMessageBox.warning(self, u'警告', u'当前类别下有数据,不能删除')
                 return                        
         else:
             query.clear()                
             query.prepare("DELETE FROM pricetemplateh WHERE `name`=:curname")                
             query.bindValue(":curname", self.curEditData[0])
             if query.exec_()!=True:
                 QMessageBox.warning(self, u'警告', u'删除类别失败,请检查数据')
                 return
             query.clear()
             query.prepare(u"UPDATE pricetemplateh SET rgt=rgt-2 WHERE rgt>=:currgt")  
             query.bindValue(':currgt', self.curEditData[2])
             if query.exec_()!=True:
                 QMessageBox.warning(self, u'警告', u'更新类别失败,请检查数据')
                 return
             query.clear()
             query.prepare(u"UPDATE pricetemplateh SET lft=lft-2 WHERE lft>=:currgt")
             query.bindValue(':currgt', self.curEditData[2])
             if query.exec_()!=True:
                 QMessageBox.warning(self, u'警告', u'更新类别失败,请检查数据')
                 return
                               
             
             
         gtreeView(self.treeView, 'pricetemplateh')
         self.viewmodel.clear()
         self.viewmodel.setTable('routingtemplate')
         self.viewmodel.setFilter(u"`产品系列名`='产品'")
         
         self.viewmodel.select()
Пример #3
0
    def addSameLayerItem(self):
#        print(self.curEditData)
        text, ok=QInputDialog.getText(self,u'新增类别',  u"名称:")
        if ok:
            inputname=text
            if len(inputname)==0:
                QMessageBox.warning(self, u'警告',  u'没有输入任何内容')
                return
        else:
            return
        
        query=QSqlQuery()    
        query.prepare("select count(*) from pricetemplateh where `name`=:inputname")
        query.bindValue(':inputname', inputname)
        query.exec_()
        while query.next():
            if query.value(0)>0:
                QMessageBox.warning(self, u'错误提醒', u'名字重复,请重新输入')
                return
        query.clear()
        query.prepare(u"UPDATE pricetemplateh SET rgt=rgt+2 WHERE rgt>:currgt")  
        query.bindValue(':currgt', self.curEditData[2])
        if query.exec_()!=True:
            QMessageBox.warning(self, u'警告', u'更新类别失败,请检查数据')
            return
        query.clear()
        query.prepare(u"UPDATE pricetemplateh SET lft=lft+2 WHERE lft>:currgt")
        query.bindValue(':currgt', self.curEditData[2])
        if query.exec_()!=True:
            QMessageBox.warning(self, u'警告', u'更新类别失败,请检查数据')
            return
        
        query.clear()
        query.prepare("INSERT INTO pricetemplateh(name,lft,rgt) VALUES (:name,:lft,:rgt)")
        query.bindValue(':name', inputname)
        query.bindValue(':lft', self.curEditData[2]+1)
        query.bindValue(':rgt', self.curEditData[2]+2)
        if query.exec_()!=True:
            QMessageBox.warning(self, u'警告', u'插入类别失败,请检查数据')
            return
        
        gtreeView(self.treeView, 'pricetemplateh')
Пример #4
0
 def renameCurItem(self):
     str=u'更换类别:'+' '+self.curEditData[0]+' '+u'为:'
     text, ok=QInputDialog.getText(self,u'更名',  str)
     if ok:
         inputname=text
     else:
         return
     
     query=QSqlQuery()    
     query.prepare("select count(*) from pricetemplateh where `name`=:inputname")
     query.bindValue(':inputname', inputname)
     query.exec_()
     while query.next():
         if query.value(0)>0:
             QMessageBox.warning(self, u'错误提醒', u'名字重复,请重新输入')
             return
     query.clear()
     query.prepare("UPDATE pricetemplateh SET `name`=:newname where `name`=:oldname")
     query.bindValue(':newname', inputname)
     query.bindValue(':oldname',self.curEditData[0] )
     if query.exec_()!=True:
         QMessageBox.warning(self, u'警告', u'更名失败,请检查数据')
         return
     query.clear()
     query.prepare(u"UPDATE routingtemplate SET `产品系列名`=:newname where `产品系列名`=:oldname")
     query.bindValue(":newname", inputname)
     query.bindValue(":oldname", self.curEditData[0])
     if query.exec_()!=True:
         QMessageBox.warning(self, u'警告', u'更名模板数据库失败,请检查数据')
         return
     
     gtreeView(self.treeView, 'pricetemplateh')
     self.viewmodel.clear()
     self.viewmodel.setTable('routingtemplate')
     self.viewmodel.setFilter("`产品系列名`={name}".format(name=self.curEditData[0]))
     self.viewmodel.select()
Пример #5
0
 def __init__(self, parent=None, data={}):
     """
     Constructor
     
     @param parent reference to the parent widget
     @type QWidget
     """
     QDialog.__init__(self, parent)
     self.data=data   
     self.picturemodifyFlag=['False' for x in range(5)]  
     self.picturedata=['' for x in range(5)]   
     self.setupUi(self)
     self.lineEdit_MID.setEnabled(False)
     self.lineEdit_MID.setFocus()   
     self._createcombosize()
     self._createcombounit()
     self.gtreeview=gtreeView(self.treeView, 'materialtype')
     self.treeView.hide()
     self._initdata()
Пример #6
0
 def __init__(self, parent=None):
     """
     Constructor
     
     @param parent reference to the parent widget
     @type QWidget
     """
     super(MainWindow_PriceTemplete, self).__init__(parent)
     self.parent=parent
     self.curIndexData=None
     
     self.setupUi(self)
     self.setPriceTempleteToolbar()
     connectdb()
     self.viewmodel=QSqlTableModel()
     self.treeviewshow=gtreeView(self.treeView, 'pricetemplateh')
     self.closeview.triggered.connect(self.viewclose)
     self.treeView.customContextMenuRequested[QPoint].connect(self.setPopMenu)
     self.newview.triggered.connect(self.viewnew)
     self.modifyview.triggered.connect(self.viewmodify)
     self.deleteview.triggered.connect(self.viewdelete)
Пример #7
0
 def addNextLayerItem(self):
     
     text, ok=QInputDialog.getText(self,u'新增下级类别',  u"名称:")
     if ok:
         inputname=text
         if len(inputname)==0:
             QMessageBox.warning(self, u'警告',  u'没有输入任何内容')
             return
     else:
         return
     
     query=QSqlQuery()    
     query.prepare("select count(*) from pricetemplateh where `name`=:inputname")
     query.bindValue(':inputname', inputname)
     query.exec_()
     while query.next():
         if query.value(0)>0:
             QMessageBox.warning(self, u'错误提醒', u'名字重复,请重新输入')
             return
     print(self.curEditData[2], self.curEditData[1])
     if self.curEditData[2]-self.curEditData[1]==1:
         query.clear()
         query.prepare(u"select count(*) from routingtemplate where `产品系列名`=:serisname")
         query.bindValue(":serisname", self.curEditData[0])
         if query.exec_()==True:
             while query.next():
                 count=query.value(0)
                 if count>0:
                     if QMessageBox.question(self, u'错误提醒', u'类别:{name} \n下已有模板,是否将该模板转入新的系列名之下'.format(name=self.curEditData[0]), QMessageBox.Ok, QMessageBox.Cancel)==QMessageBox.Cancel:
                         return                        
                 else:
                     break
         print("end")
     
     query.clear()
     query.prepare(u"UPDATE pricetemplateh SET rgt=rgt+2 WHERE rgt>=:currgt")  
     query.bindValue(':currgt', self.curEditData[2])
     if query.exec_()!=True:
         QMessageBox.warning(self, u'警告', u'更新类别失败,请检查数据')
         return
     query.clear()
     query.prepare(u"UPDATE pricetemplateh SET lft=lft+2 WHERE lft>=:currgt")
     query.bindValue(':currgt', self.curEditData[2])
     if query.exec_()!=True:
         QMessageBox.warning(self, u'警告', u'更新类别失败,请检查数据')
         return
     
     query.clear()
     query.prepare("INSERT INTO pricetemplateh(name,lft,rgt) VALUES (:name,:lft,:rgt)")
     query.bindValue(':name', inputname)
     query.bindValue(':lft', self.curEditData[2])
     query.bindValue(':rgt', self.curEditData[2]+1)
     if query.exec_()!=True:
         QMessageBox.warning(self, u'警告', u'插入类别失败,请检查数据')
         return
         
     query.clear()
     query.prepare(u"UPDATE routingtemplate SET `产品系列名`=:newname where `产品系列名`=:oldname")
     query.bindValue(":newname", inputname)
     query.bindValue(":oldname", self.curEditData[0])
     if query.exec_()!=True:
         QMessageBox.warning(self, u'警告', u'更名模板数据库失败,请检查数据')
         return
         
     
     gtreeView(self.treeView, 'pricetemplateh')