1
# -*- coding: utf-8 -*-
4
import Synergy.Visual as Visual
6
import wx.lib.pubsub as pubsub
7
from Windows import Dialogs
8
from Synergy import Exceptions
10
class CasesVisual(Visual.Visual):
11
def __init__(self,*args,**kwargs):
12
super(CasesVisual,self).__init__(*args,**kwargs)
16
super(CasesVisual,self)._Subscribe()
17
pubsub.Publisher().subscribe(self.OnDialogEvent, "Cases.Events.Dialog")
18
pubsub.Publisher().subscribe(self.OnEvent, "Users.Events")
21
def OnDialogEvent(self,message):
22
if hasattr(self,message.data[0]):
23
getattr(self,message.data[0])(*message.data[1:])
27
self.loggedUser=data[0]
30
def NewCaseDialog(self,*args,**kwargs):
31
dlg=Dialogs.CasesDialog(self._model)
32
if dlg.ShowModal() == wx.ID_OK:
36
self._model.InsertCase(data)
37
except Exceptions.DatabaseError,error:
38
wiad=u"Pojawił się nieoczekiwany problem z wykoniem zapytania SQL. Szczegóły błędu:\n\n"
39
dlg2=wx.MessageDialog(None,wiad+error.message,u"Problem z bazą danych",wx.OK|wx.ICON_ERROR)
45
def NewActionDialog(self,*args,**kwargs):
46
dlg=Dialogs.ActionDialog(self._model)
47
if dlg.ShowModal() == wx.ID_OK:
51
data['user_id']=self.loggedUser
52
self._model.InsertAction(data)
53
except Exceptions.DatabaseError,error:
54
wiad=u"Pojawił się nieoczekiwany problem z wykoniem zapytania SQL. Szczegóły błędu:\n\n"
55
dlg2=wx.MessageDialog(None,wiad+error.message,u"Problem z bazą danych",wx.OK|wx.ICON_ERROR)
62
def UpdateAction(self,*args,**kwargs):
63
dlg=Dialogs.UpdateActionDialog(args[0],self._model)
64
if dlg.ShowModal() == wx.ID_OK:
68
self._model.UpdateAction(data,{'aid':args[0]})
69
except Exceptions.DatabaseError,error:
70
wiad=u"Pojawił się nieoczekiwany problem z wykoniem zapytania SQL. Szczegóły błędu:\n\n"
71
dlg2=wx.MessageDialog(None,wiad+error.message,u"Problem z bazą danych",wx.OK|wx.ICON_ERROR)
78
def NewTermDialog(self,*args,**kwargs):
79
dlg=Dialogs.TermDialog(self._model)
80
if dlg.ShowModal() == wx.ID_OK:
84
data['user_id']=self.loggedUser
85
self._model.InsertTerm(data)
86
except Exceptions.DatabaseError,error:
87
wiad=u"Pojawił się nieoczekiwany problem z wykoniem zapytania SQL. Szczegóły błędu:\n\n"
88
dlg2=wx.MessageDialog(None,wiad+error.message,u"Problem z bazą danych",wx.OK|wx.ICON_ERROR)
95
def UpdateTerm(self,*args,**kwargs):
96
dlg=Dialogs.UpdateTermDialog(args[0],self._model)
97
if dlg.ShowModal() == wx.ID_OK:
101
self._model.UpdateTerm(data,{'tid':args[0]})
102
except Exceptions.DatabaseError,error:
103
wiad=u"Pojawił się nieoczekiwany problem z wykoniem zapytania SQL. Szczegóły błędu:\n\n"
104
dlg2=wx.MessageDialog(None,wiad+error.message,u"Problem z bazą danych",wx.OK|wx.ICON_ERROR)
112
def UpdateCase(self,*args,**kwargs):
113
dlg=Dialogs.UpdateCaseDialog(args[0],self._model)
114
if dlg.ShowModal() == wx.ID_OK:
118
self._model.UpdateCase(data,{'cid':args[0]})
119
except Exceptions.DatabaseError,error:
120
wiad=u"Pojawił się nieoczekiwany problem z wykoniem zapytania SQL. Szczegóły błędu:\n\n"
121
dlg2=wx.MessageDialog(None,wiad+error.message,u"Problem z bazą danych",wx.OK|wx.ICON_ERROR)