COMPILE FUNCTION Comm_Dialog_RDS_Val_Change(Method, Parm1, Parm2)

/*
	Commuter module for Dialog_RDS_Val_Change window.
	
	06/06/2004 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Set_Status, ErrMsg
DECLARE SUBROUTINE obj_Appwindow, Start_Window, Msg
DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Popup, Send_Message

EQU CRLF$	TO \0D0A\

$INSERT POPUP_EQUATES
$INSERT APPCOLORS


ErrTitle = 'Error in Comm_Dialog_RDS_Val_Chg'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE Method = 'Create'			; GOSUB Create
	CASE Method = 'OK'				; GOSUB OK
	CASE Method = 'Cancel'			; GOSUB Cancel
	CASE Method = 'Refresh'			; GOSUB Refresh
	CASE Method = 'InsertRow'		; GOSUB InsertRow
	CASE Method = 'DeleteRow'		; GOSUB DeleteRow
	CASE Method = 'SetCommitDt'		; GOSUB SetCommitDt
	CASE 1
		ErrMsg(ErrTitle:@SVM:'Unknown method ':QUOTE(Method):' passed to routine.')
		
END CASE


RETURN Result


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

obj_AppWindow('Create')

Style = Get_Property(@WINDOW:'.CASSETTES', 'STYLE')
IF Style [1,2] _EQC "0x" THEN
  CONVERT @LOWER.CASE TO @UPPER.CASE IN STYLE
  Style = ICONV(Style [3,99], "MX")
END
AddStyle = 512 	;* MultiLine Select
MultiStyle = BitOr(Style, AddStyle)
Set_Property(@WINDOW:'.CASSETTES', 'STYLE', MultiStyle)

CassetteList	= Parm1

Set_Property(@WINDOW:'.CASSETTES','LIST',CassetteList)
Set_Property(@WINDOW,'@ORG_CASS_LIST',CassetteList)

RETURN


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

CtrlName = @WINDOW:'.CASSETTES'
ActiveList = Get_Property(CtrlName,'LIST')
OrgList = Get_Property(@WINDOW,'@ORG_CASS_LIST')

FOR I = 1 TO COUNT(ActiveList,@FM) + (ActiveList NE '')
	ActiveLine = ActiveList<I>
	FOR K = 1 TO COUNT(ActiveLine,@VM) + (ActiveLine NE '')
		IF ActiveList<I,K> NE OrgList<I,K> THEN
			stat = Send_Message(CtrlName,'COLOR_BY_POS',K,I,YELLOW$)
		END ELSE
			stat = Send_Message(CtrlName,'COLOR_BY_POS',K,I,GREEN$)
		END
	NEXT K
NEXT I


RETURN


* * * * * * *
InsertRow:
* * * * * * *

CtrlName = @WINDOW:'.CASSETTES'

RowIndex = Parm1

DeletedItem = Send_Message(CtrlName, "DELETE", RowIndex)

ErrMsg('Rows may not be inserted in this table.')

RETURN


* * * * * * *
DeleteRow:
* * * * * * *

CtrlName = @WINDOW:'.CASSETTES'

RowIndex = Parm1
RowData = Parm2

InsertedPosition = Send_Message(CtrlName, "INSERT", RowIndex, RowData)

ErrMsg('Rows may not be deleted from this table.')

RETURN


* * * * * * *
SetCommitDt:
* * * * * * *

SelectedLines = Get_Property(@WINDOW:'.CASSETTES','SELPOS')<2>

IF SelectedLines = '' THEN
 	ErrMsg('You must have at least one line selected in order to change a commit date.')
	RETURN
END

CommitDt = Get_Property(@WINDOW:'.COMMIT_DT','TEXT')

IF CommitDt = '' THEN
	ErrMsg('Please enter the new commit date you wish to use.')
	Set_Property(@WINDOW,'FOCUS',@WINDOW:'.COMMIT_DT')
	RETURN
END
 
FOR I = 1 TO COUNT(SelectedLines,@VM) + (SelectedLines NE '')
	SelectedLine = SelectedLines<1,I>
	Set_Property(@WINDOW:'.CASSETTES','CELLPOS',CommitDt,4:@FM:SelectedLine)		;* Column 4 is the commit date 	
NEXT I


GOSUB Refresh

RETURN


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


* * * * * * *
Cancel:
* * * * * * *

End_Dialog(@WINDOW,'Cancel')

RETURN



* * * * * * *
OK:
* * * * * * *

CtrlName = @WINDOW:'.CASSETTES'
ActiveList = Get_Property(CtrlName,'LIST')
OrgList = Get_Property(@WINDOW,'@ORG_CASS_LIST')

RDSNos		= ''
CommitDts	= ''
HotLots		= ''
MUBoxes		= ''
CassNos		= ''

ResultCnt = 1
FOR I = 1 TO COUNT(ActiveList,@FM) + (ActiveList NE '')
	ActiveLine = ActiveList<I>
	OrgLine	= OrgList<I>
	IF ActiveLine NE OrgLine THEN
		CassNos<1,ResultCnt>	= ActiveLine<1,1>
		RDSNos<1,ResultCnt>		= ActiveLine<1,2>
		CommitDts<1,ResultCnt>	= ActiveLine<1,4>
		HotLots<1,ResultCnt>	= ActiveLine<1,3>
		MUBoxes<1,ResultCnt>	= ActiveLine<1,6>
		ResultCnt += 1
	END
NEXT I

Result = RDSNos:@FM:CommitDts:@FM:HotLots:@FM:MUBoxes:@FM:CassNos

End_Dialog(@WINDOW,Result)

RETURN


