Example #1
0
        // METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *	\fn		        AtOrPastCity
         *	\brief			This method determins if a truck is currently at or past a destination city
         *	\param[in]      FC_LocalContract inContract, FC_TripTicket inTicket
         *	\param[out]	    none
         *	\return		    bool
         * ---------------------------------------------------------------------------------------------------- */
        public bool AtOrPastCity(FC_LocalContract inContract, FC_TripTicket inTicket)
        {
            int OrginId = LoadCSV.ToCityID(inContract.Origin);
            int DestId  = LoadCSV.ToCityID(inContract.Destination);

            int current = LoadCSV.ToCityID(inTicket.CurrentLocation);

            if (OrginId > DestId)
            {
                //going west

                if (current <= DestId)
                {
                    return(true);
                }
            }
            else
            {
                if (current >= DestId)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #2
0
        //Ivan
        public static List <FC_TripTicket> TicketsWithStatus_Populate(int status)
        {
            string        query = "select * from FC_TripTicket where Is_Complete = " + status.ToString() + ";";
            FC_TripTicket temp  = new FC_TripTicket();

            return(temp.ObjToTable(SQL.Select(temp, query)));
        }
Example #3
0
        public void RefreshPossibleTickets()
        {
            string query = "Select * from FC_TripTicket where Is_Complete = 0 and CurrentLocation = \"" + PassedInContract.Origin + "\" and not Size_in_Palettes = 0;";

            FC_TripTicket        t                = new FC_TripTicket();
            List <FC_TripTicket> OtherTickets     = t.ObjToTable(SQL.Select(t, query));
            List <FC_TripTicket> ValidatedTickets = new List <FC_TripTicket>();

            foreach (FC_TripTicket x in OtherTickets)
            {
                List <FC_LocalContract> ContractsForTicket = PlannerClass.ContractsPerTicket_Populate(x);

                bool matchfound = false;

                foreach (FC_LocalContract y in ContractsForTicket)
                {
                    if (y.FC_LocalContractID == PassedInContract.FC_LocalContractID)
                    {
                        matchfound = true;
                    }

                    if (y.Van_type != PassedInContract.Van_type)
                    {
                        matchfound = true;
                    }
                }

                if (!matchfound)
                {
                    ValidatedTickets.Add(x);
                }
            }

            PossibleTickets.ItemsSource = ValidatedTickets;
        }
Example #4
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" + " | ");
        }
Example #5
0
        private void AllTickets_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.AllTickets.SelectedItem != null)
            {
                FC_TripTicket selected = (FC_TripTicket)this.AllTickets.SelectedItem;

                SelectedTicket = selected;
            }
        }
Example #6
0
        //Ivan
        public static List <FC_LocalContract> ContractsPerTicket_Populate(FC_TripTicket temp)
        {
            string query = "select LC.FC_LocalContractID, LC.Client_Name, LC.Job_type, LC.Quantity, LC.Origin, LC.Destination, LC.Van_type, LC.Contract_Status " +
                           "from FC_LocalContract as LC " +
                           "left join FC_TripTicketLine as ttl on ttl.FC_LocalContractID = LC.FC_LocalContractID " +
                           "left join FC_TripTicket as tt on tt.FC_TripTicketID = ttl.FC_TripTicketID " +
                           "where tt.FC_TripTicketID = " + temp.FC_TripTicketID + ";";
            FC_LocalContract lc = new FC_LocalContract();

            return(lc.ObjToTable(SQL.Select(lc, query)));
        }
Example #7
0
        //Ivan
        public static List <FC_TripTicket> ConnectedTickets_Populate(FC_LocalContract temp)
        {
            ConnectedTickets.Clear();
            string query = "select t.FC_TripTicketID, t.FC_CarrierID, t.CurrentLocation, t.Size_in_Palettes, t.Days_Passes, t.Is_Complete from FC_LocalContract as lc " +
                           "left join FC_TripTicketLine as tt on tt.FC_LocalContractID = lc.FC_LocalContractID " +
                           "left join FC_TripTicket as t on t.FC_TripTicketID = tt.FC_TripTicketID " +
                           "where lc.FC_LocalContractID = " + temp.FC_LocalContractID + ";";
            FC_TripTicket lc = new FC_TripTicket();

            ConnectedTickets = lc.ObjToTable(SQL.Select(lc, query));

            return(ConnectedTickets);
        }
Example #8
0
        //Ivan
        public static List <FC_RouteSeg> RoutSegsPerTicket_Populate(FC_TripTicket inTicket)
        {
            if (inTicket != null)
            {
                string query = "select * from FC_RouteSeg where FC_TripTicketID =  " + inTicket.FC_TripTicketID + ";";

                FC_RouteSeg c = new FC_RouteSeg();
                RouteSegsPerTicket = c.ObjToTable(SQL.Select(c, query));

                return(RouteSegsPerTicket);
            }

            return(null);
        }
Example #9
0
        public static List <FC_TripTicket> CreateTicketsFromContract(FC_LocalContract InContract)
        {
            List <FC_TripTicket> ReturnTickets = new List <FC_TripTicket>();

            if (InContract != null)
            {
                int TempTickedID = -10;

                if (InContract.Quantity == 0 || InContract.Quantity == 26)
                {
                    FC_TripTicket newTicket = new FC_TripTicket(TempTickedID, -1, InContract.Origin, 0, 0, 0);
                    ReturnTickets.Add(newTicket);
                }
                else if (InContract.Quantity < 26)
                {
                    FC_TripTicket newTicket = new FC_TripTicket(TempTickedID, -1, InContract.Origin, InContract.Quantity, 0, 0);
                    ReturnTickets.Add(newTicket);
                }
                else if (InContract.Quantity > 26)
                {
                    FC_TripTicket newTicket = new FC_TripTicket();

                    do
                    {
                        if (InContract.Quantity >= 26)
                        {
                            newTicket = new FC_TripTicket(TempTickedID--, -1, InContract.Origin, 0, 0, 0);
                        }
                        else if (InContract.Quantity < 26)
                        {
                            newTicket = new FC_TripTicket(TempTickedID--, -1, InContract.Origin, InContract.Quantity, 0, 0);
                        }

                        ReturnTickets.Add(newTicket);

                        InContract.Quantity -= 26;
                    } while (InContract.Quantity > 0);
                }
            }

            TMSLogger.LogIt(" | " + "PlannerClass.cs" + " | " + "PlannerClass" + " | " + "CreateTicketsFromContract" + " | " + "Confirmation" + " | " + "Ticket created from contract" + " | ");

            return(ReturnTickets);
        }
Example #10
0
        //Duane
        public static void UpdateTicketState(FC_TripTicket inTicket, int newState)
        {
            string query = "update FC_TripTicket set Is_Complete = " + newState.ToString() + " where FC_TripTicketID = " + inTicket.FC_TripTicketID.ToString() + ";";

            SQL.GenericFunction(query);
        }
Example #11
0
        //Duane
        public static void UpdateTicketLocation(FC_TripTicket inTicket)
        {
            string query = "update FC_TripTicket set CurrentLocation = \'" + inTicket.CurrentLocation + "\' , Days_Passes = " + inTicket.Days_Passes + "  where FC_TripTicketID = " + inTicket.FC_TripTicketID + ";";

            SQL.GenericFunction(query);
        }
Example #12
0
        public static int AddContractToTicket(FC_TripTicket OriginalTick, FC_TripTicket TempTicket, FC_LocalContract TheContract)
        {
            string Query = "select * from FC_RouteSeg where FC_TripTicketID = " + OriginalTick.FC_TripTicketID + ";";

            FC_RouteSeg        r            = new FC_RouteSeg();
            List <FC_RouteSeg> OriginalSegs = r.ObjToTable(SQL.Select(r, Query));

            MappingClass map = new MappingClass();

            List <FC_RouteSeg> NewSegs = map.GetTravelData(TheContract.Origin, TheContract.Destination, 0, -1);

            //check that these tickets are going in the same direction
            if (OriginalSegs[0].CityA == NewSegs[0].CityA && OriginalSegs[0].CityB == NewSegs[0].CityB && TempTicket.Size_in_Palettes != 0)
            {
                int PalletesAddedToOgrinal = 26 - OriginalTick.Size_in_Palettes;

                if (PalletesAddedToOgrinal > TempTicket.Size_in_Palettes)
                {
                    PalletesAddedToOgrinal = TempTicket.Size_in_Palettes;
                }

                int OrignalTickNewSize = OriginalTick.Size_in_Palettes + PalletesAddedToOgrinal;

                if (OrignalTickNewSize == 26)
                {
                    OrignalTickNewSize = 0;
                }

                string query = "update FC_TripTicket " +
                               "set Size_in_Palettes = " + OrignalTickNewSize +
                               " where FC_TripTicketID = " + OriginalTick.FC_TripTicketID + ";";

                SQL.GenericFunction(query);

                int FTL = 0;

                List <FC_RouteSeg> NewSegmentsFTL = new List <FC_RouteSeg>();
                List <FC_RouteSeg> NewSegmentsLTL = new List <FC_RouteSeg>();

                if (NewSegs.Count > OriginalSegs.Count)
                {
                    string orginCity = LoadCSV.ToCityName(OriginalSegs[0].CityA);
                    string EndOfFTL  = LoadCSV.ToCityName(OriginalSegs[OriginalSegs.Count - 1].CityB);
                    string startLTL  = LoadCSV.ToCityName(NewSegs[OriginalSegs.Count].CityA);
                    string endCity   = LoadCSV.ToCityName(NewSegs[NewSegs.Count - 1].CityB);

                    NewSegmentsFTL = map.GetTravelData(orginCity, EndOfFTL, FTL, OriginalTick.FC_TripTicketID);
                    NewSegmentsLTL = map.GetTravelData(startLTL, endCity, 1, OriginalTick.FC_TripTicketID);
                }
                else if (NewSegs.Count < OriginalSegs.Count)
                {
                    string orginCity = LoadCSV.ToCityName(OriginalSegs[0].CityA);
                    string EndOfFTL  = LoadCSV.ToCityName(NewSegs[NewSegs.Count - 1].CityB);
                    string startLTL  = LoadCSV.ToCityName(OriginalSegs[NewSegs.Count].CityA);
                    string endCity   = LoadCSV.ToCityName(OriginalSegs[OriginalSegs.Count - 1].CityB);

                    NewSegmentsFTL = map.GetTravelData(orginCity, EndOfFTL, FTL, OriginalTick.FC_TripTicketID);
                    NewSegmentsLTL = map.GetTravelData(startLTL, endCity, 1, OriginalTick.FC_TripTicketID);
                }
                else
                {
                    string orginCity = LoadCSV.ToCityName(OriginalSegs[0].CityA);
                    string endCity   = LoadCSV.ToCityName(OriginalSegs[NewSegs.Count - 1].CityB);

                    NewSegmentsLTL = map.GetTravelData(orginCity, endCity, FTL, OriginalTick.FC_TripTicketID);
                }

                if (NewSegmentsLTL != null)
                {
                    NewSegmentsLTL[0].PickUpTime = 0;
                }


                query = "delete from FC_RouteSeg where FC_TripTicketID = " + OriginalTick.FC_TripTicketID + ";";
                SQL.GenericFunction(query);

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

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

                FC_TripTicketLine NewLine = new FC_TripTicketLine(OriginalTick.FC_TripTicketID, TheContract.FC_LocalContractID, PalletesAddedToOgrinal);
                SQL.Insert(NewLine);

                TMSLogger.LogIt(" | " + "PlannerClass.cs" + " | " + "PlannerClass" + " | " + "AddContractToTicket" + " | " + "Confirmation" + " | " + "Contract added to ticket" + " | ");

                return(PalletesAddedToOgrinal);
            }

            return(-1);
        }
Example #13
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();
        }
Example #14
0
        public static void IncrementOneDay()
        {
            try
            {
                string FirstQuery = "Select * from FC_TripTicket where not Is_Complete = 0;";

                FC_TripTicket        t          = new FC_TripTicket();
                List <FC_TripTicket> AllTickets = t.ObjToTable(SQL.Select(t, FirstQuery));

                foreach (FC_TripTicket x in AllTickets)
                {
                    x.Days_Passes++;

                    FC_RouteSeg s = new FC_RouteSeg();

                    string query = "Select FC_TripTicketID, CityA, CityB, PickUpTime, DropOffTime, LtlTime, DrivenTime, KM from FC_RouteSeg where FC_TripTicketID = " + x.FC_TripTicketID + ";";

                    List <FC_RouteSeg> AllSegments = s.ObjToTable(SQL.Select(s, query));

                    double totalTime = x.Days_Passes * 12;
                    double DriveTime = x.Days_Passes * 8;

                    int         SegIndex       = 0;
                    FC_RouteSeg currentSegment = AllSegments[SegIndex];

                    while (true)
                    {
                        totalTime -= currentSegment.PickUpTime;

                        totalTime -= currentSegment.DrivenTime;
                        DriveTime -= currentSegment.DrivenTime;

                        totalTime -= currentSegment.LtlTime;

                        totalTime -= currentSegment.DropOffTime;

                        if (totalTime <= 0 || DriveTime <= 0)
                        {
                            x.CurrentLocation = LoadCSV.ToCityName(currentSegment.CityA);
                            break;
                        }
                        else
                        {
                            SegIndex++;

                            if (SegIndex >= AllSegments.Count)
                            {
                                x.CurrentLocation = LoadCSV.ToCityName(currentSegment.CityB);
                                break;
                            }
                            else
                            {
                                currentSegment = AllSegments[SegIndex];
                            }

                            x.CurrentLocation = LoadCSV.ToCityName(currentSegment.CityB);
                        }
                    }

                    PlannerClass.UpdateTicketLocation(x);
                }

                string Query = "select FC_LocalContractID, Client_Name, Job_type, Quantity, Origin, Destination, Van_type, Contract_Status from " +
                               "FC_LocalContract where Contract_Status = 1";

                FC_LocalContract        l = new FC_LocalContract();
                List <FC_LocalContract> OnrouteContracts = l.ObjToTable(SQL.Select(l, Query));

                MappingClass map = new MappingClass();

                foreach (FC_LocalContract x in OnrouteContracts)
                {
                    bool isComplete = true;

                    List <FC_TripTicket> theTickets = PlannerClass.ConnectedTickets_Populate(x);

                    foreach (FC_TripTicket y in theTickets)
                    {
                        if (!map.AtOrPastCity(x, y))
                        {
                            isComplete = false;
                            break;
                        }
                    }

                    if (isComplete)
                    {
                        PlannerClass.UpdateContratState(x, 2);
                    }
                }

                string theQuery = "Select * from FC_TripTicket where Is_Complete = 1";

                FC_TripTicket        w             = new FC_TripTicket();
                List <FC_TripTicket> ActiveTickets = t.ObjToTable(SQL.Select(t, theQuery));

                foreach (FC_TripTicket x in ActiveTickets)
                {
                    bool foundNotComple = false;

                    List <FC_LocalContract> ContactsPerTick = PlannerClass.ContractsPerTicket_Populate(x);

                    foreach (FC_LocalContract y in ContactsPerTick)
                    {
                        if (y.Contract_Status < 2)
                        {
                            foundNotComple = true;
                        }
                    }

                    if (!foundNotComple)
                    {
                        theQuery = "Update FC_TripTicket set Is_Complete = 2 where FC_TripTicketID = " + x.FC_TripTicketID + ";";
                        SQL.GenericFunction(theQuery);
                    }
                }

                TMSLogger.LogIt(" | " + "TimePass.cs" + " | " + "TimePass" + " | " + "IncrementOneDay" + " | " + "Confirmation" + " | " + "Day incremented" + " | ");
            }
            catch (Exception e)
            {
                TMSLogger.LogIt(" | " + "TimePass.cs" + " | " + "TimePass" + " | " + "IncrementOneDay" + " | " + e.GetType().ToString() + " | " + e.Message + " | ");
            }
        }