Exemple #1
0
        /*****************************************************************/
        // BUTTON EVENTS
        /*****************************************************************/
        #region Button events

        /***********************************************************/
        // "Start / Continue" click
        /***********************************************************/
        private void btnStartContinue_Click(object sender, RoutedEventArgs e)
        {
            ObservableCollection <TimeRegistration> list = (ObservableCollection <TimeRegistration>)dgTimeRegistrations.ItemsSource;

            if (list.Count > 0)
            {
                var tr = list[0];

                if (tr.EndTime == "")
                {
                    MessageBox.Show("Please end your current time registration first");
                    return;
                }
            }

            if (order == null)
            {
                MessageBox.Show("Please select an order");
                return;
            }

            var      dt = DateTime.Parse(dpStartTimeDate.SelectedDate.Value.ToString("dd-MM-yyyy"));
            TimeSpan ts = new TimeSpan(int.Parse(tbStartTimeHour.Text), int.Parse(tbStartTimeMinutes.Text), 0);

            dt = dt + ts;

            if (dt.ToString("dd-MM-yyyy HH:mm") != DateTime.Now.ToString("dd-MM-yyyy HH:mm"))
            {
                if (MessageBox.Show("Start time is set before or after current time. Want to set it to current?", "Start time", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    dt = DateTime.Now;
                    SetStartAndEndTime(DateTime.Now, null);
                }
            }

            var wsObj = WebserviceCalls.StartTimeRegistration(dt.ToString("yyyy-MM-dd'T'HH:mm:ss"), user.UserId, order.OrderId);

            if (wsObj.Success)
            {
                GetTimeRegistrations();
            }
        }