def __find_sale(self): pdt = ProductDao() selectionIdxs = self.ui.tableWidget_2.selectedIndexes()[0] code = self.ui.tableWidget_2.item(selectionIdxs.row(), 1).text() res = pdt.select(code) find_res = str(res[0][1]) QMessageBox.information(self, '검색완료', find_res, QMessageBox.Ok)
def __delete(self): pdt = ProductDao() selectionIdxs = self.ui.tableWidget.selectedIndexes()[0] code = self.ui.tableWidget.item(selectionIdxs.row(), 0).text() self.ui.tableWidget.removeRow(selectionIdxs.row()) pdt.delete_product(code) QMessageBox.information(self, 'Delete', '확인', QMessageBox.Ok)
def __init__(self, *args, **kwargs): super().__init__() self.pdt = ProductDao() self.idt = IDDao() self.sdt = SaleDao() self.ui = uic.loadUi("ui/main_menu.ui", self) self.month_count = 14 self.graphcount = 0 # combobox self.combobox_setting() # graph self.graph() # table self.table_pro = create_table(table=self.ui.table_pro, data=['제품코드', '제품명', '종류', '제품가격', '마진율(%)']) self.sale_pro = create_table(table=self.ui.table_sale, data=['제품명', '판매량', '판매금액', '판매일']) self.load_pro_all() self.load_sale_all() self.ui.btn_out.clicked.connect(self.exit) # logout self.ui.btn_manage.clicked.connect(self.manage) self.ui.btn_sale.clicked.connect(self.sale_manage) self.ui.btn_exit.clicked.connect(self.exit) self.ui.btn_set.clicked.connect(self.user_setting) self.ui.combo_menu.currentIndexChanged.connect(self.select_menu) self.ui.combo_sale_year.currentIndexChanged.connect(self.select_sale) self.ui.combo_sale_month.currentIndexChanged.connect(self.select_month) self.ui.show()
def __init__(self): super().__init__() self.ui = uic.loadUi("ui/sale_manage.ui") self.pdt = ProductDao() self.sdt = SaleDao() self.ui.table_sale.setColumnCount(7) self.ui.table_order.setColumnCount(3) self.table_order = create_table(table=self.ui.table_order, data=['제품명', '종류', '갯수']) self.table_sale_detail = create_table( table=self.ui.table_sale, data=['제품명', '종류', '판매량', '판매액', '세금', '마진액', '판매 시간']) self.load_sale() self.ui.combo_menu.addItem('all') self.ui.combo_sel_pro.addItem('--select--') self.count = 0 self.nextIdx = 0 self.namelist = [] self.order_list = {} for i in range(len(self.pdt.select_category())): self.ui.combo_menu.addItems(self.pdt.select_category()[i]) self.ui.combo_category.addItem('all') for i in range(len(self.pdt.select_category())): self.ui.combo_category.addItems(self.pdt.select_category()[i]) for i in range(len(self.pdt.select_name())): self.ui.combo_sel_pro.addItems(self.pdt.select_name()[i]) self.ui.btn_insert_menu.clicked.connect(self.ins_menu) self.ui.btn_del_menu.clicked.connect(self.del_menu) self.ui.btn_edit_menu.clicked.connect(self.edit_menu) self.ui.btn_ins_category.clicked.connect(self.category) self.ui.combo_menu.currentIndexChanged.connect(self.select_menu) self.ui.btn_exit.clicked.connect(self.exit) # sale_manage self.ui.tab_product.currentChanged.connect(self.tab_change) self.ui.btn_insert.clicked.connect(self.ins_order) self.ui.combo_category.currentIndexChanged.connect(self.order_category) self.ui.btn_edit.clicked.connect(self.edit_order) self.ui.btn_delete.clicked.connect(self.del_order) self.ui.btn_reset.clicked.connect(self.reset_order) self.ui.btn_ok.clicked.connect(self.ok_order) # select self.ui.btn_select.clicked.connect(self.select_sale_detail) self.ui.btn_init.clicked.connect(self.select_init) self.set_context_menu(self.ui.table_sale) self.set_context_menu_order(self.ui.table_order) self.ui.btn_edit_menu.setEnabled(False) self.ui.btn_edit.setEnabled(False) self.ui.btn_edit_menu.setText('편집시 우클릭') self.ui.btn_edit.setText('편집시 주문 현황 우클릭') self.ui.show()
def init_item(self): pdt = ProductDao() res = pdt.select() self.ui.le_code.clear() self.ui.le_name.clear() row_res = self.ui.tableWidget.rowCount() [self.ui.tableWidget.removeRow(i) for i in reversed(range(row_res))] self.load_data(res)
def buy_product(self, itemid, fuzzy_id): pro: Product = ProductDao.product_by_pro_no(itemid) if pro: user_id = decrypt_user_id(fuzzy_id) acc_auth = AuthDao.query_account_auth(user_id) if acc_auth: a = ProductDao.new_order_assets(acc_auth, pro) return a return None
def insert_item(self): item_code, item_name, code, name = self.get_item_form_le() currentIdx = self.ui.tableWidget.rowCount() self.ui.tableWidget.insertRow(currentIdx) self.ui.tableWidget.setItem(currentIdx, 0, item_code) self.ui.tableWidget.setItem(currentIdx, 1, item_name) pdt = ProductDao() pdt.insert_item(code, name) self.init_item()
def test_create(self, create_instance): product = create_instance prod_dao = ProductDao() new_prod = prod_dao.save(product) assert new_prod is not None assert new_prod.name == product.name assert new_prod.price == product.price assert new_prod.description == product.description prod_dao.delete(new_prod)
def update_item(self): pdt = ProductDao() selectionIdx = self.ui.tableWidget.selectedIndexes()[0] item_code, item_name, code, name = self.get_item_form_le() pdt_code = (self.ui.tableWidget.item(selectionIdx.row(), 0)).text() pdt.update_item(code, name, pdt_code) self.ui.tableWidget.setItem(selectionIdx.row(), 0, item_code) self.ui.tableWidget.setItem(selectionIdx.row(), 1, item_name) self.init_item()
def get_item_form_le(self): pdt = ProductDao() sdt = SaleDao() code = self.ui.line_code.text() name = self.ui.line_name.text() price = self.ui.line_price.text() count = self.ui.line_count.text() margin = self.ui.line_margin.text() pdt.insert_product(code=code, name=name) sdt.insert_item(price=price,salecnt=count,marginrate=margin) return self.create_item(code, name)
def __init__(self): super().__init__() pf = Product_form() sf = Sale_form() pdt = ProductDao() sdt = SaleDao() sdd = Sale_Detail_Dao() self.ui = uic.loadUi("ui/application.ui") # create table self.table = create_table(table=self.ui.tableWidget, data=['code', 'name']) self.table_sale = create_table( table=self.ui.tableWidget_2, data=['no', 'code', 'price', 'saleCnt', 'marginRate']) self.table_sdd = create_table( table=self.ui.table_sd, data=['no', 'sale_price', 'addTax', 'supply_price', 'marginPrice']) self.table_sdd_proc = create_table(table=self.ui.table_proc, data=[ 'rank', 'code', 'name', 'price', 'saleCnt', 'supply_price', 'addTax', 'sale_price', 'marginRate', 'marginPrice' ]) # select data res = pdt.select() res2 = sdt.select_item() res3 = sdd.select_item() self.load_data(res) self.load_data_sale(res2) self.load_data_sale_detail(res3) # product 버튼 연결 self.ui.btn_insert.clicked.connect(self.add_item) self.ui.btn_update.clicked.connect(self.update_item) self.ui.btn_delete.clicked.connect(self.del_item) self.ui.btn_init.clicked.connect(self.init_item) self.ui.btn_pd_explain.clicked.connect(self.explain_pd) # sale 버튼 연결 self.ui.btn_insert_2.clicked.connect(self.add_item_sale) self.ui.btn_update_2.clicked.connect(self.update_item_sale) self.ui.btn_delete_2.clicked.connect(self.del_item_sale) self.ui.btn_init_2.clicked.connect(self.init_item_sale) self.ui.btn_explain.clicked.connect(self.explain_sale) # sale_detail_proc 버튼 연결 self.ui.rdbtn_sp.clicked.connect(self.call_proc_sp) self.ui.rdbtn_mp.clicked.connect(self.call_proc_mp) # 마우스 우클릭시 메뉴 pf.set_context_menu(self.ui.tableWidget, self.__update, self.__delete, self.__find) sf.set_context_menu_sale(self.ui.tableWidget_2, self.__update_sale, self.__delete_sale, self.__find_sale) self.ui.show()
def init_ui(self): # create the view tableView = create_table_view(20, 60) pdt = ProductDao() data = pdt.select_product() self.model = ProductTableModel(data) tableView.setModel(self.model) layout = QVBoxLayout() layout.addWidget(tableView) self.setLayout(layout) self.show()
def un_tag_product(self, itemid): es_rs = es_dao_local().es_get( itemid, { "_source": ",".join([ 'isdir', 'fs_id', 'size', 'account', 'tags', 'filename', 'parent', 'sourceid' ]) }) if es_rs and "_source" in es_rs: source = es_rs["_source"] tags = source["tags"] if PRODUCT_TAG in tags: tags.remove(PRODUCT_TAG) es_dao_local().update_field(itemid, 'tags', tags) ProductDao.update_product(itemid, {'pin': 1})
def test_delete(self, create_instance): prod_dao = ProductDao() new_prod = prod_dao.save(create_instance) result = prod_dao.read_by_id(new_prod.id) prod_dao.delete(result) result = prod_dao.read_by_id(new_prod.id) assert result is None
def __init__(self): super().__init__() self.ui = uic.loadUi("ui/coffee_ui.ui") self.ui.show() self.table = view_table(table=self.ui.tableWidget, data=["code", "name"]) self.table = view_table( table=self.ui.tableWidget_2, data=["no", "code", "price", "saleCnt", "marginRate"]) self.table = view_table( table=self.ui.tableWidget_3, data=["no", "sale_price", "addTax", "supply_price", "marginPrice"]) # product slot/signal self.ui.btn_insert.clicked.connect(self.insert_item) self.ui.btn_delete.clicked.connect(self.delete_item) self.ui.btn_update.clicked.connect(self.update_item) self.ui.btn_init.clicked.connect(self.init_item) # sale slot/signal self.ui.btn_insert_2.clicked.connect(self.insert_item2) self.ui.btn_delete_2.clicked.connect(self.delete_item2) self.ui.btn_update_2.clicked.connect(self.update_item2) self.ui.btn_init_2.clicked.connect(self.init_item2) # sale_detail slot/signal self.load_data3() self.ui.btn_init_3.clicked.connect(self.load_data3) self.ui.btn_procedure.clicked.connect( lambda stat, x=True: self.procedure(stat, x)) self.ui.btn_procedure2.clicked.connect( lambda stat, x=False: self.procedure(stat, x)) pdt = ProductDao() data = pdt.select_item() self.load_data(data) sale = SaleDao() data2 = sale.select_item() self.load_data2(data2) # 우클릭 선택 self.set_context_menu(self.ui.tableWidget) self.set_context_menu2(self.ui.tableWidget_2)
def search_assets(self, user_ref_id, page, total): size = 15 offset = int(page) * size if page == 0: total = ProductDao.query_assets_count_by_ref_id(user_ref_id) assets_list = ProductDao.query_assets_by_ref_id(user_ref_id, offset=offset, limit=size) datas = [] for assets in assets_list: datas.append(Assets.to_dict(assets, ["id"])) has_next = offset + size < total rs = { "data": datas, "has_next": has_next, "total": total, "pagesize": size } return rs
def product_dao_test(): global pdt pdt = ProductDao() [print(row) for row in pdt.select_product()] [ print(row) for row in pdt.select_product( sql="select * from product where code like %s", code='A%') ] sdt = SaleDao() [print(row) for row in sdt.select_item()] # sdt.insert_item(code='A001', price=5000, saleCnt=10, marginRate=10) [print(row) for row in sdt.select_item(no=1)] select_product() pdt.insert_product("Insert into product values(%s, %s)", 'C001', '라떼') select_product() pdt.update_product("update product set name = %s where code = %s", '라떼수정', 'C001') select_product() pdt.delete_product("delete from product where code = %s", 'C001') select_product()
def tag_product(self, ref_id, itemid, layer, p_price) -> Product: es_rs = es_dao_local().es_get( itemid, { "_source": ",".join([ 'isdir', 'fs_id', 'size', 'account', 'tags', 'filename', 'parent', 'sourceid' ]) }) logger.info("es_rs:{},layer:{},price:{}".format(es_rs, layer, p_price)) if es_rs and "_source" in es_rs: source = es_rs["_source"] isdir = source["isdir"] size = source["size"] # format_size = scale_size(size) tags = source["tags"] if not tags: tags = [] if PRODUCT_TAG not in tags: tags.append(PRODUCT_TAG) es_dao_local().update_field(itemid, 'tags', tags) pro: Product = ProductDao.product_by_pro_no(itemid) if not pro: pro = ProductDao.new_product( itemid, ref_id, { 'isdir': isdir, 'name': source['filename'], 'fs_id': source['fs_id'], 'size': size, 'price': int(p_price * 100) }) else: ProductDao.update_product(itemid, { 'pin': 0, 'price': int(p_price * 100) }) return pro
def test_read_by_id(self, create_instance): product = create_instance prod_dao = ProductDao() new_prod = prod_dao.save(product) result = prod_dao.read_by_id(new_prod.id) assert isinstance(result, Product) assert new_prod.name == result.name assert new_prod.price == result.price assert new_prod.description == result.description prod_dao.delete(new_prod)
def get(self): path = self.request.path # print(path) if path.endswith("/list"): parent = self.get_argument("parent", default='55') item_list = DataDao.query_data_item_by_parent(int(parent), True) params = {"list": item_list} # print("params:", params) # for item in item_list: # print(item.filename) self.render('list.html', **params) elif path.endswith("/fload"): source = self.get_argument("source", "") node_id = self.get_argument("id") # parent_path = self.get_argument("path") # if not parent_path.endswith("/"): # parent_path = "%s/" % parent_path logger.info("fload node_id:{},source:{}".format(node_id, source)) # parent_id = 55 params = [] if not '#' == node_id: # if "shared" == source: # params = pan_service.query_shared_file_list(parent_id, self.request.user_id) if "assets" == source: if 'assets_0' == node_id: params = ProductDao.query_assets_by_ref_id_for_tree( self.ref_id) elif "free" == source: if 'free_0' == node_id: params = pan_service.query_root_list() elif "self" == source: if 'self_0' == node_id: if not self.default_pan_id: pan_acc = auth_service.default_pan_account( self.user_id) self.default_pan_id = pan_acc.id if self.default_pan_id: params = pan_service.query_client_root_list( self.default_pan_id) else: node_id_val = decrypt_id(node_id) parent_id = int(node_id_val) params = pan_service.query_client_sub_list( parent_id, self.ref_id) elif "empty" == source: pass else: node_id_val = decrypt_id(node_id) parent_id = int(node_id_val) params = pan_service.query_file_list(parent_id) else: # params = pan_service.query_root_list(self.request.user_id) params.append({ "id": "free_0", "text": PAN_TREE_TXT['free_root'], "data": { "source": "free" }, "children": True, "icon": "folder" }) params.append({ "id": "assets_0", "text": PAN_TREE_TXT['buy_root'], "data": { "source": "assets" }, "children": True, "icon": "folder" }) params.append({ "id": "self_0", "text": PAN_TREE_TXT['self_root'], "data": { "source": "self" }, "children": True, "icon": "folder" }) params.append({ "id": "empty_0", "text": PAN_TREE_TXT['empty_root'], "data": { "source": "empty" }, "children": False, "icon": "file" }) self.to_write_json(params) elif path.endswith("/search"): params = {} self.render('search.html', **params) elif path.endswith("/load"): kw = self.get_body_argument("kw") source = self.get_body_argument("source") print("kw:", kw) print("source:", source) kw = kw.replace(' ', '%') page = self.get_body_argument("page") size = 100 offset = int(page) * size sp: SearchParams = SearchParams.build_params(offset, size) sp.add_must(value=kw) es_dao_fun = es_dao_local if source: sp.add_must(field='source', value=source) es_dao_fun = es_dao_share # es_dao_fun = es_dao_dir es_body = build_query_item_es_body(sp) print("es_body:", json.dumps(es_body)) es_result = es_dao_fun().es_search_exec(es_body) hits_rs = es_result["hits"] total = hits_rs["total"] datas = [_s["_source"] for _s in hits_rs["hits"]] # print("es_result:", es_result) # item_list = DataDao.query_file_list_by_keyword(kw, offset=offset, limit=size) # objs = [object_to_dict(o, FIELDS) for o in item_list] # has_next = len(objs) == size has_next = offset + size < total rs = {"data": datas, "has_next": has_next} # print("rs:", rs) self.to_write_json(rs) elif path.endswith("/finfo"): # item_id = self.get_argument("id") item_fuzzy_id = self.get_argument("id") item_id = int(decrypt_id(item_fuzzy_id)) params = pan_service.query_file(item_id) self.to_write_json(params) elif path.endswith("/readydownload"): fs_id = self.get_argument("fs_id") print("readydownload fs_id:", fs_id) params, share_log, data_item = pan_service.share_folder(fs_id) # sub_params = [] min_size = 6000 # min_size = 60 if data_item.size > min_size: sub_params = pan_service.sub_account_transfer(share_log) result = {"subs": sub_params} else: result = {"master": params} # result = {"master": params, "subs": sub_params} self.to_write_json(result) elif path.endswith("/check_transfer"): transfer_log_id = self.get_argument("id") rs = {} print("transfer_log_id:", transfer_log_id) if transfer_log_id: t = pan_service.recheck_transfer_d_link(int(transfer_log_id)) if t: rs = t self.to_write_json(rs) elif path.endswith("/check_shared_log"): shared_log_id = self.get_argument("id") rs = {} print("shared_log_id:", shared_log_id) if shared_log_id: t = pan_service.recheck_shared_d_link(int(shared_log_id)) if t: rs = t self.to_write_json(rs) elif path.endswith("/sync_used"): pan_account_ids_str = self.get_argument("ids") used_str = self.get_argument("useds") if pan_account_ids_str and used_str: _ids = pan_account_ids_str.split(",") useds = used_str.split(",") params = [] ul = len(useds) for i in range(len(_ids)): _id = _ids[i] if i < ul: used = useds[i] params.append({'id': int(_id), 'used': int(used)}) if params: DataDao.update_pan_account_used(params) self.to_write_json({}) elif path.endswith("/dlink"): item_id = self.get_argument("id") params = pan_service.query_file(item_id) self.render('dlink.html', **params) elif path.endswith("/manage"): pan_id = self.get_argument("panid", "0") params = {'pan_id': pan_id} self.render('ftree.html', **params) elif path.endswith("/helptokens"): res = pan_service.pan_accounts_dict() self.to_write_json(res) elif path.endswith("/syncallnodes"): item_fuzzy_id = self.get_argument("id", None) item_id = int(decrypt_id(item_fuzzy_id)) pan_id = self.get_argument('panid', "0") logger.info("syncallnodes pan_id:{}".format(pan_id)) pan_id = int(pan_id) recursion = self.get_argument("recursion") if recursion == "1": recursion = True else: recursion = False if not item_id: if pan_id: root_item: DataItem = sync_pan_service.fetch_root_item( pan_id) logger.info('root_item:{}'.format( DataItem.to_dict(root_item))) if root_item: item_id = root_item.id else: item_id = sync_pan_service.new_root_item( self.request.user_id, pan_id) else: item_id = 55 item_id = int(item_id) rs = sync_pan_service.sync_from_root(item_id, recursion, pan_id, self.request.user_id) self.to_write_json(rs) elif path.endswith("/synccommunity"): # print("in...:") bd = self.request.body data_obj = json.loads(bd) print('/synccommunity payload:', self.request.user_id) open_service.sync_community_item_to_es(self.request.user_id, data_obj) self.to_write_json({'state': 0}) pass elif path.endswith("/syncstate"): self.release_db = False pan_id = self.get_argument('panid', "0") dir_item_id = sync_pan_service.check_sync_state( pan_id, self.request.user_id) if dir_item_id: self.to_write_json({'state': 1, 'item': dir_item_id}) else: self.to_write_json({'state': 0})
class SaleMenu(QWidget): def __init__(self): super().__init__() self.ui = uic.loadUi("ui/sale_manage.ui") self.pdt = ProductDao() self.sdt = SaleDao() self.ui.table_sale.setColumnCount(7) self.ui.table_order.setColumnCount(3) self.table_order = create_table(table=self.ui.table_order, data=['제품명', '종류', '갯수']) self.table_sale_detail = create_table( table=self.ui.table_sale, data=['제품명', '종류', '판매량', '판매액', '세금', '마진액', '판매 시간']) self.load_sale() self.ui.combo_menu.addItem('all') self.ui.combo_sel_pro.addItem('--select--') self.count = 0 self.nextIdx = 0 self.namelist = [] self.order_list = {} for i in range(len(self.pdt.select_category())): self.ui.combo_menu.addItems(self.pdt.select_category()[i]) self.ui.combo_category.addItem('all') for i in range(len(self.pdt.select_category())): self.ui.combo_category.addItems(self.pdt.select_category()[i]) for i in range(len(self.pdt.select_name())): self.ui.combo_sel_pro.addItems(self.pdt.select_name()[i]) self.ui.btn_insert_menu.clicked.connect(self.ins_menu) self.ui.btn_del_menu.clicked.connect(self.del_menu) self.ui.btn_edit_menu.clicked.connect(self.edit_menu) self.ui.btn_ins_category.clicked.connect(self.category) self.ui.combo_menu.currentIndexChanged.connect(self.select_menu) self.ui.btn_exit.clicked.connect(self.exit) # sale_manage self.ui.tab_product.currentChanged.connect(self.tab_change) self.ui.btn_insert.clicked.connect(self.ins_order) self.ui.combo_category.currentIndexChanged.connect(self.order_category) self.ui.btn_edit.clicked.connect(self.edit_order) self.ui.btn_delete.clicked.connect(self.del_order) self.ui.btn_reset.clicked.connect(self.reset_order) self.ui.btn_ok.clicked.connect(self.ok_order) # select self.ui.btn_select.clicked.connect(self.select_sale_detail) self.ui.btn_init.clicked.connect(self.select_init) self.set_context_menu(self.ui.table_sale) self.set_context_menu_order(self.ui.table_order) self.ui.btn_edit_menu.setEnabled(False) self.ui.btn_edit.setEnabled(False) self.ui.btn_edit_menu.setText('편집시 우클릭') self.ui.btn_edit.setText('편집시 주문 현황 우클릭') self.ui.show() #product manage def ins_menu(self): item_mode = self.ui.combo_menu.currentText() count = 0 if item_mode == 'all': QMessageBox.information(self, '제품 관리', '제품의 종류를 설정해 주세요.', QMessageBox.Ok) count = 1 else: item_code = self.ui.le_pro_code.text().upper() item_name = self.ui.le_pro_name.text() item_price = self.ui.le_pro_price.text() item_margin = self.ui.le_pro_margin.text() check_name = [(item_name.upper(), )] check_code = [(item_code, )] if count == 0: if item_code == '': QMessageBox.information(self, '제품 관리', '코드를 입력해주세요.', QMessageBox.Ok) count = 1 else: if item_name == '': QMessageBox.information(self, '제품 관리', '제품명을 입력해주세요.', QMessageBox.Ok) count = 1 elif check_code == self.pdt.select_check_menu_code(item_code): QMessageBox.information(self, '제품 관리', '코드가 이미 있습니다.', QMessageBox.Ok) count = 1 else: if check_name == self.pdt.select_check_menu_name( item_name): QMessageBox.information(self, '제품 관리', '해당 메뉴가 이미 있습니다.', QMessageBox.Ok) count = 1 elif item_price == '': QMessageBox.information(self, '제품 관리', '가격을 입력해주세요.', QMessageBox.Ok) count = 1 else: if item_margin == '': QMessageBox.information(self, '제품 관리', '마진율을 입력해주세요.', QMessageBox.Ok) count = 1 if count == 0: self.pdt.insert_item(item_code, item_name, item_mode, item_price, item_margin) self.load_pro_all() def del_menu(self): selectionIdxs = self.ui.table_sale.selectedIndexes()[0] item_code = self.ui.table_sale.item(selectionIdxs.row(), 0).text().upper() category = self.ui.combo_menu.currentText() self.pdt.delete_item(item_code) if category == 'all': self.load_pro_all() else: res = list(self.pdt.select_menu(self.ui.combo_menu.currentText())) self.load_pro(res) def edit_menu(self): code = self.ui.le_pro_code.text() category = self.ui.combo_menu.currentText() name = self.ui.le_pro_name.text() price = self.ui.le_pro_price.text() margin = self.ui.le_pro_margin.text() if category == 'all': QMessageBox.information(self, '제품 관리', '제품의 종류 설정해 주세요.', QMessageBox.Ok) else: item_code, item_name, item_price, item_margin = self.pro_create_item( code, name, price, margin) countIdxs = self.ui.table_sale.rowCount() self.ui.table_sale.setItem(countIdxs, 0, item_code) self.ui.table_sale.setItem(countIdxs, 1, item_name) self.ui.table_sale.setItem(countIdxs, 3, item_price) self.ui.table_sale.setItem(countIdxs, 4, item_margin) self.pdt.update_item(name, price, margin, category, code) QMessageBox.information(self, '사용자 관리', '확인', QMessageBox.Ok) self.ui.btn_del_menu.setEnabled(True) self.ui.btn_insert_menu.setEnabled(True) self.ui.btn_edit_menu.setEnabled(False) self.ui.btn_edit_menu.setText('편집시 우클릭') self.ui.le_pro_code.setEnabled(True) self.ui.btn_insert.setEnabled(False) self.ui.btn_ins_category.setEnabled(True) self.ui.btn_ins_category.clicked.connect(self.category) self.ui.le_pro_price.clear() self.ui.le_pro_code.clear() self.ui.le_pro_margin.clear() self.ui.le_pro_name.clear() if category == 'all': self.load_pro_all() else: res = list( self.pdt.select_menu(self.ui.combo_menu.currentText())) self.load_pro(res) def load_pro(self, res): self.ui.table_sale.setRowCount(0) for (code, name, category, price, marginrate) in res: item_code, item_name, item_category, item_price, item_marginrate = self.pro_create_item( code, name, category, price, marginrate, ) nextIdx = self.ui.table_sale.rowCount() self.ui.table_sale.insertRow(nextIdx) self.ui.table_sale.setItem(nextIdx, 0, item_code) self.ui.table_sale.setItem(nextIdx, 1, item_name) self.ui.table_sale.setItem(nextIdx, 2, item_category) self.ui.table_sale.setItem(nextIdx, 3, item_price) self.ui.table_sale.setItem(nextIdx, 4, item_marginrate) def pro_create_item(self, code, name, price, marginrate, category): item_code = QTableWidgetItem() item_code.setTextAlignment(Qt.AlignCenter) item_code.setData(Qt.DisplayRole, code) item_name = QTableWidgetItem() item_name.setTextAlignment(Qt.AlignCenter) item_name.setData(Qt.DisplayRole, name) item_category = QTableWidgetItem() item_category.setTextAlignment(Qt.AlignCenter) item_category.setData(Qt.DisplayRole, category) item_price = QTableWidgetItem() item_price.setTextAlignment(Qt.AlignRight) if price != None: item_price.setData(Qt.DisplayRole, format(int(price), ',d')) else: item_price.setData(Qt.DisplayRole, '-') item_marginrate = QTableWidgetItem() item_marginrate.setTextAlignment(Qt.AlignRight) if marginrate != None: item_marginrate.setData(Qt.DisplayRole, (marginrate)) else: item_marginrate.setData(Qt.DisplayRole, '-') return item_code, item_name, item_category, item_price, item_marginrate def select_menu(self): if self.ui.combo_menu.currentText() == 'all': self.load_pro_all() else: res = list(self.pdt.select_menu(self.ui.combo_menu.currentText())) self.load_pro(res) def load_pro_all(self): self.ui.table_sale.setRowCount(0) res = self.pdt.select_menu2() for (code, name, category, price, marginrate) in res: item_code, item_name, item_category, item_price, item_marginrate = self.pro_create_item( code, name, category, price, marginrate) nextIdx = self.ui.table_sale.rowCount() self.ui.table_sale.insertRow(nextIdx) self.ui.table_sale.setItem(nextIdx, 0, item_code) self.ui.table_sale.setItem(nextIdx, 1, item_name) self.ui.table_sale.setItem(nextIdx, 2, item_category) self.ui.table_sale.setItem(nextIdx, 3, item_price) self.ui.table_sale.setItem(nextIdx, 4, item_marginrate) def set_context_menu(self, tv): tv.setContextMenuPolicy(Qt.ActionsContextMenu) update_action = QAction('수정', tv) tv.addAction(update_action) update_action.triggered.connect(self.update) def update(self): selectionIdxs = self.ui.table_sale.selectedIndexes()[0] QMessageBox.information(self, '제품 관리', '제품의 종류 설정해 주세요.', QMessageBox.Ok) returnIdxs1 = self.ui.table_sale.item(selectionIdxs.row(), 0).text() returnIdxs2 = self.ui.table_sale.item(selectionIdxs.row(), 1).text() if self.ui.table_sale.item(selectionIdxs.row(), 3).text().count(',') >= 1: returnIdxs3 = self.ui.table_sale.item( selectionIdxs.row(), 3).text().split(',')[0] + self.ui.table_sale.item( selectionIdxs.row(), 3).text().split(',')[1] else: returnIdxs3 = self.ui.table_sale.item(selectionIdxs.row(), 3).text() returnIdxs4 = self.ui.table_sale.item(selectionIdxs.row(), 3).text() self.ui.le_pro_code.setText(returnIdxs1) self.ui.le_pro_name.setText(returnIdxs2) self.ui.le_pro_price.setText(returnIdxs3) self.ui.le_pro_margin.setText(returnIdxs4) self.ui.btn_insert.setEnabled(False) self.ui.btn_del_menu.setEnabled(False) self.ui.btn_insert_menu.setEnabled(False) self.ui.btn_edit_menu.setEnabled(True) self.ui.btn_edit_menu.setText('편집') self.ui.le_pro_code.setEnabled(False) self.ui.btn_ins_category.setEnabled(False) def category(self): self.ca = Category() self.ca.ui.btn_ins_category.clicked.connect(self.init_category) self.ca.ui.btn_del_category.clicked.connect(self.init_category2) self.ca.ui.btn_edit_category.clicked.connect(self.init_category) def init_category(self): cdt = CateDao() for i in range(len(cdt.select_item()) + 1): self.ui.combo_menu.removeItem(0) self.ui.combo_menu.addItem('all') for i in range(len(cdt.select_item())): self.ui.combo_menu.addItems(self.pdt.select_category()[i]) self.load_pro_all() def init_category2(self): cdt = CateDao() for i in range(len(cdt.select_item()) + 2): self.ui.combo_menu.removeItem(0) self.ui.combo_menu.addItem('all') for i in range(len(cdt.select_item())): self.ui.combo_menu.addItems(self.pdt.select_category()[i]) self.load_pro_all() def load_order(self): index = self.ui.tab_product.currentIndex() if self.ui.tab_product.tabText(index) == '제품 관리 (&1)': self.ui.table_sale.setColumnCount(5) self.table_sale = create_table( table=self.ui.table_sale, data=['제품코드', '제품명', '종류', '제품가격', '마진율(%)']) self.load_pro_all() self.ui.table_order.hide() self.ui.lb_order.hide() elif self.ui.tab_product.tabText(index) == '판매 관리 (&2)': self.ui.table_sale.setColumnCount(7) self.table_sale_detail = create_table( table=self.ui.table_sale, data=['제품명', '종류', '판매량', '판매액', '세금', '마진액', '판매 시간']) self.ui.table_order.setColumnCount(3) self.table_sale_order = create_table(table=self.ui.table_order, data=['제품명', '종류', '갯수']) self.ui.table_order.show() self.ui.lb_order.show() self.load_sale() elif self.ui.tab_product.tabText(index) == '검색 (&3)': self.ui.table_sale.setColumnCount(4) self.table_select = create_table( table=self.ui.table_sale, data=['제품명', '판매량', '판매가', '판매시간']) self.ui.table_order.hide() self.ui.lb_order.hide() self.load_select() def order_category(self): self.init_combo_pro_name() category = self.ui.combo_category.currentText() res = list(self.pdt.select_order_name(category)) for i in range(len(self.pdt.select_order_name(category))): self.ui.combo_pro_name.addItems(res[i]) self.count += 1 def ins_order(self): name = self.ui.combo_pro_name.currentText() category = self.pdt.select_order_name_category(name) category = str(category).strip(("[('")).strip("',)]") cnt = self.ui.le_salecnt.text() if name in self.order_list.keys(): self.order_list[name] = int(self.order_list[name]) + int(cnt) else: self.order_list[name] = int(cnt) self.namelist.append(name) item_name = QTableWidgetItem() item_name.setTextAlignment(Qt.AlignCenter) item_name.setData(Qt.DisplayRole, name) item_category = QTableWidgetItem() item_category.setTextAlignment(Qt.AlignCenter) item_category.setData(Qt.DisplayRole, category) item_cnt = QTableWidgetItem() item_cnt.setTextAlignment(Qt.AlignRight) item_cnt.setData(Qt.DisplayRole, cnt) self.ui.table_order.insertRow(self.nextIdx) self.ui.table_order.setItem(self.nextIdx, 0, item_name) self.ui.table_order.setItem(self.nextIdx, 1, item_category) self.ui.table_order.setItem(self.nextIdx, 2, item_cnt) self.nextIdx += 1 self.ui.le_salecnt.clear() def init_combo_pro_name(self): for i in range(self.count): self.ui.combo_pro_name.removeItem(0) self.count = 0 def tab_change(self): self.init_combo_pro_name() for i in range(len(self.pdt.select_category()) + 1): self.ui.combo_category.removeItem(0) self.ui.combo_category.addItem('--select--') for i in range(len(self.pdt.select_category())): self.ui.combo_category.addItems(self.pdt.select_category()[i]) self.count += 1 self.load_order() def edit_order(self): try: self.ui.btn_edit.setText('편집시 우클릭') self.ui.btn_ok.setEnabled(True) self.ui.btn_reset.setEnabled(True) self.ui.btn_delete.setEnabled(True) self.ui.btn_exit.setEnabled(True) self.ui.btn_insert.setEnabled(True) self.ui.btn_edit.setEnabled(False) selectionIdxs = self.ui.table_order.selectedIndexes()[0] cnt = self.ui.le_salecnt.text() item_cnt = QTableWidgetItem() item_cnt.setTextAlignment(Qt.AlignCenter) item_cnt.setData(Qt.DisplayRole, int(cnt)) self.ui.table_order.setItem(selectionIdxs.row(), 2, item_cnt) except Error as err: print(err) def del_order(self): selectionIdxs = self.ui.table_order.selectedIndexes()[0] self.ui.table_order.removeRow(selectionIdxs.row()) def reset_order(self): for i in range(self.nextIdx): self.ui.table_order.removeRow(0) self.nextIdx = 0 def load_sale(self): self.ui.table_sale.setRowCount(0) res = self.sdt.select_sale_table() for (name, category, cnt, sale_price, tax, margin_price, time) in res: item_name, item_category, item_cnt, item_sale_price, item_tax, item_margin_price, item_time = self.sale_create_item( name, category, cnt, sale_price, tax, margin_price, time) nextIdx = self.ui.table_sale.rowCount() self.ui.table_sale.insertRow(nextIdx) self.ui.table_sale.setItem(nextIdx, 0, item_name) self.ui.table_sale.setItem(nextIdx, 1, item_category) self.ui.table_sale.setItem(nextIdx, 2, item_cnt) self.ui.table_sale.setItem(nextIdx, 3, item_sale_price) self.ui.table_sale.setItem(nextIdx, 4, item_tax) self.ui.table_sale.setItem(nextIdx, 5, item_margin_price) self.ui.table_sale.setItem(nextIdx, 6, item_time) def sale_create_item(self, name, category, cnt, sale_price, tax, margin_price, time): item_name = QTableWidgetItem() item_name.setTextAlignment(Qt.AlignCenter) item_name.setData(Qt.DisplayRole, name) item_category = QTableWidgetItem() item_category.setTextAlignment(Qt.AlignCenter) item_category.setData(Qt.DisplayRole, category) item_name = QTableWidgetItem() item_name.setTextAlignment(Qt.AlignCenter) item_name.setData(Qt.DisplayRole, name) item_cnt = QTableWidgetItem() item_cnt.setTextAlignment(Qt.AlignRight) if cnt != None: item_cnt.setData(Qt.DisplayRole, format(int(cnt), ',d')) else: item_cnt.setData(Qt.DisplayRole, '-') item_sale_price = QTableWidgetItem() item_sale_price.setTextAlignment(Qt.AlignRight) item_sale_price.setData(Qt.DisplayRole, format(int(sale_price), ',d')) item_tax = QTableWidgetItem() item_tax.setTextAlignment(Qt.AlignRight) item_tax.setData(Qt.DisplayRole, format(int(tax), ',d')) item_margin_price = QTableWidgetItem() item_margin_price.setTextAlignment(Qt.AlignRight) item_margin_price.setData(Qt.DisplayRole, format(int(margin_price), ',d')) item_time = QTableWidgetItem() item_time.setTextAlignment(Qt.AlignCenter) item_time.setData(Qt.DisplayRole, time) return item_name, item_category, item_cnt, item_sale_price, item_tax, item_margin_price, item_time def set_context_menu_order(self, tv): tv.setContextMenuPolicy(Qt.ActionsContextMenu) update_action = QAction('수정', tv) tv.addAction(update_action) update_action.triggered.connect(self.update_order) def update_order(self, tv): selectionIdxs = self.ui.table_order.selectedIndexes()[0] returnIdxs = self.ui.table_order.item(selectionIdxs.row(), 2).text() self.ui.le_salecnt.setText(returnIdxs) self.ui.btn_ok.setEnabled(False) self.ui.btn_reset.setEnabled(False) self.ui.btn_insert.setEnabled(False) self.ui.btn_delete.setEnabled(False) self.ui.btn_exit.setEnabled(False) self.ui.btn_edit.setText('편집') self.ui.btn_edit.setEnabled(True) def ok_order(self): self.ui.table_order.setRowCount(0) for i in range(len(self.namelist)): self.sdt.insert_item(self.namelist[i], self.order_list[self.namelist[i]]) self.ui.le_salecnt.clear() self.nextIdx = 0 self.load_sale() # tab index = 3 def load_select(self): self.ui.table_sale.setRowCount(0) seldt = SelDao() res = seldt.select_item_where() for (name, cnt, sale_price, date) in res: item_name, item_cnt, item_sale_price, item_date = self.select_create_item( name, cnt, sale_price, date) nextIdx = self.ui.table_sale.rowCount() self.ui.table_sale.insertRow(nextIdx) self.ui.table_sale.setItem(nextIdx, 0, item_name) self.ui.table_sale.setItem(nextIdx, 1, item_cnt) self.ui.table_sale.setItem(nextIdx, 2, item_sale_price) self.ui.table_sale.setItem(nextIdx, 3, item_date) def select_create_item(self, name, cnt, sale_price, date): item_name = QTableWidgetItem() item_name.setTextAlignment(Qt.AlignCenter) item_name.setData(Qt.DisplayRole, name) item_cnt = QTableWidgetItem() item_cnt.setTextAlignment(Qt.AlignCenter) item_cnt.setData(Qt.DisplayRole, format(int(cnt), 'd')) item_sale_price = QTableWidgetItem() item_sale_price.setTextAlignment(Qt.AlignRight) item_sale_price.setData(Qt.DisplayRole, format(int(sale_price), ',d')) item_date = QTableWidgetItem() item_date.setTextAlignment(Qt.AlignRight) item_date.setData(Qt.DisplayRole, date) return item_name, item_cnt, item_sale_price, item_date def select_sale_detail(self): name = self.ui.combo_sel_pro.currentText() seldt = SelDao() if name == '--select--': name = '' min_price = self.ui.le_min_price.text() max_price = self.ui.le_max_price.text() min_date = self.ui.le_min_date_y.text( ) + '-' + self.ui.le_min_date_m.text( ) + '-' + self.ui.le_min_date_d.text() max_date = self.ui.le_max_date_y.text( ) + '-' + self.ui.le_max_date_m.text( ) + '-' + self.ui.le_max_date_d.text() if min_date == '--': min_date = '' if max_date == '--': max_date = '' self.ui.table_sale.setRowCount(0) res = seldt.select_item_where(name, min_price, max_price, min_date, max_date) for (name, cnt, sale_price, date) in res: item_name, item_cnt, item_sale_price, item_date = self.select_create_item( name, cnt, sale_price, date) nextIdx = self.ui.table_sale.rowCount() self.ui.table_sale.insertRow(nextIdx) self.ui.table_sale.setItem(nextIdx, 0, item_name) self.ui.table_sale.setItem(nextIdx, 1, item_cnt) self.ui.table_sale.setItem(nextIdx, 2, item_sale_price) self.ui.table_sale.setItem(nextIdx, 3, item_date) def select_init(self): self.load_select() self.ui.le_min_price.setText('0') self.ui.le_max_price.clear() self.ui.le_min_date_d.clear() self.ui.le_min_date_m.clear() self.ui.le_min_date_y.clear() self.ui.le_max_date_d.clear() self.ui.le_max_date_m.clear() self.ui.le_max_date_y.clear() def exit(self): self.ui.close()
class Main(QtWidgets.QMainWindow): def __init__(self, *args, **kwargs): super().__init__() self.pdt = ProductDao() self.idt = IDDao() self.sdt = SaleDao() self.ui = uic.loadUi("ui/main_menu.ui", self) self.month_count = 14 self.graphcount = 0 # combobox self.combobox_setting() # graph self.graph() # table self.table_pro = create_table(table=self.ui.table_pro, data=['제품코드', '제품명', '종류', '제품가격', '마진율(%)']) self.sale_pro = create_table(table=self.ui.table_sale, data=['제품명', '판매량', '판매금액', '판매일']) self.load_pro_all() self.load_sale_all() self.ui.btn_out.clicked.connect(self.exit) # logout self.ui.btn_manage.clicked.connect(self.manage) self.ui.btn_sale.clicked.connect(self.sale_manage) self.ui.btn_exit.clicked.connect(self.exit) self.ui.btn_set.clicked.connect(self.user_setting) self.ui.combo_menu.currentIndexChanged.connect(self.select_menu) self.ui.combo_sale_year.currentIndexChanged.connect(self.select_sale) self.ui.combo_sale_month.currentIndexChanged.connect(self.select_month) self.ui.show() # button ui def manage(self): self.ms = management_system() self.ms.ui.lbl_ID.setText(self.ui.lbl_ID.text()) self.ms.ui.lbl_mode.setText(list(self.idt.select_item(self.ui.lbl_ID.text()))[0][1]) self.ms.check_grant() def sale_manage(self): self.sale = SaleMenu() grant = [] for i in range(len(IDDao().select_grant('admin'))): a = IDDao().select_grant(self.ui.lbl_mode.text()).count(IDDao().select_grant('admin')[i]) grant.append(a) if grant[2] == 0: self.sale.ui.tab_product.removeTab(0) def logout(self): self.ui.close() def exit(self): self.ui.close() def combobox_setting(self): self.ui.combo_menu.addItem('all') self.ui.combo_sale_year.addItem('all') self.ui.combo_sale_month.addItem('년도를 선택해주세요') for i in range(len(self.pdt.select_category())): self.ui.combo_menu.addItems(self.pdt.select_category()[i]) for i in range(len(self.sdt.select_item(True))): self.ui.combo_sale_year.addItems(tuple(self.sdt.select_item(True)[i])) # product table def select_menu(self): if self.ui.combo_menu.currentText() == 'all': self.load_pro_all() else: res = list(self.pdt.select_menu(self.ui.combo_menu.currentText())) self.load_pro(res) def load_pro(self, res): self.ui.table_pro.setRowCount(0) for (code, name, price, marginrate, category) in res: item_code, item_name, item_price, item_marginrate, item_category = self.pro_create_item(code, name, price, marginrate, category) nextIdx = self.ui.table_pro.rowCount() self.ui.table_pro.insertRow(nextIdx) self.ui.table_pro.setItem(nextIdx, 0, item_code) self.ui.table_pro.setItem(nextIdx, 1, item_name) self.ui.table_pro.setItem(nextIdx, 2, item_category) self.ui.table_pro.setItem(nextIdx, 3, item_price) self.ui.table_pro.setItem(nextIdx, 4, item_marginrate) def pro_create_item(self, code, name, price, marginrate, category): item_code = QTableWidgetItem() item_code.setTextAlignment(Qt.AlignCenter) item_code.setData(Qt.DisplayRole, code) item_name = QTableWidgetItem() item_name.setTextAlignment(Qt.AlignCenter) item_name.setData(Qt.DisplayRole, name) item_price = QTableWidgetItem() item_price.setTextAlignment(Qt.AlignRight) if price != None: item_price.setData(Qt.DisplayRole, format(int(price), ',d')) else: item_price.setData(Qt.DisplayRole, '-') item_marginrate = QTableWidgetItem() item_marginrate.setTextAlignment(Qt.AlignRight) if marginrate != None: item_marginrate.setData(Qt.DisplayRole, (marginrate)) else: item_marginrate.setData(Qt.DisplayRole, '-') item_category = QTableWidgetItem() item_category.setTextAlignment(Qt.AlignCenter) item_category.setData(Qt.DisplayRole, category) return item_code, item_name, item_price, item_marginrate, item_category def load_pro_all(self): self.ui.table_pro.setRowCount(0) res = self.pdt.select_menu2() for (code, name, price, marginrate, category) in res: item_code, item_name, item_price, item_marginrate, item_category = self.pro_create_item(code, name, price, marginrate, category) nextIdx = self.ui.table_pro.rowCount() self.ui.table_pro.insertRow(nextIdx) self.ui.table_pro.setItem(nextIdx, 0, item_code) self.ui.table_pro.setItem(nextIdx, 1, item_name) self.ui.table_pro.setItem(nextIdx, 2, item_category) self.ui.table_pro.setItem(nextIdx, 3, item_price) self.ui.table_pro.setItem(nextIdx, 4, item_marginrate) # sale_table def sale_create_item(self, name, salecnt, sale_price, date): item_name = QTableWidgetItem() item_name.setTextAlignment(Qt.AlignCenter) item_name.setData(Qt.DisplayRole, name) item_salecnt = QTableWidgetItem() item_salecnt.setTextAlignment(Qt.AlignCenter) item_salecnt.setData(Qt.DisplayRole, salecnt) item_sale_price = QTableWidgetItem() item_sale_price.setTextAlignment(Qt.AlignRight) item_sale_price.setData(Qt.DisplayRole, format(int(sale_price), ',d')) item_date = QTableWidgetItem() item_date.setTextAlignment(Qt.AlignCenter) item_date.setData(Qt.DisplayRole, date) return item_name, item_salecnt, item_sale_price, item_date def load_sale_all(self): self.ui.table_sale.setRowCount(0) res = self.sdt.select_item() for (name, salecnt, sale_price, date) in res: item_name, item_salecnt, item_sale_price, item_date = self.sale_create_item(name, salecnt, sale_price, date) nextIdx = self.ui.table_sale.rowCount() self.ui.table_sale.insertRow(nextIdx) self.ui.table_sale.setItem(nextIdx, 0, item_name) self.ui.table_sale.setItem(nextIdx, 1, item_salecnt) self.ui.table_sale.setItem(nextIdx, 2, item_sale_price) self.ui.table_sale.setItem(nextIdx, 3, item_date) def select_sale(self): if self.ui.combo_sale_year.currentText() == 'all': for i in range(0, self.month_count): self.ui.combo_sale_month.removeItem(0) self.ui.combo_sale_month.addItem('년도를 선택해주세요') self.load_sale_all() else: res = list(self.sdt.select_date(self.ui.combo_sale_year.currentText())) for i in range(0, self.month_count): self.ui.combo_sale_month.removeItem(0) self.ui.combo_sale_month.addItem('all') self.load_sale(res) for i in range(len(self.sdt.select_date(self.ui.combo_sale_year.currentText(), 2))): self.ui.combo_sale_month.addItems(self.sdt.select_date(self.ui.combo_sale_year.currentText(), 2)[i]) def load_sale(self, res): self.ui.table_sale.setRowCount(0) for (name, salecnt, sale_price, date) in res: item_name, item_salecnt, item_sale_price, item_date = self.sale_create_item(name, salecnt, sale_price, date) nextIdx = self.ui.table_sale.rowCount() self.ui.table_sale.insertRow(nextIdx) self.ui.table_sale.setItem(nextIdx, 0, item_name) self.ui.table_sale.setItem(nextIdx, 1, item_salecnt) self.ui.table_sale.setItem(nextIdx, 2, item_sale_price) self.ui.table_sale.setItem(nextIdx, 3, item_date) def select_month(self, res): if self.ui.combo_sale_month.currentText() is None or self.ui.combo_sale_month.currentText() == 'all': self.load_sale(self.sdt.select_date(self.ui.combo_sale_year.currentText())) else: date = self.sdt.select_date( self.ui.combo_sale_year.currentText() + ' ' + self.ui.combo_sale_month.currentText(), 3) self.load_sale(date) # 계정관리 def user_setting(self): self.set = Setting() self.set.ui.lbl_id.setText(self.ui.lbl_ID.text()) self.set.ui.lbl_name.setText(self.idt.select_item_id(self.ui.lbl_ID.text())[0][0]) self.set.ui.lbl_mode.setText(self.idt.select_item_id(self.ui.lbl_ID.text())[0][1]) # graph def graph(self): # 글꼴 mpl.rcParams['font.family'] = 'NanumGothic' mpl.rcParams['axes.unicode_minus'] = False # data name, price = self.sdt.select_graph() fig, ax1 = plt.subplots() # plot self.plotWidget = FigureCanvas(fig) ax1.set_title("커피 판매량") self.lay = QtWidgets.QVBoxLayout(self.ui.content_plot) self.lay.addWidget(self.plotWidget) ax1.pie(price, labels=name, autopct=lambda pct: self.func(pct, price), shadow=False, startangle=90, radius=1.0) def func(self, pct, data): absolute = round(int(pct * float(math.ceil(np.sum(data)))) / 100) return "{:.1f}%\n({:,d})".format(pct, absolute)
def all_ui(): app = QApplication([]) # 모든 PyQt5 어플리케이션은 어플리케이션 객체를 생성해야 합 dao = ProductDao() ex = ProductTableViewFromUI(dao) app.exec_()
def check_file_authorized(self, user_ref_id, item_id, pids, tag): st = 0 p_fuzzy_id_list = pids.split(",") logger.info("p_fuzzy_id_list:{}".format(p_fuzzy_id_list)) def check_mid_parent(perent_item_id): pos = len(p_fuzzy_id_list) - 1 check_pass = True while pos > 0: pos = pos - 1 _item_id = decrypt_id(p_fuzzy_id_list[pos]) if DataDao.check_data_item_exists_by_parent( _item_id, perent_item_id): perent_item_id = _item_id else: check_pass = False break return check_pass, perent_item_id if "asset" == tag: asset_fuzzy_id = p_fuzzy_id_list[-1] asset_id = int(decrypt_id(asset_fuzzy_id)) assets: Assets = ProductDao.fetch_assets_by_ref_id_assets_id( user_ref_id, asset_id) if assets and assets.pro_no: p_item_id = decrypt_id(assets.pro_no) # print("p_item_id:", p_item_id) check_pass, perent_item_id = check_mid_parent(p_item_id) if check_pass: if p_item_id != item_id: if not DataDao.check_data_item_exists_by_parent( item_id, perent_item_id): st = -2 else: st = -2 pass else: st = -2 # 未购买该资源 # print("asset_fuzzy_id:", asset_fuzzy_id) elif "free" == tag: free_item_fuzzy_id = p_fuzzy_id_list[-1] # print("free_item_fuzzy_id:", free_item_fuzzy_id) free_item_id = int(decrypt_id(free_item_fuzzy_id)) isok = DataDao.check_free_root_files_exist(str(free_item_id), "local") if isok: p_item_id = free_item_id check_pass, perent_item_id = check_mid_parent(p_item_id) if check_pass: if p_item_id != item_id: if not DataDao.check_data_item_exists_by_parent( item_id, perent_item_id): st = -2 else: st = -2 pass else: st = -2 # 未购买该资源 elif "self" == tag: if not ClientDataDao.check_data_item_exists_by_ref_id_id( user_ref_id, item_id): st = -10 else: st = -10 return st
def get_item_form_le_updatepdt(self, le_code, le_name): pdt = ProductDao() code = le_code name = le_name pdt.update_product(name, code) return self.create_item(code, name)
def get_item_form_le_addpdt(self, le_code, le_name): pdt = ProductDao() code = le_code name = le_name pdt.insert_product(code, name) return self.create_item(code, name)
def test_instance(self): prod_dao = ProductDao() assert isinstance(prod_dao, ProductDao)
def test_read_all(self): result = ProductDao().read_all() assert isinstance(result, list)
def __init__(self): self.__dao = ProductDao() self.__model_type = Product super().__init__(self.__dao, self.__model_type)
import datetime from flask import Blueprint, request, jsonify from dao.product_dao import ProductDao from logger import api_logger product_blue = Blueprint('product_blue', __name__) dao = ProductDao() #全部的产品 @product_blue.route('/all_pro/', methods=('POST', 'GET')) def show_pro(): datas = [] all_prouductstyles = dao.all_productstyles() for prouductstyle in all_prouductstyles: data = {} data['productBigId'] = prouductstyle['productBigId'] data['productBigName'] = prouductstyle['productBigName'] all_prouducts = dao.all_products(data['productBigId']) data['pruduct_info'] = all_prouducts datas.append(data) return jsonify(datas) #每种产品的出借记录 @product_blue.route('/lendrecords/', methods=('POST', ))