Beispiel #1
0
 def delete_item(self):
     try:
         selcted_item = self.table_view.get_selected_item()  # {'idx':selected_index.row(), 'item':title}
         TitleDao.instance().delete_item(dto=selcted_item['item'])
         self.table_view.delete_item(selcted_item['idx'])
     except Exception as err:
         raise err
 def add_item(self):
     title = self.title_item.get_item()
     if self.add_btn.text() == '추가':
         try:
             TitleDao.instance().insert_item(dto=title)
             self.table_view.add_item(title)
             self.title_item.clear_line_edit()
         except Exception as err:
             raise err
     else:
         try:
             TitleDao.instance().update_item(dto=title)
             self.table_view.update_item(self.set_table_idx, title)
             self.add_btn.setText('추가')
             self.title_item.clear_line_edit()
         except Exception as err:
             raise err
Beispiel #3
0
 def execAddOrUpdate(self):
     print('execAddOrUpdate')
     title = self.title_item.get_item()
     if self.ui.btn_add.text() == '추가':
         try:
             TitleDao.instance().insert_item(dto=title)
             self.table_view.add_item(title)
             self.title_item.clear_line_edit()
         except Exception as err:
             raise err
     else:
         try:
             TitleDao.instance().update_item(dto=title)
             self.table_view.update_item(self.set_table_idx, title)
             self.ui.btn_add.setText('추가')
             self.title_item.clear_line_edit()
         except Exception as err:
             raise err
    def __init__(self, parent=None):
        super(EmployeeContent, self).__init__(parent)
        ui_path = pkg_resources.resource_filename('ui', 'designer/content_employee.ui')
        self.ui = uic.loadUi(ui_path, self)

        self.ui.de_hire_date.setDate(QDate.currentDate())

        self.title_list = TitleDao.instance().select_item()
        title_name_list = [title.title_name for title in self.title_list]
        self.ui.cb_title.addItems(title_name_list)
        self.ui.cb_title.setCurrentIndex(-1)

        self.dept_list = DepartmentDao.instance().select_item()
        dept_name_list = [dept.dept_name for dept in self.dept_list]
        self.ui.cb_dept.addItems(dept_name_list)
        self.ui.cb_dept.setCurrentIndex(-1)

        self.ui.cb_dept.currentTextChanged.connect(self.on_cmb_dept_changed)
        self.ui.le_pass1.textChanged.connect(self.passwd_valid_check)
        self.ui.le_pass2.textChanged.connect(self.passwd_valid_check)
        self.ui.lbl_img.mousePressEvent = self.file_open
 def get_data(self):
     return [tuple(title) for title in TitleDao.instance().select_item()]
Beispiel #6
0
    def init_component(self, root_layout):
        item_size = QSize(150, 40)
        self.file_name = pkg_resources.resource_filename('resources', 'no_img.png')

        self.lbl_no = QLabel('사원 번호', self)
        self.lbl_no.setAlignment(Qt.AlignCenter)
        self.lbl_no.setMinimumSize(item_size)
        self.le_no = QLineEdit()
        self.le_no.setMinimumSize(item_size)

        self.lbl_name = QLabel('사원명', self)
        self.lbl_name.setAlignment(Qt.AlignCenter)
        self.lbl_name.setMinimumSize(item_size)
        self.le_name = QLineEdit()
        self.le_name.setMinimumSize(item_size)

        self.lbl_gender = QLabel('성별', self)
        self.lbl_gender.setAlignment(Qt.AlignCenter)
        self.lbl_gender.setMinimumSize(item_size)

        layout_gender = QHBoxLayout()
        self.rb_male = QRadioButton('남', self)
        self.rb_male.setChecked(True)
        # self.rb_male.setMinimumSize(item_size)
        layout_gender.addWidget(self.rb_male)

        self.rb_female = QRadioButton('여', self)
        # self.rb_female.setMinimumSize(item_size)
        layout_gender.addWidget(self.rb_female)

        btn_group = QButtonGroup()
        btn_group.addButton(self.rb_male)
        btn_group.addButton(self.rb_female)
        # layout_gender.setContentsMargins(10, 0, 10, 0)

        #직속상사
        self.lbl_manager = QLabel('직속 상사', self)
        self.lbl_manager.setAlignment(Qt.AlignCenter)
        self.lbl_manager.setMinimumSize(item_size)

        self.cb_manager = QComboBox(self)
        self.cb_manager.setMinimumSize(item_size)
        self.cb_manager.setCurrentIndex(-1)

        # 급여
        self.lbl_salary = QLabel('급여', self)
        self.lbl_salary.setAlignment(Qt.AlignCenter)
        self.lbl_salary.setMinimumSize(item_size)

        self.sp_salary = QSpinBox()
        self.sp_salary.setMinimumSize(item_size)
        self.sp_salary.setRange(1500000, 5000000)
        self.sp_salary.setSingleStep(100000)
        self.sp_salary.setGroupSeparatorShown(True);
        self.sp_salary.setAlignment(Qt.AlignRight)
        echo_group = QGroupBox('사원', self)

        #부서
        self.lbl_dept = QLabel('부서', self)
        self.lbl_dept.setAlignment(Qt.AlignCenter)
        self.lbl_dept.setMinimumSize(item_size)

        self.cb_dept = QComboBox(self)
        self.cb_dept.setMinimumSize(item_size)

        self.dept_list = DepartmentDao.instance().select_item()
        dept_name_list = [dept.dept_name for dept in self.dept_list]
        self.cb_dept.addItems(dept_name_list)
        self.cb_dept.setCurrentIndex(-1)

        # 입사일
        self.lbl_hire_date = QLabel('입사일', self)
        self.lbl_hire_date.setAlignment(Qt.AlignCenter)
        self.lbl_hire_date.setMinimumSize(item_size)

        self.de_hire_date = QDateEdit(self)
        self.de_hire_date.setMinimumSize(item_size)
        self.de_hire_date.setDate(QDate.currentDate())
        self.de_hire_date.setMinimumDate(QDate(1900, 1, 1))
        self.de_hire_date.setMaximumDate(QDate(2100, 12, 31))
        self.de_hire_date.setDisplayFormat('yyyy-MM-dd')
        self.de_hire_date.setAlignment(Qt.AlignCenter)

        # 직책
        self.lbl_title = QLabel('직책', self)
        self.lbl_title.setAlignment(Qt.AlignCenter)
        self.lbl_title.setMinimumSize(item_size)

        self.cb_title = QComboBox(self)
        self.cb_title.setMinimumSize(item_size)
        self.title_list = TitleDao.instance().select_item()
        title_name_list = [title.title_name for title in self.title_list]
        self.cb_title.addItems(title_name_list)
        self.cb_title.setCurrentIndex(-1)

        #비밀번호
        self.lbl_pass1 = QLabel('비밀 번호', self)
        self.lbl_pass1.setAlignment(Qt.AlignCenter)
        self.lbl_pass1.setMinimumSize(item_size)

        self.le_pass1 = QLineEdit()
        self.le_pass1.setEchoMode(QLineEdit.Password)
        self.le_pass1.setMinimumSize(item_size)

        self.lbl_pass2 = QLabel('비밀 번호 확인', self)
        self.lbl_pass2.setAlignment(Qt.AlignCenter)
        self.lbl_pass2.setMinimumSize(item_size)
        self.le_pass2 = QLineEdit()
        self.le_pass2.setEchoMode(QLineEdit.Password)
        self.le_pass2.setMinimumSize(item_size)

        self.lbl_pass_confirm = QLabel('', self)
        self.lbl_pass_confirm.setStyleSheet('color: red')
        self.lbl_pass_confirm.setAlignment(Qt.AlignCenter)
        self.lbl_pass_confirm.setMinimumSize(item_size)

        #사진
        self.lbl_img = QLabel()
        self.lbl_img.setMinimumSize(QSize(200, 275))
        self.lbl_img.setAlignment(Qt.AlignCenter)
        self.lbl_img.setFrameShape(QFrame.Box)
        self.lbl_img.setFrameShadow(QFrame.Sunken)

        pixmap = QPixmap(self.file_name)
        self.lbl_img.setPixmap(pixmap.scaled(150, 275, Qt.KeepAspectRatio))

        self.btn_pic = QPushButton('사진 추가')
        self.btn_pic.setMinimumSize(item_size)

        group_layout = QGridLayout()
        echo_group.setLayout(group_layout)
        group_layout.addWidget(self.lbl_no,           0, 0, 1, 1)
        group_layout.addWidget(self.le_no,            0, 1, 1, 1)
        group_layout.addWidget(self.lbl_name,         1, 0, 1, 1)
        group_layout.addWidget(self.le_name,          1, 1, 1, 1)
        group_layout.addWidget(self.lbl_salary,       2, 0, 1, 1)
        group_layout.addWidget(self.sp_salary,        2, 1, 1, 1)
        group_layout.addWidget(self.lbl_pass1,        3, 0, 1, 1)
        group_layout.addWidget(self.le_pass1,         3, 1, 1, 1)
        group_layout.addWidget(self.lbl_pass2,        4, 0, 1, 1)
        group_layout.addWidget(self.le_pass2,         4, 1, 1, 1)
        group_layout.addWidget(self.lbl_pass_confirm, 5, 1, 1, 1)

        group_layout.addWidget(self.lbl_hire_date,    0, 2, 1, 1)
        group_layout.addWidget(self.de_hire_date,     0, 3, 1, 1)
        group_layout.addWidget(self.lbl_gender,       1, 2, 1, 1)
        group_layout.addLayout(layout_gender,         1, 3, 1, 1)
        group_layout.addWidget(self.lbl_dept,         2, 2, 1, 1)
        group_layout.addWidget(self.cb_dept,          2, 3, 1, 1)
        group_layout.addWidget(self.lbl_manager,      3, 2, 1, 1)
        group_layout.addWidget(self.cb_manager,       3, 3, 1, 1)
        group_layout.addWidget(self.lbl_title,        4, 2, 1, 1)
        group_layout.addWidget(self.cb_title,         4, 3, 1, 1)

        group_layout.addWidget(self.lbl_img,               0, 5, 4, 1)
        group_layout.addWidget(self.btn_pic,          4, 5, 1, 1)

        horizontalSpacer = QSpacerItem(150, 40, QSizePolicy.Expanding, QSizePolicy.Minimum)
        group_layout.addItem(horizontalSpacer,          0, 4, 1, 1)

        self.cb_dept.currentTextChanged.connect(self.on_cmb_dept_changed)
        self.le_pass1.textChanged.connect(self.passwd_valid_check)
        self.le_pass2.textChanged.connect(self.passwd_valid_check)
        self.btn_pic.clicked.connect(self.file_open)
        root_layout.addWidget(echo_group)