예제 #1
0
파일: per_stat.py 프로젝트: ehoac/wfund
 def OnPopupDeleteSelected(self, event):
     if not self.apply_sign:
         wx.MessageBox('暂时不能申请!', '提示')
     else:
         applyId = self.grid_data.get((self.select_grid_row, 5))
         if applyId:
             FundApply.delete_by_key(applyId)
             self.refresh(self.user)
예제 #2
0
 def get_sheet_data(self):
     ids = ''
     states = ''
     for id in self.apply_ids:
         ids += "user_id='" + id + "' or "
     ids = ids[:-3]
     for state in self.states:
         states += "state='" + state + "' or "
     states = states[:-3]
     applies = FundApply.find(where="(" + ids + ")" + " and (" + states +
                              ")")
     sheet_data = []
     applies = sorted(applies, key=lambda key: key['date'])
     for apply in applies:
         item = []
         try:
             dt = wx.DateTime(
                 datetime.datetime.strptime(apply.date, '%Y年%m月%d日'))
         except ValueError:
             dt = wx.DateTime(
                 datetime.datetime.strptime(apply.date, '%Y-%m-%d'))
         df = dt.Format('%Y-%m-%d')
         if self.dates['begin'] < df < self.dates['end']:
             item.append(apply.date)
             item.append(self.user_map[apply.user_id])
             item.append(Compute.get(apply.money))
             item.append(self.kinds[apply.kind])
             item.append(apply.reason)
             item.append(apply.state)
             item.append(apply.persons)
             sheet_data.append(tuple(item))
     return sheet_data
예제 #3
0
파일: form.py 프로젝트: ehoac/wfund
 def OnSave(self, event):
     if self.Validate():
         if self.update:
             apply = FundApply(**self.data)
             apply.update()
             wx.MessageBox('修改成功!', 'Error')
         else:
             apply = FundApply(user_id=self.user.id, state='未报销', create_time=now_time_str(), update_time=now_time_str(),
                               **self.data)
             apply.save()
             wx.MessageBox('保存成功!', 'Error')
         self.EndModal(wx.ID_OK)
예제 #4
0
    def show(self):
        self.applies = FundApply.find(where="state='未报销'")
        self.fund_kind = FundKind.all()
        self.users = User.all()
        self.money_dict = self.all_money(self.applies)

        all = Part.GenShowText(self, round(self.money_dict['all'], 2),
                               self.default_font, wx.ALIGN_CENTER)
        allSizer = Part.GenStaticBoxSizer(self, '总计(元)', [all],
                                          wx.ALL | wx.EXPAND)

        self.grid = self.init_grid()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(allSizer, 0, wx.EXPAND | wx.ALL, 5)
        sizer.Add(self.show_detail(), 0, wx.EXPAND | wx.ALL, 5)
        sizer.Add(self.grid, 1, wx.EXPAND | wx.ALL, 5)
        self.SetSizer(sizer)
        self.Layout()
예제 #5
0
 def OnPopupPaySelected(self, event):
     pay = Compute.parse(self.grid.GetTable().GetDataValue(
         self.select_grid_row, 5))
     user_id = self.grid_data.get((self.select_grid_row, 6))
     # dlg = wx.MessageDialog(None, '此操作将清空此用户申请信息!', '提示', wx.YES_NO | wx.ICON_QUESTION)
     dlg = EnsurePay(self, user_id, pay)
     if dlg.ShowModal() == wx.ID_OK:
         if round(pay, 2) > 0 and user_id:
             fund_pay = FundPayRecord(money=pay,
                                      user_id=user_id,
                                      create_time=now_time_str())
             fund_pay.save()
             self.send_email(user_id)
             applies = FundApply.find(where='user_id=?', args=user_id)
             if applies and len(applies) > 0:
                 for apply in applies:
                     apply['state'] = '已报销'
                     apply.update()
         self.refresh(self.user)
     event.Skip()
     dlg.Destroy()
예제 #6
0
파일: form.py 프로젝트: ehoac/wfund
    def __init__(self, parent, ID, user=None, applyId=None, title='新增'):
        wx.Dialog.__init__(self, parent, ID, size=(420, 300))
        self.SetTitle(title)
        self.Center()
        self.data = {}
        self.kinds = FundKind.all()
        self.allPersons = User.all()
        self.user = user
        self.update = False
        if applyId:
            applies = FundApply.find(where='id=?', args=applyId)
            print(applies)
            if len(applies) > 0:
                self.apply = applies[0]
                self.update = True

        self.nameLbl = wx.StaticText(self, -1, '姓名:', size=(60, -1), style=wx.ALIGN_RIGHT)
        self.name = wx.TextCtrl(self, -1, validator=NotEmptyValidator(), name='name', value=self.user.name)
        self.kindLbl = wx.StaticText(self, -1, '类型:', size=(60, -1), style=wx.ALIGN_RIGHT)
        self.kind = wx.Choice(self, -1, choices=[k for k in self.kinds.values()])
        nameSizer = wx.BoxSizer(wx.HORIZONTAL)
        nameSizer.Add(self.nameLbl, wx.ALL, 5)
        nameSizer.Add(self.name, wx.ALL | wx.EXPAND, 5)
        nameSizer.Add(self.kindLbl, wx.ALL, 5)
        nameSizer.Add(self.kind, wx.ALL | wx.EXPAND, 5)

        self.name.Bind(wx.EVT_KILL_FOCUS, self.OnNameEnter)
        self.kind.Bind(wx.EVT_CHOICE, self.OnChoiceKind)

        self.dateLbl = wx.StaticText(self, -1, '日期:', size=(60, -1), style=wx.ALIGN_RIGHT)
        self.date = adv.GenericDatePickerCtrl(self, -1)
        self.moneyLbl = wx.StaticText(self, -1, '金额:', size=(60, -1), style=wx.ALIGN_RIGHT)
        self.money = wx.TextCtrl(self, -1, name='money', validator=NotEmptyValidator())
        dateSizer = wx.BoxSizer(wx.HORIZONTAL)
        dateSizer.Add(self.moneyLbl, wx.ALL, 5)
        dateSizer.Add(self.money, wx.EXPAND | wx.ALL, 5)
        dateSizer.Add(self.dateLbl, wx.ALL, 5)
        dateSizer.Add(self.date, wx.EXPAND | wx.ALL, 5)

        self.money.Bind(wx.EVT_KILL_FOCUS, self.OnNameEnter)
        self.Bind(wx.adv.EVT_DATE_CHANGED, self.OnDateChange, self.date)

        self.expLbl = wx.StaticText(self, -1, '描述:', size=(60, -1), style=wx.ALIGN_RIGHT)
        self.reason = wx.TextCtrl(self, -1, name='reason', size=(200, 80), style=wx.TE_MULTILINE,
                                  validator=NotEmptyValidator())
        expSizer = wx.BoxSizer(wx.HORIZONTAL)
        expSizer.Add(self.expLbl, wx.ALL, 5)
        expSizer.Add(self.reason, wx.EXPAND|wx.ALL, 5)

        self.reason.Bind(wx.EVT_KILL_FOCUS, self.OnNameEnter)

        self.peopleLbl = wx.StaticText(self, -1, '人员:', size=(60, -1), style=wx.ALIGN_RIGHT)
        self.persons = wx.StaticText(self, -1)
        self.peopleBtn = wx.Button(self, -1, '选择')
        self.Bind(wx.EVT_BUTTON, self.OnCheckPeople, self.peopleBtn)

        peopleSizer = wx.BoxSizer(wx.HORIZONTAL)
        peopleSizer.Add(self.peopleLbl, wx.ALL, 5)
        peopleSizer.Add(self.persons, wx.ALL | wx.EXPAND, 5)
        peopleSizer.Add(self.peopleBtn, wx.ALL, 5)

        okBtn = wx.Button(self, wx.ID_OK, "保存")
        cancelBtn = wx.Button(self, wx.ID_CANCEL, "取消")
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        btnSizer.Add(okBtn, 0, wx.ALL, 5)
        btnSizer.Add(cancelBtn, 0, wx.ALL, 5)

        self.Bind(wx.EVT_BUTTON, self.OnSave, okBtn)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(nameSizer, 0, wx.ALL, 5)
        sizer.Add(dateSizer, 0, wx.ALL, 5)
        sizer.Add(expSizer, 0, wx.ALL, 5)
        sizer.Add(peopleSizer, 0, wx.ALL, 5)
        sizer.Add(btnSizer, 0, wx.ALIGN_CENTER | wx.ALL, 5)
        self.SetSizer(sizer)
        self.Layout()
        self.init_data()