Exemple #1
0
        private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            List <FC_TripTicket> ticketsFromScreen = new List <FC_TripTicket>();

            if (SelectedTicket != null)
            {
                if (this.NominatedCarrierDG.SelectedItem != null && SelectedTicket != null)
                {
                    CarrierWithDepot_View t          = (CarrierWithDepot_View)NominatedCarrierDG.SelectedCells[0].Item;
                    FC_Carrier            selCarrier = new FC_Carrier(t.FC_CarrierID, t.Carrier_Name);

                    CreateTripInfo tripInfo = new CreateTripInfo(PassedInContract, selCarrier, SelectedTicket);

                    int AvalType = t.LTL_Availibility - 1;

                    if (SelectedTicket.Size_in_Palettes == 0)
                    {
                        AvalType = t.FTL_Availibility - 1;
                    }

                    SQL.UpdateDepotAvalibility(t.FC_CarrierID, t.CityName, SelectedTicket.Size_in_Palettes, AvalType);

                    ticketsFromScreen = new List <FC_TripTicket>();

                    foreach (FC_TripTicket x in AllTickets.Items)
                    {
                        if (x.FC_TripTicketID != SelectedTicket.FC_TripTicketID)
                        {
                            ticketsFromScreen.Add(x);
                        }
                    }

                    AllTickets.ItemsSource = ticketsFromScreen;

                    if (ticketsFromScreen.Count == 0)
                    {
                        Complete.IsEnabled     = true;
                        ExitMessage.Visibility = Visibility.Hidden;
                    }
                }
                else if (this.PossibleTickets.SelectedItem != null)
                {
                    FC_TripTicket ExcistingTicket = (FC_TripTicket)this.PossibleTickets.SelectedItem;

                    int PalletesAddedToTicket = PlannerClass.AddContractToTicket(ExcistingTicket, SelectedTicket, PassedInContract);

                    if (PalletesAddedToTicket != -1)
                    {
                        SelectedTicket.Size_in_Palettes -= PalletesAddedToTicket;

                        foreach (FC_TripTicket x in AllTickets.Items)
                        {
                            if (x.FC_TripTicketID == SelectedTicket.FC_TripTicketID)
                            {
                                x.Size_in_Palettes = SelectedTicket.Size_in_Palettes;

                                if (x.Size_in_Palettes > 0)
                                {
                                    ticketsFromScreen.Add(x);
                                }
                            }
                        }

                        AllTickets.ItemsSource = ticketsFromScreen;

                        if (ticketsFromScreen.Count == 0)
                        {
                            Complete.IsEnabled     = true;
                            ExitMessage.Visibility = Visibility.Hidden;
                        }
                    }
                }
            }

            this.NominatedCarrierDG.UnselectAll();
            this.PossibleTickets.UnselectAll();

            RefreshNomCarriers();
            RefreshPossibleTickets();
        }