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); }
public static double GenerateInvoiceTotal(FC_LocalContract inContract) { List <FC_TripTicket> AllTickets = ConnectedTickets_Populate(inContract); MappingClass map = new MappingClass(); List <FC_RouteSeg> TempRouteSegs = map.GetTravelData(inContract.Origin, inContract.Destination, 1, 1); double Total_Cost = 0; foreach (FC_TripTicket x in AllTickets) { List <FC_RouteSeg> TotalContractSegments = new List <FC_RouteSeg>(); List <FC_RouteSeg> segments = RoutSegsPerTicket_Populate(x); for (int i = 0; i < TempRouteSegs.Count; i++) { TotalContractSegments.Add(segments[i]); } RouteSumData sumData = new RouteSumData(); sumData = sumData.SummerizeTrip(TotalContractSegments); string query = "select FC_CarrierID, CityName, FTL_Availibility, LTL_Availibility, FTL_Rate, LTL_Rate, Reefer_Charge " + "from FC_DepotCity " + "where FC_CarrierID = " + x.FC_CarrierID.ToString() + " and CityName = \"" + inContract.Origin + "\";"; FC_DepotCity d = new FC_DepotCity(); List <FC_DepotCity> theDepotCity = d.ObjToTable(SQL.Select(d, query)); double tempPrice = 0; if (inContract.Job_type == 0) { tempPrice = sumData.totalKM * theDepotCity[0].FTL_Rate * 1.08; } else { query = "select * from FC_TripTicketLine where FC_TripTicketID = " + x.FC_TripTicketID.ToString() + " and FC_LocalContractID = " + inContract.FC_LocalContractID.ToString() + " ;"; FC_TripTicketLine t = new FC_TripTicketLine(); List <FC_TripTicketLine> theTicketLine = t.ObjToTable(SQL.Select(t, query)); int QuantityOnTruck = theTicketLine[0].PalletsOnTicket; if (QuantityOnTruck == 0) { QuantityOnTruck = 26; } tempPrice = sumData.totalKM * theDepotCity[0].LTL_Rate * QuantityOnTruck * 1.05; } if (inContract.Van_type == 1) { tempPrice *= (theDepotCity[0].Reefer_Charge + 1); } Total_Cost += tempPrice; } try { Total_Cost = Math.Round(Total_Cost, 2); } catch (Exception e) { TMSLogger.LogIt(" | " + "PlannerClass.cs" + " | " + "PlannerClass" + " | " + "GenerateInvoiceTotal" + " | " + e.GetType().ToString() + " | " + e.Message + " | "); } TMSLogger.LogIt(" | " + "PlannerClass.cs" + " | " + "PlannerClass" + " | " + "GenerateInvoiceTotal" + " | " + "Confirmation" + " | " + "Invoice total generated" + " | "); return(Total_Cost); }
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 + " | "); } }