-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmPatientView.cs
178 lines (166 loc) · 6.88 KB
/
frmPatientView.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
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
using Infragistics.Win.UltraWinGrid;
using MyCompany.MyProject.Db;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Hospital
{
public partial class frmPatientView : Form
{
public frmPatientView()
{
InitializeComponent();
comboCall();
}
public DataTable dtPatient;
frmNewPatient objfrmNewPatient;
HospitalDB objHospitalDB;
private void frmPatientView_Load(object sender, EventArgs e)
{
objHospitalDB = new HospitalDB();
Patient objPatient = new Patient(objHospitalDB);
dtPatient = objPatient.GetAllAsDataTable();
ultraGridPatient.DataSource=dtPatient;
// con.Open();
/* SqlCommand cmd=objHospitalDB.CreateCommand( "SELECT * FROM Patient");
SqlDataAdapter sdap = new SqlDataAdapter(cmd);
dtPatient = new DataTable();
sdap.Fill(dtPatient);
ultraGridPatient.DataSource = dtPatient;*/
}
private void ultraBtnPNew_Click(object sender, EventArgs e)
{
objfrmNewPatient = new frmNewPatient();
objfrmNewPatient.strFormMode = "NEW";
objfrmNewPatient.ShowDialog();
}
public void comboCall()
{
DataTable dtPat = Class_Files.comboClass.LoadSearch();
ultraComboPSearch.DataSource = dtPat;
ultraComboPSearch.BindingContext = this.BindingContext;
ultraComboPSearch.DisplayMember = "Search";
ultraComboPSearch.ValueMember = "Search";
}
public string Pat_id;
public string Pat_name;
public string Pat_phone;
public string Pat_dob;
public string Pat_address;
public string Pat_emergency;
public string Pat_dor;
private void ultraBtnPEdit_Click(object sender, EventArgs e)
{
objfrmNewPatient = new frmNewPatient();
objfrmNewPatient.id = Pat_id.ToString();
objfrmNewPatient.name = Pat_name.ToString();
objfrmNewPatient.phone = Pat_phone.ToString();
objfrmNewPatient.emergencyContact = Pat_emergency.ToString();
objfrmNewPatient.address = Pat_address.ToString();
objfrmNewPatient.dob = Pat_dob.ToString();
objfrmNewPatient.dor = Pat_dor.ToString();
objfrmNewPatient.strFormMode = "EDIT";
objfrmNewPatient.ShowDialog();
}
private void ultraBtnPDelete_Click(object sender, EventArgs e)
{
objHospitalDB = new HospitalDB();
Patient objPatient = new Patient(objHospitalDB);
PatientRow objPatientRow = new PatientRow();
objPatientRow.Patient_ID = Convert.ToInt32(this.Pat_id);
objPatient.Delete(objPatientRow);
ultraGridPatient.DataSource = objPatient.GetAll();
/* ultraGridPatient.Rows[this.ultraGridPatient.ActiveRow.Index].Delete(true);
SqlCommand query = objHospitalDB.CreateCommand("delete from Patient where Patient_ID='" + this.Pat_id + "';", false);
int p = query.ExecuteNonQuery();
MessageBox.Show(p + "Deleted");*/
}
private void ultraGridPatient_AfterRowActivate(object sender, EventArgs e)
{
UltraGridRow row = this.ultraGridPatient.ActiveRow;
if (row != null)
{
//this.txtFirstName.Text = row.Cells["First Name"].Text;
Pat_id = row.Cells["Patient_ID"].Text;
Pat_name = row.Cells["FullName"].Text;
Pat_address = row.Cells["Patient_Address"].Text;
Pat_dob = row.Cells["DateOfBirth"].Text;
Pat_phone = row.Cells["Phone"].Text;
Pat_emergency = row.Cells["Emergency_Contact"].Text;
Pat_dor = row.Cells["DateOfRegistration"].Text;
// this.txtLastName.Text = row.Cells["Last Name"].Text;
}
}
private void ultraBtnPSearch_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
if (ultraComboPSearch.Value.ToString() == "Patient Name")
{
try
{
objHospitalDB = new HospitalDB();
Patient objPatient = new Patient(objHospitalDB);
SqlCommand cmd = objHospitalDB.CreateCommand("Patient_Search");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@FullName", ultraTextPSearch.Text);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
ultraGridPatient.DataSource = ds.Tables[0];
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
else if (ultraComboPSearch.Value.ToString() == "Date Of Registration")
{
objHospitalDB = new HospitalDB();
Patient objPatient = new Patient(objHospitalDB);
SqlCommand cmd = objHospitalDB.CreateCommand("Patient_SearchByDate");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@DOR", ultraDateTimePSearch.Value);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
ultraGridPatient.DataSource = ds.Tables[0];
}
}
public DataSet dsPatient;
private void ultraBtnPRefresh_Click(object sender, EventArgs e)
{
dsPatient = new DataSet();
try
{
ultraTextPSearch.Text = "";
ultraDateTimePSearch.Value = "";
objHospitalDB = new HospitalDB();
Patient objPatient = new Patient(objHospitalDB);
PatientRow objPatientRow = new PatientRow();
dtPatient = objPatient.GetAllAsDataTable();
ultraGridPatient.DataSource = dtPatient;
/*SqlCommand cmd = objHospitalDB.CreateCommand("Select * from [Hospital].[dbo].[Patient]", false);
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
sda.Fill(dsPatient);
ultraGridPatient.DataSource = dsPatient.Tables[0];*/
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
if (objHospitalDB != null)
{
objHospitalDB.Dispose();
}
}
}
private void ultraDateTimePSearch_ValueChanged(object sender, EventArgs e)
{
}
}
}