コード例 #1
0
        public virtual IEnumerable ProcessDetail(PXAdapter adapter)
        {
            if (Filter.Current != null &&
                Filter.Current.AppointmentID != null)
            {
                AppointmentEntry graphAppointment = PXGraph.CreateInstance <AppointmentEntry>();

                graphAppointment.AppointmentRecords.Current = graphAppointment.AppointmentRecords.Search <FSAppointment.appointmentID>(Filter.Current.AppointmentID, Filter.Current.SrvOrdType);
                graphAppointment.SkipLongOperation          = this.IsMobile;

                if (Filter.Current.Me == true)
                {
                    Filter.Current.Me = false;
                }

                graphAppointment.LogActionFilter.Current     = Filter.Current;
                graphAppointment.LogActionFilter.View.Answer = WebDialogResult.OK;

                bool isThereARecordSelected = false;

                if (Filter.Current.Action == ID.LogActions.START)
                {
                    if (Filter.Current.Type == ID.Type_Log.SERVICE || Filter.Current.Type == ID.Type_Log.TRAVEL)
                    {
                        FSAppointmentEmployeeFSLogStart selectedItem = StaffMemberLogStartAction.Current;

                        if (selectedItem != null)
                        {
                            foreach (FSAppointmentEmployeeFSLogStart row in graphAppointment.StaffMemberLogStartAction
                                     .Select()
                                     .RowCast <FSAppointmentEmployeeFSLogStart>()
                                     .Where(x => x.Selected == true))
                            {
                                row.Selected = false;
                                graphAppointment.StaffMemberLogStartAction.Update(row);
                            }

                            FSAppointmentEmployeeFSLogStart rowInApp = graphAppointment.StaffMemberLogStartAction
                                                                       .Select()
                                                                       .RowCast <FSAppointmentEmployeeFSLogStart>()
                                                                       .Where(x => x.DocID == selectedItem?.DocID && x.BAccountID == selectedItem?.BAccountID)
                                                                       .FirstOrDefault();

                            if (rowInApp != null)
                            {
                                isThereARecordSelected = true;
                                rowInApp.Selected      = true;
                                graphAppointment.StaffMemberLogStartAction.Update(rowInApp);
                            }
                        }
                    }
                    else if (Filter.Current.Type == ID.Type_Log.STAFF_ASSIGMENT)
                    {
                        FSStaffLogActionDetail selectedItem = LogStaffActionDetails.Current;

                        if (selectedItem != null)
                        {
                            foreach (FSStaffLogActionDetail row in graphAppointment.LogStaffActionDetails
                                     .Select()
                                     .RowCast <FSStaffLogActionDetail>()
                                     .Where(x => x.Selected == true))
                            {
                                row.Selected = false;
                                graphAppointment.LogStaffActionDetails.Update(row);
                            }

                            FSStaffLogActionDetail rowInApp = graphAppointment.LogStaffActionDetails
                                                              .Select()
                                                              .RowCast <FSStaffLogActionDetail>()
                                                              .Where(x => x.DocID == selectedItem?.DocID && x.LineRef == selectedItem?.LineRef)
                                                              .FirstOrDefault();

                            if (rowInApp != null)
                            {
                                isThereARecordSelected = true;
                                rowInApp.Selected      = true;
                                graphAppointment.LogStaffActionDetails.Update(rowInApp);
                            }
                        }
                        else
                        {
                            FSStaffLogActionDetail row = graphAppointment.LogStaffActionDetails
                                                         .Select()
                                                         .RowCast <FSStaffLogActionDetail>()
                                                         .Where(_ => _.LineRef == Filter.Current.EmployeeLineRef)
                                                         .FirstOrDefault();
                            if (row != null)
                            {
                                row.Selected = true;

                                if (LogStaffActionDetails.Cache.GetStatus(row) == PXEntryStatus.Notchanged)
                                {
                                    LogStaffActionDetails.Cache.SetStatus(row, PXEntryStatus.Updated);
                                }
                            }
                        }
                    }
                    else if (Filter.Current.Type == ID.Type_Log.SERV_BASED_ASSIGMENT)
                    {
                        FSDetailFSLogAction selectedItem = ServicesLogAction.Current;

                        if (selectedItem != null)
                        {
                            foreach (FSDetailFSLogAction row in graphAppointment.ServicesLogAction
                                     .Select()
                                     .RowCast <FSDetailFSLogAction>()
                                     .Where(x => x.Selected == true))
                            {
                                row.Selected = false;
                                graphAppointment.ServicesLogAction.Update(row);
                            }

                            FSDetailFSLogAction rowInApp = graphAppointment.ServicesLogAction
                                                           .Select()
                                                           .RowCast <FSDetailFSLogAction>()
                                                           .Where(x => x.AppDetID == selectedItem?.AppDetID && x.LineRef == selectedItem?.LineRef)
                                                           .FirstOrDefault();

                            if (rowInApp != null)
                            {
                                isThereARecordSelected = true;
                                rowInApp.Selected      = true;
                                graphAppointment.ServicesLogAction.Update(rowInApp);
                            }
                        }
                    }

                    if (isThereARecordSelected)
                    {
                        PressActionButton(graphAppointment, Filter.Current.Action, Filter.Current.Type);
                    }
                    else
                    {
                        throw new PXRowPersistingException(null, null, TX.Error.CANNOT_PERFORM_LOG_ACTION_RECORD_NOT_SELECTED);
                    }
                }
                else if (Filter.Current.Action == ID.LogActions.COMPLETE)
                {
                    if (Filter.Current.Type == ID.Type_Log.SERVICE)
                    {
                        NoTravelLogInProcess selectedItem = LogActionServiceDetails.Current;

                        if (selectedItem != null)
                        {
                            foreach (NoTravelLogInProcess row in graphAppointment.LogActionServiceDetails
                                     .Select()
                                     .RowCast <NoTravelLogInProcess>()
                                     .Where(x => x.Selected == true))
                            {
                                row.Selected = false;
                                graphAppointment.LogActionServiceDetails.Update(row);
                            }

                            NoTravelLogInProcess rowInApp = graphAppointment.LogActionServiceDetails
                                                            .Select()
                                                            .RowCast <NoTravelLogInProcess>()
                                                            .Where(x => x.DocID == selectedItem?.DocID && x.LineRef == selectedItem?.LineRef)
                                                            .FirstOrDefault();

                            if (rowInApp != null)
                            {
                                isThereARecordSelected = true;
                                rowInApp.Selected      = true;
                                graphAppointment.LogActionServiceDetails.Update(rowInApp);
                            }
                        }
                    }
                    else if (Filter.Current.Type == ID.Type_Log.TRAVEL)
                    {
                        FSLogActionTravelDetail selectedItem = LogActionTravelDetails.Current;

                        if (selectedItem != null)
                        {
                            foreach (FSLogActionTravelDetail row in graphAppointment.LogActionTravelDetails
                                     .Select()
                                     .RowCast <FSLogActionTravelDetail>()
                                     .Where(x => x.Selected == true))
                            {
                                row.Selected = false;
                                graphAppointment.LogActionTravelDetails.Update(row);
                            }

                            FSLogActionTravelDetail rowInApp = graphAppointment.LogActionTravelDetails
                                                               .Select()
                                                               .RowCast <FSLogActionTravelDetail>()
                                                               .Where(x => x.DocID == selectedItem?.DocID && x.LineRef == selectedItem?.LineRef)
                                                               .FirstOrDefault();
                            if (rowInApp != null)
                            {
                                isThereARecordSelected = true;
                                rowInApp.Selected      = true;
                                graphAppointment.LogActionTravelDetails.Update(rowInApp);
                            }
                        }
                    }

                    if (isThereARecordSelected)
                    {
                        PressActionButton(graphAppointment, Filter.Current.Action, Filter.Current.Type);
                    }
                    else
                    {
                        throw new PXRowPersistingException(null, null, TX.Error.CANNOT_PERFORM_LOG_ACTION_RECORD_NOT_SELECTED);
                    }
                }
            }

            return(adapter.Get());
        }
コード例 #2
0
        public virtual void UpdateLogActionViews(string type, bool fromStaffTab)
        {
            if (type == ID.Type_Log.TRAVEL)
            {
                if (AppointmentDetails.Current?.IsTravelItem == true)
                {
                    LogActionFilter.Current.DetLineRef = AppointmentDetails.Current.LineRef;
                }
                else
                {
                    LogActionFilter.Current.DetLineRef = SharedFunctions.GetItemLineRef(this, AppointmentRecords.Current.AppointmentID, true);
                }

                if (LogActionFilter.Current.DetLineRef != null)
                {
                    foreach (FSLogActionTravelDetail row in LogActionTravelDetails.Select())
                    {
                        row.Selected = row.DetLineRef == LogActionFilter.Current.DetLineRef;

                        if (LogActionTravelDetails.Cache.GetStatus(row) == PXEntryStatus.Notchanged)
                        {
                            LogActionTravelDetails.Cache.SetStatus(row, PXEntryStatus.Updated);
                        }
                    }
                }
            }
            else if (type == ID.Type_Log.SERVICE)
            {
                LogActionFilter.Current.DetLineRef = AppointmentDetails.Current?.LineType == ID.LineType_ALL.SERVICE ? AppointmentDetails.Current.LineRef : null;

                foreach (NoTravelLogInProcess row in LogActionServiceDetails.Select())
                {
                    if (fromStaffTab == false)
                    {
                        row.Selected = row.DetLineRef == LogActionFilter.Current.DetLineRef;
                    }
                    else
                    {
                        row.Selected = row.BAccountID == AppointmentServiceEmployees.Current?.EmployeeID;
                    }

                    if (LogActionServiceDetails.Cache.GetStatus(row) == PXEntryStatus.Notchanged)
                    {
                        LogActionServiceDetails.Cache.SetStatus(row, PXEntryStatus.Updated);
                    }
                }
            }
            else if (type == ID.Type_Log.STAFF_ASSIGMENT)
            {
                FSStaffLogActionDetail row = LogStaffActionDetails.Select()
                                             .RowCast <FSStaffLogActionDetail>()
                                             .Where(_ => _.LineRef == AppointmentServiceEmployees.Current.LineRef)
                                             .FirstOrDefault();

                if (row != null)
                {
                    foreach (FSStaffLogActionDetail selectedRow in LogStaffActionDetails.Select()
                             .RowCast <FSStaffLogActionDetail>()
                             .Where(_ => _.Selected == true))
                    {
                        selectedRow.Selected = false;

                        if (LogStaffActionDetails.Cache.GetStatus(selectedRow) == PXEntryStatus.Notchanged)
                        {
                            LogStaffActionDetails.Cache.SetStatus(selectedRow, PXEntryStatus.Updated);
                        }
                    }

                    row.Selected = row.BAccountID == AppointmentServiceEmployees.Current.EmployeeID;

                    if (LogStaffActionDetails.Cache.GetStatus(row) == PXEntryStatus.Notchanged)
                    {
                        LogStaffActionDetails.Cache.SetStatus(row, PXEntryStatus.Updated);
                    }
                }
            }
        }