def OnAddBill(self, e): if IntValidator.valid(self.apartamentNumber.GetValue(), 0, 99) == False: dlg = wx.MessageDialog(None, "Invalid input!", "Info", wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() return if IntValidator.valid(self.billCost.GetValue(), 0, 10000) == False: dlg = wx.MessageDialog(None, "Invalid input!", "Info", wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() return apNumber = int(self.apartamentNumber.GetValue()) billCost = int(self.billCost.GetValue()) billType = self.billType.GetCurrentSelection() + 1 self.apartamentController.addBill(apNumber, billType, billCost) dlg = wx.MessageDialog(None, "Bill added!", "Info", wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy()
def OnClick(self,e): if IntValidator.valid(self.cost.GetValue(),0,10000) == False: dlg = wx.MessageDialog(None, "Invalid input!", "Info", wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() return cost = int(self.cost.GetValue()) dlg = wx.MessageDialog(None, "Result:\n"+self.apartamentController.getApartamentsWithCostGreatherThanAsString(cost), "Info", wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy()
def OnEditBill(self,e): if IntValidator.valid(self.leftNumber.GetValue(),0,99) == False: dlg = wx.MessageDialog(None, "Invalid input!", "Info", wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() return if IntValidator.valid(self.rightNumber.GetValue(),0,99) == False: dlg = wx.MessageDialog(None, "Invalid input!", "Info", wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() return leftNumberInt = int(self.leftNumber.GetValue()) rightNumberInt = int(self.rightNumber.GetValue()) if leftNumberInt>rightNumberInt: dlg = wx.MessageDialog(None, "Invalid input!", "Info", wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() return self.apartamentController.deleteAllBillsFromApartamentsInRange(leftNumberInt,rightNumberInt) dlg = wx.MessageDialog(None, "Success", "Info", wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy()
def OnEditBill(self, e): if ( IntValidator.valid(self.apartamentNumber.GetValue(), 0, self.apartamentController.getApartamentsCount() - 1) == False ): dlg = wx.MessageDialog(None, "Invalid input!", "Info", wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() return apNumber = int(self.apartamentNumber.GetValue()) self.apartamentController.clearApartamentBills(apNumber) dlg = wx.MessageDialog(None, "Apartament bills deleted!", "Info", wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy()
def testIntValidator(self): self.assertEqual(IntValidator.valid("123",0,200),True) self.assertEqual(IntValidator.valid("lala",0,200),False) self.assertEqual(IntValidator.valid("123",0,50),False)