示例#1
0
 private void AddTechButton_Click(object sender, RoutedEventArgs e)
 {
     if (TechListView.SelectedItem == null)
     {
         MessageBox.Show("Select a Technician!");
     }
     else
     {
         // Add to appr window
         if (_previousWindow is CreateTicketWindow)
         {
             CreateTicketWindow window = (CreateTicketWindow)_previousWindow;
             window.Technicians.Add(TechListView.SelectedItem as Technician);
             window.Show();
             this.Close();
         }
         else
         {
             ViewTicketWindow window = (ViewTicketWindow)_previousWindow;
             window.Technicians.Add(TechListView.SelectedItem as Technician);
             window.Show();
             this.Close();
         }
     }
 }
示例#2
0
        private void AddSupEventButton_Click(object sender, RoutedEventArgs e)
        {
            // Check data
            if (Utility.TextHasNoData(this.SupNameTextBox) || Utility.TextHasNoData(this.SupDescTextBox) ||
                Utility.TextHasNoData(this.TimeSupClose) || Utility.TextHasNoData(this.TimeSupOpen))
            {
                MessageBox.Show("Please fill all of the fields");
                return;
            }

            // Get time time if we can
            const DateTimeStyles style = DateTimeStyles.AllowWhiteSpaces;
            string   todayDate         = DateTime.Now.ToString("yyy-MM-dd");
            DateTime closeTime;
            DateTime openTime;

            if (
                !DateTime.TryParseExact(todayDate + " " + TimeSupClose.Text, "yyyy-MM-dd HH:mm",
                                        CultureInfo.InvariantCulture, style, out closeTime))
            {
                MessageBox.Show("Invalid HH:mm in CloseTime");
                return;
            }

            if (
                !DateTime.TryParseExact(todayDate + " " + TimeSupOpen.Text, "yyyy-MM-dd HH:mm",
                                        CultureInfo.InvariantCulture, style, out openTime))
            {
                MessageBox.Show("Invalid HH:mm in OpenTime");
                return;
            }

            SupportEvent supportEvent = new SupportEvent
            {
                SupportEventDescription = SupDescTextBox.Text,
                SupportEventName        = SupNameTextBox.Text,
                SupportEventStart       = openTime,
                SupportEventStop        = closeTime
            };

            // Add it to the appropiate window

            if (_previousWindow is CreateTicketWindow)
            {
                CreateTicketWindow ticketWindow = (CreateTicketWindow)_previousWindow;
                ticketWindow.SupportEvents.Add(supportEvent);
                ticketWindow.Show();
                this.Close();
            }
            else
            {
                ViewTicketWindow ticketWindow = (ViewTicketWindow)_previousWindow;
                ticketWindow.SupportEvents.Add(supportEvent);
                ticketWindow.Show();
                this.Close();
            }
        }