PdcClockLine.CopyID: Difference between revisions

From External Bemet Wiki
Jump to navigation Jump to search
Created page with "== Declaration == CopyID as Integer == Description == This method copies a clockline. == Notes == Returns the AO_ID from the newly copied clockline. If the clockline is part..."
 
No edit summary
Line 18: Line 18:


     OriginalClockLine = PDC.App.ProductRegistration.ClockLines.Open(ClockLineID)
     OriginalClockLine = PDC.App.ProductRegistration.ClockLines.Open(ClockLineID)
     CopiedID = PDC.App.ProductRegistration.ClockLines.CopyID(ClockLineID)
     CopiedID = OriginalClockLine.CopyID(ClockLineID)


     If CopiedID > 0 Then
     If CopiedID > 0 Then

Revision as of 13:38, 11 April 2018

Declaration

CopyID as Integer

Description

This method copies a clockline.

Notes

Returns the AO_ID from the newly copied clockline. If the clockline is part of a nest, it will copy all the clocklines in the nest and returns the last AO_ID. If Copy is not succesfull, it will return 0 and stores the error in PdC.App.LastError.

Code example

This code example copies a clockline which includes a nest. After the copy, it alters the EndTime of the original clockline and the StartTime of the copied clockline. With this example it's possible to split a nesting of clocklines and change the TimeTyp of the copied nest.

  Dim ClockLineID As Integer = 381
  Dim CopiedID As Integer = 0 
  Dim OriginalClockLine As PDCEXT.IClockLine 
  Dim CopiedClockLine As PDCEXT.IClockLine

    OriginalClockLine = PDC.App.ProductRegistration.ClockLines.Open(ClockLineID)
    CopiedID = OriginalClockLine.CopyID(ClockLineID)

    If CopiedID > 0 Then
      CopiedClockLine = PDC.App.ProductRegistration.ClockLines.Open(CopiedID)
      OriginalClockLine.EndTime = OriginalClockLine.EndTime - 1
      CopiedClockLine.StartTime = CopiedClockLine.StartTime + 1
      CopiedClockLine.TimeType = "2"
      if Not OriginalClockLine.Save Then
        MsgBox(PDC.App.LastError)
      End If
      if Not CopiedClockLine.Save Then
        MsgBox(PDC.App.LastError)
      End If
    Else
      MsgBox(PDC.App.LastError)
    End If

Availability

Available since januari 2018 (from version 5.4.55).