Esempio n. 1
0
        //Update the resource with all the information entered
        private void UpdateResource()
        {
            resource.setResourceName(resourceNameTextBox.Text);

            int movinghh = 0;
            int movingmm = 0;

            if (!movingHHTextBox.Text.Equals("hh"))
            {
                try
                {
                    movinghh = int.Parse(movingHHTextBox.Text);
                    movingmm = int.Parse(movingMMTextBox.Text);

                    DateTime moving = DateTime.Now;
                    moving = moving.Date + new TimeSpan(movinghh, movingmm, 0);

                    //Don't change the time if it wasn't changed, to preserve the correct time span
                    if (!(resource.getMovingTime().Hour == moving.Hour && resource.getMovingTime().Minute == moving.Minute))
                    {
                        resource.setMoving(moving);
                    }
                }
                catch (Exception e)
                {
                    return;
                }
            }

            int arrivalhh = 0;
            int arrivalmm = 0;

            if (!arrivalHHTextBox.Text.Equals("hh"))
            {
                try
                {
                    arrivalhh = int.Parse(arrivalHHTextBox.Text);
                    arrivalmm = int.Parse(arrivalMMTextBox.Text);

                    DateTime arrival = DateTime.Now;
                    arrival = arrival.Date + new TimeSpan(arrivalhh, arrivalmm, 0);

                    //Don't change the time if it wasn't changed, to preserve the correct time span
                    if (!(resource.getArrivalTime().Hour == arrival.Hour && resource.getArrivalTime().Minute == arrival.Minute))
                    {
                        resource.setArrival(arrival);
                    }
                }
                catch (Exception e)
                {
                    return;
                }
            }

            intervention.ResourceModified();
        }
        //Submitting end of intervention
        private void EndIntervention(object sender, RoutedEventArgs e)
        {
            try
            {
                int      hh      = int.Parse(Endhh.Text);
                int      mm      = int.Parse(Endmm.Text);
                DateTime endTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, hh, mm, DateTime.Now.Second);
                int      offset  = (int)DateTime.Now.Subtract(endTime).TotalMinutes;

                List <Resource> resources = this.intervention.getResourceList();

                if (offset < 0)
                {
                    MessageBox.Show(ETD.Properties.Resources.MessageBox_Notification_FutureTime);
                }
                else
                {
                    ComboBoxItem conclusion = (ComboBoxItem)ConclusionBox.SelectedItem;

                    if (Grid.GetColumnSpan(ComboBoxBorder) == 1 && AdditionalInformation.Text.Equals(""))
                    {
                        MessageBox.Show(ETD.Properties.Resources.MessageBox_Notification_NoConclusion);
                    }
                    else
                    {
                        intervention.Completed();
                        intervention.setConclusionTime(endTime);
                        if (Grid.GetColumnSpan(ComboBoxBorder) == 1)
                        {
                            intervention.setConclusionAdditionalInfo(AdditionalInformation.Text);
                        }
                        interventionForm.CompleteIntervention(offset);
                    }
                }
                intervention.ResourceModified();
            }
            catch (FormatException ex)
            {
                MessageBox.Show(ETD.Properties.Resources.MessageBox_Notification_InvalidTime);
            }
        }
Esempio n. 3
0
        //Populate intervention form page
        private void PopulateForm()
        {
            int position = 1;

            foreach (Resource resource in intervention.getResourceList())
            {
                //Creating line and adding the items to the main Grid
                ResourceLine  resourceLine  = new ResourceLine(resource, intervention);
                RowDefinition rowDefinition = new RowDefinition();
                rowDefinition.Height = new GridLength(25);
                Grid_Main.RowDefinitions.Add(rowDefinition);

                Grid_Main.Children.Add(resourceLine.getResourceNameTextBox());
                Grid.SetColumn(resourceLine.getResourceNameTextBox(), 0);
                Grid.SetRow(resourceLine.getResourceNameTextBox(), position);

                Grid_Main.Children.Add(resourceLine.getTeamNameLabel());
                Grid.SetColumn(resourceLine.getTeamNameLabel(), 1);
                Grid.SetRow(resourceLine.getTeamNameLabel(), position);

                Grid_Main.Children.Add(resourceLine.getMovingBorder());
                Grid.SetColumn(resourceLine.getMovingBorder(), 2);
                Grid.SetRow(resourceLine.getMovingBorder(), position);

                Grid_Main.Children.Add(resourceLine.getArrivalBorder());
                Grid.SetColumn(resourceLine.getArrivalBorder(), 3);
                Grid.SetRow(resourceLine.getArrivalBorder(), position);

                //Setting default text to the first resource textbox
                if (position == 1 && resourceLine.getResourceNameTextBox().Text.Equals(""))
                {
                    resourceLine.getResourceNameTextBox().Text = "Prise en charge";
                    resource.setResourceName("Prise en charge");
                    intervention.ResourceModified();
                }

                position++;
            }
        }