コード例 #1
0
ファイル: shipping.py プロジェクト: XHApplet/GoodsBook
    def OutputGoods(self):
        if not self.ValidOutput():
            return
        self.dateEditOutput.setTime(QtCore.QTime.currentTime())
        oDataTime = self.dateEditOutput.dateTime()
        iTime = oDataTime.toTime_t()
        sGoods = self.comboBoxOutputGoods.currentText()
        sBuyer = self.comboBoxOutputBuyer.currentText()
        fPrice = float(self.lineEditOutputPrice.text())
        iNum = int(self.lineEditOutputNum.text())
        sRemark = self.lineEditOutputRemark.text()

        tInfo = [iTime, sGoods, sBuyer, fPrice, iNum, sRemark]
        logging.info("OutputGoods:%s" % (tInfo, ))
        pubmisc.Write2File("xh/shipping", str(tInfo))

        # 计算本次卖出的利润为多少
        pubmisc.CallManagerFunc("shippingmgr", "OutputGoods", *tInfo)
        pubmisc.CallManagerFunc("goodsmgr", "OutputGoods", sGoods, fPrice,
                                iNum)

        pubmisc.CallManagerFunc("globalmgr", "AddBuyer", sBuyer)
        pubmisc.Write2File("xh/shipping", str(iTime))
        # pubui.slotInformation("出货成功")
        self.InitUI()
コード例 #2
0
ファイル: shipping.py プロジェクト: XHApplet/GoodsBook
 def FocusOutOutputGoods(self):
     """卖出商品:当输入完商品之后自动填写价格"""
     sGoods = self.comboBoxOutputGoods.text()
     if not sGoods:
         return
     if not pubmisc.CallManagerFunc("globalmgr", "HasGoods", sGoods):
         # pubui.slotInformation("库存中无商品记录")
         return
     fPrice = pubmisc.CallManagerFunc("goodsmgr", "GetGoodsSellPrice",
                                      sGoods)
     if abs(fPrice) > 1e-6:
         self.lineEditOutputPrice.setText(str(fPrice))  # 价格自动变
コード例 #3
0
ファイル: shippingrecord.py プロジェクト: XHApplet/GoodsBook
 def InitUI(self):
     """初始化界面"""
     oCurData = QtCore.QDate.currentDate()
     self.dateEditBeginOutputRecord.setDate(oCurData.addMonths(-1))
     self.dateEditEndOutputRecord.setDate(oCurData)
     self.comboBoxOutputRecordGoods.clear()
     lstGoods = pubmisc.CallManagerFunc("globalmgr", "GetAllGoodsList")
     self.comboBoxOutputRecordGoods.addItems(lstGoods)
     self.comboBoxOutputRecordGoods.setCurrentIndex(-1)
     self.comboBoxOutputRecordBuyer.clear()
     lstBuyer = pubmisc.CallManagerFunc("globalmgr", "GetAllBuyer")
     self.comboBoxOutputRecordBuyer.addItems(lstBuyer)
     self.comboBoxOutputRecordBuyer.setCurrentIndex(-1)
コード例 #4
0
ファイル: shippingrecord.py プロジェクト: XHApplet/GoodsBook
    def QueryOutputRecord(self):
        """查询出货记录"""
        oBeginDate = self.dateEditBeginOutputRecord.date()
        sBeginTime = oBeginDate.toString("yyyy-MM-dd 00:00:00")
        iBeginTime = pubmisc.Str2Time(sBeginTime)
        oEndDate = self.dateEditEndOutputRecord.date()
        sEndTime = oEndDate.toString("yyyy-MM-dd 23:59:59")
        iEndTime = pubmisc.Str2Time(sEndTime)
        sGoods = self.comboBoxOutputRecordGoods.currentText()
        sBuyer = self.comboBoxOutputRecordBuyer.currentText()

        dSellInfo = pubmisc.CallManagerFunc("shippingmgr", "GetSellInfoRecord", iBeginTime, iEndTime, sGoods, sBuyer)
        lstHead = ["日期", "商品", "卖家", "售价", "数量", "备注", "利润", "双击删除"]
        self.tableWidgetOutputRecord.setColumnCount(len(lstHead))
        self.tableWidgetOutputRecord.setRowCount(len(dSellInfo))
        self.tableWidgetOutputRecord.setHorizontalHeaderLabels(lstHead)
        self.tableWidgetOutputRecord.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
        iRow = iAllNum = fPrice = fProfile = 0
        for iID, tSellInfo in dSellInfo.items():
            iTime, sGoods, sSeller, fSellPrice, iNum, sRemark = tSellInfo
            for iCol, xValue in enumerate(tSellInfo):
                if iCol == 0:
                    xValue = pubmisc.Time2Str(xValue)
                item = QtWidgets.QTableWidgetItem(str(xValue))
                item.setTextAlignment(QtCore.Qt.AlignCenter)
                self.tableWidgetOutputRecord.setItem(iRow, iCol, item)

            fBuyPrice = pubmisc.CallManagerFunc("goodsmgr", "GetGoodsBuyPrice", sGoods)
            fCurProfile = (fSellPrice - fBuyPrice) * iNum
            item = QtWidgets.QTableWidgetItem(str(fCurProfile))
            item.setTextAlignment(QtCore.Qt.AlignCenter)
            self.tableWidgetOutputRecord.setItem(iRow, iCol + 1, item)

            icon = QtGui.QIcon(QtGui.QPixmap("image/main.ico"))
            item = QtWidgets.QTableWidgetItem(icon, str(iID))
            item.setTextAlignment(QtCore.Qt.AlignCenter)
            self.tableWidgetOutputRecord.setItem(iRow, iCol + 2, item)

            iRow += 1
            fProfile += fCurProfile
            iAllNum += tSellInfo[4]
            fPrice += tSellInfo[3] * tSellInfo[4]

        self.labelNum.setText("总售货数量: %s" % iAllNum)
        self.labelAmount.setText("总售货金额: %s" % fPrice)
        self.labelProfile.setText("总利润: %s" % fProfile)
        self.labelNum.show()
        self.labelAmount.show()
        self.labelProfile.show()
コード例 #5
0
 def FocusOutInputGoods(self):
     """录入商品:当输入完商品之后自动填写类型+价格"""
     sGoods = self.comboBoxInputGoods.text()
     if not sGoods:
         return
     if not pubmisc.CallManagerFunc("globalmgr", "HasGoods", sGoods):
         self.InputTiplabel.show()
         return
     self.InputTiplabel.hide()
     fPrice = pubmisc.CallManagerFunc("goodsmgr", "GetGoodsBuyPrice",
                                      sGoods)
     self.lineEditInputPrice.setText(str(fPrice))  # 价格自动变
     sType = pubmisc.CallManagerFunc("globalmgr", "GetGoodsType", sGoods)
     if sType:
         self.comboBoxInputType.setCurrentText(sType)
コード例 #6
0
ファイル: shipping.py プロジェクト: XHApplet/GoodsBook
 def ValidOutput(self):
     """卖出商品时控件判断"""
     if not self.lineEditOutputPrice.text():
         pubui.slotInformation("价格不能为空")
         return False
     if not self.lineEditOutputNum.text():
         pubui.slotInformation("数量不能为空")
         return False
     if not self.dateEditOutput.dateTime():
         pubui.slotInformation("日期不能为空")
         return False
     if not self.comboBoxOutputBuyer.currentText():
         pubui.slotInformation("买家不能为空")
         return False
     if not self.comboBoxOutputGoods.currentText():
         pubui.slotInformation("商品不能为空")
         return False
     sGoods = self.comboBoxOutputGoods.text()
     if not pubmisc.CallManagerFunc("globalmgr", "HasGoods", sGoods):
         pubui.slotInformation("库存中无商品记录")
         return False
     # iStock = pubmisc.CallManagerFunc("goodsmgr", "GetGoodsNum", sGoods)
     # iNum = int(self.lineEditOutputNum.text())
     # if iStock < iNum:
     #     pubui.slotInformation("没有足够的库存,当前库存%s" % iStock)
     #     return False
     return True
コード例 #7
0
 def CellDoubleClicked(self, iRow, iCol):
     if iCol != 6:
         return
     item = self.tableWidgetInputRecord.item(iRow, iCol)
     iID = int(item.text())
     pubmisc.CallManagerFunc("purchasemgr", "DelPurchase4DB", iID)
     self.QueryInputRecord()
コード例 #8
0
ファイル: base.py プロジェクト: XHApplet/GoodsBook
 def Load(self):
     sql = "select %s from %s where %s='%s'" % (
         self.m_DataName, self.m_TableName, self.m_KeyName, self.m_DBKey)
     result = pubmisc.CallManagerFunc("dbmgr", "Query", sql, True)
     if not result:
         return False
     self.m_Data = pubdb.GetResultData(result[0], "blob")
コード例 #9
0
ファイル: shipping.py プロジェクト: XHApplet/GoodsBook
 def InitUI(self):
     """初始化卖出商品界面"""
     oCurData = QtCore.QDate.currentDate()
     self.dateEditOutput.setDate(oCurData)
     self.comboBoxOutputGoods.clear()
     self.comboBoxOutputBuyer.clear()
     lstGoods = pubmisc.CallManagerFunc("globalmgr", "GetAllGoodsList")
     self.comboBoxOutputGoods.addItems(lstGoods)
     lstBuyer = pubmisc.CallManagerFunc("globalmgr", "GetAllBuyer")
     self.comboBoxOutputBuyer.addItems(lstBuyer)
     self.comboBoxOutputGoods.setCurrentIndex(-1)
     self.comboBoxOutputBuyer.setCurrentIndex(-1)
     self.lineEditOutputNum.setText("")
     self.lineEditOutputPrice.setText("")
     self.lineEditOutputRemark.setText("")
     self.labelAmount.hide()
コード例 #10
0
ファイル: shippingrecord.py プロジェクト: XHApplet/GoodsBook
 def CellDoubleClicked(self, iRow, iCol):
     if iCol != 7:
         return
     item = self.tableWidgetOutputRecord.item(iRow, iCol)
     iID = int(item.text())
     pubmisc.CallManagerFunc("shippingmgr", "DelShipping4DB", iID)
     self.QueryOutputRecord()
コード例 #11
0
ファイル: shipping.py プロジェクト: XHApplet/GoodsBook
 def DelShipping4DB(self, iID):
     """从数据库中删除一条出货记录"""
     obj = self.GetItemBlock(iID)
     if not obj:
         return
     pubmisc.CallManagerFunc("goodsmgr", "AddGoodsNum", obj.m_Goods,
                             obj.m_Num)
     self.DelItemBlock(iID)
コード例 #12
0
 def InitUI(self):
     """初始化录入商品界面"""
     oCurData = QtCore.QDate.currentDate()
     self.dateEditInput.setDate(oCurData)
     self.comboBoxInputType.clear()
     self.comboBoxInputGoods.clear()
     lstGoodsType = pubmisc.CallManagerFunc("globalmgr", "GetAllType")
     self.comboBoxInputType.addItems(lstGoodsType)
     lstGoods = pubmisc.CallManagerFunc("globalmgr", "GetAllGoodsList")
     self.comboBoxInputGoods.addItems(lstGoods)
     self.comboBoxInputType.setCurrentIndex(0)
     self.comboBoxInputGoods.setCurrentIndex(-1)
     self.InputTiplabel.hide()
     self.lineEditInputNum.setText("")
     self.lineEditInputPrice.setText("")
     self.lineEditInputRemark.setText("")
     self.labelAmount.hide()
コード例 #13
0
 def GetBuyInfo(self, iBegin, iEnd):
     dBuyInfo = {}
     sql = "select * from %s where Time>=%s and Time<=%s" % (TABLE_NAME,
                                                             iBegin, iEnd)
     result = pubmisc.CallManagerFunc("dbmgr", "Query", sql)
     for ID, *tData in result:
         logging.debug("buy info:%s %s" % (ID, tData))
         dBuyInfo[ID] = tData
     return dBuyInfo
コード例 #14
0
ファイル: goods.py プロジェクト: XHApplet/GoodsBook
    def ShowStock(self):
        lstTitle = ["商品", "进价", "售价", "库存", "预警值"]
        lstGoods = pubmisc.CallManagerFunc("globalmgr", "GetAllGoodsList")

        self.tableWidgetStock.setColumnCount(len(lstTitle))
        self.tableWidgetStock.setRowCount(len(lstGoods))
        self.tableWidgetStock.setHorizontalHeaderLabels(lstTitle)
        self.tableWidgetStock.horizontalHeader().setSectionResizeMode(
            QtWidgets.QHeaderView.Stretch)

        for iRow, sGoods in enumerate(lstGoods):
            lstGoodsInfo = pubmisc.CallManagerFunc("goodsmgr", "GetGoodsInfo",
                                                   sGoods)
            for iCol, value in enumerate(lstGoodsInfo):
                item = QtWidgets.QTableWidgetItem(str(value))
                item.setTextAlignment(QtCore.Qt.AlignCenter)
                if iCol == 0:
                    item.setFlags(QtCore.Qt.ItemIsEditable)
                self.tableWidgetStock.setItem(iRow, iCol, item)
コード例 #15
0
ファイル: shipping.py プロジェクト: XHApplet/GoodsBook
 def GetSellInfo(self, iBegin, iEnd):
     """查询iBegin-iEnd时间段的出货信息"""
     dSellInfo = {}
     sql = "select * from %s where Time>=%s and Time<=%s" % (TABLE_NAME,
                                                             iBegin, iEnd)
     result = pubmisc.CallManagerFunc("dbmgr", "Query", sql)
     for ID, *tData in result:
         logging.debug("sell info:%s %s" % (ID, tData))
         dSellInfo[ID] = tData
     return dSellInfo
コード例 #16
0
 def GetBuyInfoRecord(self, iBegin, iEnd, sGoods):
     dBuyInfo = {}
     sql = "select * from %s where Time>=%s and Time<=%s" % (TABLE_NAME,
                                                             iBegin, iEnd)
     if sGoods:
         sql = sql + " and Goods like '%%%s%%'" % sGoods
     sql += " ORDER BY Time"
     result = pubmisc.CallManagerFunc("dbmgr", "Query", sql)
     for ID, *tData in result:
         logging.debug("buy record:%s %s" % (ID, tData))
         dBuyInfo[ID] = tData
     return dBuyInfo
コード例 #17
0
ファイル: goods.py プロジェクト: XHApplet/GoodsBook
 def CellChanged(self, iRow, iCol):
     if iCol == 0:
         return
     itemGoods = self.tableWidgetStock.item(iRow, 0)
     sGoods = itemGoods.text()
     item = self.tableWidgetStock.item(iRow, iCol)
     if iCol == 1:
         fBuyPrice = float(item.text())
         pubmisc.CallManagerFunc("goodsmgr", "Excute", "SetBuyPrice",
                                 sGoods, fBuyPrice)
     elif iCol == 2:
         fSellPrice = float(item.text())
         pubmisc.CallManagerFunc("goodsmgr", "Excute", "SetSellPrice",
                                 sGoods, fSellPrice)
     elif iCol == 3:
         iStock = int(item.text())
         pubmisc.CallManagerFunc("goodsmgr", "Excute", "SetGoodsNum",
                                 sGoods, iStock)
     elif iCol == 4:
         iAlert = int(item.text())
         pubmisc.CallManagerFunc("goodsmgr", "Excute", "SetGoodsAlert",
                                 sGoods, iAlert)
コード例 #18
0
ファイル: base.py プロジェクト: XHApplet/GoodsBook
 def Load(self):
     sql = self.GetQuerySQL()
     result = pubmisc.CallManagerFunc("dbmgr", "Query", sql, True)
     if not result:
         return False
     for iIndex, sCol in enumerate(self.m_ColList):
         if sCol in self.m_KeyList:
             continue
         sType = self.m_ColType[sCol]
         sValue = result[iIndex]
         value = pubdb.GetResultData(sValue, sType)
         setattr(self, "m_" + sCol, value)
     return True
コード例 #19
0
    def OnPurchase(self):
        """点击录入商品调用"""
        if not self.ValidInput():
            return
        self.dateEditInput.setTime(QtCore.QTime.currentTime())
        oDataTime = self.dateEditInput.dateTime()
        iTime = oDataTime.toTime_t()
        sGoodsType = self.comboBoxInputType.currentText()
        sGoods = self.comboBoxInputGoods.currentText()
        fPrice = float(self.lineEditInputPrice.text())
        iNum = int(self.lineEditInputNum.text())
        sRemark = self.lineEditInputRemark.text()

        tInfo = [iTime, sGoodsType, sGoods, fPrice, iNum, sRemark]
        logging.info("InputGoods:%s" % (tInfo, ))
        pubmisc.Write2File("xh/purchase", str(tInfo))

        pubmisc.CallManagerFunc("purchasemgr", "InputGoods", *tInfo)
        pubmisc.CallManagerFunc("goodsmgr", "InputGoods", sGoods, fPrice, iNum)

        pubmisc.CallManagerFunc("globalmgr", "AddGoods", sGoodsType, sGoods)
        pubmisc.Write2File("xh/purchase", str(iTime))
        # pubui.slotInformation("进货成功")
        self.InitUI()
コード例 #20
0
    def QueryInputRecord(self):
        """查询进货记录"""
        oBeginDate = self.dateEditBeginInputRecord.date()
        sBeginTime = oBeginDate.toString("yyyy-MM-dd 00:00:00")
        iBeginTime = pubmisc.Str2Time(sBeginTime)
        oEndDate = self.dateEditEndInputRecord.date()
        sEndTime = oEndDate.toString("yyyy-MM-dd 23:59:59")
        iEndTime = pubmisc.Str2Time(sEndTime)
        sGoods = self.comboBoxInputRecord.currentText()

        dbuyInfo = pubmisc.CallManagerFunc("purchasemgr", "GetBuyInfoRecord",
                                           iBeginTime, iEndTime, sGoods)
        lstHead = ["日期", "类型", "商品", "进价", "数量", "备注", "双击删除"]
        self.tableWidgetInputRecord.setColumnCount(len(lstHead))
        self.tableWidgetInputRecord.setRowCount(len(dbuyInfo))
        self.tableWidgetInputRecord.setHorizontalHeaderLabels(lstHead)
        self.tableWidgetInputRecord.horizontalHeader().setSectionResizeMode(
            QtWidgets.QHeaderView.Stretch)
        iRow = iAllNum = fPrice = 0
        for iID, tBuyInfo in dbuyInfo.items():
            for iCol, xValue in enumerate(tBuyInfo):
                if iCol == 0:
                    xValue = pubmisc.Time2Str(tBuyInfo[iCol])
                item = QtWidgets.QTableWidgetItem(str(xValue))
                item.setTextAlignment(QtCore.Qt.AlignCenter)
                self.tableWidgetInputRecord.setItem(iRow, iCol, item)

            icon = QtGui.QIcon(QtGui.QPixmap("image/main.ico"))
            item = QtWidgets.QTableWidgetItem(icon, str(iID))
            item.setTextAlignment(QtCore.Qt.AlignCenter)
            self.tableWidgetInputRecord.setItem(iRow, iCol + 1, item)

            iRow += 1
            iAllNum += tBuyInfo[4]
            fPrice += tBuyInfo[3] * tBuyInfo[4]

        self.labelNum.setText("总进货数量: %s" % iAllNum)
        self.labelAmount.setText("总进货金额: %s" % fPrice)
        self.labelNum.show()
        self.labelAmount.show()
コード例 #21
0
    def QueryProfile(self):
        """查询利润"""
        oBeginDate = self.dateEditBegin.date()
        sBeginTime = oBeginDate.toString("yyyy-MM-dd 00:00:00")
        iBeginTime = pubmisc.Str2Time(sBeginTime)
        oEndDate = self.dateEditEnd.date()
        sEndTime = oEndDate.toString("yyyy-MM-dd 23:59:59")
        iEndTime = pubmisc.Str2Time(sEndTime)
        self.MaxProfileCol = 0
        dSellInfo = pubmisc.CallManagerFunc("shippingmgr", "GetSellInfo",
                                            iBeginTime, iEndTime)
        self.ProfileInfo = {}
        for _, tSellInfo in dSellInfo.items():
            iTime, sGoods, _, fSellPrice, iNum, __ = tSellInfo
            sTime = pubmisc.Time2Str(iTime)
            fBuyPrice = pubmisc.CallManagerFunc("goodsmgr", "GetGoodsBuyPrice",
                                                sGoods)
            fProfile = (fSellPrice - fBuyPrice) * iNum

            sDayTime = sTime[:10]
            sMonthTime = sTime[:7]
            sYearTime = sTime[:4]
            self.AddProfile(sGoods, sDayTime, fProfile)
            self.AddProfile(sGoods, sMonthTime + "月", fProfile)
            self.AddProfile(sGoods, sYearTime + "年", fProfile)
            self.AddProfile(sGoods, "总利润", fProfile)

        iGoodsNum = len(self.ProfileInfo)
        self.tableWidgetProfile.setRowCount(iGoodsNum)

        lstTime = [
            "总利润",
        ]
        sLastYear = ""
        while oBeginDate.toString("yyyy-MM") <= oEndDate.toString("yyyy-MM"):
            sCurYear = oBeginDate.toString("yyyy")
            if sLastYear != sCurYear:
                lstTime.append(sCurYear + "年")
                sLastYear = sCurYear
            lstTime.append(oBeginDate.toString("yyyy-MM") + "月")
            oBeginDate = oBeginDate.addMonths(1)

        self.tableWidgetProfile.setColumnCount(len(lstTime) + 1)

        lstGoods = [sGoods for sGoods in self.ProfileInfo]

        lstTitle = lstTime[:]
        lstTitle.insert(0, "商品")
        self.tableWidgetProfile.setHorizontalHeaderLabels(lstTitle)
        # if len(lstTitle) < 14:
        #     self.tableWidgetProfile.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)

        for iRow, sGoods in enumerate(lstGoods):
            item = QtWidgets.QTableWidgetItem(sGoods)
            item.setTextAlignment(QtCore.Qt.AlignCenter)
            self.tableWidgetProfile.setItem(iRow, 0, item)
            for iCol, sTime in enumerate(lstTime):
                fProfile = self.GetProfileByDate(sGoods, sTime)
                item = QtWidgets.QTableWidgetItem(str(fProfile))
                item.setTextAlignment(QtCore.Qt.AlignCenter)
                self.tableWidgetProfile.setItem(iRow, iCol + 1, item)
コード例 #22
0
ファイル: base.py プロジェクト: XHApplet/GoodsBook
 def Save(self, *colList):
     sql = self.GetUpdateSQL(*colList)
     pubmisc.CallManagerFunc("dbmgr", "Excute", sql)
コード例 #23
0
ファイル: base.py プロジェクト: XHApplet/GoodsBook
 def Delete(self):
     sql = self.GetDeleteSQL()
     pubmisc.CallManagerFunc("dbmgr", "Excute", sql)
コード例 #24
0
ファイル: base.py プロジェクト: XHApplet/GoodsBook
 def New(self):
     sData = pubdb.GetInsertValue(self.m_Data, "blob")
     sql = "insert into %s values('%s', %s)" % (self.m_TableName,
                                                self.m_DBKey, sData)
     pubmisc.CallManagerFunc("dbmgr", "Excute", sql)
コード例 #25
0
ファイル: base.py プロジェクト: XHApplet/GoodsBook
 def Save(self):
     sData = pubdb.GetInsertValue(self.m_Data, "blob")
     sql = "update %s set %s=%s where %s='%s'" % (
         self.m_TableName, self.m_DataName, sData, self.m_KeyName,
         self.m_DBKey)
     pubmisc.CallManagerFunc("dbmgr", "Excute", sql)
コード例 #26
0
 def InputGoods(self, *data):
     """进货保存数据库"""
     ID = pubmisc.CallManagerFunc("globalmgr", "NewPurchaseID")
     self.NewItem(ID, *data)
コード例 #27
0
 def QueryAllInfo(self):
     """查询所有的进货信息"""
     sql = "select * from %s" % TABLE_NAME
     result = pubmisc.CallManagerFunc("dbmgr", "Query", sql)
     for ID, *tData in result:
         logging.debug("buy query:%s %s" % (ID, tData))
コード例 #28
0
ファイル: base.py プロジェクト: XHApplet/GoodsBook
 def New2DB(self):
     sql = self.GetCreateSQL()
     pubmisc.CallManagerFunc("dbmgr", "Excute", sql)
コード例 #29
0
ファイル: shipping.py プロジェクト: XHApplet/GoodsBook
 def OutputGoods(self, *data):
     """出货保存数据库"""
     ID = pubmisc.CallManagerFunc("globalmgr", "NewShippingID")
     self.NewItem(ID, *data)