source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/BMX41000/IHS BMX Framework/IndianHealthService.BMXNet.WinForm/DesktopContext.cs@ 1492

Last change on this file since 1492 was 1146, checked in by Sam Habiel, 14 years ago

Initial Import of BMX4

File size: 3.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using IndianHealthService.BMXNet.Model;
5using System.Data;
6
7namespace IndianHealthService.BMXNet.WinForm
8{
9 public class DesktopContext : DesktopObject, Context
10 {
11
12
13 public event EventHandler<ContextChangedArgs> Changed;
14
15 public event EventHandler<ContextChangingArgs> Changing;
16
17
18 public bool HasPatient
19 {
20 get { return this.Patient != null; }
21 }
22
23 public bool HasVisit
24 {
25 get { return this.Visit != null; }
26 }
27
28 private User _user = null;
29
30 public User User
31 {
32 get { return _user; }
33 set { _user = value; }
34 }
35
36
37 private DesktopVisit _desktopVisit;
38
39
40
41internal DesktopVisit DesktopVisit
42{
43 get { return _desktopVisit; }
44 set { _desktopVisit = value; }
45}
46
47private DesktopPatient _desktopPatient;
48
49internal DesktopPatient DesktopPatient
50{
51 get { return _desktopPatient; }
52 set { _desktopPatient = value; }
53}
54 public Visit Visit
55 {
56 get { return this.DesktopVisit; }
57 }
58
59
60 public Patient Patient
61 {
62 get { return this.DesktopPatient; }
63 }
64
65
66 public bool RequestCanChangePatient(Patient aPatient, bool force)
67 {
68 if (this.Changing != null)
69 {
70 ContextChangingArgs args = new ContextChangingArgs();
71 args.IsPatientChange = true;
72 args.Cancel = false;
73 args.BeforeContext = this;
74 this.Changing.Invoke(this, args);
75
76 return !args.Cancel || force;
77 }
78 else
79 {
80 return true;
81 }
82 }
83
84
85 public bool RequestCanChangeVisit(Visit aVisit, bool force)
86 {
87 if (this.Changing != null)
88 {
89 ContextChangingArgs args = new ContextChangingArgs();
90 args.IsVisitChange = true;
91 args.Cancel = false;
92 args.BeforeContext = this;
93 this.Changing.Invoke(this, args);
94
95 return !args.Cancel || force;
96 }
97 else
98 {
99 return true;
100 }
101 }
102
103
104 public bool ChangePatient(Patient aPatient)
105 {
106 this.DesktopPatient= (DesktopPatient)aPatient;
107 this.DesktopVisit= null;
108
109 if (this.Changed != null)
110 {
111 ContextChangedArgs args = new ContextChangedArgs();
112 args.IsPatientChange = true;
113 args.AfterContext = this;
114 this.Changed.Invoke(this, args);
115 }
116 return true;
117 }
118
119 public bool ChangeVisit(Visit aVisit)
120 {
121 this.DesktopVisit = (DesktopVisit)aVisit;
122
123 if (this.Changed != null)
124 {
125 ContextChangedArgs args = new ContextChangedArgs();
126 args.IsVisitChange = true;
127 args.AfterContext = this;
128 this.Changed.Invoke(this, args);
129 }
130 return true;
131 }
132
133
134 }
135}
Note: See TracBrowser for help on using the repository browser.