-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form5Consultation.cs
108 lines (88 loc) · 3.32 KB
/
Form5Consultation.cs
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
using Lab4NHibernateIndividual.dao;
using Lab4NHibernateIndividual.domain;
using NHibernate;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Lab4NHibernateIndividual
{
public partial class Form5Consultation : Form
{
private ISession _session;
private Form1 _parent;
// Doctor Name
private string _key1DocName;
// Insurance Id -- We need them to find target Doctor and target Patient
private int _key2InsId;
// Target consulation id.
private long _key3ConsultationId;
public ISession SetSession
{
set => _session = value;
}
public Form1 FormParent
{
set => _parent = value;
}
public string Key1DocName
{
set => _key1DocName = value;
}
public int Key2InsId
{
set => _key2InsId = value;
}
public long Key3ConsultationId
{
set => _key3ConsultationId = value;
}
public void SetAllComponents(string t1, string t2, bool v1, bool v2)
{
dateTimePicker1.Text = t1;
roomTextBox1.Text = t2;
addButton1.Visible = v1;
editButton2.Visible = v2;
}
public Form5Consultation()
{
InitializeComponent();
}
// We can create additional Consultations for selected Doctor and Patient
private void addButton1_Click(object sender, EventArgs e)
{
NHibernateDAOFactory nHibernateDAOFactory = new NHibernateDAOFactory(_session);
Doctor doctor = nHibernateDAOFactory.GetDoctorDAO().GetDoctorByName(_key1DocName);
Patient patient = nHibernateDAOFactory.GetPatientDAO().GetPatientByInsuranceId(_key2InsId);
Consultation consultation = new Consultation()
{
GetConsultationTime = DateTime.SpecifyKind(dateTimePicker1.Value, DateTimeKind.Utc),
RoomNumber = int.Parse(roomTextBox1.Text),
GetDoctor = doctor,
GetPatient = patient
};
doctor.ConsultationList.Add(consultation);
patient.ConsultationList.Add(consultation);
nHibernateDAOFactory.GetConsultationDAO().SaveOrUpdate(consultation);
_parent.fillConsultDataGridView3(patient, false);
Dispose();
}
private void editButton2_Click(object sender, EventArgs e)
{
DAOFactory dao = new NHibernateDAOFactory(_session);
IConsultationDAO consultationDAO = dao.GetConsultationDAO();
Consultation consultation = consultationDAO.GetById(_key3ConsultationId);
Patient patient = consultation.GetPatient;
consultation.GetConsultationTime = DateTime.SpecifyKind(dateTimePicker1.Value, DateTimeKind.Utc);
consultation.RoomNumber = int.Parse(roomTextBox1.Text);
consultationDAO.SaveOrUpdate(consultation);
_parent.fillConsultDataGridView3(patient, false);
Dispose();
}
}
}