class Short_EmployeeList(QtGui.QDialog): def __init__(self, query, parent=None): QtGui.QDialog.__init__(self, parent) self.ui = Ui_EmpList() self.ui.setupUi(self) self.query = query QtCore.QObject.connect(self.ui.lineEdit, QtCore.SIGNAL("textChanged(QString)"), self.filter_data) QtCore.QObject.connect( self.ui.treeWidget, QtCore.SIGNAL("itemDoubleClicked(QTreeWidgetItem*,int)"), self.send_id) self.showdata() def send_id(self, item, text): name = item.text(0) empid = item.text(1) self.li = [name, empid] self.close() def get_list(self): return self.li def filter_data(self, var): li = [] self.query.exec_( """ select first_name, last_name,employee_id from employee_information where first_name LIKE '%s%%' or employee_id LIKE '%s%%' """ % (var, var)) while self.query.next(): self.ui.treeWidget.clear() li.append((self.query.value(0).toString() + ' ' + self.query.value(1).toString(), self.query.value(2).toString())) for i in li: item = QtGui.QTreeWidgetItem(self.ui.treeWidget) item.setText(0, i[0]) item.setText(1, i[1]) def showdata(self): li = [] self.query.exec_( """ select concat(first_name,' ',last_name),employee_id from employee_information ; """ ) while self.query.next(): li.append((self.query.value(0).toString(), self.query.value(1).toString())) for i in li: item = QtGui.QTreeWidgetItem(self.ui.treeWidget) item.setText(0, i[0]) item.setText(1, i[1])
class AllInfo(QtGui.QDialog): def __init__(self,query,empId,parent = None): QtGui.QDialog.__init__(self,parent) self.ui = Ui_EmpList() self.ui.setupUi(self) self.query = query QtCore.QObject.connect(self.ui.lineEdit,QtCore.SIGNAL("textChanged(QString)"),self.filter_data) QtCore.QObject.connect(self.ui.treeWidget,QtCore.SIGNAL("itemDoubleClicked(QTreeWidgetItem*,int)"),self.send_id) self.showdata() def send_id(self,item,text) : name = item.text(0) empid = item.text(1) self.li = [name,empid] self.query.exec_(""" select employee_information_id from employee_information where employee_id='%s' """%(empid)) while self.query.next(): empId = self.query.value(0).toString() obj = EmployeeAllInformation(self.query,empId) obj.exec_() def get_list(self): return self.li def filter_data(self,var): li = [] self.query.exec_(""" select first_name, last_name,employee_id from employee_information where first_name LIKE '%s%%' or employee_id LIKE '%s%%' """%(var,var)) while self.query.next(): self.ui.treeWidget.clear() li.append((self.query.value(0).toString()+' '+self.query.value(1).toString(),self.query.value(2).toString())) for i in li: item = QtGui.QTreeWidgetItem(self.ui.treeWidget) item.setText(0,i[0]) item.setText(1,i[1]) def showdata(self): li =[] self.query.exec_(""" select concat(first_name,' ',last_name),employee_id from employee_information ; """) while self.query.next(): li.append((self.query.value(0).toString(),self.query.value(1).toString())) for i in li: item = QtGui.QTreeWidgetItem(self.ui.treeWidget) item.setText(0,i[0]) item.setText(1,i[1])
def __init__(self, query, empId, parent=None): QtGui.QDialog.__init__(self, parent) self.ui = Ui_EmpList() self.ui.setupUi(self) self.query = query QtCore.QObject.connect(self.ui.lineEdit, QtCore.SIGNAL("textChanged(QString)"), self.filter_data) QtCore.QObject.connect( self.ui.treeWidget, QtCore.SIGNAL("itemDoubleClicked(QTreeWidgetItem*,int)"), self.send_id) self.showdata()
def __init__(self,query,empId,parent = None): QtGui.QDialog.__init__(self,parent) self.ui = Ui_EmpList() self.ui.setupUi(self) self.query = query QtCore.QObject.connect(self.ui.lineEdit,QtCore.SIGNAL("textChanged(QString)"),self.filter_data) QtCore.QObject.connect(self.ui.treeWidget,QtCore.SIGNAL("itemDoubleClicked(QTreeWidgetItem*,int)"),self.send_id) self.showdata()