-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateAppointment.xaml.cs
More file actions
125 lines (100 loc) · 4.17 KB
/
Copy pathUpdateAppointment.xaml.cs
File metadata and controls
125 lines (100 loc) · 4.17 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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Text;
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.Shapes;
namespace BOP3_Task_1_C_Sharp_Application_Development
{
/// <summary>
/// Interaction logic for UpdateAppointment.xaml
/// </summary>
public partial class UpdateAppointment : Window
{
public UpdateAppointment()
{
InitializeComponent();
}
public Dashboard dashboardObject;
private void StartTimeCalendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
{
startTimeTextBox.Text = startTimePick.SelectedDate.ToString();
}
private void EndTimeCalendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
{
endTimeTextBox.Text = endTimePick.SelectedDate.ToString();
}
private void CancelClick(object sender, RoutedEventArgs e)
{
Close();
}
private void UpdateClick(object sender, RoutedEventArgs e)
{
if (String.IsNullOrWhiteSpace(CustomerID.Text) ||
String.IsNullOrWhiteSpace(apptTypeTextBox.Text) ||
String.IsNullOrWhiteSpace(startTimeTextBox.Text) ||
String.IsNullOrWhiteSpace(endTimeTextBox.Text))
{
MessageBox.Show("Ensure all field are valid.");
}
DateTime startTime = DateTime.Parse(startTimeTextBox.Text).ToUniversalTime();
DateTime endTime = DateTime.Parse(endTimeTextBox.Text).ToUniversalTime();
UpdateAppointmentDataClass apptUpdate = new UpdateAppointmentDataClass();
apptUpdate.CustomerID = Int32.Parse(CustomerID.Text);
apptUpdate.AppointmentID = Int32.Parse(ApptIDSearchBox.Text);
apptUpdate.type = apptTypeTextBox.Text;
apptUpdate.start = startTime;
apptUpdate.end = endTime;
try
{
if (SharedDataHelp.AppointmentConflictCheck(DateTime.Parse(SharedDataHelp.convertToTimezone(startTime.ToString())), DateTime.Parse(SharedDataHelp.convertToTimezone(endTime.ToString()))))
MessageBox.Show("Exception occured, appointment time conflics with another appointment");
else
{
try
{
if (SharedDataHelp.AppointmentBusinessHoursCheck(DateTime.Parse(SharedDataHelp.convertToTimezone(startTime.ToString())), DateTime.Parse(SharedDataHelp.convertToTimezone(endTime.ToString()))))
MessageBox.Show("Exception occured, appointments need to be within normal business hours");
else
{
SharedDataHelp.updateAppointment(apptUpdate);
MessageBox.Show("Record Updated");
dashboardObject.updateCalendar();
Close();
}
}
catch (Exception ex)
{
MessageBox.Show("Could not update appointment");
}
}
}
catch (Exception ex)
{
MessageBox.Show("Could not update appointment");
}
}
private void AppointmentSearch(object sender, RoutedEventArgs e)
{
try
{
UpdateAppointmentDataClass apptSearch = SharedDataHelp.getAppointmentDetails(Int32.Parse(ApptIDSearchBox.Text));
CustomerID.Text = apptSearch.CustomerID.ToString();
apptTypeTextBox.Text = apptSearch.type;
startTimeTextBox.Text = apptSearch.start.ToString();
endTimeTextBox.Text = apptSearch.end.ToString();
}
catch
{
MessageBox.Show("Could not search the ID.");
}
}
}
}