def open_modify(self, event): """ 打开修改页 """ rows = self.grid.GetSelectedRows() if rows is None or len(rows) == 0: wx.MessageBox(u"请选择要修改的数据!", "提示", style=wx.ICON_HAND) return selected = rows[0] select_data = self.grid.GetTable().data[selected] self.edit_win = customerwin.CustomerWin(self) self.edit_win.set_data(select_data) self.edit_win.CenterOnScreen() val = self.edit_win.ShowModal() if val == wx.ID_OK: try: self.edit_win.update() except ValueError as e: wx.MessageBox(str(e), "提示", style=wx.ICON_HAND) else: wx.MessageBox(u"修改成功!", "提示", style=wx.ICON_INFORMATION) self.edit_win.Destroy() self.grid.GetTable().data = service.search_customer( None, self.id_number_search.GetValue()) self.grid.reset()
def on_search(self, event): """ 搜索 """ self.grid.GetTable().data = service.search_customer( None, self.id_number_search.GetValue()) self.grid.reset()
def on_delete(self, event): """ 删除 """ rows = self.grid.GetSelectedRows() if rows is None or len(rows) == 0: wx.MessageBox(u"请选择要删除的数据!", "提示", style=wx.ICON_HAND) return False selected = rows[0] select_data = self.grid.GetTable().data[selected] dlg = wx.MessageDialog(self, u"是否确定删除数据?", "警告", style=wx.YES_NO | wx.NO_DEFAULT | wx.ICON_INFORMATION) val = dlg.ShowModal() if val == wx.ID_NO: return False dlg.Destroy() service.delete_customer(select_data[6]) self.grid.GetTable().data = service.search_customer( None, self.id_number_search.GetValue()) self.grid.reset()
def __init__(self): gridlib.GridTableBase.__init__(self) self.colLabels = ['姓名', '性别', '身份证号', '电话', '住址', '备注'] self.dataTypes = [ gridlib.GRID_VALUE_STRING, gridlib.GRID_VALUE_STRING, gridlib.GRID_VALUE_STRING, gridlib.GRID_VALUE_STRING, gridlib.GRID_VALUE_STRING, gridlib.GRID_VALUE_STRING ] self.data = service.search_customer(None, None) self._rows = self.GetNumberRows() self._cols = self.GetNumberCols()
def filter_customer(self, event): if self.ignoreEvtText: self.ignoreEvtText = False return text = event.GetString().strip() self.customer_data = service.search_customer(text, None) data_count = len(self.customer_data) for index in range(0, data_count): self.customerCombobox.Insert(self.customer_data[index][0], index, self.customer_data[index][6]) for i in range(data_count, len(self.customerCombobox.GetItems())): self.customerCombobox.Delete(data_count) self.ignoreEvtText = False
def open_create(self, event): """ 打开新增页 """ self.edit_win = customerwin.CustomerWin(self) self.edit_win.CenterOnScreen() val = self.edit_win.ShowModal() if val == wx.ID_OK: try: self.edit_win.save() except ValueError as e: wx.MessageBox(str(e), "提示", style=wx.ICON_HAND) else: wx.MessageBox(u"保存成功!", "提示", style=wx.ICON_INFORMATION) self.edit_win.Destroy() self.grid.GetTable().data = service.search_customer( None, self.id_number_search.GetValue()) self.grid.reset()
def __init__(self, parent): wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=u"编辑车辆信息", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE) self.data = None border = wx.BoxSizer(wx.VERTICAL) # load customer combo data self.customer_data = service.search_customer(None, None) # load insurance company combo data self.company_data = service.search_dict(1) # load authorization self.current_user = auth.Auth.logon_user # new box ------------------------------------------------------------------------- box = wx.StaticBox(self, -1, u"客户信息") box.SetForegroundColour((119, 136, 153)) box_sizer = wx.StaticBoxSizer(box, wx.VERTICAL) border.Add(box_sizer, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) # new line ######################################################################## sizer = wx.BoxSizer(wx.HORIZONTAL) box_sizer.Add(sizer) # 客户姓名 label = wx.StaticText(self, wx.ID_ANY, u"* 姓名:", size=(60, -1), style=wx.ALIGN_RIGHT) label.SetForegroundColour(wx.RED) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.customerCombobox =\ wx.ComboBox(self, wx.ID_ANY, size=wx.Size(120, -1), choices=[], style=wx.CB_DROPDOWN) for customer in self.customer_data: self.customerCombobox.Append(customer[0], customer[6]) sizer.Add(self.customerCombobox, 1, wx.ALIGN_CENTRE | wx.ALL, 5) self.Bind(wx.EVT_COMBOBOX, self.select_customer, self.customerCombobox) self.Bind(wx.EVT_TEXT, self.filter_customer, self.customerCombobox) self.Bind(wx.EVT_CHAR, self.enable_filter, self.customerCombobox) self.ignoreEvtText = False # 客户性别 label = wx.StaticText(self, wx.ID_ANY, u"性别:", size=(60, -1), style=wx.ALIGN_RIGHT) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.customerGenderPanel =\ wx.StaticText(self, wx.ID_ANY, size=wx.Size(120, -1)) sizer.Add(self.customerGenderPanel, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # 身份证号 label = wx.StaticText(self, wx.ID_ANY, u"身份证号:", size=(60, -1), style=wx.ALIGN_RIGHT) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.customerIdNumberPanel =\ wx.StaticText(self, wx.ID_ANY, size=wx.Size(130, -1)) sizer.Add(self.customerIdNumberPanel, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # 客户电话 label = wx.StaticText(self, wx.ID_ANY, u"电话:", size=(60, -1), style=wx.ALIGN_RIGHT) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.customerPhonePanel =\ wx.StaticText(self, wx.ID_ANY, size=wx.Size(120, -1)) sizer.Add(self.customerPhonePanel, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # new box ------------------------------------------------------------------------- box = wx.StaticBox(self, -1, u"车辆信息") box.SetForegroundColour((119, 136, 153)) box_sizer = wx.StaticBoxSizer(box, wx.VERTICAL) border.Add(box_sizer, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) # new line ######################################################################## sizer = wx.BoxSizer(wx.HORIZONTAL) box_sizer.Add(sizer) # 车牌号 label = wx.StaticText(self, wx.ID_ANY, u"* 车牌号:", size=(110, -1), style=wx.ALIGN_RIGHT) label.SetForegroundColour(wx.RED) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.vehiclePlateNumInput =\ wx.TextCtrl(self, wx.ID_ANY, "", size=wx.Size(230, -1), validator=platenumvalidator.PlateNumValidator(None)) sizer.Add(self.vehiclePlateNumInput, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # 车辆型号 label = wx.StaticText(self, wx.ID_ANY, u"* 车辆型号:", size=(110, -1), style=wx.ALIGN_RIGHT) label.SetForegroundColour(wx.RED) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.vehicleModelInput =\ wx.TextCtrl(self, wx.ID_ANY, "", size=wx.Size(230, -1), validator=textvalidator.TextValidator(u"车辆型号")) sizer.Add(self.vehicleModelInput, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # new line ######################################################################## sizer = wx.BoxSizer(wx.HORIZONTAL) box_sizer.Add(sizer) # 车辆登记日期 label = wx.StaticText(self, wx.ID_ANY, u"* 车辆登记日期:", size=(110, -1), style=wx.ALIGN_RIGHT) label.SetForegroundColour(wx.RED) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.vehicleRegDate =\ wx.adv.DatePickerCtrl(self, wx.ID_ANY, size=wx.Size(230, -1), style=wx.adv.DP_DROPDOWN | wx.adv.DP_SHOWCENTURY) sizer.Add(self.vehicleRegDate, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # 公里数 label = wx.StaticText(self, wx.ID_ANY, u"公里数:", size=(110, -1), style=wx.ALIGN_RIGHT) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.mileageInput =\ intctrl.IntCtrl(self, wx.ID_ANY, size=wx.Size(230, -1)) sizer.Add(self.mileageInput, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # new line ######################################################################## sizer = wx.BoxSizer(wx.HORIZONTAL) box_sizer.Add(sizer) # 过户次数 label = wx.StaticText(self, wx.ID_ANY, u"* 过户次数:", size=(110, -1), style=wx.ALIGN_RIGHT) label.SetForegroundColour(wx.RED) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.transCountInput =\ intctrl.IntCtrl(self, wx.ID_ANY, 1, size=wx.Size(230, -1), min=0) sizer.Add(self.transCountInput, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # new box ------------------------------------------------------------------------- box = wx.StaticBox(self, -1, u"贷款信息") box.SetForegroundColour((119, 136, 153)) box_sizer = wx.StaticBoxSizer(box, wx.VERTICAL) border.Add(box_sizer, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) # new line ######################################################################## sizer = wx.BoxSizer(wx.HORIZONTAL) box_sizer.Add(sizer) # 贷款产品、期次 label = wx.StaticText(self, wx.ID_ANY, u"* 贷款产品:", size=(110, -1), style=wx.ALIGN_RIGHT) label.SetForegroundColour(wx.RED) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.loanProductInput =\ wx.TextCtrl(self, wx.ID_ANY, "", size=wx.Size(230, -1), validator=textvalidator.TextValidator(u"贷款产品")) sizer.Add(self.loanProductInput, 1, wx.ALIGN_CENTRE | wx.ALL, 5) label = wx.StaticText(self, wx.ID_ANY, u"* 期次:", size=(110, -1), style=wx.ALIGN_RIGHT) label.SetForegroundColour(wx.RED) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.loanPeriodInput =\ wx.TextCtrl(self, wx.ID_ANY, "", size=wx.Size(230, -1), validator=textvalidator.TextValidator(u"期次")) sizer.Add(self.loanPeriodInput, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # new line ######################################################################## sizer = wx.BoxSizer(wx.HORIZONTAL) box_sizer.Add(sizer) # 贷款年限 label = wx.StaticText(self, wx.ID_ANY, u"* 贷款年限:", size=(110, -1), style=wx.ALIGN_RIGHT) label.SetForegroundColour(wx.RED) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.loanTermInput =\ intctrl.IntCtrl(self, wx.ID_ANY, 1, size=wx.Size(230, -1), min=1) sizer.Add(self.loanTermInput, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # 贷款金额 label = wx.StaticText(self, wx.ID_ANY, u"贷款金额:", size=(110, -1), style=wx.ALIGN_RIGHT) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.loanValueInput =\ intctrl.IntCtrl(self, wx.ID_ANY, 1, size=wx.Size(230, -1)) sizer.Add(self.loanValueInput, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # new line ######################################################################## sizer = wx.BoxSizer(wx.HORIZONTAL) box_sizer.Add(sizer) # 贷款提报日期 label = wx.StaticText(self, wx.ID_ANY, u"贷款提报日期:", size=(110, -1), style=wx.ALIGN_RIGHT) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.loanReportDate = \ wx.adv.DatePickerCtrl(self, wx.ID_ANY, size=wx.Size(230, -1), style=wx.adv.DP_DROPDOWN | wx.adv.DP_SHOWCENTURY | wx.adv.DP_ALLOWNONE) sizer.Add(self.loanReportDate, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # 贷款通过日期 label = wx.StaticText(self, wx.ID_ANY, u"贷款通过日期:", size=(110, -1), style=wx.ALIGN_RIGHT) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.loanPassedDate = \ wx.adv.DatePickerCtrl(self, wx.ID_ANY, size=wx.Size(230, -1), style=wx.adv.DP_DROPDOWN | wx.adv.DP_SHOWCENTURY | wx.adv.DP_ALLOWNONE) sizer.Add(self.loanPassedDate, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # new line ######################################################################## sizer = wx.BoxSizer(wx.HORIZONTAL) box_sizer.Add(sizer) # 放款日期 label = wx.StaticText(self, wx.ID_ANY, u"* 放款日期:", size=(110, -1), style=wx.ALIGN_RIGHT) label.SetForegroundColour(wx.RED) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.loanDate = \ wx.adv.DatePickerCtrl(self, wx.ID_ANY, size=wx.Size(230, -1), style=wx.adv.DP_DROPDOWN | wx.adv.DP_SHOWCENTURY) sizer.Add(self.loanDate, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # new box ------------------------------------------------------------------------- box = wx.StaticBox(self, -1, u"投保信息") box.SetForegroundColour((119, 136, 153)) box_sizer = wx.StaticBoxSizer(box, wx.VERTICAL) border.Add(box_sizer, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) # new line ######################################################################## sizer = wx.BoxSizer(wx.HORIZONTAL) box_sizer.Add(sizer) # 承保公司 label = wx.StaticText(self, wx.ID_ANY, u"承保公司:", size=(110, -1), style=wx.ALIGN_RIGHT) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.insuranceCompanyCombobox = \ wx.ComboBox(self, wx.ID_ANY, size=wx.Size(230, -1), choices=[], style=wx.CB_DROPDOWN | wx.CB_READONLY) sizer.Add(self.insuranceCompanyCombobox, 1, wx.ALIGN_CENTRE | wx.ALL, 5) for company in self.company_data: self.insuranceCompanyCombobox.Append(company[1], company[0]) # 险种 label = wx.StaticText(self, wx.ID_ANY, u"险种:", size=(110, -1), style=wx.ALIGN_RIGHT) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.insuranceTypeInput =\ wx.TextCtrl(self, wx.ID_ANY, "", size=wx.Size(230, -1)) sizer.Add(self.insuranceTypeInput, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # new line ######################################################################## sizer = wx.BoxSizer(wx.HORIZONTAL) box_sizer.Add(sizer) # 保险生效日期 label = wx.StaticText(self, wx.ID_ANY, u"* 保险生效日期:", size=(110, -1), style=wx.ALIGN_RIGHT) label.SetForegroundColour(wx.RED) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.insuranceStartDate = \ wx.adv.DatePickerCtrl(self, wx.ID_ANY, size=wx.Size(230, -1), style=wx.adv.DP_DROPDOWN | wx.adv.DP_SHOWCENTURY) sizer.Add(self.insuranceStartDate, 1, wx.ALIGN_CENTRE | wx.ALL, 5) self.Bind(wx.adv.EVT_DATE_CHANGED, self.get_end, self.insuranceStartDate) # 保险到期日期 label = wx.StaticText(self, wx.ID_ANY, u"* 保险到期日期:", size=(110, -1), style=wx.ALIGN_RIGHT) label.SetForegroundColour(wx.RED) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.insuranceEndDate = \ wx.adv.DatePickerCtrl(self, wx.ID_ANY, size=wx.Size(230, -1), style=wx.adv.DP_DROPDOWN | wx.adv.DP_SHOWCENTURY) sizer.Add(self.insuranceEndDate, 1, wx.ALIGN_CENTRE | wx.ALL, 5) # new line ######################################################################## sizer = wx.BoxSizer(wx.HORIZONTAL) border.Add(sizer, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) # 备注 label = wx.StaticText(self, wx.ID_ANY, u"备注:", size=(110, -1), style=wx.ALIGN_RIGHT) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.remarkInput =\ wx.TextCtrl(self, wx.ID_ANY, "", size=wx.Size(470, -1), style=wx.TE_MULTILINE) sizer.Add(self.remarkInput, 1, wx.ALIGN_CENTRE | wx.ALL, 5) line = wx.StaticLine(self, -1, size=wx.DefaultSize, style=wx.HORIZONTAL) border.Add(line, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.TOP, 5) # 按钮 buttons = wx.StdDialogButtonSizer() btn = wx.Button(self, wx.ID_OK, u"保存") btn.SetDefault() buttons.Add(btn) btn = wx.Button(self, wx.ID_CANCEL, u"取消") buttons.Add(btn) buttons.Realize() border.Add(buttons, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.SetSizer(border) border.Fit(self)