Apel functie de modificare din cod

Lasă un comentariu

6 Aprilie 2010 de liviustoica55


public void modifiedField(fieldId _fieldId)
{
    #define.startTime('08:00')
    #define.endTime('16:00')
    #define.AllDayEndTime('23:59')
    smmActivities       smmActivities_Orig;
    boolean             updateReminderDate;
    ;

    smmActivities_Orig = this.orig();

    super(_fieldId);

    switch (_fieldId)
    {

        case fieldnum(smmActivities, KeepSynchronized) :
            if (this.KeepSynchronized)
            {
                this.updateOutlookText();
            }
            else
            {
                this.ExternalMemo = '';
            }
            break;

        case fieldnum(smmActivities, ReminderActive) :
            if (this.ReminderActive && !this.reminderDateTime())
            {
                updateReminderDate = true;
            }
            break;

        case fieldnum(smmActivities, EndDateTime) :
             updateReminderDate = true;
            break;

        case fieldnum(smmActivities, Closed) :
            if (smmActivityParentLinkTable::existsParentLink(this.ActivityNumber, smmActivityParentType::ServiceOrderLine))
            {
                this.updateSignOff();
            }
            if (this.Closed == NoYes::Yes)
            {
                this.ActualEndDateTime  = DateTimeUtil::getSystemDateTime();
                this.DoneByEmployee     = smmUtility::getCurrentContact();
                // Set task to completed
                if (this.Category == smmActivityCategory::Task)
                {
                    this.ActivityTaskTimeType = smmActivityTaskTimeType::Completed;
                    this.PercentageCompleted  = 100;
                }

            }
            else
            {
                this.ActualEndDateTime  = utcDateTimeNull();
                this.DoneByEmployee     = '';
                // Set task to in process
                if (this.Category == smmActivityCategory::Task)
                {
                    this.ActivityTaskTimeType = smmActivityTaskTimeType::InProgress;
                    this.PercentageCompleted  = 0;
                }

            }
            break;

        case fieldnum(smmActivities, PercentageCompleted) :
            if (this.PercentageCompleted == 100)
            {
                this.Closed                 = NoYes::Yes;
                this.ActualEndDateTime      = DateTimeUtil::getSystemDateTime();
                this.DoneByEmployee         = smmUtility::getCurrentContact();
                this.ActivityTaskTimeType   = smmActivityTaskTimeType::Completed;
            }
            else if (this.PercentageCompleted == 0)
            {
                this.Closed                 = NoYes::No;
                this.ActualEndDateTime      = utcDateTimeNull();
                this.DoneByEmployee         = '';
                this.ActivityTaskTimeType   = smmActivityTaskTimeType::InProgress;
            }
            break;


        case fieldnum(smmActivities, ActualEndDateTime) :
            // If closed date is removed , activity is made open
            if (this.actualEndDate() == dateNull() && this.Closed)
            {
                this.Closed             = NoYes::No;
                this.ActualEndDateTime  = utcDateTimeNull();
                this.DoneByEmployee     = '';

                // For task type activity , it is set back to In progress
                if (this.Category == smmActivityCategory::Task)
                {
                    this.ActivityTaskTimeType = smmActivityTaskTimeType::InProgress;
                    this.PercentageCompleted  = 0;
                }
            }
            else if (DateTimeUtil::date(this.actualEndDateTime()) != dateNull() && !this.Closed)
            {
                this.Closed             = NoYes::Yes;
                this.ActualEndDateTime  = DateTimeUtil::getSystemDateTime();
                this.DoneByEmployee     = smmUtility::getCurrentContact();

                // For task type activity , it is set to Completed
                if (this.Category == smmActivityCategory::Task)
                {
                    this.ActivityTaskTimeType = smmActivityTaskTimeType::Completed;
                    this.PercentageCompleted  = 100;
                }

            }
            break;


        case fieldnum(smmActivities, StartDateTime) :
            if (this.Category == smmActivityCategory::Appointment ||
                this.Category == smmActivityCategory::Action)
            {
                // start date has changed
                if (smmActivities_Orig.startDate() != this.startDate())
                {
                    this.EndDateTime = DateTimeUtil::newDateTime(this.startDate(),this.endTime(),DateTimeUtil::getUserPreferredTimeZone());
                }
            }
            // start time has changed
            if (smmActivities_Orig.startTime() != this.startTime())
            {
                if (this.Category == smmActivityCategory::Appointment && smmActivityParentLinkTable::existsParentLink(this.ActivityNumber, smmActivityParentType::ServiceOrderLine))
                {
                    this.findEndDateTimeBasedOnTotalWork();
                }
                else
                {
                    this.setEndTime(this.startTime() + this.defaultActivityDuration());
                }

            }

            // End date = start date for events
            if (this.Category == smmActivityCategory::Event)
            {
                this.setEndDate(this.startDate());
            }
            break;

        case fieldnum(smmActivities, AllDay) :
            this.setStartTime(0);
            this.setEndTime(str2time(#allDayEndTime));
            break;

        case fieldnum(smmActivities, TotalWork) :
            this.findEndDateTimeBasedOnTotalWork();
            break;
    }
    if (updateReminderDate)
    {
        this.setReminderDate(this.endDate());
        this.setReminderTime(str2time(#startTime));
    }
}
  smmActivities = record;
        smmActivities.selectForUpdate(true);
        smmActivities.Closed = args.parmEnum();
        smmActivities.modifiedField(fieldnum(smmActivities,Closed));
        smmActivities.update();

Lasă un răspuns

Completează mai jos detaliile despre tine sau dă clic pe un icon pentru autentificare:

Logo WordPress.com

Comentezi folosind contul tău WordPress.com. Dezautentificare / Schimbă )

Poză Twitter

Comentezi folosind contul tău Twitter. Dezautentificare / Schimbă )

Fotografie Facebook

Comentezi folosind contul tău Facebook. Dezautentificare / Schimbă )

Fotografie Google+

Comentezi folosind contul tău Google+. Dezautentificare / Schimbă )

Conectare la %s

%d blogeri au apreciat asta: