open-insight/LSL2/STPROC/NDW_PTO_MAT_SCAN_EVENTS.txt
2024-09-24 18:44:36 +02:00

360 lines
12 KiB
Plaintext

Function NDW_PTO_MAT_SCAN_EVENTS(CtrlEntId, Event, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15)
/***********************************************************************************************************************
This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
permission from SRP Computer Solutions, Inc.
Name : NDW_PTO_MAT_SCAN_EVENTS
Description : This function acts as a commuter module for all events related to this window.
Notes : This procedure supports the same-named form. Form is single use, for moving lots with 1K*PTI location
angd warehouse code. The form must
Parameters :
CtrlEntId [in] -- The fully qualified name of the control calling the promoted event
Event [in] -- The event being executed. See the Notes section regarding "PRE" events
Param1-15 [in] -- Additional event parameter holders
EventFlow [out] -- Set to 1 or 0 so the calling event knows whether or not to chain forward. See comments in
EVENT_SETUP insert
History (Date, Initials, Notes)
08/23/21 DPC Original programmer.
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
#window NDW_PTO_MAT_SCAN
$insert EVENT_SETUP
$insert LOGICAL
$insert MSG_EQUATES
$insert POPUP_EQUATES
$insert REACT_RUN_EQUATES
$insert RDS_EQUATES
$insert WO_MAT_EQUATES
$insert APPCOLORS
$insert MESSAGE_BOX_EQUATES
$insert SRP_POPUP_EQUATES
Equ CRLF$ to \0D0A\
Equ MSG_WIDTH$ to 600
Equ Label1$ to @Window:'.EDL_LABEL1_SCAN'
Equ Label2$ to @Window:'.EDL_LABEL2_SCAN'
Equ ClearBtn$ to @Window:'.PUB_CLEAR'
Equ SaveBtn$ to @Window:'.PUB_SAVE'
Equ Popup$ to @Window:".OLE_POPUP"
Declare subroutine Set_Property, Send_Event, Post_Event, Send_Message, SendMessage, Error_Services, PlaceDialog
Declare subroutine Obj_Wo_Mat_Log, Errmsg, Utility, SRP_Show_Window, Material_Movement_Services, Delay, Getengineversion
Declare function Get_Property, Send_Message, SendMessage, Material_Movement_Services, Error_Services
Declare function Popup, obj_WO_Mat, Database_Services, Utility, Rds_Services, Message_Box, SRP_Get_Window_Rect
MsgStruct = ''
MsgStruct<MTEXTWIDTH$> = MSG_WIDTH$
If Event EQ 'OLE' then
Transfer Event to OIEvent
Transfer Param1 to Event
Transfer Param2 to Param1
Transfer Param3 to Param2
Transfer Param4 to Param3
Transfer Param5 to Param4
Transfer Param6 to Param5
Transfer Param7 to Param6
Transfer Param8 to Param7
end
GoToEvent Event for CtrlEntId else
// Event not implemented
end
Return EventFlow or 1
*global
ScanField = ''
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Events
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Event WINDOW.CREATE(CreateParam)
GoSub SetupOLEControls
GoSub ResetForm
PlaceDialog(-2, -2)
end event
Event EDL_LABEL1_SCAN.LOSTFOCUS(Flag, FocusID)
ScanField = 'Label1'
If Flag EQ 1 then
ScanData = Get_Property(CtrlEntID, 'TEXT')
If ScanData NE '' then
ScanData = Material_Movement_Services('ProcessPTOScanData', ScanData, 'LABEL1')
If Error_Services('NoError') then
Set_Property(CtrlEntID, 'TEXT', ScanData)
Set_Property(Label2$, 'ENABLED', True$)
Set_Property(Label2$, 'FOCUS', True$)
Set_Property(CtrlEntID, 'ENABLED', False$)
Gosub SetupForm
end else
GoSub ResetForm
ErrorMessage = Error_Services('GetMessage')
if ErrorMessage NE 'Scan Cancelled' then
Msg(@Window, MsgStruct, 'PROCESS_ERROR', '', ErrorMessage)
end
Set_Property(@Window:'.EDL_LABEL1_SCAN', 'FOCUS', True$)
end
end
end
end event
Event EDL_LABEL2_SCAN.LOSTFOCUS(Flag, FocusID)
ScanField = 'Label2'
If Flag EQ 1 then
ScanData = Get_Property(CtrlEntID, 'TEXT')
Cass1 = Get_Property(Label1$, 'TEXT')
If ScanData NE '' then
ScanData = Material_Movement_Services('ProcessPTOScanData', ScanData, 'LABEL2', Cass1)
If Error_Services('NoError') then
Set_Property(CtrlEntID, 'TEXT', ScanData)
Set_Property(CtrlEntID, 'ENABLED', False$)
Set_Property(SaveBtn$, 'ENABLED', True$)
Set_Property(SaveBtn$, 'FOCUS', True$)
Gosub SetupForm
end else
ErrorMessage = Error_Services('GetMessage')
If ErrorMessage[1,13] EQ 'Scan Mismatch' then
Msg(@Window, MsgStruct, 'PROCESS_ERROR', '', ErrorMessage)
Gosub ResetForm
Set_Property(Label1$, 'FOCUS', True$)
end else
Set_Property(Label2$, 'ENABLED', True$)
Set_Property(Label2$, 'TEXT', '')
Msg(@Window, MsgStruct, 'PROCESS_ERROR', '', ErrorMessage)
Set_Property(Label2$, 'FOCUS', True$)
end
end
end
end
end event
Event OLE_POPUP.OnItemClick(Item)
gosub HidePopup
end event
Event PUB_CLEAR.CLICK()
gosub HidePopup
If Get_Property(Label1$, 'TEXT') NE '' AND Get_Property(Label2$, 'TEXT') NE '' then
MsgHead = 'Record not saved'
MsgText = 'Record has not been saved - are you sure you want to clear form?'
OK = Msg(@WINDOW,'','YESNO','',MsgHead:@FM:MsgText)
If OK then
GoSub ResetForm
end else
Set_Property(ClearBtn$, 'ENABLED', True$)
Set_Property(SaveBtn$, 'ENABLED', True$)
end
end else
GoSub ResetForm
end
end event
Event PUB_SAVE.CLICK()
Cassette1 = Get_Property(Label1$, 'TEXT')
Cassette2 = Get_Property(Label2$, 'TEXT')
Warehouse = '1K'
Location = 'PTO'
Gosub SaveRecord
end event
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal Gosubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SaveRecord:
ErrorMessage = 'undefined'
Material_Movement_Services('SaveRecord', Cassette1, '1K', 'PTO', @User4);//save PTO transaction
Delay(1)
Material_Movement_Services('SaveRecord', Cassette1, 'SR', 'VER', @User4);//save PSVER transaction
popupTitle = 'Save Record'
popupMsg = ''
saveErr = 0
If Error_Services('NoError') then
popupMsg = 'Record saved'
end else
ErrorMessage = Error_Services('GetMessages')
saveErr = 1
popupMsg = 'Error saving record - ':ErrorMessage
end
Gosub ShowPopup
Gosub ResetForm
return
ShowPopup:
GoSub HidePopup
BackColor = Get_Property(@Window, 'BACKCOLOR')
ForeColor = Get_Property(@Window, 'FORECOLOR')
FormSize = Get_Property(@Window, 'SIZE')
FormXPos = FormSize<1>
FormYPos = FormSize<2>
FormWidth = FormSize<3>
FormHeight = FormSize<4>
PopupWidth = 0
PopupHeight = 0
XPadding = 10
YPadding = 10
XOffset = 10
YOffset = 55
Delay = 0
If saveErr EQ True$ then
BackColor = 255 + (51*256) + (51*65536)
end else
Delay = 2500
BackColor = 153 + (255*256) + (153*65536)
end
ItemData = popupMsg
NumLines = DCount(ItemData, @FM)
ItemList = ''
If ItemData NE '' then
For Each Item in ItemData using @FM setting ItemCount
ItemLength = Len(Item)
PopupWidth += (20 * ItemLength)
rows = INT(PopupWidth /300)
if (PopupWidth) GE 300 then
PopupWidth = 300
PopupHeight = (30 * rows)
end else
PopupHeight = 50
end
ItemList<ItemCount,SRP_POPUP.RECTANGLE,1> = XPadding ; // X Position of item
ItemList<ItemCount,SRP_POPUP.RECTANGLE,2> = (20 * (ItemCount - 1) ) ; // Y Position of item
ItemList<ItemCount,SRP_POPUP.RECTANGLE,3> = PopupWidth - (2 * XPadding) ; // Width
ItemList<ItemCount,SRP_POPUP.RECTANGLE,4> = PopupHeight - (2 * YPadding) ; // Height
ItemList<ItemCount,SRP_POPUP.CAPTION> = Item
ItemList<ItemCount,SRP_POPUP.COLORS> = Forecolor
ItemList<ItemCount,SRP_POPUP.FONT> = 'Tahoma' : @SVM : '16' : @SVM : '700' : @SVM : '0' : @SVM : '0'
ItemList<ItemCount,SRP_POPUP.ALIGNMENT> = 'Center' : @SVM : 'Center'
Next Item
end
PopupXPos = FormXPos + FormWidth/2 - PopupWidth/2
PopupYPos = FormYPos + FormHeight/2 - PopupHeight/2
Set_Property(Popup$, 'OLE.Size', Size)
Set_Property(Popup$, 'OLE.Opacity', 255)
Set_Property(Popup$, 'OLE.ShowDelay', Delay)
Set_Property(Popup$, 'OLE.Theme', 'Custom')
Set_Property(Popup$, 'OLE.Background', 'Vertical(Gradient(' : Backcolor : ', ' : Backcolor : '), Border(' : Backcolor : ' L=20))' : @FM : 'None' : @FM : 'None')
Set_Property(Popup$, 'OLE.ItemList', ItemList)
Set_Property(Popup$, 'OLE.Size', 0 : @FM : 0 : @FM : PopupWidth : @FM : PopupHeight)
Send_Message(Popup$, 'OLE.ShowAt', PopupXPos, PopupYPos)
return
HidePopup:
PopupVisible = Get_Property(Popup$, 'OLE.Visible')
If PopupVisible EQ True$ then
Send_Message(Popup$, 'OLE.Close')
end
return
SetupForm:
Cassette1 = Get_Property(Label1$, 'TEXT')
Cassette2 = Get_Property(Label2$, 'TEXT')
If INDEX(Cassette1,'.',2) then
RDSType = 'EPP'
end else if INDEX(Cassette1,'.',1) then
RDSType = 'GAN'
end else
RDSType = 'SIC'
end
Convert '.' to '*' in Cassette1
Begin Case
Case RDSType EQ 'SIC'
WOMatKey = XLATE('RDS',Cassette1, 'WO_MAT_KEY', '', '')
Location = XLATE('WO_MAT', WOMatKey, 'CURR_LOCATION', '', '')
Case RDSType EQ 'EPP'
WOMatKey = FIELD(Cassette1,'*',1):'*':FIELD(Cassette1,'*',3)
Location = XLATE('WO_MAT', WOMatKey, 'CURR_LOCATION', '', '')
Case RDSType EQ 'GAN'
WOMatKey = Cassette1
Location = XLATE('WO_MAT', WOMatKey, 'CURR_LOCATION', '', '')
End Case
return
DisableFormControls:
Set_Property(Label1$, 'TEXT', '')
Set_Property(Label2$, 'TEXT', '')
Set_Property(Label1$, 'ENABLED', False$)
Set_Property(Label2$, 'ENABLED', False$)
return
SetupOLEControls:
// Qualify OLE events that we want to intercept
Qualifier = ''
Qualifier<1> = 1
Qualifier<3> = ''
Qualifier<4> = 0 ; * process synchronously
Send_Message(Popup$, 'QUALIFY_EVENT', 'OLE.OnItemClick', Qualifier)
return
ResetForm:
Set_Property(Label1$, 'ENABLED', True$)
Set_Property(Label2$, 'ENABLED', True$)
Set_Property(Label1$, 'TEXT', '')
Set_Property(Label2$, 'TEXT', '')
Set_Property(Label1$, 'ENABLED', True$)
Set_Property(Label2$, 'ENABLED', False$)
Set_Property(Label1$, 'FOCUS', True$)
Set_Property(SaveBtn$, 'ENABLED', False$)
return