/***********************************************************/ // "Set" click /***********************************************************/ private void btnSet_Click(object sender, RoutedEventArgs e) { // Check if an order has been selected if (order == null) { MessageBox.Show("Please select an order"); return; } // Check if start- and endtime hours and minutes has been filled out if (tbStartTimeHour.Text == "" || tbStartTimeMinutes.Text == "" || tbEndTimeHour.Text == "" || tbEndTimeMinutes.Text == "") { MessageBox.Show("Please fill out hours and minutes"); return; } // Get start time var dtStart = DateTime.Parse(dpStartTimeDate.SelectedDate.Value.ToString("dd-MM-yyyy")); TimeSpan ts = new TimeSpan(int.Parse(tbStartTimeHour.Text), int.Parse(tbStartTimeMinutes.Text), 0); dtStart += ts; // Get end time var dtEnd = DateTime.Parse(dpEndTimeDate.SelectedDate.Value.ToString("dd-MM-yyyy")); ts = new TimeSpan(int.Parse(tbEndTimeHour.Text), int.Parse(tbEndTimeMinutes.Text), 0); dtEnd += ts; // Check if endtime is before starttime if (dtEnd < dtStart) { MessageBox.Show("End time is before start time"); return; } // Create time registration var wsObj = WebserviceCalls.CreateTimeRegistration(dtStart.ToString("yyyy-MM-dd'T'HH:mm:ss"), dtEnd.ToString("yyyy-MM-dd'T'HH:mm:ss"), user.UserId, order.OrderId); if (wsObj.Success) { GetTimeRegistrations(); } else { MessageBox.Show(wsObj.Response.ToString()); } }