Bonsoirs, je doit concevoir un service en WCF (Architecture SOA) le problème est que ma class OList qui hérite de ObservableCollection ne me rafraîchi pas sur le client lorsque les données son modifier il faut redémarrer le programme pour obtenir un rafraîchissement de la fenêtre...
Donc si quelqu'un a une idée..
Voilà une Partie du code
Couche BE : 5 Classes Medicine, Doctor, Patient, Visit et OList
Voilà Pour le OList:
Couche DAL: 3 Class (Dal_imp, Dal_XML_imp et Datasource) et 1 Interface IDAL
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Runtime.Serialization; namespace BE { public class OList<T> : ObservableCollection<T> { public OList() { } public bool Exists(Predicate<T> match) { return this.ToList().Exists(match); } public T Find(Predicate<T> match) { return this.ToList().Find(match); } } }
Couche BL 1 CLass BL_Class et une Interface IBL:
Voilà le BL_Class :
Couche BL_WcfService : 1 Classe BL_Class et 1 Interface IBL :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481 using System;// using System.Collections.Generic; using System.Linq; using BE; using DAL; using System.Collections.ObjectModel; using System.ComponentModel; using System.Xml.Linq; using System.IO; using System.Data.Services.Client; namespace BL { public class BL_Class : IBL, INotifyPropertyChanged // a MAJ (creer une method qui ne donne le medoc que si la dette du patient n'a pas depasé x ou que le medoc est critiq { #region Binding #region INotifyPropertyChanged public event PropertyChangedEventHandler PropertyChanged; public void RaisePropertyChanged(string PropertyName) { if (this.PropertyChanged != null) { this.PropertyChanged(this, new PropertyChangedEventArgs(PropertyName)); } } #endregion #region Property private OList<Visit> m_lstVisits = new OList<Visit>(); public OList<Visit> lstVisits { get { return m_lstVisits; } set { m_lstVisits = value; RaisePropertyChanged("lstVisits"); } } private Visit m_SelectedVisit; public Visit SelectedVisit { get { return m_SelectedVisit; } set { m_SelectedVisit = value; RaisePropertyChanged("SelectedVisit"); } } private OList<Doctor> m_lstDoctors = new OList<Doctor>(); public OList<Doctor> lstDoctors { get { return m_lstDoctors; } set { m_lstDoctors = value; RaisePropertyChanged("lstDoctors"); } } private Doctor m_SelectedDoctor; public Doctor SelectedDoctor { get { return m_SelectedDoctor; } set { m_SelectedDoctor = value; RaisePropertyChanged("SelectedDoctor"); } } private OList<Patient> m_lstPatients = new OList<Patient>(); public OList<Patient> lstPatients { get { return m_lstPatients; } set { m_lstPatients = value; RaisePropertyChanged("lstPatients"); } } private Patient m_SelectedPatient; public Patient SelectedPatient { get { return m_SelectedPatient; } set { m_SelectedPatient = value; RaisePropertyChanged("SelectedPatient"); } } private OList<Visit> m_GetVisitsOfPatient = new OList<Visit>(); public OList<Visit> GetVisitsOfPatient { get { return m_GetVisitsOfPatient; } set { m_GetVisitsOfPatient = value; RaisePropertyChanged("GetVisitsOfPatient"); } } private OList<Medicine> m_lstMedicines = new OList<Medicine>(); public OList<Medicine> lstMedicines { get { return m_lstMedicines; } set { m_lstMedicines = value; RaisePropertyChanged("lstMedicines"); } } private Medicine m_SelectedMedicine; public Medicine SelectedMedicine { get { return m_SelectedMedicine; } set { m_SelectedMedicine = value; RaisePropertyChanged("SelectedMedicine"); } } #endregion #endregion public int VisitNum { get; set; } public Dal_XML_imp Dal { get; set; } public XElement XVisitNum { get; set; } // Constructor public BL_Class() { Dal = new Dal_XML_imp(); lstDoctors = GetListDoctors(); lstMedicines = GetListMedecine(); lstVisits = GetListVisit(); VisitNum = 0; lstPatients = GetListPatient(); // GetVisitsOfPatient = GetVisits(SelectedPatient); // Load the value of VisitNum from the app.config if (File.Exists(@"Config.xml")) XVisitNum = XElement.Load(@"Config.xml"); else XVisitNum = new XElement("VisitNum", "0"); if (XVisitNum == null) XVisitNum = new XElement("VisitNum"); if (XVisitNum.Value == "") VisitNum = 0; else VisitNum = Convert.ToInt32(XVisitNum.Value); } // IBL public double PriceCalculator(int id, DateTime begining, DateTime end) { double price = 0; List<Visit> visitopatient = new List<Visit>(); visitopatient = GetListVisit().Where(v => v.IdInsured == id && (v.Date <= end && v.Date >= begining)).ToList(); //We make the whole list of visits for this patient according to the dates. foreach (Visit vis in visitopatient) // For each visit there'sa list of medicines { foreach (Medicine med in vis.Medicines) //For each medicines, we need to know if the patient pays the whole price or not { if (med.InBasket) price += med.Price * med.Participation; //We make the some of the each medicines'price. else price += med.Price; } } return price; } public OList<Visit> GetVisits(Patient patient) { OList<Visit> LV = new OList<Visit>(); IEnumerable<Visit> VisitOfPatient = GetListVisit().Where<Visit>(v => v.IdInsured == patient.Id); foreach (Visit item in VisitOfPatient) LV.Add(item); return LV; } public double PriceCalculator(Doctor doctor) { return Dal.GetListVisit().Where<Visit>(i => i.LicenseNum == doctor.NumDoctor).ToList<Visit>().Sum(j => j.Medicines.Sum(k => k.Price)); // I create a list of visits for this doctor with which I use sum() to make the sum of every prices. } public OList<Medicine> SortedListMedecine() { OList<Medicine> LM = new OList<Medicine>(); IEnumerable<Medicine> SortedMedecine = GetListMedecine().OrderBy(medecine => medecine.Count); foreach (Medicine item in SortedMedecine) LM.Add(item); return LM; } public OList<Patient> FilterOfPatients(Predicate<Patient> function) { OList<Patient> LP = new OList<Patient>(); IEnumerable<Patient> FilterPatients = GetListPatient().Where<Patient>(p => function(p)); foreach (Patient item in FilterPatients) LP.Add(item); return LP; } public void Paypal(ref Visit visit) { Visit myVisit = visit; Patient myPat = GetListPatient().Find(p => p.Id == myVisit.IdInsured); if (GetListPatient().Find(p => p.Id == myVisit.IdInsured).Debt < 1000000000 || myVisit.Medicines.Exists(m => m.Critical)) { myPat.Debt += PriceCalculator(myVisit.IdInsured, myVisit.Date, myVisit.Date); updatePatient(myPat, GetListPatient().IndexOf(GetListPatient().Find(p => p.Id == myVisit.IdInsured))); visit.Paid = true; } } //Doctor public void addDoctor(Doctor doctor) { Dal.addDoctor(doctor); } public void delDoctor(int i) { Dal.delDoctor(i); } public void updateDoctor(Doctor doctor, int i) { Dal.updateDoctor(doctor, i); } //Patient public void addPatient(Patient patient) { Dal.addPatient(patient); } public void delPatient(int i) { if ((GetListPatient()[i].Debt == 0) && (GetListPatient()[i].Bonus == 0)) Dal.delPatient(i); } public void updatePatient(Patient patient, int i) { Dal.updatePatient(patient, i); } //Visit public void addVisit(Visit visit) { if (GetListPatient().Exists(p => p.Id == visit.IdInsured) && GetListDoctors().Exists(d => d.NumDoctor == visit.LicenseNum)) { Medicine currentMed = new Medicine(); int indexMed; visit.Nbr = VisitNum; Dal.addVisit(visit); VisitNum++; XVisitNum.Value = VisitNum.ToString(); XVisitNum.Save(@"Config.xml"); //Incrementation du count de chaque medicine pris foreach (Medicine item in visit.Medicines) { currentMed = GetListMedecine().ToList().Find(m => m.Code == item.Code); indexMed = GetListMedecine().IndexOf(currentMed); currentMed.Count++; //Incrementation updateMedecine(currentMed, indexMed); //Update } } } //Incrementation faite public void updateVisit(Visit visit, int i) { int indexMed; Medicine currentMed = new Medicine(); visit.Nbr = GetListVisit()[i].Nbr; //The number of the visit can't be changed. if (!GetListPatient().ToList().Exists(p => p.Id == visit.IdInsured)) //If the patient's ID doesn't exist, so it will keep the old one. visit.IdInsured = GetListVisit()[i].IdInsured; if (!GetListDoctors().ToList().Exists(d => d.NumDoctor == visit.LicenseNum)) //Idem for the doctor's number. visit.LicenseNum = GetListVisit()[i].LicenseNum; //Decrementation des count foreach ( Medicine item in GetListVisit()[i].Medicines) { currentMed = GetListMedecine().ToList().Find(m => m.Code == item.Code); indexMed = GetListMedecine().IndexOf(currentMed); currentMed.Count--; updateMedecine(currentMed, indexMed); } // Updating of our visit Dal.updateVisit(visit, i); //reIncrementation des count foreach (Medicine item in visit.Medicines) { currentMed = GetListMedecine().ToList().Find(m => m.Code == item.Code); indexMed = GetListMedecine().IndexOf(currentMed); currentMed.Count++; // Incrementation updateMedecine(currentMed, indexMed); // Update } } //Decrementation & reIncrementation of medicines DONE. //Medicines public void addMedecine(Medicine medecine) { Dal.addMedecine(medecine); } public void delMedecine(int i) { Dal.delMedecine(i); } public void updateMedecine(Medicine medecine, int i) { Dal.updateMedecine(medecine, i); } public OList<Doctor> GetListDoctors() { return Dal.GetListDoctors(); } public OList<Patient> GetListPatient() { return Dal.GetListPatient(); } public OList<Medicine> GetListMedecine() { return Dal.GetListMedecine(); } public OList<Visit> GetListVisit() { return Dal.GetListVisit(); } //EXPLICIT IMPLEMENT double IBL.PriceCalculator(int id, DateTime begining, DateTime end) { double price = 0; List<Visit> visitopatient = new List<Visit>(); visitopatient = GetListVisit().Where(v => v.IdInsured == id && (v.Date <= end && v.Date >= begining)).ToList(); //We make the whole list of visits for this patient according to the dates. foreach (Visit vis in visitopatient) // For each visit there'sa list of medicines { foreach (Medicine med in vis.Medicines) //For each medicines, we need to know if the patient pays the whole price or not { if (med.InBasket) price += med.Price * med.Participation; //We make the some of the each medicines'price. else price += med.Price; } } return price; } OList<Visit> IBL.GetVisits(Patient patient) { OList<Visit> LV = new OList<Visit>(); IEnumerable<Visit> VisitOfPatient = GetListVisit().Where<Visit>(v => v.IdInsured == patient.Id); foreach (Visit item in VisitOfPatient) LV.Add(item); return LV; } double IBL.PriceCalculator(Doctor doctor) { return Dal.GetListVisit().Where<Visit>(i => i.LicenseNum == doctor.NumDoctor).ToList<Visit>().Sum(j => j.Medicines.Sum(k => k.Price)); } OList<Medicine> IBL.SortedListMedecine() { OList<Medicine> LM = new OList<Medicine>(); IEnumerable<Medicine> SortedMedecine = GetListMedecine().OrderBy(medecine => medecine.Count); foreach (Medicine item in SortedMedecine) LM.Add(item); return LM; } OList<Patient> IBL.FilterOfPatients(Predicate<Patient> function) { OList<Patient> LP = new OList<Patient>(); IEnumerable<Patient> FilterPatients = GetListPatient().Where<Patient>(p => function(p)); foreach (Patient item in FilterPatients) LP.Add(item); return LP; } void IBL.Paypal(Visit visit) { Visit myVisit = visit; Patient myPat = GetListPatient().Find(p => p.Id == myVisit.IdInsured); if (GetListPatient().Find(p => p.Id == myVisit.IdInsured).Debt < 1000000000 || myVisit.Medicines.Exists(m => m.Critical)) { myPat.Debt += PriceCalculator(myVisit.IdInsured, myVisit.Date, myVisit.Date); updatePatient(myPat, GetListPatient().IndexOf(GetListPatient().Find(p => p.Id == myVisit.IdInsured))); visit.Paid = true; } } //MAJ void IBL.addDoctor(Doctor doctor) { Dal.addDoctor(doctor); } void IBL.delDoctor(int i) { Dal.delDoctor(i); } void IBL.updateDoctor(Doctor doctor, int i) { Dal.updateDoctor(doctor, i); } void IBL.addPatient(Patient patient) { Dal.addPatient(patient); } void IBL.delPatient(int i) { Dal.delPatient(i); } void IBL.updatePatient(Patient patient, int i) { Dal.updatePatient(patient, i); } void IBL.addVisit(Visit visit) { if (GetListPatient().Exists(p => p.Id == visit.IdInsured) && GetListDoctors().Exists(d => d.NumDoctor == visit.LicenseNum)) { Medicine currentMed = new Medicine(); int indexMed; visit.Nbr = VisitNum; Dal.addVisit(visit); VisitNum++; //Incrementation du count de chaque medicine pris foreach (Medicine item in visit.Medicines) { currentMed = GetListMedecine().ToList().Find(m => m.Code == item.Code); indexMed = GetListMedecine().IndexOf(currentMed); currentMed.Count++; //Incrementation updateMedecine(currentMed, indexMed); //Update } } } void IBL.updateVisit(Visit visit, int i) { int indexMed; Medicine currentMed = new Medicine(); visit.Nbr = GetListVisit()[i].Nbr; //The number of the visit can't be changed. if (!GetListPatient().ToList().Exists(p => p.Id == visit.IdInsured)) //If the patient's ID doesn't exist, so it will keep the old one. visit.IdInsured = GetListVisit()[i].IdInsured; if (!GetListDoctors().ToList().Exists(d => d.NumDoctor == visit.LicenseNum)) //Idem for the doctor's number. visit.LicenseNum = GetListVisit()[i].LicenseNum; //Decrementation des count foreach (Medicine item in GetListVisit()[i].Medicines) { currentMed = GetListMedecine().ToList().Find(m => m.Code == item.Code); indexMed = GetListMedecine().IndexOf(currentMed); currentMed.Count--; updateMedecine(currentMed, indexMed); } } void IBL.addMedecine(Medicine medecine) { Dal.addMedecine(medecine); } void IBL.delMedecine(int i) { Dal.delMedecine(i); } void IBL.updateMedecine(Medicine medecine, int i) { Dal.updateMedecine(medecine, i); } OList<Doctor> IBL.GetListDoctors() { return Dal.GetListDoctors(); } OList<Patient> IBL.GetListPatient() { return Dal.GetListPatient(); } OList<Medicine> IBL.GetListMedecine() { return Dal.GetListMedecine(); } OList<Visit> IBL.GetListVisit() { return Dal.GetListVisit(); } } }
Voilà pour le IBL :
et Enfin la Couche UI (WPF): une référence de service IBLService, Un BL_Adaptator et le MainWindow (et d'autre fenêtre)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 using System; using System.Collections.Generic; using System.Linq; using System.ServiceModel; using System.Text; using System.Threading.Tasks; using BE; using System.Runtime.Serialization; using System.Collections.ObjectModel; namespace BL_WcfService { [ServiceContract] interface IBL { [OperationContract] void addDoctor(Doctor doctor); [OperationContract] void delDoctor(int i); [OperationContract] void updateDoctor(Doctor doctor, int i); [OperationContract] void addPatient(Patient patient); [OperationContract] void delPatient(int i); [OperationContract] void updatePatient(Patient patient, int i); [OperationContract] void addVisit(Visit visit); [OperationContract] void updateVisit(Visit visit, int i); [OperationContract] void addMedecine(Medicine medecine); [OperationContract] void delMedecine(int i); [OperationContract] void updateMedecine(Medicine medecine, int i); [OperationContract] OList<Doctor> GetListDoctors(); [OperationContract] OList<Patient> GetListPatient(); [OperationContract] OList<Medicine> GetListMedecine(); [OperationContract] OList<Visit> GetListVisit(); [OperationContract] double PriceCalculator(int id, DateTime begining, DateTime end); //Get the price a patient has to pay for all the visits he got since "beguining" untill "end". [OperationContract] OList<Visit> GetVisits(Patient patient); //Get a patient's list of visits [OperationContract(Name="PriceCalculatorDoctor")] double PriceCalculator(Doctor doctor); //Get how much 1 doctor earned [OperationContract] OList<Medicine> SortedListMedecine(); //Get a sorted list of medecines [OperationContract] OList<Patient> FilterOfPatients(Predicate<Patient> function); // Get a filtered list of patient [OperationContract] void Paypal(Visit visit); //Make him pay } }
Voilà le MainWindow :
Voilà pour le BL_Adaptator :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using BL; using UI.IBLService; using System.Collections.ObjectModel; namespace UI { /// <summary> /// Logique d'interaction pour MainWindow.xaml /// </summary> public partial class MainWindow : Window { private BL_Adaptor m_BL = new BL_Adaptor(); public BL_Adaptor BL { get { return m_BL; } set { m_BL = value; } } //private BL_Class m_BL = new BL_Class(); //public BL_Class BL //{ // get { return m_BL; } // set { m_BL = value; } //} public MainWindow() { InitializeComponent(); this.DataContext = BL; } private void AddVisit_Click(object sender, RoutedEventArgs e) { Visit.VisitWindow AddVis = new Visit.VisitWindow(BL); AddVis.ShowDialog(); if (AddVis.Save) BL.addVisit(AddVis.Visit); } private void AddDoctor_Click(object sender, RoutedEventArgs e) { Doctor.DoctorWindow AddDoc = new Doctor.DoctorWindow(); AddDoc.ShowDialog(); if (AddDoc.Save) BL.addDoctor(AddDoc.Doct); } private void AddPatient_Click(object sender, RoutedEventArgs e) { Patient.PatientWindow AddPatient = new Patient.PatientWindow(); AddPatient.ShowDialog(); if(AddPatient.Save) BL.addPatient(AddPatient.Patient); } private void AddMedicine_Click(object sender, RoutedEventArgs e) { Medicine.MedicineWindow AddMedicine = new Medicine.MedicineWindow(); AddMedicine.ShowDialog(); if(AddMedicine.Save) BL.addMedecine(AddMedicine.Medi); } private void UpdateVisit_Click(object sender, RoutedEventArgs e) { if (listVisits.SelectedItem != null) { Visit.VisitWindow UpdVis = new Visit.VisitWindow(BL); BE.Visit v = BL.GetListVisit()[listVisits.SelectedIndex]; UpdVis.Visit = new BE.Visit(v.Nbr, v.Date, v.IdInsured, v.LicenseNum, v.Recommendation, v.Medicines, v.Paid); UpdVis.ShowDialog(); if (UpdVis.Save) BL.updateVisit(UpdVis.Visit, listVisits.SelectedIndex); } } private void UpdateDoctor_Click(object sender, RoutedEventArgs e) { if (listDoctors.SelectedItem != null) { Doctor.DoctorWindow UpdDoc = new Doctor.DoctorWindow(); BE.Doctor d = BL.GetListDoctors()[listDoctors.SelectedIndex]; UpdDoc.Doct = new BE.Doctor(d.NumDoctor, d.Name, d.Adress, d.BirthDate, d.YearsOfXp, d.NameHInternship, d.Specialisation); UpdDoc.ShowDialog(); if (UpdDoc.Save) BL.updateDoctor((BE.Doctor)UpdDoc.Doct, listDoctors.SelectedIndex); } } private void UpdatePatient_Click(object sender, RoutedEventArgs e) { if (listPatients.SelectedItem != null) { Patient.PatientWindow UpdPatient = new Patient.PatientWindow(); BE.Patient p = BL.GetListPatient()[listPatients.SelectedIndex]; UpdPatient.Patient = new BE.Patient(p.Id, p.Adress, p.BirthDate, p.BAccNum, p.CCardNum, p.Bonus, p.Debt); UpdPatient.ShowDialog(); if (UpdPatient.Save) BL.updatePatient(UpdPatient.Patient, listPatients.SelectedIndex); } } private void UpdateMedicine_Click(object sender, RoutedEventArgs e) { if (listMedicines.SelectedItem != null) { Medicine.MedicineWindow UpdMedicine = new Medicine.MedicineWindow(); BE.Medicine m = BL.GetListMedecine()[listMedicines.SelectedIndex]; UpdMedicine.Medi = new BE.Medicine(m.Code, m.Type, m.Price,m.InBasket, m.Participation, m.Critical); UpdMedicine.ShowDialog(); if (UpdMedicine.Save) BL.updateMedecine(UpdMedicine.Medi, listMedicines.SelectedIndex); } } private void DelDoctor_Click(object sender, RoutedEventArgs e) { if (listDoctors.SelectedIndex != -1) { BL.delDoctor(listDoctors.SelectedIndex); } } private void DelPatient_Click(object sender, RoutedEventArgs e) { if (listPatients.SelectedIndex != -1) { BL.delPatient(listPatients.SelectedIndex); } } private void DelMedicine_Click(object sender, RoutedEventArgs e) { if (listMedicines.SelectedIndex != -1) { BL.delMedecine(listMedicines.SelectedIndex); } } } }
Je vous remercie d'avance et pour ceux qui n'aime pas le code balancé comme ça ce que comprend j'ai joint le projet:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using BL; using UI.IBLService; using System.ComponentModel; using BE; using System.Collections; using System.Data.Services.Client; namespace UI { public class BL_Adaptor : BL.IBL, INotifyPropertyChanged { #region Binding #region INotifyPropertyChanged public event PropertyChangedEventHandler PropertyChanged; public void RaisePropertyChanged(string PropertyName) { if (this.PropertyChanged != null) { this.PropertyChanged(this, new PropertyChangedEventArgs(PropertyName)); } } #endregion #region Property private OList<BE.Visit> m_lstVisits = new OList<BE.Visit>(); public OList<BE.Visit> lstVisits { get { return m_lstVisits; } set { m_lstVisits = value; RaisePropertyChanged("lstVisits"); } } private BE.Visit m_SelectedVisit; public BE.Visit SelectedVisit { get { return m_SelectedVisit; } set { m_SelectedVisit = value; RaisePropertyChanged("SelectedVisit"); } } private OList<BE.Doctor> m_lstDoctors = new OList<BE.Doctor>(); public OList<BE.Doctor> lstDoctors { get { return m_lstDoctors; } set { m_lstDoctors = value; RaisePropertyChanged("lstDoctors"); } } private BE.Doctor m_SelectedDoctor; public BE.Doctor SelectedDoctor { get { return m_SelectedDoctor; } set { m_SelectedDoctor = value; RaisePropertyChanged("SelectedDoctor"); } } private OList<BE.Patient> m_lstPatients = new OList<BE.Patient>(); public OList<BE.Patient> lstPatients { get { return m_lstPatients; } set { m_lstPatients = value; RaisePropertyChanged("lstPatients"); } } private BE.Patient m_SelectedPatient; public BE.Patient SelectedPatient { get { return m_SelectedPatient; } set { m_SelectedPatient = value; RaisePropertyChanged("SelectedPatient"); } } private OList<BE.Visit> m_GetVisitsOfPatient = new OList<BE.Visit>(); public OList<BE.Visit> GetVisitsOfPatient { get { return m_GetVisitsOfPatient; } set { m_GetVisitsOfPatient = value; RaisePropertyChanged("GetVisitsOfPatient"); } } private OList<BE.Medicine> m_lstMedicines = new OList<BE.Medicine>(); public OList<BE.Medicine> lstMedicines { get { return m_lstMedicines; } set { m_lstMedicines = value; RaisePropertyChanged("lstMedicines"); } } private BE.Medicine m_SelectedMedicine; public BE.Medicine SelectedMedicine { get { return m_SelectedMedicine; } set { m_SelectedMedicine = value; RaisePropertyChanged("SelectedMedicine"); } } #endregion #endregion public BLClient MyBLClient { get; set; } // Constructor public BL_Adaptor() { MyBLClient = new BLClient(); lstDoctors = GetListDoctors(); lstPatients = GetListPatient(); lstMedicines = GetListMedecine(); lstVisits = GetListVisit(); } // Methods public void addDoctor(BE.Doctor doctor) { MyBLClient.addDoctor(doctor); } public void delDoctor(int i) { MyBLClient.delDoctor(i); } public void updateDoctor(BE.Doctor doctor, int i) { MyBLClient.updateDoctor(doctor, i); } public void addPatient(BE.Patient patient) { MyBLClient.addPatient(patient); } public void delPatient(int i) { MyBLClient.delPatient(i); } public void updatePatient(BE.Patient patient, int i) { MyBLClient.updatePatient(patient, i); } public void addVisit(BE.Visit visit) { MyBLClient.addVisit(visit); } public void updateVisit(BE.Visit visit, int i) { MyBLClient.updateVisit(visit, i); } public void addMedecine(BE.Medicine medecine) { MyBLClient.addMedecine(medecine); } public void delMedecine(int i) { MyBLClient.delMedecine(i); } public void updateMedecine(BE.Medicine medecine, int i) { MyBLClient.updateMedecine(medecine, i); } public OList<T> CastToOlist<T>(List<T> myList) { OList<T> retour = new OList<T>(); foreach (T item in myList) retour.Add(item); return retour; } public OList<BE.Doctor> GetListDoctors() { return CastToOlist<BE.Doctor>(MyBLClient.GetListDoctors().ToList()); } public OList<BE.Patient> GetListPatient() { return CastToOlist<BE.Patient>(MyBLClient.GetListPatient().ToList()); } public OList<BE.Medicine> GetListMedecine() { return CastToOlist<BE.Medicine>(MyBLClient.GetListMedecine().ToList()); } public OList<BE.Visit> GetListVisit() { return CastToOlist<BE.Visit>(MyBLClient.GetListVisit().ToList()); } public double PriceCalculator(int id, DateTime begining, DateTime end) { return MyBLClient.PriceCalculator(id, begining, end); } public OList<BE.Visit> GetVisits(BE.Patient patient) { return CastToOlist<BE.Visit>(MyBLClient.GetVisits(patient).ToList()); } public double PriceCalculator(BE.Doctor doctor) { return MyBLClient.PriceCalculatorDoctor(doctor); } public OList<BE.Medicine> SortedListMedecine() { return CastToOlist<BE.Medicine>(MyBLClient.SortedListMedecine().ToList()); } public OList<BE.Patient> FilterOfPatients(Predicate<BE.Patient> function) { return CastToOlist<BE.Patient>(MyBLClient.FilterOfPatients(function).ToList()); } public void Paypal(BE.Visit visit) { MyBLClient.Paypal(visit); } } }
Partager