COMPILE FUNCTION Comm_ASM_Part(Instruction, Parm1,Parm2)

/*
	Commuter module for ASM Part window
	
	08/28/2006 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property,  Set_Status, ErrMsg, Set_Property, obj_AppWindow, Set_List_Box_Data
DECLARE SUBROUTINE Btree.Extract, Send_Event, Security_Err_Msg, Forward_Event, End_Window, Start_Window
DECLARE SUBROUTINE Send_Message
DECLARE FUNCTION Get_Property, Get_Status, Popup, Send_Message, Msg, Security_Check, Dialog_Box, RowExists
DECLARE FUNCTION Dialog_Box, obj_WO_Log, MemberOf, obj_NCR, Send_Message, MemberOf, obj_Popup


$INSERT POPUP_EQUATES
$INSERT MSG_EQUATES
$INSERT APPCOLORS
$INSERT LSL_USERS_EQU
$INSERT SECURITY_RIGHTS_EQU


EQU CRLF$	TO \0D0A\


ErrTitle = 'Error in Comm_ASM_Part'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE Instruction = 'Create' 				; GOSUB Create
	CASE Instruction = 'Refresh'				; GOSUB Refresh
	CASE Instruction = 'Read'					; GOSUB Read
	CASE Instruction = 'Write'					; GOSUB Write
	CASE Instruction = 'Clear'					; GOSUB Clear
	CASE Instruction = 'Delete'					; GOSUB Delete
	CASE Instruction = 'Close'					; GOSUB Close
	CASE Instruction = 'LU_ASMPart'				; GOSUB LU_ASMPart
	CASE Instruction = 'GasesDC'				; GOSUB GasesDC
	
	CASE 1
		ErrorMsg = 'Unknown Instruction passed to routine'
END CASE

RETURN Result


* * * * * * * 
Create:
* * * * * * *

obj_Appwindow('Create',@WINDOW)

IF NOT(Security_Check('ASM Part',READ$)) THEN
	Security_Err_Msg('ASM Part',READ$)
	End_Window(@WINDOW)
	RETURN
END

GOSUB Refresh

RETURN


* * * * * * *
Read:
* * * * * * *


GOSUB Refresh

RETURN


* * * * * * *
Write:
* * * * * * *

RETURN


* * * * * * *
Clear:
* * * * * * *


GOSUB Refresh

RETURN


* * * * * * *
Delete:
* * * * * * *

Result = 1

RETURN



* * * * * * *
Close:
* * * * * * *

obj_Appwindow('DetailReturn')

RETURN 


* * * * * * *
Refresh:
* * * * * * *



* QBF buttons

Ctrls  = @WINDOW:'.QBF_FIRST_FIX':@RM		; Props  = 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_PREV_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_ABS_FIX':@RM			; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_NEXT_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_LAST_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_STOP_FIX'			; Props := 'ENABLED'

IF Get_Property(@WINDOW,'QBFLIST') = '' THEN
	Vals = 0:@RM:0:@RM:0:@RM:0:@RM:0:@RM:0
END ELSE
	Vals = 1:@RM:1:@RM:1:@RM:1:@RM:1:@RM:1
END

Set_Property(Ctrls,Props,Vals)

* Turn edit table symbolic column backgrounds to green

ETSymbolics = Get_Property(@WINDOW,'@ET_SYMBOLICS')		;* Loaded during 'Create' in obj_Appwindow

ETCtrls	= ETSymbolics<1>
ETCols	= ETSymbolics<2>

FOR I = 1 TO COUNT(ETCtrls,@VM) + (ETCtrls NE '')
	ETCtrl	= ETCtrls<1,I>
	ETList = Get_Property(ETCtrl,'LIST')
	FOR Line = 1 TO COUNT(ETList,@FM) + (ETList NE '')
		IF ETList<Line,1> NE '' THEN
			FOR N = 1 TO COUNT(ETCols<1,I>,@SVM) + (ETCols<1,I> NE '')
				stat = Send_Message(ETCtrl,'COLOR_BY_POS',ETCols<1,I,N>,Line,GREEN$)
			NEXT N
		END
	NEXT Line
	
NEXT I


RETURN


* * * * * * *
LU_ASMPart:
* * * * * * *

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1
IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos = Parm2

Set_Status(0)

Retval = Popup(@WINDOW,TypeOver,'ASM_MFC')

IF RetVal = '' THEN RETURN

obj_Appwindow('LoadFormKeys',@WINDOW:@RM:RetVal)

RETURN




* * * * * * *
MFC_DC:
* * * * * * *

ReactorNo = Get_Property(@WINDOW:'.REACT_NO','TEXT')

CtrlEntID = @WINDOW:'.MFC_FUNC'
CurrPos = Get_Property(CtrlEntID,'SELPOS')
CurrCol = CurrPos<1>
CurrRow = CurrPos<2>


IF CurrCol = COL$MFC_CODE THEN

	CurrMfcCodes = Get_Property(CtrlEntID,'ARRAY')<COL$MFC_CODE>	;* Existing MFC codes in edit table
	CurrMfcCodesTrimmed = ''
	FOR I = 1 TO COUNT(CurrMfcCodes,@VM) + (CurrMfcCodes NE '')
		IF CurrMfcCodes<1,I> NE '' THEN
			CurrMfcCodesTrimmed<1,I> = CurrMfcCodes<1,I>
		END
	NEXT I
	CurrMfcCodes			= CurrMfcCodesTrimmed
	CurrMfcCodePositions	= obj_Popup('CodePosition','REACT_MFC_FUNC':@RM:CurrMfcCodes)
	
	MfcCodes				= Popup(@WINDOW,'','REACT_MFC_FUNC')
	
	IF MfcCodes	= '' THEN RETURN
	
	NewMfcCodePositions		= obj_Popup('CodePosition','REACT_MFC_FUNC':@RM:MfcCodes)
	
	FOR I = 1 TO COUNT(NewMfcCodePositions,@VM) + (NewMfcCodePositions NE '')
		NewMFcCodePosition = NewMfcCodePositions<1,I>
		MfcCode = MfcCodes<1,I>
		LOCATE NewMfcCodePosition IN CurrMfcCodePositions  BY 'AR' USING @VM SETTING POS ELSE
			CurrMfcCodePositions = INSERT(CurrMfcCodePositions,1,POS,0,NewMfcCodePosition)
			
			Send_Message(CtrlEntID,'INSERT',POS,MfcCode:@VM:@VM)
		END
		
	NEXT I
	Send_Event(@WINDOW:'.MFC_FUNC','CALCULATE',COL$MFC_FUNCTION)
		
	GOSUB Refresh
END	;* End of MfcCode column

/*
IF CurrCol = COL$MFC_SERIAL_NO THEN
	QuoteNo = Get_Property(CtrlEntID,'CELLPOS',COL$QUOTE_NO:@FM:CurrRow)

	IF OrderNo NE '' AND QuoteNo NE '' THEN
		IF Get_Property(@WINDOW,'QBFLIST') = '' THEN
			Send_Event(@WINDOW,'WRITE')
		END
		
		DetWindow	= 'QUOTE2'
		DetKeys		= QuoteNo
		DefaultRec	= ''
		RetKey		= OrderNo
		RetPage		= 1
		RetCtrl		= CtrlEntID
		RetPos		= CurrPos
		
		oAParms = DetWindow:@RM:DetKeys:@RM:DefaultRec:@RM:RetKey:@RM:RetPage:@RM:RetCtrl:@RM:RetPos

		obj_AppWindow('ViewNewDetail',oAParms)
		IF Get_Status(errCode) THEN
			ErrMsg(errCode)
		END
	END
END	;* End of QuoteNo column

*/

RETURN



* * * * * * *
GasesDC:
* * * * * * *

ReactorNo = Get_Property(@WINDOW:'.REACT_NO','TEXT')

CtrlEntID = @WINDOW:'.GASES'
CurrPos = Get_Property(CtrlEntID,'SELPOS')
CurrCol = CurrPos<1>
CurrRow = CurrPos<2>

CurrGases = Get_Property(CtrlEntID,'ARRAY')	;* Existing MFC codes in edit table
CurrGasesTrimmed = ''
FOR I = 1 TO COUNT(CurrGases,@VM) + (CurrGases NE '')
	IF CurrGases<1,I> NE '' THEN
		CurrGasesTrimmed<1,I> = CurrGases<1,I>
	END
NEXT I

CurrGases = CurrGasesTrimmed
CurrGasesPositions	= obj_Popup('CodePosition','REACTOR_GASES':@RM:CurrGases)

Gases = Popup(@WINDOW,'','REACTOR_GASES')

IF Gases = '' THEN RETURN

NewGasesPositions = obj_Popup('CodePosition','REACTOR_GASES':@RM:Gases)

FOR I = 1 TO COUNT(NewGasesPositions,@VM) + (NewGasesPositions NE '')
	NewGasesPosition = NewGasesPositions<1,I>
	Gas = Gases<1,I>
	LOCATE NewGasesPosition IN CurrGasesPositions  BY 'AR' USING @VM SETTING POS ELSE
		CurrGasesPositions = INSERT(CurrGasesPositions,1,POS,0,NewGasesPosition)
		
		Send_Message(CtrlEntID,'INSERT',POS,Gas)
	END
	
NEXT I
*Send_Event(@WINDOW:'.MFC_FUNC','CALCULATE',COL$MFC_FUNCTION)
	
GOSUB Refresh

RETURN













