-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSharedDataHelp.cs
More file actions
734 lines (568 loc) · 26.8 KB
/
Copy pathSharedDataHelp.cs
File metadata and controls
734 lines (568 loc) · 26.8 KB
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
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
namespace BOP3_Task_1_C_Sharp_Application_Development
{
public class SharedDataHelp
{
private static int _currentUserId;
private static string _currentUserName;
TimeZone localZone = TimeZone.CurrentTimeZone;
//public static string conString = "server=127.0.0.1 ;database=client_schedule;uid=sqlUser;pwd=Passw0rd!;";
public static string uid = "root";
public static string pwd = "test";
public static string server = "127.0.0.1";
public static string database = "u05jyp";
public static string conString = $"server={server};database={database};uid={uid};pwd={pwd}";
public static int getCurrentUserId()
{
return _currentUserId;
}
public static void setCurrentUserId(int currentUserId)
{
_currentUserId = currentUserId;
}
public static string getCurrentUserName()
{
return _currentUserName;
}
public static void setCurrentUserName(string currentUserName)
{
_currentUserName = currentUserName;
}
public static List<AppointmentByMonthDataClass> getAppointments()
{
List<AppointmentByMonthDataClass> apptByMonthList = new List<AppointmentByMonthDataClass>();
string query = $@"select date_format(start, '%M %Y') as 'MonthYear', `type`, count(type)
from appointment
GROUP BY `type`, date_format(start, '%M %Y')
ORDER BY start asc";
MySqlConnection c = new MySqlConnection(SharedDataHelp.conString);
c.Open();
MySqlCommand cmd = new MySqlCommand(query, c);
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
AppointmentByMonthDataClass apptByMonthReport = new AppointmentByMonthDataClass();
apptByMonthReport.MonthYear = rdr[0].ToString();
apptByMonthReport.Type = rdr[1].ToString();
apptByMonthReport.Count = rdr[2].ToString();
apptByMonthList.Add(apptByMonthReport);
}
return apptByMonthList;
}
public static int newID(List<int> idList)
{
int highestID = 0;
foreach (int id in idList)
{
if (id > highestID)
highestID = id;
}
return highestID + 1;
}
public static string createTimestamp()
{
return DateTime.Now.ToString();
}
public static int createID(string table)
{
MySqlConnection c = new MySqlConnection(conString);
c.Open();
MySqlCommand cmd = new MySqlCommand($"SELECT {table + "Id"} FROM {table}", c);
MySqlDataReader rdr = cmd.ExecuteReader();
List<int> idList = new List<int>();
while (rdr.Read())
{
idList.Add(Convert.ToInt32(rdr[0]));
}
rdr.Close();
c.Close();
return newID(idList);
}
static public int createRecord(Record record)
{
int recId = createID(record.table);
string recInsert = "";
try
{
recInsert = $"INSERT INTO {record.table} (appointmentId, customerId, userId, title, description, location, contact, type, url, start, end, createDate, createdBy, lastUpdate, lastUpdateBy)" +
$" VALUES ('{recId}', '{record.customerId}', " +
$"{getCurrentUserId()},'' ,'' ,'' ,'' ,'{record.type}','' ,STR_TO_DATE('{record.start}', '%m/%d/%Y %h:%i:%s %p'), STR_TO_DATE('{record.end}', '%m/%d/%Y %h:%i:%s %p'), " +
$"STR_TO_DATE('{record.timestamp}', '%m/%d/%Y %h:%i:%s %p')," +
$" '{record.userName}', STR_TO_DATE('{record.timestamp}', '%m/%d/%Y %h:%i:%s %p'), '{record.userName}')";
Debug.WriteLine(recInsert);
}
catch
{
}
MySqlConnection c = new MySqlConnection(conString);
c.Open();
MySqlCommand cmd = new MySqlCommand(recInsert, c);
cmd.ExecuteNonQuery();
c.Close();
return recId;
}
static public int findCustomer(string search)
{
int customerId;
string query;
if (int.TryParse(search, out customerId))
{
query = $"SELECT customerId FROM customer WHERE customerId = '{search.ToString()}'";
}
else
{
query = $"SELECT customerId FROM customer WHERE customerName LIKE '{search}'";
}
MySqlConnection c = new MySqlConnection(SharedDataHelp.conString);
c.Open();
MySqlCommand cmd = new MySqlCommand(query, c);
MySqlDataReader rdr = cmd.ExecuteReader();
if (rdr.HasRows)
{
rdr.Read();
customerId = Convert.ToInt32(rdr[0]);
rdr.Close(); c.Close();
return customerId;
}
return 0;
}
static public CustomerDetailsDataClass getCustomerDetails(int customerId)
{
CustomerDetailsDataClass customerDetails = new CustomerDetailsDataClass();
string query = $"SELECT * FROM customer WHERE customerId = '{customerId}'";
MySqlConnection c = new MySqlConnection(SharedDataHelp.conString);
c.Open();
MySqlCommand cmd = new MySqlCommand(query, c);
MySqlDataReader rdr = cmd.ExecuteReader();
rdr.Read();
Debug.WriteLine(rdr[3].ToString());
// Customer Table Details
customerDetails.customerName = rdr[1].ToString();
customerDetails.addressId = Int32.Parse(rdr[2].ToString());
customerDetails.active = rdr[3].ToString();
rdr.Close();
query = $"SELECT * FROM address WHERE addressId = '{customerDetails.addressId}'";
cmd = new MySqlCommand(query, c);
rdr = cmd.ExecuteReader();
rdr.Read();
// Address Table Details
customerDetails.address = rdr[1].ToString();
customerDetails.cityId = Int32.Parse(rdr[3].ToString());
customerDetails.zip = rdr[4].ToString();
customerDetails.phone = rdr[5].ToString();
rdr.Close();
query = $"SELECT * FROM city WHERE cityId = '{customerDetails.cityId}'";
cmd = new MySqlCommand(query, c);
rdr = cmd.ExecuteReader();
rdr.Read();
// City Table Details
customerDetails.city = rdr[1].ToString();
customerDetails.countryId = Int32.Parse(rdr[2].ToString());
rdr.Close();
query = $"SELECT * FROM country WHERE countryId = '{customerDetails.countryId}'";
cmd = new MySqlCommand(query, c);
rdr = cmd.ExecuteReader();
rdr.Read();
// Country Table Details
customerDetails.country = rdr[1].ToString();
rdr.Close();
c.Close();
return customerDetails;
}
public static bool CreateCustomer(CreateCustomerRecordDataClass record, int addressId)
{
int recId = createID("customer");
string query = $@"INSERT INTO `customer`
(`customerId`,
`customerName`,
`addressId`,
`active`,
`createDate`,
`createdBy`,
`lastUpdate`,
`lastUpdateBy`)
VALUES
(
'{recId}',
'{record.customerName}',
'{addressId}',
'{(record.active ? 1 : 0)}',
'{DateTime.Parse(DateTime.Now.ToString()).ToString("yyyy-M-dd HH:mm:ss", CultureInfo.CurrentCulture)}',
'{getCurrentUserName()}',
'{DateTime.Parse(DateTime.Now.ToString()).ToString("yyyy-M-dd HH:mm:ss", CultureInfo.CurrentCulture)}',
'{getCurrentUserName()}'
)";
try
{
MySqlConnection c = new MySqlConnection(conString);
c.Open();
MySqlCommand cmd = new MySqlCommand(query, c);
cmd.ExecuteNonQuery();
c.Close();
return true;
}
catch (Exception ex)
{
return false;
}
}
public static bool UpdateCustomer(CustomerDetailsDataClass record)
{
string addressQuery = $@"UPDATE `address`
SET
`address` = '{record.address}',
`postalCode` = '{record.zip}',
`phone` = '{record.phone}',
`lastUpdate` = '{DateTime.Parse(DateTime.Now.ToString()).ToString("yyyy-M-dd HH:mm:ss", CultureInfo.CurrentCulture)}',
`lastUpdateBy` = '{getCurrentUserName()}'
WHERE addressId = '{record.addressId}'";
Debug.WriteLine(addressQuery);
try
{
MySqlConnection c = new MySqlConnection(SharedDataHelp.conString);
c.Open();
MySqlCommand cmd = new MySqlCommand(addressQuery, c);
cmd.ExecuteReader();
c.Close();
}
catch
{
Debug.WriteLine("Failure with Address");
return false;
}
string cityQuery = $@"UPDATE `city`
SET
`city` = '{record.city}',
`lastUpdate` = '{DateTime.Parse(DateTime.Now.ToString()).ToString("yyyy-M-dd HH:mm:ss", CultureInfo.CurrentCulture)}',
`lastUpdateBy` = '{getCurrentUserName()}'
WHERE cityId = '{record.cityId}'";
Debug.WriteLine(cityQuery);
try
{
MySqlConnection c = new MySqlConnection(conString);
c.Open();
MySqlCommand cityCmd = new MySqlCommand(cityQuery, c);
cityCmd.ExecuteReader();
c.Close();
}
catch
{
Debug.WriteLine("Failure with city");
return false;
}
string countryQuery = $@"UPDATE `country`
SET
`country` = '{record.country}',
`lastUpdate` = '{DateTime.Parse(DateTime.Now.ToString()).ToString("yyyy-M-dd HH:mm:ss", CultureInfo.CurrentCulture)}',
`lastUpdateBy` = '{getCurrentUserName()}'
WHERE countryId = '{record.countryId}'";
Debug.WriteLine(countryQuery);
try
{
MySqlConnection c = new MySqlConnection(conString);
c.Open();
MySqlCommand countryCmd = new MySqlCommand(countryQuery, c);
countryCmd.ExecuteReader();
c.Close();
}
catch
{
Debug.WriteLine("Failure with country");
return false;
}
string customerQuery = $@"UPDATE `customer`
SET
`customerName` = '{record.customerName}',
`active` = {record.active},
`lastUpdate` = '{DateTime.Parse(DateTime.Now.ToString()).ToString("yyyy-M-dd HH:mm:ss", CultureInfo.CurrentCulture)}',
`lastUpdateBy` = '{getCurrentUserName()}'
WHERE customerId = '{record.customerId}'";
Debug.WriteLine(customerQuery);
try
{
MySqlConnection c = new MySqlConnection(conString);
c.Open();
MySqlCommand customerCmd = new MySqlCommand(customerQuery, c);
customerCmd.ExecuteReader();
c.Close();
}
catch
{
Debug.WriteLine("Failure with customer");
return false;
}
return true;
}
public static bool DeleteCustomer(int customerId)
{
MySqlConnection c = new MySqlConnection(conString);
c.Open();
string addressIdquery = $@"SELECT `addressId` from customer where `customerId` = '{customerId}'";
MySqlCommand cmd = new MySqlCommand(addressIdquery, c);
MySqlDataReader rdr = cmd.ExecuteReader();
rdr.Read();
string addressId = rdr[0].ToString();
rdr.Close();
string cityIdquery = $@"SELECT `cityId` from address where `addressId` = '{addressId}'";
cmd = new MySqlCommand(cityIdquery, c);
rdr = cmd.ExecuteReader();
rdr.Read();
string cityId = rdr[0].ToString();
rdr.Close();
string countryIdquery = $@"SELECT `countryId` from city where `cityId` = '{cityId}'";
cmd = new MySqlCommand(countryIdquery, c);
rdr = cmd.ExecuteReader();
rdr.Read();
string countryId = rdr[0].ToString();
rdr.Close();
//Deleting Records
try
{
DropRecordByID("address", addressId);
DropRecordByID("city", cityId);
DropRecordByID("country", countryId);
DropRecordByID("customer", customerId.ToString());
}
catch
{
return false;
}
return true;
}
public static bool DropRecordByID(string table, string id)
{
MySqlConnection c = new MySqlConnection(conString);
c.Open();
try
{
string query = $@"DELETE FROM {table} where `{table}Id` = '{id}'";
MySqlCommand cmd = new MySqlCommand(query, c);
cmd.ExecuteNonQuery();
c.Close();
}
catch
{
Debug.WriteLine("Failed to delete the record.");
return false;
}
return true;
}
static public int createRecordID(string timestamp, string userName, string table, string partOfQuery)
{
int recId = createID(table);
string recInsert;
recInsert = $"INSERT INTO {table}" +
$" VALUES ('{recId}', {partOfQuery}, '{timestamp}', '{userName}', '{timestamp}', '{userName}')";
MySqlConnection c = new MySqlConnection(conString);
c.Open();
MySqlCommand cmd = new MySqlCommand(recInsert, c);
cmd.ExecuteNonQuery();
c.Close();
return recId;
}
static public UpdateAppointmentDataClass getAppointmentDetails(int appointmentId)
{
string query = $"SELECT * FROM appointment WHERE appointmentId = '{appointmentId}'";
MySqlConnection c = new MySqlConnection(SharedDataHelp.conString);
c.Open();
MySqlCommand cmd = new MySqlCommand(query, c);
MySqlDataReader rdr = cmd.ExecuteReader();
rdr.Read();
UpdateAppointmentDataClass appt = new UpdateAppointmentDataClass();
// Customer Table Details
appt.AppointmentID = appointmentId;
appt.CustomerID = Int32.Parse(rdr[1].ToString());
appt.type = rdr[7].ToString();
appt.start = DateTime.Parse(convertToTimezone(rdr[9].ToString()));
appt.end = DateTime.Parse(convertToTimezone(rdr[10].ToString()));
rdr.Close();
return appt;
}
static public void updateAppointment(UpdateAppointmentDataClass appointment)
{
string query = $@"UPDATE appointment
SET
`appointmentId` = {appointment.AppointmentID},
`customerId` = {appointment.CustomerID},
`type` = '{appointment.type}',
`start` = '{appointment.start.ToString("yyyy-M-dd HH:mm:ss")}',
`end` = '{appointment.end.ToString("yyyy-M-dd HH:mm:ss")}',
`lastUpdate` = '{DateTime.Now.ToString("yyyy-M-dd HH:mm:ss")}',
`lastUpdateBy` = '{getCurrentUserName()}'
WHERE appointmentId = '{appointment.AppointmentID}'";
Debug.WriteLine(query);
MySqlConnection c = new MySqlConnection(SharedDataHelp.conString);
c.Open();
MySqlCommand cmd = new MySqlCommand(query, c);
MySqlDataReader rdr = cmd.ExecuteReader();
}
static public string convertToTimezone(string dateTime)
{
DateTime utcDateTime = DateTime.Parse(dateTime);
DateTime localDateTime = utcDateTime.ToLocalTime();
return localDateTime.ToString("MM/dd/yyyy hh:mm tt");
}
public static List<UserReportsDataClass> getUserReport()
{
List<UserReportsDataClass> userReportList = new List<UserReportsDataClass>();
string query = $@"select u.userName, appt.`type`, appt.start, appt.end, cust.customerName
from appointment appt
join user u
on appt.userId = u.userId
join customer cust
on appt.customerId = cust.customerId
Order By appt.userId, appt.start
";
MySqlConnection c = new MySqlConnection(SharedDataHelp.conString);
c.Open();
MySqlCommand cmd = new MySqlCommand(query, c);
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
UserReportsDataClass userReport = new UserReportsDataClass();
userReport.userName = rdr[0].ToString();
userReport.type = rdr[1].ToString();
userReport.startTime = DateTime.Parse(convertToTimezone(rdr[2].ToString()));
userReport.endTime = DateTime.Parse(convertToTimezone(rdr[3].ToString()));
userReport.customer = rdr[4].ToString();
userReportList.Add(userReport);
}
return userReportList;
}
public static List<TimingsReportDataClass> GetTimingsReport()
{
List<TimingsReportDataClass> timingReportList = new List<TimingsReportDataClass>();
string query = $@"SELECT DATE_FORMAT(start, '%H:%i %p') as `time`, count(DATE_FORMAT(start, '%H:%i %p')) FROM appointment
GROUP BY DATE_FORMAT(start, '%H:%i %p')
ORDER BY DATE_FORMAT(start, '%H:%i %p') DESC";
MySqlConnection c = new MySqlConnection(SharedDataHelp.conString);
c.Open();
MySqlCommand cmd = new MySqlCommand(query, c);
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
TimingsReportDataClass timingReport = new TimingsReportDataClass();
timingReport.time = DateTime.Parse(convertToTimezone(rdr[0].ToString())).ToString("h:mm tt");
timingReport.count = rdr[1].ToString();
timingReportList.Add(timingReport);
}
return timingReportList;
}
public static void LogToFile(string message)
{
string workingDirectory = Environment.CurrentDirectory;
string projectDirectory = Directory.GetParent(workingDirectory).Parent.Parent.FullName;
string path = String.Format("{0}\\{1}", projectDirectory, "Log\\Log.txt");
using (StreamWriter sw = File.Exists(path) ? File.AppendText(path) : File.CreateText(path))
{
sw.WriteLine(message);
}
}
public static IOrderedEnumerable<ViewAllCustomersDataCall> ViewAllCustomers()
{
List<ViewAllCustomersDataCall> viewAllCustomersList = new List<ViewAllCustomersDataCall>();
string query = $@"SELECT customerId, customerName, active, createDate, createdBy FROM customer;";
MySqlConnection c = new MySqlConnection(SharedDataHelp.conString);
c.Open();
MySqlCommand cmd = new MySqlCommand(query, c);
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
ViewAllCustomersDataCall viewAllCustomerItem = new ViewAllCustomersDataCall();
viewAllCustomerItem.customerId = Int32.Parse(rdr[0].ToString());
viewAllCustomerItem.customerName = rdr[1].ToString();
viewAllCustomerItem.active = rdr[2].ToString();
viewAllCustomerItem.createDate = DateTime.Parse(convertToTimezone(rdr[3].ToString()));
viewAllCustomerItem.createdBy = rdr[4].ToString();
viewAllCustomersList.Add(viewAllCustomerItem);
}
var newDetails = viewAllCustomersList.OrderBy(x => x.customerName); //Lambda to order Customer name alphabetically
return newDetails;
}
public static AppointmentReminderDataClass AppointmentReminders()
{
AppointmentReminderDataClass appointmentReminder = new AppointmentReminderDataClass();
DateTime endDate = DateTime.Now.AddMinutes(15);
DateTime startDate = DateTime.Now;
string query = $@"SELECT c.customerName, a.start
FROM appointment a
JOIN customer c on a.customerId = c.customerId
WHERE DATE(start) = CURDATE()";
MySqlConnection c = new MySqlConnection(SharedDataHelp.conString);
c.Open();
MySqlCommand cmd = new MySqlCommand(query, c);
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
if (DateTime.Parse(rdr[1].ToString()) >= startDate && DateTime.Parse(rdr[1].ToString()) < endDate)
{
appointmentReminder.trueFalse = true;
appointmentReminder.customerName = rdr[0].ToString();
appointmentReminder.start = DateTime.Parse(convertToTimezone(rdr[1].ToString()));
return appointmentReminder;
}
}
appointmentReminder.trueFalse = false;
return appointmentReminder;
}
public static bool AppointmentConflictCheck(DateTime start, DateTime end)
{
string query = $@"SELECT start, end FROM appointment;";
MySqlConnection c = new MySqlConnection(SharedDataHelp.conString);
c.Open();
MySqlCommand cmd = new MySqlCommand(query, c);
MySqlDataReader rdr = cmd.ExecuteReader();
List<AppointmentDateCheckDataClass> appointmentCheckList = new List<AppointmentDateCheckDataClass>();
while (rdr.Read())
{
AppointmentDateCheckDataClass appontmentCheck = new AppointmentDateCheckDataClass();
appontmentCheck.start = DateTime.Parse(convertToTimezone(rdr[0].ToString()));
appontmentCheck.end = DateTime.Parse(convertToTimezone(rdr[1].ToString()));
appointmentCheckList.Add(appontmentCheck);
}
var ff = (from checklist in appointmentCheckList where checklist.start >= start && checklist.start <= end select checklist.start);
if (ff.Any())
{
return true;
}
return false;
}
public static bool AppointmentBusinessHoursCheck(DateTime startTime, DateTime endTime)
{
DateTime businessStart = DateTime.Today.AddHours(8); // 8am
DateTime businessEnd = DateTime.Today.AddHours(17); // 5pm
if (startTime.TimeOfDay > businessStart.TimeOfDay && startTime.TimeOfDay < businessEnd.TimeOfDay &&
endTime.TimeOfDay > businessStart.TimeOfDay && endTime.TimeOfDay < businessEnd.TimeOfDay)
return false;
Debug.WriteLine(string.Format("{0} or {1} is outside {2} or {3}", startTime, endTime, businessStart, businessEnd));
return true;
}
public static bool DeleteAppointmentByID(int appointmentID)
{
MySqlConnection c = new MySqlConnection(conString);
c.Open();
try
{
string query = $@"DELETE FROM appointment where `appointmentId` = '{appointmentID}'";
MySqlCommand cmd = new MySqlCommand(query, c);
cmd.ExecuteNonQuery();
c.Close();
}
catch
{
Debug.WriteLine("Failed to delete the appointment.");
return false;
}
return true;
}
}
}