COMPILE FUNCTION Dialog_React_Run_history(EntID,Event,Parm1,Parm2,Parm3,Parm4,Parm5)

/*
	Commuter module for DIALOG_REACT_MODE_HISTORY  window
	
	01/26/2010 - 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,SRP_EditTable_Manager 
DECLARE SUBROUTINE obj_Notes, Security_Err_Msg, End_Window, Forward_Event, Start_Window, Create_Note

DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility, Popup, Collect.Ixvals
DECLARE FUNCTION Send_Message, Msg, Security_Check, obj_React_Run_CI



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

$INSERT LOGICAL


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


ErrTitle = 'Error in Dialog_React_Mode_History'
ErrorMsg = ''

Result = ''

DEBUG

BEGIN CASE
	CASE EntID = @WINDOW
		BEGIN CASE
			CASE Event = 'CREATE' 			; GOSUB Create
			CASE Event = 'CLOSE'			; GOSUB Close
			
		END CASE
		
	CASE EntID = @WINDOW:'.CLOSE_BUTTON' AND Event = 'CLICK' 	; GOSUB Close
	CASE EntID = @WINDOW:'.PRINT_BUTTON' AND Event = 'CLICK' 	; GOSUB Close
		
	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)

DEBUG

GOSUB Setup_OLE_Controls


RETURN


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


RETURN



* * * * * * *
Setup_OLE_Controls:
* * * * * * *

	
Ctrl = @Window:".OLE_MODE_HISTORY"

TitleList = ""
TitleList<1, 1> = "Qty"
TitleList<1, 2> = "Part No"
TitleList<1, 3> = "Description"
TitleList<1, 4> = "Ship Date"
TitleList<1, 5> = "Tax?"
TitleList<1, 6> = "Unit Cost"
TitleList<1, 7> = "Extension"
TitleList<1, 8> = "Comments"

DEBUG

SRP_EditTable_Manager("Setup1", Ctrl, 7:@FM:1, TitleList, 50:@FM:150:@FM:"A":@FM:80:@FM:50:@FM:80:@FM:80:@FM:80, "R":@FM:"L":@FM:"L":@FM:"C":@FM:"C":@FM:"R":@FM:"R":@FM:"L" , 1:@VM:2:@VM:3:@VM:4:@VM:5:@VM:6:@VM:7:@VM:8, "", "", 1, 2)

// Set up general properties that affect the entire EditTable.

Set_Property(Ctrl, "OLE.ImageList", "DROPCAL.BMP")							    ; // Load an image list for use by other properties that can use images. In this case, we are only loading a one frame image.


// Set up column 1 (Qty) properties (this is column 1 on row 1).

CellConvInfo = "MD0":@FM:"MD0,":@FM:"'@DATA' is not a valid integer":@FM:@FM:@FM:Yes$
Set_Property(Ctrl, "OLE.CellConv[1; All]", CellConvInfo)					    ; // Set the column validation and conversion to MD0. Currently, this does not work automatically so it will have to be handled via the BeforeUpdate and AfterUpdate events.

// Set up column 2 (Part No) properties.

TypeData		= ""															; // Setting up the combobox array.
TypeData<1>		= "COB"
TypeData<2, 1>	= "Part No":@TM:"Description":@TM:"Unit Cost"
TypeData<2, 2>	= "L":@STM:"":@TM:"L":@STM:"":@TM:"R":@STM:""
TypeData<2, 3>	= "AAAA":@STM:"BBBB":@STM:"CCCC":@TM:"Miscellaneous":@STM:"Thingamajig":@STM:"Widget":@TM:"$12.34":@STM:"$543.21":@STM:"$1,000.00"	; // The combobox list data. Normally this might be data driven but this is hard-coded for this example.
TypeData<2, 4>	= 1																; // Column 1 of the combobox contains the data we want returned to the cell.
TypeData<2, 5>	= Yes$															; // Auto fill is on.
TypeData<2, 6>	= No$															; // Case sensitive is off.
TypeData<2, 9>	= Yes$															; // Autoshrink is on.
TypeData<2, 12>	= 2																; // Column 2 of the combobox is what the autofill will be using.
Set_Property(Ctrl, "OLE.CellType[2; All]", TypeData)							; // Set the cell type with the combobox array.

// Set up column 4 (Ship Date) properties.

Set_Property(Ctrl, "OLE.CellType[4; All]", "OPT":@FM:1)							; // Set the cell type so it has an option button. Clicking this will trigger the OnOptionClick event.
CellConvInfo = "D":@FM:"D4/":@FM:"'@DATA' is not a valid date":@FM:@FM:@FM:Yes$
Set_Property(Ctrl, "OLE.CellConv[4; All]", CellConvInfo)						; // Set the column validation and conversion to D4/. Currently, this does not work automatically so it will have to be handled via the BeforeUpdate and AfterUpdate events.

// Set up column 5 (Tax?) properties.

Set_Property(Ctrl, "OLE.CellType[5; All]", "CHB")								; // Set the cell type so it is a checkbox.

// Set up column 6 (Unit Cost) properties.

CellConvInfo = "MD2":@FM:"MD2,$,":@FM:"'@DATA' is not a valid currency amount":@FM:@FM:@FM:Yes$
Set_Property(Ctrl, "OLE.CellConv[6; All]", CellConvInfo)					    ; // Set the column validation and conversion to MD2. Currently, this does not work automatically so it will have to be handled via the BeforeUpdate and AfterUpdate events.

// Set up column 7 (Extension) properties.

CellConvInfo = "MD2":@FM:"MD2,$,":@FM:"'@DATA' is not a valid currency amount":@FM:@FM:@FM:Yes$
Set_Property(Ctrl, "OLE.CellConv[7; All]", CellConvInfo)					    ; // Set the column validation and conversion to MD2. Currently, this does not work automatically so it will have to be handled via the BeforeUpdate and AfterUpdate events.
Set_Property(Ctrl, "OLE.CellProtection[7; All]", "FUL")							; // Set the cell protection to Full since this is working like a symbolic column.
FontArray = ""
FontArray<1, 1, 1> = "Tahoma"													; // Make the font type Tahoma.
FontArray<1, 1, 2> = "8"														; // Make the font 8 pt.
FontArray<1, 1, 3> = "700"														; // Make the font heavy weight (i.e. bold).
Set_Property(Ctrl, "OLE.CellFont[7; All]", FontArray)							; // Set the FontArray for this cell.

// Set up column 1 (Comments) properties (This is column 1 on the row 2).

Set_Property(Ctrl, "OLE.CellMerge[1; 2]", 7)									; // Make the first cell in the second row into a merged cell. In this case, merge all 6 columns into one cell.
																		; // NOTE: Cells should be merged before any other property changes are made.
																		; // NOTE: The CellMerge property will always use the cell coordinates based on the visual format of the EditTable. In this case, we know the Comments cell is the first cell on the second row. Therefore the coordinate needs to be [1; 2].
Set_Property(Ctrl, "OLE.CellMultilined[8; All]", Yes$)							; // Make cell able to store multilined (delimited) data. Keep the default delimiter of @TM.
																		; // NOTE: When the RowsToRecord property is greater than 1, cells in other rows need to be considered as additional columns to the logical record. Therefore, even though Comments is physically the first cell on the second row, logically it is the 8th column of the firt record. Therefore the coordinate needs to be [8; 1] or [8; All] (Which is different than the CellMerge property. See above.)
FontArray = ""
FontArray<1, 1, 1> = "Tahoma"													; // Make the font type Tahoma.
FontArray<1, 1, 2> = "8"														; // Make the font 8 pt.
FontArray<1, 1, 3> = "400"														; // Make the font regular weight (i.e. not bold).
FontArray<1, 1, 4> = Yes$														; // Make the font italic.
Set_Property(Ctrl, "OLE.CellFont[8; All]", FontArray)							; // Set the FontArray for this cell. The cell coordinate is [8; All]. See the notes for CellMerge and CellMultilined above for further details.

Send_Message(Ctrl, "OLE.Clear", 1)												; // Blank out edittable and fill up with empty rows.

RETURN



