Esempio n. 1
0
    def button_save_click(self, evt):
        attrName = self.tc_attrName.GetValue()
        if attrName.strip() == '':
            wx.MessageBox(u'请输入属性名称', u'错误', wx.OK | wx.ICON_ERROR)
            return

        productId = self.product["productId"]
        attrId = None
        if self.attr:
            attrId = self.attr["attrId"]

        if IsAttrNameExist(productId, attrId, attrName):
            wx.MessageBox(u'属性名称已存在,请检查', u'错误', wx.OK | wx.ICON_ERROR)
            return

        attrValue = self.tc_attrValue.GetValue()
        if attrValue.strip() == '':
            wx.MessageBox(u'请输入属性值', u'错误', wx.OK | wx.ICON_ERROR)
            return

        attrRemark = self.tc_attrRemark.GetValue()

        if self.attr:
            db = sqliteUtil.EasySqlite()
            db.execute(
                "update product_attr set attr_name = ?, attr_value = ?, remark = ?, utime = datetime('now') where attr_id = ?",
                [attrName, attrValue, attrRemark, attrId])
        else:
            db = sqliteUtil.EasySqlite()
            db.execute(
                "insert into product_attr(product_id, attr_name, attr_value, remark, sort_no, ctime, cby, utime, uby) values(?, ?, ?, ?, (select ifnull(max(sort_no),0)+1 from product_attr where product_id = ?),datetime('now'),'',datetime('now'),'')",
                [productId, attrName, attrValue, attrRemark, productId])

        self.EndModal(wx.ID_OK)
Esempio n. 2
0
    def button_add_click(self, evt):
        shId = self.tc_shId.GetValue()
        if shId.strip() == '':
            wx.MessageBox(u'请输入仓库编号', u'错误', wx.OK | wx.ICON_ERROR)
            return
        if IsSHExist(shId):
            wx.MessageBox(u'仓库编号已存在,请检查', u'错误', wx.OK | wx.ICON_ERROR)
            return

        shName = self.tc_shName.GetValue()
        if shName.strip() == '':
            wx.MessageBox(u'请输入仓库名称', u'错误', wx.OK | wx.ICON_ERROR)
            return

        shAddr = self.tc_addr.GetValue()
        if shAddr.strip() == '':
            wx.MessageBox(u'请输入仓库地址', u'错误', wx.OK | wx.ICON_ERROR)
            return

        remark = self.tc_remark.GetValue()

        db = sqliteUtil.EasySqlite()
        db.execute(
            "insert into storehouse(sh_id, sh_name, sh_addr, remark, status, ctime, cby, utime, uby) values(?, ?, ?, ?, 1, datetime('now'),'',datetime('now'),'')",
            [shId, shName, shAddr, remark])
        self.EndModal(wx.ID_OK)
Esempio n. 3
0
    def button_del_click(self, evt):
        rows = self.m_grid1.GetCheckedRows()
        if not rows:
            wx.MessageBox(u'请勾选要删除的供应商', u'错误', wx.OK | wx.ICON_ERROR)
            return

        res = wx.MessageBox(u'确认要删除勾选的' + str(len(rows)) + '条数据吗', u'提示', wx.YES_NO | wx.ICON_INFORMATION)
        if res == wx.NO:
            return
        datas = self.m_grid1.GetGridData(rows=rows)
        sql = "delete from supplier where supplier_id in ("

        for index, data in enumerate(datas):
            id = int(data["supplierId"].replace("S", ""))
            sql += " " + str(id)
            if index < len(datas) - 1:
                sql += ","
        sql += ")"

        # 执行删除
        db = sqliteUtil.EasySqlite()
        db.execute(sql)

        # 刷新table
        rows.sort(reverse=True)
        for row in rows:
            self.m_grid1.DeleteRows(pos=row)
Esempio n. 4
0
    def button_del_click(self, evt):
        rows = self.m_grid1.GetCheckedRows()
        if not rows:
            wx.MessageBox(u'请勾选要删除的库位', u'错误', wx.OK | wx.ICON_ERROR)
            return

        res = wx.MessageBox(u'确认要删除勾选的' + str(len(rows)) + '条数据吗', u'提示', wx.YES_NO | wx.ICON_INFORMATION)
        if res == wx.NO:
            return
        datas = self.m_grid1.GetGridData(rows=rows)
        sql = "delete from storehouse_location where sl_id in ("

        for index, data in enumerate(datas):
            sql += " '" + data["slId"] + "'"
            if index < len(datas) - 1:
                sql += ","
        sql += ")"

        # 执行删除
        db = sqliteUtil.EasySqlite()
        db.execute(sql)

        # 刷新table
        rows.sort(reverse=True)
        for row in rows:
            self.m_grid1.DeleteRows(pos=row)
Esempio n. 5
0
    def DrawList(self):
        self.list.DeleteAllItems()

        sql = "select attach_id as attachId, " \
              "product_id as productId, " \
              "attach_name as attachName, " \
              "attach_path as attachPath, " \
              "attach_size as attachSize, " \
              "remark as remark, " \
              "ctime, " \
              "cby, " \
              "utime, " \
              "uby " \
              "from product_attach where product_id = ? order by ctime desc"
        print(sql)
        db = sqliteUtil.EasySqlite()
        result = db.execute(sql, str(self.data["productId"]))

        self.product_attach = result
        if result:
            for idx, data in enumerate(result):
                index = self.list.InsertItem(idx, data["attachName"])
                self.list.SetItem(index, 1, data["attachSize"])
                self.list.SetItem(index, 2, data["ctime"])
                self.list.SetItem(index, 3, data["remark"])
Esempio n. 6
0
    def button_update_click(self, evt):
        productCategory = GetDicTypeByName(
            self.page1.product_category_dict,
            self.page1.choice_productCategoryName.GetStringSelection())
        productCode = self.page1.tc_productCode.GetValue()
        if productCode.strip() == '':
            wx.MessageBox(u'请输入商品编码', u'错误', wx.OK | wx.ICON_ERROR)
            return

        if IsProductCodeExist(self.data["productId"], productCode):
            wx.MessageBox(u'商品编码已存在,请检查', u'错误', wx.OK | wx.ICON_ERROR)
            return

        productName = self.page1.tc_productName.GetValue()
        if productName.strip() == '':
            wx.MessageBox(u'请输入商品名称', u'错误', wx.OK | wx.ICON_ERROR)
            return
        productDesc = self.page1.tc_productDesc.GetValue()
        remark = self.page1.tc_remark.GetValue()

        db = sqliteUtil.EasySqlite()
        db.execute(
            "update product set product_code = ?, product_name = ?, product_desc = ?, product_category = ?, remark = ?, utime = datetime('now') where product_id = ?",
            [
                productCode, productName, productDesc, productCategory, remark,
                self.data["productId"]
            ])
        self.EndModal(wx.ID_OK)
Esempio n. 7
0
 def button_add_click(self, evt):
     dlg = StoreHouseLocationDialog(None, title="新增库位信息")
     res = dlg.ShowModal()
     if res == wx.ID_OK:
         db = sqliteUtil.EasySqlite()
         result = db.execute(self.GenQuerySql(offset=0, pageSize=1))
         self.m_grid1.InsertRows(data=result)
     dlg.Destroy()
Esempio n. 8
0
def IsProductCodeExist(productId, productCode):
    sql = "select 1 from product where product_code = '" + productCode + "'"
    if productId:
        sql += " and product_id != " + str(productId)

    db = sqliteUtil.EasySqlite()
    result = db.execute(sql)

    return result
Esempio n. 9
0
def GetDicTypeDict():
    dic = {}
    db = sqliteUtil.EasySqlite()
    result = db.execute(
        "select dic_key as key, dic_value as value from sys_dictionary where dic_type = ? order by dic_key",
        [DIC_TYPE_VALUE])
    for e in result:
        dic[e["key"]] = e["value"]

    return dic
Esempio n. 10
0
def GetSHDict():
    dic = {}
    db = sqliteUtil.EasySqlite()
    result = db.execute(
        " select t1.sh_id as key, t1.sh_id || '-' || (case when t1.status = 1 then t1.sh_name else t1.sh_name || '(失效)' end) as value "
        " from storehouse t1 "
        " order by t1.ctime desc")
    for e in result:
        dic[e["key"]] = e["value"]

    return dic
Esempio n. 11
0
    def button_search_click(self, evt):
        name = self.supplier_name_text.GetValue()
        phone = self.supplier_phone_text.GetValue()

        if name.strip() == '':
            name = None
        if phone.strip() == '':
            phone = None

        db = sqliteUtil.EasySqlite()
        result = db.execute(self.GenQuerySql(supplierName=name, supplierPhone=phone))
        self.m_grid1.ReDrawTable(result)
Esempio n. 12
0
    def button_search_click(self, evt):
        id = self.sh_id_text.GetValue()
        name = self.sh_name_text.GetValue()

        if id.strip() == '':
            id = None

        if name.strip() == '':
            name = None

        db = sqliteUtil.EasySqlite()
        result = db.execute(self.GenQuerySql(shId=id, shName=name))
        self.m_grid1.ReDrawTable(result)
Esempio n. 13
0
 def button_add_click(self, evt):
     name = self.page1.tc_name.GetValue()
     if name.strip() == '':
         wx.MessageBox(u'请输入供应商名称', u'错误', wx.OK | wx.ICON_ERROR)
         return
     addr = self.page1.tc_addr.GetValue()
     phone = self.page1.tc_phone.GetValue()
     email = self.page1.tc_email.GetValue()
     remark = self.page1.tc_remark.GetValue()
     db = sqliteUtil.EasySqlite()
     db.execute(
         "insert into supplier(supplier_name, supplier_addr, phone_number, email, remark, ctime, cby, utime, uby) values('" + name + "','" + addr + "','" + phone + "','" + email + "','" + remark + "',datetime('now'),'',datetime('now'),'')")
     self.EndModal(wx.ID_OK)
Esempio n. 14
0
def IsAttrNameExist(productId, attrId, attrName):
    sql = "select 1 from product_attr where attr_name = '" + attrName + "'"

    if productId:
        sql += " and product_id = " + str(productId)

    if attrId:
        sql += " and attr_id != " + str(attrId)

    db = sqliteUtil.EasySqlite()
    result = db.execute(sql)

    return result
Esempio n. 15
0
    def button_update_click(self, evt):
        slName = self.tc_slName.GetValue()
        if slName.strip() == '':
            wx.MessageBox(u'请输入库位名称', u'错误', wx.OK | wx.ICON_ERROR)
            return

        shId = GetDicTypeByName(self.sh_dict, self.sh_choice.GetStringSelection())
        remark = self.tc_remark.GetValue()

        db = sqliteUtil.EasySqlite()
        db.execute(
            "update storehouse_location set sh_id = ?, sl_name = ?, remark = ?, utime = datetime('now') where sl_id = ?",
            [shId, slName, remark, self.data["slId"]])
        self.EndModal(wx.ID_OK)
Esempio n. 16
0
    def DrawTable(self):
        self.m_grid1.SetRowBackgroundColourChangeEnable(True)
        item1 = qtable.MenuBarItem("查看/修改\tF2", self.update)
        self.m_grid1.AddPopupMenuItem(item1)
        item2 = qtable.MenuBarItem("设置", None)
        item2.AddChild(qtable.MenuBarItem("有效", self.valid_status))
        item2.AddChild(qtable.MenuBarItem("失效", self.invalid_status))
        self.m_grid1.AddPopupMenuItem(item2)

        self.m_grid1.AddHotKey(wx.WXK_F2, self.update)

        db = sqliteUtil.EasySqlite()
        result = db.execute(self.GenQuerySql())
        self.m_grid1.DrawTable(qtable.GridData(self.m_grid1, columns, result))
Esempio n. 17
0
    def button_search_click(self, evt):
        shId = GetDicTypeByName(self.sh_dict, self.sh_name_choice.GetStringSelection())
        slId = self.sl_id_text.GetValue()
        slName = self.sl_name_text.GetValue()

        if slId.strip() == '':
            slId = None

        if slName.strip() == '':
            slName = None

        db = sqliteUtil.EasySqlite()
        result = db.execute(self.GenQuerySql(shId=shId, slId=slId, slName=slName))
        self.m_grid1.ReDrawTable(result)
Esempio n. 18
0
    def button_search_click(self, evt):
        dicTypeName = self.dic_type_choice.GetStringSelection()
        dicValue = self.dic_value_text.GetValue()

        dicType = None
        if dicTypeName.strip() != '':
            dicType = GetDicTypeByName(dicTypeName)

        if dicValue.strip() == '':
            dicValue = None

        db = sqliteUtil.EasySqlite()
        result = db.execute(
            self.GenQuerySql(dicType=dicType, dicValue=dicValue))
        self.m_grid1.ReDrawTable(result)
Esempio n. 19
0
    def button_add_click(self, evt):
        typeName = self.tc_dicType.GetValue()
        if typeName.strip() == '':
            wx.MessageBox(u'请输入字典类型', u'错误', wx.OK | wx.ICON_ERROR)
            return

        if IsDicTypeAndValueExist(DIC_TYPE_VALUE, typeName):
            wx.MessageBox(u'字典类型已存在,请检查', u'错误', wx.OK | wx.ICON_ERROR)
            return

        db = sqliteUtil.EasySqlite()
        db.execute(
            "insert into sys_dictionary(dic_type, dic_value, remark, status, ctime, cby, utime, uby) values(?, ?, ?, 1,datetime('now'),'',datetime('now'),'')",
            [DIC_TYPE_VALUE, typeName, ""])
        self.EndModal(wx.ID_OK)
Esempio n. 20
0
    def button_add_click(self, evt):
        dlg = DictionaryDialog(None, title="新增字典信息")
        res = dlg.ShowModal()
        if res == wx.ID_OK:
            db = sqliteUtil.EasySqlite()
            result = db.execute(
                self.GenQuerySql(offset=0, pageSize=1, orderby=["ctime desc"]))
            self.m_grid1.InsertRows(data=result)

        # 检查字典类型是否有改变
        choice = self.dic_type_choice.GetItems()
        for item in DIC_TYPE_LIST.items():
            if item[1] not in choice:
                self.dic_type_choice.AppendItems([item[1]])
        dlg.Destroy()
Esempio n. 21
0
def GetProductCategoryDict():
    dic = {}
    db = sqliteUtil.EasySqlite()
    result = db.execute(
        " select t1.dic_key as key, t1.dic_value as value "
        " from sys_dictionary t1 "
        " inner join sys_dictionary t2 "
        " on t2.dic_key = t1.dic_type "
        " where t2.dic_type = ?"
        " and t2.dic_value = ? "
        " and t1.status = 1 "
        " order by t1.dic_key", ["_$1", PRODUCT_CATEGORY_VALUE])
    for e in result:
        dic[e["key"]] = e["value"]

    return dic
Esempio n. 22
0
    def GetExistAttach(self, productId, paths):
        db = sqliteUtil.EasySqlite()
        result = db.execute(
            "select attach_id, attach_name, attach_path from product_attach where product_id = ?",
            [productId])
        attachDict = {}
        for attachInfo in result:
            attachDict[attachInfo["attach_name"]] = attachInfo

        exist_dict = {}
        for path in paths:
            filename = os.path.basename(path)
            if attachDict.keys().__contains__(filename):
                exist_dict[filename] = attachDict[filename]

        return exist_dict
Esempio n. 23
0
    def button_update_click(self, evt):
        name = self.page1.tc_name.GetValue()
        if name.strip() == '':
            wx.MessageBox(u'请输入供应商名称', u'错误', wx.OK | wx.ICON_ERROR)
            return
        id = int(self.page1.tc_id.GetValue().replace("S", ""))
        addr = self.page1.tc_addr.GetValue()
        phone = self.page1.tc_phone.GetValue()
        email = self.page1.tc_email.GetValue()
        remark = self.page1.tc_remark.GetValue()

        db = sqliteUtil.EasySqlite()
        db.execute(
            "update supplier set supplier_name = ?, supplier_addr = ?, phone_number = ?, email = ?, remark = ?, utime = datetime('now') where supplier_id = ?",
            [name, addr, phone, email, remark, id])
        self.EndModal(wx.ID_OK)
Esempio n. 24
0
def GetCustomerTypeDict():
    dic = {}
    db = sqliteUtil.EasySqlite()
    result = db.execute(
        " select t1.dic_key as key, t1.dic_value as value "
        " from sys_dictionary t1 "
        " inner join sys_dictionary t2 "
        " on t2.dic_key = t1.dic_type "
        " where t2.dic_type = ?"
        " and t2.dic_value = ? "
        " and t1.status = 1 "
        " order by t1.dic_key", ["_$1", CUSTOMER_TYPE_VALUE])
    for e in result:
        dic[e["key"]] = e["value"]

    return dic
Esempio n. 25
0
 def button_add_click(self, evt):
     dicType = GetDicTypeByName(
         self.choice_dicTypeName.GetStringSelection())
     dicValue = self.tc_dicValue.GetValue()
     remark = self.tc_remark.GetValue()
     if dicValue.strip() == '':
         wx.MessageBox(u'请输入字典值', u'错误', wx.OK | wx.ICON_ERROR)
         return
     if IsDicTypeAndValueExist(dicType, dicValue):
         wx.MessageBox(u'字典已存在,请检查', u'错误', wx.OK | wx.ICON_ERROR)
         return
     db = sqliteUtil.EasySqlite()
     db.execute(
         "insert into sys_dictionary(dic_type, dic_value, remark, status, ctime, cby, utime, uby) values(?, ?, ?, 1,datetime('now'),'',datetime('now'),'')",
         [dicType, dicValue, remark])
     self.EndModal(wx.ID_OK)
Esempio n. 26
0
 def button_add_click(self, evt):
     name = self.page1.tc_name.GetValue()
     if name.strip() == '':
         wx.MessageBox(u'请输入客户名称', u'错误', wx.OK | wx.ICON_ERROR)
         return
     customerType = GetDicTypeByName(
         self.page1.customer_type_dict,
         self.page1.customer_type_choice.GetStringSelection())
     addr = self.page1.tc_addr.GetValue()
     phone = self.page1.tc_phone.GetValue()
     email = self.page1.tc_email.GetValue()
     remark = self.page1.tc_remark.GetValue()
     db = sqliteUtil.EasySqlite()
     db.execute(
         "insert into customer(customer_type, customer_name, customer_addr, phone_number, email, remark, ctime, cby, utime, uby) values(?, ?, ?, ?, ?, ?, datetime('now'),'',datetime('now'),'')",
         [customerType, name, addr, phone, email, remark])
     self.EndModal(wx.ID_OK)
Esempio n. 27
0
    def button_search_click(self, evt):
        customerType = GetDicTypeByName(
            self.customer_type_dict,
            self.customer_type_choice.GetStringSelection())
        name = self.customer_name_text.GetValue()
        phone = self.customer_phone_text.GetValue()

        if name.strip() == '':
            name = None
        if phone.strip() == '':
            phone = None

        db = sqliteUtil.EasySqlite()
        result = db.execute(
            self.GenQuerySql(customerType=customerType,
                             customerName=name,
                             customerPhone=phone))
        self.m_grid1.ReDrawTable(result)
Esempio n. 28
0
    def button_update_click(self, evt):
        dicType = GetDicTypeByName(
            self.choice_dicTypeName.GetStringSelection())
        dicValue = self.tc_dicValue.GetValue()
        remark = self.tc_remark.GetValue()

        if dicValue.strip() == '':
            wx.MessageBox(u'请输入字典值', u'错误', wx.OK | wx.ICON_ERROR)
            return
        if IsDicTypeAndValueExist(dicType, dicValue):
            wx.MessageBox(u'字典已存在,请检查', u'错误', wx.OK | wx.ICON_ERROR)
            return

        db = sqliteUtil.EasySqlite()
        db.execute(
            "update sys_dictionary set dic_type = ?, dic_value = ?, remark = ?, utime = datetime('now') where dic_key = ?",
            [dicType, dicValue, remark, self.data["dicKey"]])
        self.EndModal(wx.ID_OK)
Esempio n. 29
0
    def button_update_click(self, evt):
        shName = self.tc_shName.GetValue()
        if shName.strip() == '':
            wx.MessageBox(u'请输入仓库名称', u'错误', wx.OK | wx.ICON_ERROR)
            return

        shAddr = self.tc_addr.GetValue()
        if shAddr.strip() == '':
            wx.MessageBox(u'请输入仓库地址', u'错误', wx.OK | wx.ICON_ERROR)
            return

        remark = self.tc_remark.GetValue()

        db = sqliteUtil.EasySqlite()
        db.execute(
            "update storehouse set sh_name = ?, sh_addr = ?, remark = ?, utime = datetime('now') where sh_id = ?",
            [shName, shAddr, remark, self.data["shId"]])
        self.EndModal(wx.ID_OK)
Esempio n. 30
0
    def button_update_click(self, evt):
        name = self.page1.tc_name.GetValue()
        if name.strip() == '':
            wx.MessageBox(u'请输入客户名称', u'错误', wx.OK | wx.ICON_ERROR)
            return
        id = int(self.page1.tc_id.GetValue().replace("A", ""))
        customerType = GetDicTypeByName(
            self.page1.customer_type_dict,
            self.page1.customer_type_choice.GetStringSelection())
        addr = self.page1.tc_addr.GetValue()
        phone = self.page1.tc_phone.GetValue()
        email = self.page1.tc_email.GetValue()
        remark = self.page1.tc_remark.GetValue()

        db = sqliteUtil.EasySqlite()
        db.execute(
            "update customer set customer_type = ?, customer_name = ?, customer_addr = ?, phone_number = ?, email = ?, remark = ?, utime = datetime('now') where customer_id = ?",
            [customerType, name, addr, phone, email, remark, id])
        self.EndModal(wx.ID_OK)