Beispiel #1
0
 def update_staff(self):
     indexes = self.selectionModel().selectedRows()
     if(len(indexes)) == 1:
         dialog = Dialog()
         id_text = self.item(indexes[0].row(), 0).text()
         staff_item = StaffManager.get_one_item_by_user_id(int(id_text))
         dialog.name_edit.setText(staff_item.name)
         dialog.employee_id_edit.setText(staff_item.employee_id)
         dialog.phone_number_edit.setText(staff_item.phone_number)
         dialog.tel_number_edit.setText(staff_item.tel_number)
         dialog.birth_date_edit.setDate(staff_item.birth_date)
         dialog.title_edit.setCurrentIndex(dialog.title_edit.findText(staff_item.title))
         dialog.position_edit.setCurrentIndex(dialog.position_edit.findText(staff_item.position))
         dialog.education_edit.setCurrentIndex(dialog.education_edit.findText(staff_item.education))
         dialog.description_edit.setText(staff_item.description)
         dialog.name_edit.setReadOnly(True)
         if dialog.exec_():
             dic = dialog.get_add_datas()
             dic['id'] = int(id_text)
             StaffManager.updata_staff(dic)
             search_datas = StaffManager.search_all_staff()
             self.refresh_staff(search_datas)
             dialog.destroy()
     else:
         # 弹出警告
         ToolsManager.information_box(u"注意", u"请选择一行进行更新!")
Beispiel #2
0
 def search_project_by_name(self):
     project_name = unicode(self.name_edit.text())
     if project_name not in (None, ''):
         search_datas = ProjectManager.search_project_by_name(project_name)
         self.my_table.refresh_project(search_datas)
     else:
         ToolsManager.information_box(u'注意', u'请填写项目名再搜索!')
Beispiel #3
0
 def add_staff(user_obj):
     items = session.query(User).filter(User.name == user_obj.name).all()
     if len(items) == 0:     # 数据库中没有重名的存在,则添加
         session.add(user_obj)
         session.commit()
     else:
         # 弹出警告
         ToolsManager.information_box(u"注意", u"\"%s\"已经存在数据库中!" % unicode(user_obj.name))
Beispiel #4
0
 def remove_fun(self):
     if len(self.listWidgetB.selectedItems()) == 1:
         row_num = self.listWidgetB.row(self.listWidgetB.currentItem())
         currentItem = self.listWidgetB.item(row_num).text()
         self.listWidgetA.addItem(currentItem)
         self.listWidgetB.takeItem(row_num)
     else:
         ToolsManager.information_box(u"注意", u"请选择一个参加人员!")
Beispiel #5
0
 def search_project_by_date(self):
     para = {
         'start_time': self.start_time_edit.date().toPyDate(),
         'end_time': self.end_time_edit.date().toPyDate()
     }
     if para['end_time'] < para['start_time']:
         ToolsManager.information_box(u'注意', u'起始日期应该小于终止日期!')
     else:
         search_datas = ProjectManager.search_project_by_date(**para)
         self.my_table.refresh_project(search_datas)
Beispiel #6
0
 def collect_data(self):
     para = {
         'name': unicode(self.name_edit.text()),
         'start_time': self.start_time_edit.date().toPyDate(),
         'end_time': self.end_time_edit.date().toPyDate()
     }
     if para['name'] in (None, '') or para['end_time'] < para['start_time']:
         if para['name'] in (None, ''):
             ToolsManager.information_box(u'注意', u'请填写姓名再搜索!')
         if para['end_time'] < para['start_time']:
             ToolsManager.information_box(u'注意', u'起始日期应该小于终止日期!')
     else:
         self.addButton.setVisible(False)
         self.deleteButton.setVisible(False)
         self.updateButton.setVisible(False)
         self.my_table.search_staff_by_name_and_date(**para)
Beispiel #7
0
 def delete_staff(self):
     indexes = self.selectionModel().selectedRows()
     if len(indexes) == 0:
         ToolsManager.information_box(u"注意", u"请选择一行或多行进行删除!")
     else:
         button = ToolsManager.question_box(u"提醒", u"是否删除选中行?")
         if button == QtGui.QMessageBox.Ok:
             ids_list = []
             for index in sorted(indexes):
                 id_text = self.item(index.row(), 0).text()
                 ids_list.append(int(id_text))
             StaffManager.delete_staff(ids_list)
             StaffManager.delete_staff_project_by_staff_ids(ids_list)
             search_datas = StaffManager.search_all_staff()
             self.refresh_staff(search_datas)
         else:
             pass
Beispiel #8
0
    def update_project(self):
        indexes = self.selectionModel().selectedRows()
        if(len(indexes)) == 1:
            dialog = Dialog()
            id_text = self.item(indexes[0].row(), 0).text()
            project_item = ProjectManager.get_one_item_by_project_id(int(id_text))

            dialog.name_edit.setText(project_item.name)
            dialog.search_id_edit.setText(project_item.search_id)
            dialog.source_place_edit.setCurrentIndex(dialog.source_place_edit.findText(project_item.source_place))
            dialog.main_designer_edit.setText(project_item.main_designer)
            dialog.design_all_edit.setText(project_item.design_all)
            dialog.responsible_man_edit.setText(project_item.responsible_man)
            dialog.start_time_edit.setDate(project_item.start_time)
            dialog.end_time_edit.setDate(project_item.end_time)
            dialog.description_edit.setText(project_item.description)
            dialog.name_edit.setReadOnly(True)
            staff_str = StaffManager.search_staff_by_project_id(project_item.id)
            if staff_str == '':         # 项目里没人
                staff_data_list = StaffManager.search_idle_staff()
                for staff in staff_data_list:
                    dialog.listWidgetA.addItem(staff[1])            # "1"是列表的的名字字段
            else:
                staff_name_list = staff_str.split(',')
                for staff_name in staff_name_list:
                    dialog.listWidgetB.addItem(staff_name)
                staff_data_list = StaffManager.search_idle_staff()
                for staff in staff_data_list:
                    if staff[1] not in staff_name_list:
                        dialog.listWidgetA.addItem(staff[1])

            if dialog.exec_():
                dic = dialog.get_add_datas()
                dic['id'] = int(id_text)
                ProjectManager.updata_project(dic)
                search_datas = ProjectManager.get_all_project_and_format()
                self.refresh_project(search_datas)
                dialog.destroy()
        else:
            # 弹出警告
            ToolsManager.information_box(u"注意", u"请选择一行进行更新!")
Beispiel #9
0
 def accept_fun(self):
     dic = self.get_add_datas()
     success_data = ToolsManager.validate_data('staff', self, dic)
     if success_data:
         self.accept()
Beispiel #10
0
 def accept_fun(self):
     dic = self.get_add_datas()
     success = ToolsManager.validate_data('project', self, dic)
     if success:
         self.accept()