def __slotOk(self): client = Client() client.address= u'%s'%self.ui.lineEdit_address.text() client.boss = u'%s'%self.ui.lineEdit_boss.text() client.detail = u'%s'%self.ui.textEdit_detail.toPlainText() client.mobile = u'%s'%self.ui.lineEdit_mobile.text() client.name = u'%s'%self.ui.lineEdit_name.text() client.phone = u'%s'%self.ui.lineEdit_phone.text() client.type = u'%s'%self.ui.comboBox_clienttype.currentText() #校样客户信息是否合法,客户姓名必须不能为空 client.name = client.name.lstrip() client.name = client.name.rstrip() #添加客户类型 g_configfile.addClientTypes(client.type) #客户名称不能为空 if client.name == '': QMessageBox.critical(self, u'error', u'公司名称/单位名称不能为空') self.ui.lineEdit_name.setFocus() return if self.__oldclientInfo == None: #添加客户信息''' if not dbClient().insert(client): QMessageBox.critical(self, u'error', u'添加客户项失败!') else: self.close() else: #修改客户信息''' if not dbClient().modify(self.__oldclientInfo.id, client): QMessageBox.critical(self, u'error', u'修改客户信息失败!') else: self.close()
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)
def getClientInfo(self): if self.__clientInfo is None: self.__clientInfo = dbClient().getById(self.clientid) return self.__clientInfo