69
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
1 using System;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
2 using System.ComponentModel;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
3 using System.Linq;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
4 using System.Windows;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
5 using System.Windows.Input;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
6 using FluentValidation;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
7 using SilverlightValidation.Interfaces;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
8 using SilverlightValidation.Validators;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
9 using SilverlightValidation.Models;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
10 using SilverlightValidation.Commands;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
11 using GalaSoft.MvvmLight.Messaging;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
12 using SilverlightValidation.Messages;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
13
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
14 namespace SilverlightValidation.ViewModels
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
15 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
16 public class UserViewModel : ViewModelBase, IUserModel, IEditableObject
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
17 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
18 #region Fields
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
19
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
20 private readonly UserModelValidator _validator;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
21 private UserModel _data;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
22 private UserModel _backup;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
23
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
24 #endregion
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
25
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
26 #region Constructor
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
27
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
28 public UserViewModel(UserModel model, UserModelValidator validator)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
29 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
30 _validator = validator;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
31 _data = model;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
32 _backup = model.Clone();
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
33
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
34 OkCommand = new RelayCommand(OkCommandExecute);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
35 CancelCommand = new RelayCommand(CancelCommandExecute);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
36 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
37
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
38 #endregion
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
39
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
40 #region Methods
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
41
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
42 private void SetProperties(IUserModel source)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
43 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
44 _data.Username = source.Username;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
45 _data.Password = source.Password;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
46 _data.Email = source.Email;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
47 _data.DateOfBirth = source.DateOfBirth;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
48 _data.Description = source.Description;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
49 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
50
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
51 #endregion
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
52
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
53 #region Properties
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
54
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
55 private const string UsernameProperty = "Username";
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
56 public string Username
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
57 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
58 get { return _data.Username; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
59 set
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
60 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
61 if (_data.Username != value)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
62 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
63 _data.Username = value;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
64 RaisePropertyChanged(UsernameProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
65 IsChanged = true;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
66 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
67
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
68 ClearError(UsernameProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
69 var validationResult = _validator.Validate(this, UsernameProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
70 if (!validationResult.IsValid)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
71 validationResult.Errors.ToList().ForEach(x => SetError(UsernameProperty, x.ErrorMessage));
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
72 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
73 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
74
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
75 private const string PasswordProperty = "Password";
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
76 public string Password
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
77 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
78 get { return _data.Password; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
79 set
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
80 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
81 if (_data.Password != value)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
82 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
83 _data.Password = value;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
84 RaisePropertyChanged(PasswordProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
85 IsChanged = true;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
86 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
87
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
88 ClearError(PasswordProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
89 var validationResult = _validator.Validate(this, PasswordProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
90 if (!validationResult.IsValid)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
91 validationResult.Errors.ToList().ForEach(x => SetError(PasswordProperty, x.ErrorMessage));
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
92 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
93 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
94
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
95 private const string EmailProperty = "Email";
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
96 public string Email
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
97 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
98 get { return _data.Email; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
99 set
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
100 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
101 if (_data.Email != value)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
102 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
103 _data.Email = value;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
104 RaisePropertyChanged(EmailProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
105 IsChanged = true;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
106 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
107
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
108 ClearError(EmailProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
109 var validationResult = _validator.Validate(this, EmailProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
110 if (!validationResult.IsValid)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
111 validationResult.Errors.ToList().ForEach(x => SetError(EmailProperty, x.ErrorMessage));
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
112 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
113 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
114
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
115 private const string DateOfBirthProperty = "DateOfBirth";
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
116 public DateTime? DateOfBirth
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
117 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
118 get { return _data.DateOfBirth; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
119 set
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
120 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
121 if (_data.DateOfBirth != value)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
122 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
123 _data.DateOfBirth = value;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
124 RaisePropertyChanged(DateOfBirthProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
125 IsChanged = true;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
126 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
127
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
128 ClearError(DateOfBirthProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
129 var validationResult = _validator.Validate(this, DateOfBirthProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
130 if (!validationResult.IsValid)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
131 validationResult.Errors.ToList().ForEach(x => SetError(DateOfBirthProperty, x.ErrorMessage));
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
132 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
133 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
134
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
135 private const string DescriptionProperty = "Description";
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
136 public string Description
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
137 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
138 get { return _data.Description; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
139 set
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
140 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
141 if (_data.Description != value)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
142 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
143 _data.Description = value;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
144 RaisePropertyChanged(DescriptionProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
145 IsChanged = true;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
146 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
147
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
148 ClearError(DescriptionProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
149 var validationResult = _validator.Validate(this, DescriptionProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
150 if (!validationResult.IsValid)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
151 validationResult.Errors.ToList().ForEach(x => SetError(DescriptionProperty, x.ErrorMessage));
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
152 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
153 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
154
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
155 #endregion
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
156
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
157 #region Commands
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
158
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
159 public ICommand OkCommand { get; set; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
160 public ICommand CancelCommand { get; set; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
161
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
162 private void OkCommandExecute(object obj)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
163 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
164 RefreshToViewErrors();
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
165
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
166 if (IsChanged && !HasErrors)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
167 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
168 // save here
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
169 Messenger.Default.Send<UserViewResponseMessage>(
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
170 new UserViewResponseMessage() { UserViewModel = this });
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
171 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
172 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
173
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
174 // in case user hasn't touched the form
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
175 private void RefreshToViewErrors()
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
176 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
177 Username = _data.Username;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
178 Password = _data.Password;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
179 Email = _data.Email;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
180 DateOfBirth = _data.DateOfBirth;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
181 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
182
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
183 private void CancelCommandExecute(object obj)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
184 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
185 Messenger.Default.Send<UserViewResponseMessage>(
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
186 new UserViewResponseMessage() { UserViewModel = null });
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
187 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
188
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
189 #endregion
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
190
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
191 private void ResetFormData()
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
192 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
193 SetProperties(_backup);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
194 ClearAllErrors();
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
195 IsChanged = false;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
196 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
197
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
198 public bool IsChanged { get; private set; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
199
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
200 #region IEditableObject for datagrid
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
201
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
202 private bool inEdit;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
203 public void BeginEdit()
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
204 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
205 if (inEdit) return;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
206 inEdit = true;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
207 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
208
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
209 public void CancelEdit()
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
210 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
211 if (!inEdit) return;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
212 inEdit = false;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
213 ResetFormData();
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
214 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
215
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
216 public void EndEdit()
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
217 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
218 if (!inEdit) return;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
219 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
220
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
221 #endregion
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
222 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
223 }
|