COMPILE FUNCTION EPI_Part(EntID,Event,Parm1,Parm2,Parm3,Parm4,Parm5)
#pragma precomp SRP_PreCompiler

/*
	Commuter module for EPI_Part window
	
	02/18/2011 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, Center_Window, Post_Event
DECLARE SUBROUTINE ErrMsg, Send_Message, Set_Property, Send_Event, Btree.Extract, obj_AppWindow, 
DECLARE SUBROUTINE obj_Notes, Security_Err_Msg, End_Window, Forward_Event, Start_Window, Create_Note
DECLARE SUBROUTINE Set_List_Box_Data, obj_Epi_Part, Epi_Part_Services

DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility, Popup, Collect.Ixvals, obj_Popup, Epi_Part_Services
DECLARE FUNCTION Send_Message, Msg, Security_Check, obj_React_Run_CI, Select_Into, obj_EPI_Part, obj_Prod_Spec, MemberOf



$INSERT MSG_EQUATES
$INSERT APPCOLORS
$INSERT LSL_USERS_EQU
$INSERT SECURITY_RIGHTS_EQU
$INSERT REACT_EVENT_EQUATES
$INSERT POPUP_EQUATES
$INSERT LOGICAL
$INSERT RTI_STYLE_EQUATES
$INSERT CUST_EPI_PART_EQUATES
$INSERT PROD_VER_EQUATES
$INSERT PRS_LAYER_EQU
$INSERT PROD_SPEC_EQUATES
$Insert EPI_PART_EQUATES

EQU EDITABLE$			TO 4
EQU PROTECTED$			TO 8			;* Protected  - Edittable COLSTYLE constants
EQU MULTILINE_STYLE$	TO 512 			;* MultiLine Select
EQU LOCKED$				TO 8192
EQU DROPDOWN_STYLE$		TO 131072


EQU CRLF$	TO \0D0A\
EQU TAB$	TO \09\

EQU COL$LAYER			TO 1
EQU COL$STEP			TO 2
EQU COL$STEP_LS_ID		TO 3
EQU COL$DOPANT			TO 4
EQU COL$THICK_MIN		TO 5
EQU COL$THICK_MAX		TO 6
EQU COL$THICK_TARGET	TO 7
EQU COL$RES_MIN			TO 8
EQU COL$RES_MAX			TO 9
EQU COL$RES_TARGET		TO 10

EQU COL$PROD_VER_NO				TO 1
EQU COL$PROD_VER_DESC			TO 2
EQU COL$REACT_TYPE				TO 3
EQU COL$SHIP_PSN				TO 4
EQU COL$PROD_VER_SUB_PART_NO	TO 5
EQU COL$PROD_VER_CUST_NO		TO 6
EQU COL$PROD_VER_CUST_PART_NO	TO 7
EQU COL$THIN_EPI_THICK			TO 8
EQU COL$THICK_EPI_THICK			TO 9
EQU COL$PART_STATUS				TO 10
EQU COL$PSN_STATUS				TO 11

EQU COL$TYPE_CODE		TO 1
EQU COL$TYPE_DESC		TO 2
EQU COL$TYPE_SIG		TO 3
EQU COL$TYPE_SIG_DTM	TO 4


EQU COL$CUST_NO		TO 1

EQU COL$DUMMY_1_PIXEL_WIDE		TO 1	;* Used for both INSP_SPEC and INSP controls


EQU HIDDEN$		TO 32
EQU SKIPPED$	TO 4100

ErrTitle = 'Error in EPI_Part'
ErrorMsg = ''
ErrCode	 = ''

Result = ''


BEGIN CASE
	CASE EntID = @WINDOW
		BEGIN CASE
			CASE Event = 'CLEAR'			; GOSUB Clear
			CASE Event = 'CREATE' 			; GOSUB Create
			CASE Event = 'CLOSE'			; GOSUB Close
			CASE Event = 'READ'				; GOSUB Read
			CASE Event = 'WRITE'			; GOSUB Write
			CASE Event[1,3] = 'QBF'			; GOSUB Refresh
		END CASE
		
	CASE EntID = @WINDOW:'.LU_EPI_PART_NO' AND Event = 'CLICK' 	; GOSUB LUEpiPartNo
	CASE EntID = @WINDOW:'.TAB_CONTROL' AND Event = 'CLICK'		; GOSUB TabClick
		
	CASE EntID = @WINDOW:'.NAVIGATOR'
		BEGIN CASE
			CASE Event = 'DBLCK'
				GOSUB NavigatorDC
		END CASE
	
	CASE EntID = @WINDOW:'.PROD_VER_NO'
		BEGIN CASE 
			CASE Event = 'POSCHANGED'		; GOSUB ProdVerPC
			CASE Event = 'DBLCLK'			; GOSUB ProdVerDC
		END CASE
		
	CASE EntID = @WINDOW:'.CUST_NO'
		BEGIN CASE
			CASE Event = 'DBLCLK'			; GOSUB CustNoDC
		END CASE
		
	CASE EntID = @WINDOW:'.INACTIVE_PROD_VER'
		BEGIN CASE 
			CASE Event = 'DBLCLK'			; GOSUB InactiveProdVerDC
		END CASE
	
	CASE EntID = @WINDOW:'.SUB_WAFER_SIZE' AND Event = 'GOTFOCUS'	; GOSUB SubSizeGF
	
	CASE EntID = @WINDOW:'.LOAD_LAYERS' AND Event = 'CLICK'		; GOSUB LoadLayers
	CASE EntID = @WINDOW:'.LU_SIZE' AND Event = 'CLICK'			; GOSUB LUSubSize

    Case EntID = @Window : '.MPW_ASM_SCHEDULER' AND Event = 'LOSTFOCUS'         ; GoSub MPW_ASM_SCHEDULER.LOSTFOCUS
    Case EntID = @Window : '.MPW_ASM_PLUS_SCHEDULER' AND Event = 'LOSTFOCUS'    ; GoSub MPW_ASM_PLUS_SCHEDULER.LOSTFOCUS
    Case EntID = @Window : '.MPW_HTR_SCHEDULER' AND Event = 'LOSTFOCUS'         ; GoSub MPW_HTR_SCHEDULER.LOSTFOCUS
    Case EntID = @Window : '.MPW_EPIPRO_SCHEDULER' AND Event = 'LOSTFOCUS'      ; GoSub MPW_EPIPRO_SCHEDULER.LOSTFOCUS
    Case EntID = @Window : '.MPW_GAN_SCHEDULER' AND Event = 'LOSTFOCUS'         ; GoSub MPW_GAN_SCHEDULER.LOSTFOCUS
	
	CASE 1
		ErrorMsg = 'Unknown Parameters ':EntID:' - ':Event:' passed to commuter'
		ErrMsg(ErrorMsg)
		
END CASE

IF ErrorMsg NE '' THEN
	ErrMsg(ErrTitle:@SVM:ErrorMsg)
END

RETURN Result



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

obj_Appwindow('Create',@WINDOW)

if (MemberOf(@USER4,'EXPORT_CONTROL_ADMINS')) then
    Set_Property(@WINDOW:'.EXPORT_CONTROL','VISIBLE',1)
end else
    Set_Property(@WINDOW:'.EXPORT_CONTROL','VISIBLE',0)
end

obj_Appwindow('SetDropDowns')

* Set result table special styles (Dropdowns)

LayerStyles = Send_Message(@WINDOW:'.LAYER_SPEC','COLSTYLE',0,'')
	
LayerStyles<COL$DOPANT>	= BitOr(LayerStyles<COL$DOPANT>,DTCS_DROPDOWN$)	
	
Send_Message(@WINDOW:'.LAYER_SPEC','COLSTYLE',0,LayerStyles)

Dopants = XLATE('LISTBOX_CONFIG','DOPANT','','X')

Send_Message(@WINDOW:'.LAYER_SPEC','COLFORMAT',COL$DOPANT,Dopants)

If Parm1 NE '' then
    EpiPart = Parm1[1, '*']
    Set_Property(@Window : '.EPI_PN', 'TEXT', EpiPart)
    Post_Event(@Window, 'READ')
end else
    GOSUB Refresh
end

RETURN


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


IF Get_Property(@WINDOW,'@READONLY') THEN
	obj_AppWindow('ReadOnly',@RM:1)			;* Reenables data bound controls
	Set_Property(@WINDOW,'@READONLY',0)		;* Clear flag on window
END


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

    EpiPN		= Get_Property(@WINDOW:'.EPI_PN','DEFPROP')
    EpiPartDesc = Get_Property(@WINDOW:'.EPI_PART_DESC','DEFPROP')

    IF EpiPartDesc NE '' THEN
        EpiPart = EpiPN:' - ':EpiPartDesc
    END ELSE
        EpiPart = EpiPN
    END

    NavList = ''

    IF EpiPart NE '' THEN
        NavList<1> = '1-1:':EpiPart
    END

    * SAP Substrate Section

    SubParts = ''

    SubPartList	= Get_Property(@WINDOW:'.SUB_PART_NO','LIST')
    SubCnt		= COUNT(SubPartList,@FM) + (SubPartList NE '')

    FOR I = 1 TO SubCnt
        IF SubPartList<I,1> NE '' THEN
            SubParts<-1> = '7-3:':SubPartList<I,1>:' - ':SubPartList<I,3>
        END
    NEXT I

    IF SubParts NE '' THEN
        NavList := @FM:'2-2:SAP Substrates':@FM:SubParts
    END


    * Customer Section

    CustList	= Get_Property(@WINDOW:'.CUST_NO','LIST')
    CustCount	= COUNT(CustList,@FM) + (CustList NE '')

    FOR I = 1 TO CustCount

        IF CustList<I,1> NE '' THEN
        
            IF I = 1 THEN
                NavList := @FM:'2-2:Customers'
            END
            
            CustNo = CustList<I,1>
            CustEpiPartRec = XLATE('CUST_EPI_PART',CustNo:'*':EpiPN,'','X')
            
            CustPNs		= CustEpiPartRec<CUST_EPI_PART_CUST_PART_NO$>
            CustPNCnt	= COUNT(CustPNs,@VM) + (CustPNs NE '')
            
            CustParts = ''
            
            FOR N = 1 TO CustPNCnt
                CustParts := @FM:'7-5:':CustPNs<1,N>
                IF CustEpiPartRec<CUST_EPI_PART_CUST_PART_NO_INBOUND$,N> NE '' THEN
                    CustParts := ' - Inbound: ':CustEpiPartRec<CUST_EPI_PART_CUST_PART_NO_INBOUND$,N>
                END
            NEXT N
            
            NavList := @FM:'3-3:':CustList<I,1>:' - ':CustList<I,2>
            
            IF CustParts NE '' THEN
                NavList := @FM:'4-4:Customer Part Nos'
                NavList := CustParts
            END
            
            * Substrate Part No's 
            
            CustSubPNs		= CustEpiPartRec<CUST_EPI_PART_SUBSTRATE_PART_NO$>
            CustSubPNCnt	= COUNT(CustSubPNs,@VM) + (CustSubPNs NE '')
            
            CustSubParts = ''
            
            FOR N = 1 TO CustSubPNCnt
                CustSubParts := @FM:'5-5:':CustSubPNs<1,N>
                IF CustEpiPartRec<CUST_EPI_PART_SUBSTRATE_MFR$,N> NE '' THEN
                    CustSubParts := ' - ':CustEpiPartRec<CUST_EPI_PART_SUBSTRATE_MFR$,N>
                END
            NEXT N
            
            IF CustSubParts NE '' THEN
                NavList := @FM:'4-4:Direct From Customer Substrate Part Nos'
                NavList := CustSubParts
            END
            
        END; * End of check for null Customer 
            
    NEXT I


    ProdVerList = Get_Property(@WINDOW:'.PROD_VER_NO','LIST')
            
    ProdVerCnt = COUNT(ProdVerList,@FM) + (ProdVerList NE '')

    ProdVerSort = ''
    ProdVerKeys = ''

    FOR I = 1 TO ProdVerCnt
        ProdVerNo = ProdVerList<I,COL$PROD_VER_NO>
        
        IF ProdVerNo NE '' THEN
            CustNo 		= ProdVerList<I,COL$PROD_VER_CUST_NO>
            ReactType	= ProdVerList<I,COL$REACT_TYPE>
            SubPN		= ProdVerList<I,COL$PROD_VER_SUB_PART_NO>
            
            SortKey = CustNo:'*':ReactType:'*':SubPN
            
            LOCATE SortKey IN ProdVerSort BY 'AL' USING @FM SETTING Pos ELSE
                ProdVerSort = INSERT(ProdVerSort,Pos,0,0,SortKey)
                ProdVerKeys = INSERT(ProdVerKeys,Pos,0,0,ProdVerNo)
            END
            
        END	;* End of check for null ProdVerNo
    NEXT I

    ProdVerKeyCnt = COUNT(ProdVerKeys,@FM) + (ProdVerKeys NE '')
    ProdVers = ''

    IF ProdVerKeyCnt > 0 THEN
        NavList := @FM:TAB$:@FM:'2-2:Production Versions'
    END

    SpecList		= ''	;* Tree of specification data
    ReactTypeArray	= ''	;* ReactType:'*':StepNo
    ReactDataArray	= ''	
            
    FOR I = 1 TO ProdVerKeyCnt
        
        ProdVerKey = ProdVerKeys<I>
                
        ProdVerRec = XLATE('PROD_VER',ProdVerKey,'','X')
        
        ReactType = OCONV(ProdVerRec<PROD_VER_REACT_TYPE$>,'[REACT_TYPE_CONV,OPSREF]')
        
        NavList := @FM:'5-3:':ProdVerKey:TAB$:ReactType:TAB$:FMT(ProdVerRec<PROD_VER_DESC$>,"L#25"):TAB$
        
        StepIDs = XLATE('PROD_VER',ProdVerKey,'PROC_STEP_ID','X')
        StepPSNs = XLATE('PROD_VER',ProdVerKey,'PROC_STEP_PSN','X')
        StepTypes = XLATE('PROD_VER',ProdVerKey,'PROC_STEP_LAYER_TYPE','X')
        
        StepCnt = COUNT(StepIDs,@VM) + (StepIDs NE '')
                
        IF StepCnt > 0 THEN
            
            NewRDFlag = 0
            
            FOR N = 1 TO StepCnt
                StepID	= StepIDs<1,N>
                StepPSN = StepPSNs<1,N>
                
                NavList := 'Step ':StepID:' - ':StepPSN:' - ':StepTypes<1,N>
                IF N NE StepCnt THEN
                    NavList := '/'
                END
                
                LOCATE ReactType:'*':StepID IN ReactTypeArray BY 'AR' USING @FM SETTING RTPos ELSE
                    ReactTypeArray = INSERT(ReactTypeArray,RTPos,0,0,ReactType:'*':StepID)
                    IF SpecList = '' THEN
                        SpecList = 'Reactor Type'
                    END ELSE
                        SpecList := @FM:'ReactorType'
                    END
                    
                    NewRDFlag = 1
                END
            NEXT N	
                
        END	;* End of check for StepCnt > 0		
            
            
    NEXT I


    NavList := @FM:'2-2:Specification':ReactDataArray

    Set_Property(@WINDOW:'.NAVIGATOR', 'LIST', NavList)

    Send_Message(@WINDOW:'.NAVIGATOR', 'EXPAND', 0, 6)



    * 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)

    SpecCtrl = @WINDOW:'.LAYER_SPEC'
    LSList = Get_Property(SpecCtrl,'LIST')
    LSCnt = COUNT(LSList,@FM) + (LSList NE '')

    FOR Line = 1 TO LSCnt
        BEGIN CASE
            CASE LSList<Line,COL$STEP_LS_ID> = 'L1'	; LineColor = LS1_GREEN$
            CASE LSList<Line,COL$STEP_LS_ID> = 'L2'	; LineColor = LS2_GREEN$
            CASE LSList<Line,COL$STEP_LS_ID> = 'L3'	; LineColor = LS3_GREEN$
            CASE LSList<Line,COL$LAYER> = 'CMB'		; LineColor = CMB_YELLOW$
            CASE 1 ;LineColor = WHITE$
        END CASE
        stat = Send_Message(SpecCtrl,'COLOR_BY_POS',0,Line,LineColor)
    NEXT Line


    * 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
                IF ETCtrl = 'EPI_PART.PROD_VER_NO' OR ETCtrl = 'EPI_PART.INACTIVE_PROD_VER' THEN
                    
                    IF ETList<Line,COL$PART_STATUS> = 'A' AND ETList<Line,COL$PSN_STATUS> = 'A' THEN
                        LineColor = GREEN$
                    END ELSE
                        LineColor = RED$
                    END
                END ELSE
                    LineColor = GREEN$
                END
                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,LineColor)
                NEXT N
                
            END
        NEXT I
    NEXT I

    // Scheduler tab data and calculations.
    MPWScheduler        = Get_Property(@Window : '.MINUTES_PER_WAFER_SCHEDULER', 'ARRAY')
    MPWASMScheduler     = MPWScheduler<0, 1>
    MPWASMPlusScheduler = MPWScheduler<0, 2>
    MPWHTRScheduler     = MPWScheduler<0, 3>
    MPWEpiProScheduler  = MPWScheduler<0, 4>
    MPWGaNScheduler     = MPWScheduler<0, 5>
    Set_Property(@Window : '.MPW_ASM_SCHEDULER', 'INVALUE', MPWASMScheduler)
    Set_Property(@Window : '.MPW_ASM_PLUS_SCHEDULER', 'INVALUE', MPWASMPlusScheduler)
    Set_Property(@Window : '.MPW_HTR_SCHEDULER', 'INVALUE', MPWHTRScheduler)
    Set_Property(@Window : '.MPW_EPIPRO_SCHEDULER', 'INVALUE', MPWEpiProScheduler)
    Set_Property(@Window : '.MPW_GAN_SCHEDULER', 'INVALUE', MPWGaNScheduler)
    GoSub Calculate_WPD

RETURN





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

    GOSUB Refresh

RETURN


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

    // Scheduler tab data and calculations.
    MPWASMScheduler     = Get_Property(@Window : '.MPW_ASM_SCHEDULER', 'INVALUE')
    MPWASMPlusScheduler = Get_Property(@Window : '.MPW_ASM_PLUS_SCHEDULER', 'INVALUE')
    MPWHTRScheduler     = Get_Property(@Window : '.MPW_HTR_SCHEDULER', 'INVALUE')
    MPWEpiProScheduler  = Get_Property(@Window : '.MPW_EPIPRO_SCHEDULER', 'INVALUE')
    MPWGaNScheduler     = Get_Property(@Window : '.MPW_GAN_SCHEDULER', 'INVALUE')
    MPWScheduler        = ''
    MPWScheduler<0, 1>  = MPWASMScheduler
    MPWScheduler<0, 2>  = MPWASMPlusScheduler
    MPWScheduler<0, 3>  = MPWHTRScheduler
    MPWScheduler<0, 4>  = MPWEpiProScheduler
    MPWScheduler<0, 5>  = MPWGaNScheduler
    Set_Property(@Window : '.MINUTES_PER_WAFER_SCHEDULER', 'ARRAY', MPWScheduler)

    Forward_Event()

    Post_Event(@WINDOW,'CLOSE')

    Result = 0

RETURN


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

/*
IF Security_Check('Order',Delete$) THEN
	Result = 1		;* Proceed with delete
END ELSE
	Security_Err_Msg('Order',Delete$)
	Result = 0		;* Stop event chain
END
*/

RETURN


* * * * * * *
LUEpiPartNo:
* * * * * * *

EpiPartNos = Popup(@WINDOW,'','EPI_PART_NOS')

IF EpiPartNos NE '' THEN
	IF INDEX(EpiPartNos,@VM,1) THEN
		Send_Event(@WINDOW,'QBFINIT')
		Set_Property(@WINDOW,'QBFLIST',EpiPartNos)
		Send_Event(@WINDOW,'QBFFIRST')
	END ELSE
		obj_AppWindow('LoadFormKeys',@WINDOW:@RM:EpiPartNos)
	END
END

RETURN


* * * * * * *
TabClick:
* * * * * * *

IF Parm1 NE '' THEN
	Page = Parm1
END ELSE
	Page = Get_Property(@WINDOW:'.TAB_CONTROL','VALUE')
END

Set_Property(@WINDOW,'VPOSITION',Page)

RETURN



* * * * * * *
ProdVerDC:
* * * * * * *

EpiPartNo = Get_Property(@WINDOW:'.EPI_PN','TEXT')

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

IF CurrCol = COL$PROD_VER_NO THEN
	ProdVerNo = Get_Property(CtrlEntID,'CELLPOS',COL$PROD_VER_NO:@FM:CurrRow)

	IF EpiPartNo NE '' THEN
				
		CardWindow	= 'PROD_VER'
		CardKey		= ProdVerNo
		DefaultRec	= ''
		NewCardCtrl	= ''
		RecalcCtrl	= CtrlEntID
		RecalcPos	= CurrPos
		RetCtrl		= CtrlEntID
		RetPos		= CurrPos
		
		oAParms = CardWindow:@RM:CardKey:@RM:DefaultRec:@RM:NewCardCtrl:@RM:RecalcCtrl:@RM:RecalcPos:@RM:RetCtrl:@RM:RetPos

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

RETURN



* * * * * * *
ProdVerPC:
* * * * * * *


RETURN



* * * * * * *
InactiveProdVerDC:
* * * * * * *

EpiPartNo = Get_Property(@WINDOW:'.EPI_PN','TEXT')

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

IF CurrCol = COL$PROD_VER_NO THEN
	ProdVerNo = Get_Property(CtrlEntID,'CELLPOS',COL$PROD_VER_NO:@FM:CurrRow)

	IF EpiPartNo NE '' THEN
				
		CardWindow	= 'PROD_VER'
		CardKey		= ProdVerNo
		DefaultRec	= ''
		NewCardCtrl	= ''
		RecalcCtrl	= CtrlEntID
		RecalcPos	= CurrPos
		RetCtrl		= CtrlEntID
		RetPos		= CurrPos
		
		oAParms = CardWindow:@RM:CardKey:@RM:DefaultRec:@RM:NewCardCtrl:@RM:RecalcCtrl:@RM:RecalcPos:@RM:RetCtrl:@RM:RetPos

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

RETURN




* * * * * * *
CustNoDC:
* * * * * * *

EpiPartNo = Get_Property(@WINDOW:'.EPI_PN','TEXT')

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

IF CurrCol = COL$CUST_NO THEN
	CustNo = Get_Property(CtrlEntID,'CELLPOS',COL$CUST_NO:@FM:CurrRow)

	IF EpiPartNo NE '' THEN
				
		CardWindow	= 'CUST_EPI_PART'
		CardKey		= CustNo:'*':EpiPartNo
		DefaultRec	= ''
		NewCardCtrl	= ''
		RecalcCtrl	= CtrlEntID
		RecalcPos	= CurrPos
		RetCtrl		= CtrlEntID
		RetPos		= CurrPos
		
		oAParms = CardWindow:@RM:CardKey:@RM:DefaultRec:@RM:NewCardCtrl:@RM:RecalcCtrl:@RM:RecalcPos:@RM:RetCtrl:@RM:RetPos

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


RETURN


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

*obj_Notes('Inbox',@USER4)	;* Checks for any new messages

obj_Appwindow('DetailReturn')


RETURN


* * * * * * *
LoadLayers:
* * * * * * *

EpiPartNo = Get_Property(@WINDOW:'.EPI_PN','DEFPROP')

Send_Event(@WINDOW,'WRITE')

obj_EPI_Part('LoadLayers',EpiPartNo)

Set_Property(@WINDOW:'.EPI_PN','DEFPROP',EpiPartNo)
Send_Event(@WINDOW:'.EPI_PN','LOSTFOCUS')


RETURN

* * * * * * *
SubSizeGF:
* * * * * * *

SubSize = Get_Property(@WINDOW:'.SUB_WAFER_SIZE','DEFPROP')

IF SubSize NE '' THEN
	IF SubSize MATCHES "2N' mm '1N' in'" OR SubSize MATCHES "3N' mm '1N' in'" THEN
		RETURN
	END ELSE
		ErrMsg('Application Message':@SVM:'Invalid data format entered. Select from following popup.')
	END
END

* Proceed to Popup with options

* * * * * * *
LUSubSize:
* * * * * * *

RetVal = Popup(@WINDOW,'','SUBSTRATE_SIZE')

IF RetVal NE '' THEN
	oaParms = RetVal:@RM:@WINDOW:'.SUB_WAFER_SIZE'
	obj_Appwindow('LUValReturn',oaParms)
END

RETURN


* * * * * * * *
NavigatorDC:
* * * * * * * *

RETURN


MPW_ASM_SCHEDULER.LOSTFOCUS:
    GoSub Calculate_WPD
return


MPW_ASM_PLUS_SCHEDULER.LOSTFOCUS:
    GoSub Calculate_WPD
return


MPW_HTR_SCHEDULER.LOSTFOCUS:
    GoSub Calculate_WPD
return


MPW_EPIPRO_SCHEDULER.LOSTFOCUS:
    GoSub Calculate_WPD
return


MPW_GAN_SCHEDULER.LOSTFOCUS:
    GoSub Calculate_WPD
return


Calculate_WPD:

    EpiPartNo   = Get_Property(@Window : '.EPI_PN', 'TEXT')
    MPWCtrls    = 'MPW_ASM_SCHEDULER,MPW_ASM_PLUS_SCHEDULER,MPW_HTR_SCHEDULER,MPW_EPIPRO_SCHEDULER,MPW_GAN_SCHEDULER'
    For Each MPWCtrl in MPWCtrls using ',' setting cPos
        MPWValue    = Get_Property(@Window : '.' : MPWCtrl, 'DEFPROP')
        ReactorType = Field('ASM,ASM+,HTR,EpiPro,GaN', ',', cPos, 1)
        If MPWValue NE '' then
            WPDIdeal = Epi_Part_Services('GetIdealWafersPerDayScheduler', EpiPartNo, ReactorType, MPWValue)
        end else
            WPDIdeal = ''
        end
        WPDCtrl     = MPWCtrl
        Swap 'MPW' with 'WPD' in WPDCtrl
        Set_Property(@Window : '.' : WPDCtrl, 'DEFPROP', WPDIdeal)
        If MPWValue NE '' then
            WPDAdjusted = Epi_Part_Services('GetAdjustedWafersPerDayScheduler', EpiPartNo, ReactorType, MPWValue)
        end else
            WPDAdjusted = ''
        end
        WPDCtrl     = MPWCtrl
        Swap 'MPW' with 'WPDA' in WPDCtrl
        Set_Property(@Window : '.' : WPDCtrl, 'DEFPROP', WPDAdjusted)
    Next MPWCtrl
    
return



