Пример #1
0
        // METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn		       CreatTripInfo
         *	\brief		   This inserts data into the columns for the Trip Ticket table
         *	\param[in]     FC_LocalContract inContract, FC_Carrier inCarrier, FC_TripTicket partTicket
         *	\param[out]	   None
         *	\return		   None
         * ---------------------------------------------------------------------------------------------------- */
        public CreateTripInfo(FC_LocalContract inContract, FC_Carrier inCarrier, FC_TripTicket partTicket)
        {
            FC_TripTicket theTicket = new FC_TripTicket();

            theTicket.FC_TripTicketID  = SQL.GetNextID("FC_TripTicket");
            theTicket.FC_CarrierID     = inCarrier.FC_CarrierID;
            theTicket.Days_Passes      = 0;
            theTicket.Size_in_Palettes = partTicket.Size_in_Palettes;
            theTicket.Is_Complete      = 0; //0 is not done. 1 is done
            theTicket.CurrentLocation  = inContract.Origin;

            SQL.Insert(theTicket);

            MappingClass mapping = new MappingClass();

            List <FC_RouteSeg> routeSegs = mapping.GetTravelData(inContract.Origin, inContract.Destination, inContract.Job_type, theTicket.FC_TripTicketID);

            foreach (FC_RouteSeg x in routeSegs)
            {
                SQL.Insert(x);
            }

            FC_TripTicketLine tripTicketLine = new FC_TripTicketLine(theTicket.FC_TripTicketID, inContract.FC_LocalContractID, partTicket.Size_in_Palettes);

            SQL.Insert(tripTicketLine);

            TMSLogger.LogIt(" | " + "CreateTripInfo.cs" + " | " + "CreateTripInfo" + " | " + "CreateTripInfo" + " | " + "Confirmation" + " | " + "Trip info created" + " | ");
        }
Пример #2
0
        // METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn
         *	\brief
         *	\param[in]
         *	\param[out]
         *	\return
         * ---------------------------------------------------------------------------------------------------- */
        public bool AddCarrier(int inID, string inName)
        {
            FC_Carrier temp = new FC_Carrier(inID, inName);

            TheCarriers.Add(temp);

            return(true);
        }
Пример #3
0
        // CARRIER TAB FUNCTIONS ===============================================================================
        private void LoadCarrierDataTab()
        {
            //Carrier_Data.DataContext = admin.DisplayCarrier();
            //Carrier_DataList.ItemsSource = admin.DisplayCarrier();
            FC_Carrier c = new FC_Carrier();

            Carrier_DataList.ItemsSource = c.ObjToTable(SQL.Select(c));
        }
Пример #4
0
        private void LoadCsvIntoBD(object sender, RoutedEventArgs e)
        {
            //check if it is empty
            FC_Carrier c = new FC_Carrier();

            if (c.ObjToTable(SQL.Select(c)).Count == 0)
            {
                LoadCSV.Load();
            }

            Carrier_DataLoadClick(null, null);
        }
Пример #5
0
        // METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn
         *	\brief
         *	\param[in]
         *	\param[out]
         *	\return
         * ---------------------------------------------------------------------------------------------------- */
        public bool AddCarrier(FC_Carrier inCarrier)
        {
            TheCarriers.Add(inCarrier);

            return(true);
        }
Пример #6
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();
        }
Пример #7
0
        // METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn		        Load
         *	\brief			This method loads the carrier csv, parses it for the carrier info and depot city
         *	\param[in]      none
         *	\param[out]	    none
         *	\return		    bool
         * ---------------------------------------------------------------------------------------------------- */
        public static bool Load()
        {
            bool worked = true;

            if (CSVLocation != "")
            {
                try
                {
                    string localResourcePath = CSVLocation;
                    string ReadInData        = System.IO.File.ReadAllText(localResourcePath);

                    ReadInData = ReadInData.Replace("\r\n", ",");
                    ReadInData = ReadInData.Replace(",,", ",");

                    String[] SeperaterStrings = ReadInData.Split(',');

                    List <FC_Carrier>   ReadInCarriers = new List <FC_Carrier>();
                    List <FC_DepotCity> InDeoptCities  = new List <FC_DepotCity>();

                    int  index        = 7;
                    bool CarrierFound = true;

                    index = 7;

                    do
                    {
                        int CurrentCarrierID = SQL.GetNextID("FC_Carrier");

                        FC_Carrier current = new FC_Carrier(CurrentCarrierID, SeperaterStrings[index]);
                        index++;

                        bool cityFound = true;

                        do
                        {
                            if (ToCityID(SeperaterStrings[index]) != -1)
                            {
                                FC_DepotCity tempDepot = new FC_DepotCity(CurrentCarrierID, SeperaterStrings[index], int.Parse(SeperaterStrings[index + 1]), int.Parse(SeperaterStrings[index + 2]), double.Parse(SeperaterStrings[index + 3]), double.Parse(SeperaterStrings[index + 4]), double.Parse(SeperaterStrings[index + 5]));
                                InDeoptCities.Add(tempDepot);

                                index += 6;
                            }
                            else
                            {
                                cityFound = false;
                            }
                        } while (cityFound);

                        ReadInCarriers.Add(current);

                        if (SeperaterStrings[index] == "")
                        {
                            CarrierFound = false;
                        }

                        SQL.Insert(current);
                    } while (CarrierFound);

                    foreach (FC_DepotCity x in InDeoptCities)
                    {
                        SQL.Insert(x);
                    }
                }
                catch (Exception e)
                {
                    //Console.WriteLine(e.ToString());
                    TMSLogger.LogIt(" | " + "LoadCSV.cs" + " | " + "LoadCSV" + " | " + "Load" + " | " + e.GetType().ToString() + " | " + e.Message + " | ");
                    worked = false;
                }
            }

            TMSLogger.LogIt(" | " + "LoadCSV.cs" + " | " + "LoadCSV" + " | " + "Load" + " | " + "Confirmation" + " | " + "CSV Loaded" + " | ");

            return(worked);
        }