//@TODO SD-7694 public static IEnumerable RouteRecordsDelegate( PXFilter <RouteAppointmentAssignmentFilter> filter, PXSelectBase <FSRouteDocument> cmd) { if (filter.Current == null) { yield break; } foreach (PXResult <FSRouteDocument, FSRoute> bqlResult in cmd.Select()) { FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)bqlResult; FSRoute fsRouteRow = (FSRoute)bqlResult; if (filter.Current.RouteDate.HasValue == true) { if (!fsRouteDocumentRow.TimeBegin.HasValue) { fsRouteDocumentRow.TimeBegin = AppointmentCore.GetDateTimeEnd(fsRouteDocumentRow.Date, 0, 0, 0); } if (fsRouteDocumentRow.Date.Value.Date >= filter.Current.RouteDate.Value.Date && fsRouteDocumentRow.Date.Value.Date <= AppointmentCore.GetDateTimeEnd(filter.Current.RouteDate.Value.Date, 23, 59, 59)) { yield return(bqlResult); } } else { yield return(bqlResult); } } }
protected virtual void _(Events.RowSelected <FSRouteDocument> e) { if (e.Row == null) { return; } FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)e.Row; PXCache cache = e.Cache; bool enableVehiceIDAndDriverIDFields = fsRouteDocumentRow.Status != ID.Status_Route.CANCELED; //The IsDirty flags get turned off so the 'save changes' confirmation is not thrown this.Routes.Cache.IsDirty = false; this.VehicleRouteSelected.Cache.IsDirty = false; this.DriverRouteSelected.Cache.IsDirty = false; PXUIFieldAttribute.SetEnabled <FSRouteDocument.refNbr>(cache, fsRouteDocumentRow, false); PXUIFieldAttribute.SetEnabled <FSRouteDocument.routeID>(cache, fsRouteDocumentRow, false); PXUIFieldAttribute.SetEnabled <FSRouteDocument.date>(cache, fsRouteDocumentRow, false); PXUIFieldAttribute.SetEnabled <FSRouteDocument.timeBegin>(cache, fsRouteDocumentRow, false); PXUIFieldAttribute.SetEnabled <FSRouteDocument.vehicleID>(cache, fsRouteDocumentRow, enableVehiceIDAndDriverIDFields); PXUIFieldAttribute.SetEnabled <FSRouteDocument.additionalVehicleID1>(cache, fsRouteDocumentRow, enableVehiceIDAndDriverIDFields); PXUIFieldAttribute.SetEnabled <FSRouteDocument.additionalVehicleID2>(cache, fsRouteDocumentRow, enableVehiceIDAndDriverIDFields); PXUIFieldAttribute.SetEnabled <FSRouteDocument.driverID>(cache, fsRouteDocumentRow, enableVehiceIDAndDriverIDFields); PXUIFieldAttribute.SetEnabled <FSRouteDocument.additionalDriverID>(cache, fsRouteDocumentRow, enableVehiceIDAndDriverIDFields); }
public static IEnumerable DriverRecordsDelegate(PXGraph graph, SharedClasses.RouteSelected_view routeSelected, PXFilter <DriverSelectionFilter> filter) { if (routeSelected.Current == null) { yield break; } List <object> args = new List <object>(); PXSelectBase <EPEmployee> commandFilter = new PXSelectJoinGroupBy <EPEmployee, InnerJoin <FSRouteEmployee, On < FSRouteEmployee.employeeID, Equal <EPEmployee.bAccountID> >, LeftJoin <FSRouteDocument, On < FSRouteDocument.driverID, Equal <FSRouteEmployee.employeeID>, And < FSRouteDocument.date, Equal <Required <FSRouteDocument.date> > > > > >, Where < FSRouteEmployee.routeID, Equal <Required <FSRouteEmployee.routeID> >, And < FSxEPEmployee.sDEnabled, Equal <True>, And < FSxEPEmployee.isDriver, Equal <True> > > >, Aggregate < GroupBy < EPEmployee.bAccountID> >, OrderBy < Asc <FSRouteEmployee.priorityPreference> > >(graph); args.Add(routeSelected.Current.Date); args.Add(routeSelected.Current.RouteID); if (filter.Current.ShowUnassignedDrivers == true) { commandFilter.WhereAnd <Where <FSRouteDocument.routeID, IsNull> >(); } var bqlResultSet = commandFilter.Select(args.ToArray()); foreach (PXResult <EPEmployee, FSRouteEmployee, FSRouteDocument> bqlResult in bqlResultSet) { EPEmployee epEmployeeRow = (EPEmployee)bqlResult; FSRouteEmployee fsRouteEmployeeRow = (FSRouteEmployee)bqlResult; FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)bqlResult; FSxEPEmployee fsxEPEmployeeRow = PXCache <EPEmployee> .GetExtension <FSxEPEmployee>(epEmployeeRow); if (fsRouteDocumentRow != null && fsRouteDocumentRow.RouteID != null) { fsxEPEmployeeRow.Mem_UnassignedDriver = true; } yield return(bqlResult); } }
protected virtual void _(Events.FieldUpdated <FSRouteDocument, FSRouteDocument.additionalDriverID> e) { if (e.Row == null) { return; } FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)e.Row; UpdateRoute(fsRouteDocumentRow); }
protected virtual void _(Events.FieldUpdated <FSRouteDocument, FSRouteDocument.vehicleID> e) { if (e.Row == null) { return; } FSRouteDocument fsRowDocumentRow = (FSRouteDocument)e.Row; UpdateRoute(fsRowDocumentRow); }
protected virtual void createNew() { RouteDocumentMaint graphRouteDocumentMaint = (RouteDocumentMaint)PXGraph.CreateInstance(typeof(RouteDocumentMaint)); graphRouteDocumentMaint.Clear(PXClearOption.ClearAll); FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)graphRouteDocumentMaint.RouteRecords.Cache.CreateInstance(); graphRouteDocumentMaint.RouteRecords.Insert(fsRouteDocumentRow); graphRouteDocumentMaint.RouteRecords.Cache.IsDirty = false; PXRedirectHelper.TryRedirect(graphRouteDocumentMaint, PXRedirectHelper.WindowMode.InlineWindow); }
protected virtual void FSRouteDocument_AdditionalDriverID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e) { if (e.Row == null) { return; } FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)e.Row; UpdateRoute(fsRouteDocumentRow); }
protected virtual void _(Events.RowSelected <FSRouteDocument> e) { if (e.Row == null) { return; } FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)e.Row; if (fsRouteDocumentRow.Status == ID.Status_Route.COMPLETED) { PXUIFieldAttribute.SetEnabled <FSRouteDocument.selected>(e.Cache, fsRouteDocumentRow, false); } }
public virtual void FSRouteDocument_RowSelected(PXCache cache, PXRowSelectedEventArgs e) { if (e.Row == null) { return; } FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)e.Row; if (fsRouteDocumentRow.Status == ID.Status_Route.COMPLETED) { PXUIFieldAttribute.SetEnabled <FSRouteDocument.selected>(cache, fsRouteDocumentRow, false); } }
/// <summary> /// Reassign the selected appointment <c>RefNbr</c> to the selected RouteDocumentID from the SmartPanel. /// </summary> /// <param name="fsRouteDocumentRow">New RouteDocumentID where the appointment is going to be assigned.</param> /// <param name="refNbr"><c>RefNbr</c> of the appointment to be assigned.</param> /// <param name="srvOrdType"><c>SrvOrdType</c> of the appointment to be assigned.</param> public static void ReassignAppointmentToRoute(FSRouteDocument fsRouteDocumentRow, string refNbr, string srvOrdType) { using (PXTransactionScope ts = new PXTransactionScope()) { var graphAppointmentEntry = PXGraph.CreateInstance <AppointmentEntry>(); FSAppointment fsAppointmentRow = graphAppointmentEntry.AppointmentRecords.Search <FSAppointment.refNbr>(refNbr, srvOrdType); int?originalRouteDocumentID = fsAppointmentRow.RouteDocumentID; int?originalAppointmentPosition = fsAppointmentRow.RoutePosition; fsAppointmentRow.RoutePosition = null; if (fsRouteDocumentRow != null) { fsAppointmentRow.RouteID = fsRouteDocumentRow.RouteID; fsAppointmentRow.RouteDocumentID = fsRouteDocumentRow.RouteDocumentID; fsAppointmentRow.ScheduledDateTimeBegin = fsRouteDocumentRow.TimeBegin != null ? fsRouteDocumentRow.TimeBegin : fsRouteDocumentRow.Date; } else { fsAppointmentRow.RouteID = null; fsAppointmentRow.RouteDocumentID = null; //Clear vehicle and driver if exist fsAppointmentRow.VehicleID = null; FSAppointmentEmployee fsAppointmentEmployeeRow = PXSelect <FSAppointmentEmployee, Where < FSAppointmentEmployee.appointmentID, Equal <Required <FSAppointmentEmployee.appointmentID> >, And < FSAppointmentEmployee.isDriver, Equal <True> > > > .Select(graphAppointmentEntry, fsAppointmentRow.AppointmentID); if (fsAppointmentEmployeeRow != null) { graphAppointmentEntry.AppointmentServiceEmployees.Delete(fsAppointmentEmployeeRow); } } fsAppointmentRow.IsReassigned = true; graphAppointmentEntry.AppointmentRecords.Update(fsAppointmentRow); graphAppointmentEntry.SelectTimeStamp(); graphAppointmentEntry.Save.Press(); ReassignAppointmentPositionsInRoute(originalRouteDocumentID, originalAppointmentPosition); ts.Complete(); } }
/// <summary> /// Save the FSRouteDocument row. /// </summary> public virtual void UpdateRoute(FSRouteDocument fsRouteDocumentRow) { routeDocumentMaint.RouteRecords.Current = routeDocumentMaint.RouteRecords.Search <FSRouteDocument.routeDocumentID>(fsRouteDocumentRow.RouteDocumentID); FSRouteDocument fsRouteDocumentRow_New = routeDocumentMaint.RouteRecords.Current; if (fsRouteDocumentRow_New.DriverID != fsRouteDocumentRow.DriverID || fsRouteDocumentRow_New.AdditionalDriverID != fsRouteDocumentRow.AdditionalDriverID || fsRouteDocumentRow_New.VehicleID != fsRouteDocumentRow.VehicleID || fsRouteDocumentRow_New.AdditionalVehicleID1 != fsRouteDocumentRow.AdditionalVehicleID1 || fsRouteDocumentRow_New.AdditionalVehicleID2 != fsRouteDocumentRow.AdditionalVehicleID2) { if (fsRouteDocumentRow_New.VehicleID != fsRouteDocumentRow.VehicleID) { routeDocumentMaint.RouteRecords.SetValueExt <FSRouteDocument.vehicleID> (routeDocumentMaint.RouteRecords.Current, fsRouteDocumentRow.VehicleID); } if (fsRouteDocumentRow_New.AdditionalVehicleID1 != fsRouteDocumentRow.AdditionalVehicleID1) { routeDocumentMaint.RouteRecords.SetValueExt <FSRouteDocument.additionalVehicleID1> (routeDocumentMaint.RouteRecords.Current, fsRouteDocumentRow.AdditionalVehicleID1); } if (fsRouteDocumentRow_New.AdditionalVehicleID2 != fsRouteDocumentRow.AdditionalVehicleID2) { routeDocumentMaint.RouteRecords.SetValueExt <FSRouteDocument.additionalVehicleID2> (routeDocumentMaint.RouteRecords.Current, fsRouteDocumentRow.AdditionalVehicleID2); } if (fsRouteDocumentRow_New.DriverID != fsRouteDocumentRow.DriverID) { routeDocumentMaint.RouteRecords.SetValueExt <FSRouteDocument.driverID> (routeDocumentMaint.RouteRecords.Current, fsRouteDocumentRow.DriverID); } if (fsRouteDocumentRow_New.AdditionalDriverID != fsRouteDocumentRow.AdditionalDriverID) { routeDocumentMaint.RouteRecords.SetValueExt <FSRouteDocument.additionalDriverID> (routeDocumentMaint.RouteRecords.Current, fsRouteDocumentRow.AdditionalDriverID); } routeDocumentMaint.RouteRecords.Update(routeDocumentMaint.RouteRecords.Current); routeDocumentMaint.Save.Press(); } }
public static IEnumerable VehicleRecordsDelegate(PXGraph graph, SharedClasses.RouteSelected_view routeSelected, PXFilter <VehicleSelectionFilter> filter) { if (routeSelected.Current == null) { yield break; } List <object> args = new List <object>(); PXSelectBase <FSVehicle> commandFilter = new PXSelectJoinGroupBy <FSVehicle, LeftJoin <FSRouteDocument, On < FSRouteDocument.vehicleID, Equal <FSVehicle.SMequipmentID>, And <FSRouteDocument.date, Equal <Required <FSRouteDocument.date> > > > >, Where < FSVehicle.isVehicle, Equal <True> >, Aggregate < GroupBy < FSVehicle.SMequipmentID> >, OrderBy < Asc <FSServiceVehicleType.priorityPreference> > >(graph); args.Add(routeSelected.Current.Date); if (filter.Current.ShowUnassignedVehicles == true) { commandFilter.WhereAnd <Where <FSRouteDocument.routeID, IsNull> >(); } var list = commandFilter.Select(args.ToArray()); foreach (PXResult <FSVehicle, FSRouteDocument> bqlResult in list) { FSVehicle fsEquipmentRow = (FSVehicle)bqlResult; FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)bqlResult; if (fsRouteDocumentRow != null && fsRouteDocumentRow.RouteID != null) { fsEquipmentRow.Mem_UnassignedVehicle = true; } yield return(bqlResult); } }
protected virtual void editDetail() { if (Routes.Current == null) { return; } FSRouteDocument fsRouteDocumentRow = PXSelect <FSRouteDocument, Where < FSRouteDocument.routeDocumentID, Equal <Required <FSRouteDocument.routeDocumentID> > > > .SelectSingleBound(this, null, Routes.Current.RouteDocumentID); RouteDocumentMaint graphRouteDocumentMaint = (RouteDocumentMaint)PXGraph.CreateInstance(typeof(RouteDocumentMaint)); graphRouteDocumentMaint.RouteRecords.Current = graphRouteDocumentMaint .RouteRecords.Search <FSAppointment.refNbr>(fsRouteDocumentRow.RefNbr); throw new PXRedirectRequiredException(graphRouteDocumentMaint, null) { Mode = PXBaseRedirectException.WindowMode.NewWindow }; }
/// <summary> /// Try to complete a set of routes. /// </summary> /// <param name="graphRouteDocumentMaint"> Route Document graph.</param> /// <param name="fsRouteDocumentRow">FSRouteDocument row to be processed.</param> public virtual void CompleteRoute(RouteDocumentMaint graphRouteDocumentMaint, FSRouteDocument fsRouteDocumentRow) { if (fsRouteDocumentRow.Status != ID.Status_Route.COMPLETED) { graphRouteDocumentMaint.RouteRecords.Current = graphRouteDocumentMaint.RouteRecords.Search <FSRouteDocument.refNbr>(fsRouteDocumentRow.RefNbr); graphRouteDocumentMaint.completeRoute.PressButton(); } }
/// <summary> /// Try to close a set of routes. /// </summary> /// <param name="graphRouteDocumentMaint"> Route Document graph.</param> /// <param name="graphRouteClosingMaint"> Route Closing Document graph.</param> /// <param name="fsRouteDocumentRow">FSRouteDocument row to be processed.</param> public virtual void CloseRoute(RouteDocumentMaint graphRouteDocumentMaint, RouteClosingMaint graphRouteClosingMaint, FSRouteDocument fsRouteDocumentRow) { if (fsRouteDocumentRow.Status != ID.Status_Route.CLOSED) { graphRouteDocumentMaint.RouteRecords.Current = graphRouteDocumentMaint.RouteRecords.Search <FSRouteDocument.refNbr>(fsRouteDocumentRow.RefNbr); graphRouteClosingMaint.RouteDocumentSelected.Current = graphRouteDocumentMaint.RouteRecords.Current; graphRouteClosingMaint.AutomaticallyCloseRoute = true; graphRouteClosingMaint.closeRoute.PressButton(); fsRouteDocumentRow.Status = graphRouteClosingMaint.RouteDocumentSelected.Current.Status; } }