PdcClockLine.CopyID: Difference between revisions
No edit summary |
No edit summary |
||
Line 10: | Line 10: | ||
== Code example == | == 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. | 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. | ||
BEWARE!!! The closing and re-opening of the original clockline is not a mistake, this is the only way to have both lines saved without registration problems!! | |||
<source lang="vb"> | <source lang="vb"> | ||
Line 17: | Line 19: | ||
Dim CopiedClockLine As PDCEXT.IClockLine | Dim CopiedClockLine As PDCEXT.IClockLine | ||
OriginalClockLine = PDC.App.ProductRegistration.ClockLines.Open(ClockLineID) | |||
CopiedID = OriginalClockLine.CopyID(ClockLineID) | |||
releaseObject(OriginalClockLine) | |||
OriginalClockLine = PDC.App.ProductRegistration.ClockLines.Open(ClockLineID) | |||
If CopiedID > 0 Then | If CopiedID > 0 Then |
Latest revision as of 12:28, 24 May 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.
BEWARE!!! The closing and re-opening of the original clockline is not a mistake, this is the only way to have both lines saved without registration problems!!
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)
releaseObject(OriginalClockLine)
OriginalClockLine = PDC.App.ProductRegistration.ClockLines.Open(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).