Beispiel #1
0
 def __updateArticleList(self):
     item = self.ui.treeWidget.currentItem()
     type_id = None
     if item != None:
         res = item.data(0, Qt.UserRole).toInt()
         if None != res[1]:
             type_id = res[0]
     if type_id != None:
         if type_id == -1:#id 为-1的项用来<显示所有物品列表>
             article_list = dbArticle().getAll()
         else:
             article_list = dbArticle().getArticlesByTypeId(type_id)
     else:
         article_list = []
     labels = [u'ID',u'型号/品名',u'单位',u'封装',u'功能',u'品牌',u'说明']
     model = QStandardItemModel(len(article_list), len(labels), self)
     model.setHorizontalHeaderLabels(QStringList(labels))
     #更新物品列表
     for i in range( len(article_list) ):
         article = article_list[i]
         model.setItem(i, 0, QStandardItem(QString(unicode(article.id))))
         model.setItem(i, 1, QStandardItem(QString(unicode(article.model))))
         model.setItem(i, 2, QStandardItem(QString(unicode(article.unit))))
         model.setItem(i, 3, QStandardItem(QString(unicode(article.packaging))))
         model.setItem(i, 4, QStandardItem(QString(unicode(article.function))))
         model.setItem(i, 4, QStandardItem(QString(unicode(article.pingpai))))
         model.setItem(i, 4, QStandardItem(QString(unicode(article.detail))))
     self.ui.tableView.setModel(model)
     for i in range( len(article_list)): self.ui.tableView.setRowHeight(i, 20)
     self.ui.tableView.setColumnWidth(0, 20)
     self.ui.tableView.setColumnWidth(2, 40)
Beispiel #2
0
 def slotDelType(self):
     user = ims.model.dbSysUser.g_current_user
     if user==None or not user.is_enable_write_all():return
     item = self.ui.treeWidget.currentItem()
     if item is None: return
     #需先删除所有子类别
     itemdata  = self.__getItemIdDepth__(item)
     if itemdata is None: return
     type_id = itemdata[0]
     depth = itemdata[1]
     print depth
     if depth != 2 and depth != 1: return
     if depth == 2:
         #检查2级类别下对应的是否有相关的物品信息
         article_list = dbArticle().getArticlesByTypeId(type_id)
         if article_list != None and len(article_list) > 0:
             QMessageBox.critical(self, u'error', u'需先删除该类别下所有物品!')
             return
     else:
         #1级类别检查下面是否有子类别
         if item.childCount() > 0:
             QMessageBox.critical(self, u'error', u'需先删除所有子类别')
             return
     #删除警告
     if QMessageBox.Yes != QMessageBox.warning(self, u'warning', u'确定删除此项吗', QMessageBox.Yes|QMessageBox.No, QMessageBox.No):
         return
     #删除类别
     if dbArticleType().delete(type_id):
         self.__updateArticleTree()
     else:
         QMessageBox.critical(self, u'出错了', u'删除出错,请重试')
Beispiel #3
0
 def setRecord(self,oldRecord):
     articleInfo = dbArticle().getById(oldRecord.articleid)
     #物品信息初始值
     if articleInfo!=None:
         self.ui.lineEdit_articlename.setText(articleInfo.model)
     else:
         self.ui.lineEdit_articlename.setText('')
     self.ui.lineEdit_count.setText('%f'%abs(oldRecord.count))
     self.ui.lineEdit_price.setText('%.2f'%oldRecord.price)
     self.ui.textEdit_detail.setText(oldRecord.detail)
     self.ui.lineEdit_number.setText(QString(oldRecord.number))
     #客户信息初始值
     self.__client = dbClient().getById(oldRecord.clientid)
     if self.__client:
         self.ui.lineEdit_client.setText(self.__client.name)
     #进出货初始值
     if oldRecord.count < 0:
         self.ui.radioButton_out.setChecked(True)            
         self.ui.radioButton_in.setChecked(False)
     else:        
         self.ui.radioButton_out.setChecked(True)            
         self.ui.radioButton_in.setChecked(False)
     #时间初始值
     dateStrList = oldRecord.time.split('/')
     if len(dateStrList)==3:
         date = QDate(int(dateStrList[0]), int(dateStrList[1]), int(dateStrList[2]))
         self.ui.dateEdit.setDate(date)
Beispiel #4
0
 def __updateArticleCountList(self):
     #是否匹配物品模式
     if self.ui.checkBox.isChecked():
         modelname = u'%s'%self.ui.lineEdit_model.text()
     else:
         modelname = None
     remainlist = dbArticle().getArticleRemainList(self.__article_id, modelname)
     model = QStandardItemModel(len(remainlist),5, self)
     labels = [u'id',u'大类名',u'小类名', u'物品型号', u'库存', u'最新入库单价', u'封装', u'品牌', u'详细说明']
     model.setHorizontalHeaderLabels(QStringList(labels))
     #用于查询最近入库单价的数据库对象
     dbRecord = dbInOutRecord()
     dbType = dbArticleType()
     for row in range(len(remainlist)):
         item = remainlist[row]
         model.setItem(row, 0, QStandardItem(QString(str(item.article.id) )) )
         type_str = dbType.getArticleTypeInfo(item.article.typeid)
         if type_str:
             model.setItem(row, 1, QStandardItem(QString(type_str[0])) )
             model.setItem(row, 2, QStandardItem(QString(type_str[1] )) )
         model.setItem(row, 3, QStandardItem(QString(item.article.model )) )
         model.setItem(row, 4, QStandardItem(QString(u'%.2f'%item.remainCount) ) )
         #最新单价可能为空
         lastPrice = dbRecord.getLastUnitPrice(item.article.id)
         model.setItem(row, 5, QStandardItem(QString( lastPrice and u'%.2f'%lastPrice or u'' ) ))
         model.setItem(row, 6, QStandardItem(QString(item.article.packaging )) )
         model.setItem(row, 7, QStandardItem(QString(item.article.pingpai )) )
         model.setItem(row, 8, QStandardItem(QString(item.article.detail )) )
     self.ui.tableView.setModel(model)
     self.ui.tableView.verticalHeader().setHidden(True)
     self.ui.tableView.setColumnWidth(0, 40)
     self.ui.tableView.setColumnWidth(5, 230)
     for i in range(model.rowCount()):
         self.ui.tableView.setRowHeight(i, 20)
Beispiel #5
0
 def slotDelArticle(self):
     article_id = self.__get_selected_article_id()
     res = QMessageBox.warning(self, u'危险操作', u'确认从数据库中删除当前选中的物品信息?', QMessageBox.Yes|QMessageBox.No)
     if res != QMessageBox.Yes: return
     if dbArticle().delete(article_id):
         self.__updateArticleList()
     else:
         QMessageBox.critical(self, u'出错了', u'删除操作执行出错')
Beispiel #6
0
 def slotModifyArticle(self):
     #权限检查
     user = ims.model.dbSysUser.g_current_user
     if None==user or not user.is_enable_write_all():return
     article_id = self.__get_selected_article_id()
     if article_id is None: return
     article = dbArticle().getById(article_id)
     dlg = DlgArticleChange(self, article)
     dlg.setModal(True)
     dlg.exec_()
     self.__updateArticleList()
Beispiel #7
0
    def slotOk(self):
        #权限检查
        if not ims.model.dbSysUser.g_current_user.is_enable_write_all():return

        article = Article()
        res = self.ui.comboBox_type2.itemData(self.ui.comboBox_type2.currentIndex()).toInt()
        if not res[1]:
            print 'invadate combobox item data'
            return 
        article.typeid      = int(res[0])
        article.detail      = u'%s'%self.ui.plainTextEdit_detail.toPlainText()
        article.function    = u'%s'%self.ui.lineEdit_function.text()
        article.model       = u'%s'%self.ui.lineEdit_model.text()
        article.packaging   = u'%s'%self.ui.lineEdit_pkg.text()
        article.pingpai     = u'%s'%self.ui.lineEdit_pp.text()
        #型号名必须不能为空
        if article.model == '':
            self.ui.label_tips.setText(u"<span style='color:#ff0000'>型号不能为空</span>")
            self.ui.lineEdit_model.setFocus()
            return

        if self.__oldArticle != None:
            #修改物品信息,id使用旧的物品id
            article.id = self.__oldArticle.id
            if not dbArticle().modify(article):
                QMessageBox.warning(self, u'出错了', u'修改物品信息失败')
                return
            else:
                self.close()
        else:
            #添加物品到库存中
            if not dbArticle().add(article):
                QMessageBox.warning(self, u'出错了', u'修改物品信息失败')
                return
            else:
                #询问是否继续添加
                res = QMessageBox.information(self,u'提示', u'添加物品信息成功,是否继续添加?',QMessageBox.Yes|QMessageBox.No)
                if res != QMessageBox.Yes:
                    self.close
Beispiel #8
0
 def getArticleInfo(self):
     if self.__articleInfo is None:
         self.__articleInfo = dbArticle().getById(self.articleid)
     return  self.__articleInfo
Beispiel #9
0
 def slotChoosed(self):
     article_id = self.__get_selected_article_id()
     if article_id is None: return
     self.__articleSelected = dbArticle().getById(article_id)
     self.accept()