-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppointment.vb
336 lines (299 loc) · 16.3 KB
/
Appointment.vb
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
'Imports Microsoft.Data
Imports MongoDB.Bson
Public Class Appointment
Public Sub PopulatePanel(DoctorsList As List(Of KeyValuePair(Of String, String)))
doctorCardPanel.Controls.Clear()
Dim cardWidth As Integer = 280
Dim cardHeight As Integer = 360
Dim cardsPerRow As Integer = 3
For i As Integer = 0 To DoctorsList.Count - 1
Dim doctorCard As New DoctorCard(DoctorsList(i).Key(), DoctorsList(i).Value()) With {
.Size = New Size(cardWidth, cardHeight)
}
Dim rowIndex As Integer = i \ cardsPerRow
Dim colIndex As Integer = i Mod cardsPerRow
doctorCard.Location = New Point((colIndex * cardWidth) + 30, (rowIndex * cardHeight) + 10)
doctorCard.TopLevel = False
doctorCardPanel.Controls.Add(doctorCard)
doctorCard.Show()
Next
End Sub
Private Sub Appointment_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim docLists As New List(Of KeyValuePair(Of String, String)) From {
New KeyValuePair(Of String, String)("Dr. Example 01", "Some Basic Information goes here!"),
New KeyValuePair(Of String, String)("Dr. Example 02", "Some Basic Information goes here!"),
New KeyValuePair(Of String, String)("Dr. Example 03", "Some Basic Information goes here!"),
New KeyValuePair(Of String, String)("Dr. Example 04", "Some Basic Information goes here!"),
New KeyValuePair(Of String, String)("Dr. Example 05", "Some Basic Information goes here!")
}
PopulatePanel(docLists)
End Sub
End Class
'Public Class Appointment
' Dim DbCon As SqlClient.SqlConnection
' Dim adaptor As SqlClient.SqlDataAdapter
' Dim ds As DataSet
' Dim clinicID As New Dictionary(Of Integer, String)
' Dim docID As New Dictionary(Of Integer, String)
' Private Sub Appointment_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' DBCon = New SqlClient.SqlConnection
' DbCon.ConnectionString = "Server='LAPTOP-O23E4BES';Database='AyushmanBhavahDB';Trusted_Connection=True;trustServerCertificate=True"
' Try
' DbCon.Open()
' Dim query = String.Format("SELECT DISTINCT Area FROM Hospital")
' adaptor = New SqlClient.SqlDataAdapter(query, DbCon)
' ds = New DataSet
' adaptor.Fill(ds, "Hospital")
' adaptor.Dispose()
' If ds.Tables("Hospital").Rows.Count > 0 Then
' Me.ComboBox1.Items.Clear()
' Dim i As Integer
' For i = 0 To ds.Tables("Hospital").Rows.Count - 1
' With Me.ComboBox1.Items.Add(ds.Tables("Hospital").Rows(i).Item("Area"))
' End With
' Next
' End If
' Catch ex As Exception
' MessageBox.Show("Error in Database Connection! " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
' Finally
' DbCon.Close()
' End Try
' change_label_color(Label2, Color.Silver)
' change_label_color(Label3, Color.Silver)
' change_label_color(Label4, Color.Silver)
' ComboBox2.Enabled = False
' ComboBox3.Enabled = False
' ComboBox4.Enabled = False
' End Sub
' Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
' change_label_color(Label2, Color.Black)
' ComboBox2.Enabled = True
' change_label_color(Label3, Color.Silver)
' change_label_color(Label4, Color.Silver)
' ComboBox3.SelectedIndex = -1
' ComboBox4.SelectedIndex = -1
' ComboBox3.Items.Clear()
' ComboBox4.Items.Clear()
' ComboBox3.Enabled = False
' ComboBox4.Enabled = False
' Dim area As String = ComboBox1.Text
' clinicID.Clear()
' docID.Clear()
' Try
' DbCon.Open()
' Dim query = String.Format("SELECT Name, Id FROM Hospital WHERE Area = " + area)
' adaptor = New SqlClient.SqlDataAdapter(query, DbCon)
' ds = New DataSet
' adaptor.Fill(ds, "Hospital")
' adaptor.Dispose()
' If ds.Tables("Hospital").Rows.Count > 0 Then
' Me.ComboBox2.Items.Clear()
' Dim i As Integer
' For i = 0 To ds.Tables("Hospital").Rows.Count - 1
' With Me.ComboBox2.Items.Add(ds.Tables("Hospital").Rows(i).Item("Name"))
' End With
' clinicID.Add(i, String.Format(ds.Tables("Hospital").Rows(i).Item("Id")))
' Next
' End If
' Catch ex As Exception
' MessageBox.Show("Error in Database Connection! " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
' Finally
' DbCon.Close()
' End Try
' WriteTextBox(0)
' End Sub
' Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
' change_label_color(Label3, Color.Black)
' ComboBox3.Enabled = True
' change_label_color(Label4, Color.Silver)
' ComboBox4.Enabled = False
' ComboBox4.SelectedIndex = -1
' docID.Clear()
' Dim hospital As Integer = ComboBox2.SelectedIndex
' If hospital >= 0 Then
' Try
' DbCon.Open()
' Dim query = String.Format("SELECT Name, Id FROM Doctor WHERE ClinicID=" + clinicID(hospital))
' adaptor = New SqlClient.SqlDataAdapter(query, DbCon)
' ds = New DataSet
' adaptor.Fill(ds, "Doctor")
' adaptor.Dispose()
' If ds.Tables("Doctor").Rows.Count > 0 Then
' Me.ComboBox3.Items.Clear()
' Dim i As Integer
' For i = 0 To ds.Tables("Doctor").Rows.Count - 1
' With Me.ComboBox3.Items.Add(ds.Tables("Doctor").Rows(i).Item("Name"))
' End With
' docID.Add(i, String.Format(ds.Tables("Doctor").Rows(i).Item("Id")))
' Next
' End If
' Catch ex As Exception
' MessageBox.Show("Error in Database Connection! " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
' Finally
' DbCon.Close()
' End Try
' End If
' WriteTextBox(1)
' End Sub
' Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged
' change_label_color(Label4, Color.Black)
' ComboBox4.Enabled = True
' ComboBox4.SelectedIndex = -1
' Dim doctor As Integer = ComboBox3.SelectedIndex
' If doctor >= 0 Then
' ComboBox4.Items.Add("Monday")
' ComboBox4.Items.Add("Tuesday")
' ComboBox4.Items.Add("Wednesday")
' ComboBox4.Items.Add("Thursday")
' ComboBox4.Items.Add("Friday")
' ComboBox4.Items.Add("Saturday")
' ComboBox4.Items.Add("Sunday")
' End If
' WriteTextBox(2)
' End Sub
' Private Sub ComboBox4_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox4.SelectedIndexChanged
' WriteTextBox(3)
' End Sub
' Private Sub change_label_color(lable As Label, color As Color)
' lable.ForeColor = color
' End Sub
' Private Sub Button1_MouseEnter(sender As Object, e As EventArgs) Handles Button1.MouseEnter
' Button1.BackColor = Color.FromArgb(240, 100, 100)
' End Sub
' Private Sub Button1_MouseLeave(sender As Object, e As EventArgs) Handles Button1.MouseLeave
' Button1.BackColor = Color.FromArgb(230, 70, 70)
' End Sub
' Private Sub Button2_MouseEnter(sender As Object, e As EventArgs) Handles Button2.MouseEnter
' Button2.BackColor = Color.FromArgb(50, 250, 50)
' End Sub
' Private Sub Button2_MouseLeave(sender As Object, e As EventArgs) Handles Button2.MouseLeave
' Button2.BackColor = Color.FromArgb(50, 220, 50)
' End Sub
' Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
' ' to do
' ' when all 4 data are not selected prompt users to fill up required data
' ' when all 4 data are selected, add them to the database and generate a random id (appointment id)
' End Sub
' Private Sub WriteTextBox(info_at As Integer)
' Dim area As String = ComboBox1.Text
' Dim clinic As String = ComboBox2.Text
' Dim doctor As String = ComboBox3.Text
' Dim timing As String = ComboBox4.Text
' RichTextBox1.Text = ""
' RichTextBox1.AppendText("∘ AREA: " + area + Environment.NewLine)
' Try
' DbCon.Open()
' If info_at = 0 Then
' RichTextBox1.AppendText("∘ CLINIC: " + clinic + Environment.NewLine)
' RichTextBox1.AppendText("∘ SPECIALIST: " + doctor + Environment.NewLine)
' RichTextBox1.AppendText("∘ TIME: " + timing + Environment.NewLine)
' ElseIf info_at = 1 Then
' Dim query = String.Format($"SELECT * FROM Hospital WHERE Area={area} AND Id={clinicID(ComboBox2.SelectedIndex())}")
' adaptor = New SqlClient.SqlDataAdapter(query, DbCon)
' ds = New DataSet
' adaptor.Fill(ds, "Hospital")
' adaptor.Dispose()
' If ds.Tables("Hospital").Rows.Count > 0 Then
' Dim clinicInfo As String = ""
' clinicInfo += ds.Tables("Hospital").Rows(0).Item("Name") + Environment.NewLine
' clinicInfo += " ∙ Address: " + ds.Tables("Hospital").Rows(0).Item("Address") + Environment.NewLine
' clinicInfo += " ∙ Open Hours: " + ds.Tables("Hospital").Rows(0).Item("OpenHours") + Environment.NewLine
' RichTextBox1.AppendText(Environment.NewLine)
' RichTextBox1.AppendText("∘ CLINIC: " + clinicInfo + Environment.NewLine)
' RichTextBox1.AppendText("∘ SPECIALIST: " + doctor + Environment.NewLine)
' RichTextBox1.AppendText("∘ TIME: " + timing + Environment.NewLine)
' End If
' ElseIf info_at = 2 Then
' Dim query = String.Format($"SELECT * FROM Hospital WHERE Area={area} AND Id={clinicID(ComboBox2.SelectedIndex())}")
' adaptor = New SqlClient.SqlDataAdapter(query, DbCon)
' ds = New DataSet
' adaptor.Fill(ds, "Hospital")
' adaptor.Dispose()
' If ds.Tables("Hospital").Rows.Count > 0 Then
' Dim clinicInfo As String = ""
' clinicInfo += ds.Tables("Hospital").Rows(0).Item("Name") + Environment.NewLine
' clinicInfo += " ∙ Address: " + ds.Tables("Hospital").Rows(0).Item("Address") + Environment.NewLine
' clinicInfo += " ∙ Open Hours: " + ds.Tables("Hospital").Rows(0).Item("OpenHours") + Environment.NewLine
' RichTextBox1.AppendText(Environment.NewLine)
' RichTextBox1.AppendText("∘ CLINIC: " + clinicInfo + Environment.NewLine)
' Dim docQuery = String.Format($"SELECT * FROM Doctor WHERE ClinicID={clinicID(ComboBox2.SelectedIndex())}")
' adaptor = New SqlClient.SqlDataAdapter(docQuery, DbCon)
' ds = New DataSet
' adaptor.Fill(ds, "Doctor")
' adaptor.Dispose()
' If ds.Tables("Doctor").Rows.Count > 0 Then
' Dim docInfo As String = ""
' docInfo += ds.Tables("Doctor").Rows(0).Item("Name") + Environment.NewLine
' docInfo += " ∙ Degree: " + String.Format(ds.Tables("Doctor").Rows(0).Item("Degree")) + Environment.NewLine
' docInfo += " ∙ Specialist: " + ds.Tables("Doctor").Rows(0).Item("Specialist") + Environment.NewLine
' docInfo += " ∙ Fees: " + String.Format(ds.Tables("Doctor").Rows(0).Item("Fees")) + Environment.NewLine
' RichTextBox1.AppendText("∘ SPECIALIST: " + docInfo + Environment.NewLine)
' RichTextBox1.AppendText("∘ TIME: " + ComboBox4.Text + Environment.NewLine)
' End If
' End If
' ElseIf info_at = 3 Then
' Dim query = String.Format($"SELECT * FROM Hospital WHERE Area={area} AND Id={clinicID(ComboBox2.SelectedIndex())}")
' adaptor = New SqlClient.SqlDataAdapter(query, DbCon)
' ds = New DataSet
' adaptor.Fill(ds, "Hospital")
' adaptor.Dispose()
' If ds.Tables("Hospital").Rows.Count > 0 Then
' Dim clinicInfo As String = ""
' clinicInfo += ds.Tables("Hospital").Rows(0).Item("Name") + Environment.NewLine
' clinicInfo += " ∙ Address: " + ds.Tables("Hospital").Rows(0).Item("Address") + Environment.NewLine
' clinicInfo += " ∙ Open Hours: " + ds.Tables("Hospital").Rows(0).Item("OpenHours") + Environment.NewLine
' RichTextBox1.AppendText(Environment.NewLine)
' RichTextBox1.AppendText("∘ CLINIC: " + clinicInfo + Environment.NewLine)
' Dim docQuery = String.Format($"SELECT * FROM Doctor WHERE ClinicID={clinicID(ComboBox2.SelectedIndex())}")
' adaptor = New SqlClient.SqlDataAdapter(docQuery, DbCon)
' ds = New DataSet
' adaptor.Fill(ds, "Doctor")
' adaptor.Dispose()
' If ds.Tables("Doctor").Rows.Count > 0 Then
' Dim docInfo As String = ""
' docInfo += ds.Tables("Doctor").Rows(0).Item("Name") + Environment.NewLine
' docInfo += " ∙ Degree: " + String.Format(ds.Tables("Doctor").Rows(0).Item("Degree")) + Environment.NewLine
' docInfo += " ∙ Specialist: " + ds.Tables("Doctor").Rows(0).Item("Specialist") + Environment.NewLine
' docInfo += " ∙ Fees: " + String.Format(ds.Tables("Doctor").Rows(0).Item("Fees")) + Environment.NewLine
' RichTextBox1.AppendText("∘ SPECIALIST: " + docInfo + Environment.NewLine)
' Dim dayQuery = String.Format($"SELECT {timing} FROM Doctor WHERE Id={docID(ComboBox3.SelectedIndex())}")
' adaptor = New SqlClient.SqlDataAdapter(dayQuery, DbCon)
' ds = New DataSet
' adaptor.Fill(ds, "Doctor")
' adaptor.Dispose()
' If ds.Tables("Doctor").Rows.Count > 0 Then
' Dim timeInfo As String = ""
' Dim _time = ds.Tables("Doctor").Rows(0).Item(timing)
' If IsDBNull(_time) Then
' timeInfo = "Not Available"
' Else
' timeInfo = _time
' End If
' RichTextBox1.AppendText($"∘ TIME: {timing} [ {timeInfo} ] {Environment.NewLine}")
' End If
' End If
' End If
' End If
' Catch ex As Exception
' MessageBox.Show("Error in Database Connection! " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
' Finally
' DbCon.Close()
' End Try
' RichTextBox1.SelectAll()
' RichTextBox1.SelectionFont = New Font("Segoe UI Historic", 12, FontStyle.Bold)
' End Sub
' Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' ComboBox1.Items.Clear()
' ComboBox2.Items.Clear()
' ComboBox3.Items.Clear()
' ComboBox4.Items.Clear()
' ComboBox1.SelectedIndex = -1
' ComboBox2.SelectedIndex = -1
' ComboBox3.SelectedIndex = -1
' ComboBox4.SelectedIndex = -1
' RichTextBox1.Text = ""
' clinicID.Clear()
' docID.Clear()
' Appointment_Load(sender, e)
' End Sub
'End Class