Changeset 828 for cprs/branches/GUI-config/MainU.pas
- Timestamp:
- Jul 7, 2010, 1:44:28 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/branches/GUI-config/MainU.pas
r756 r828 37 37 {$ENDIF} 38 38 Trpcb, //needed for .ptype types 39 ValEdit ;39 ValEdit, SortStringGrid; 40 40 41 41 type … … 49 49 50 50 TGridInfo = class; //forward declaration 51 TGridDataLoader = procedure (GridInfo: TGridInfo) of object; 51 TGridDataLoader = procedure (GridInfo: TGridInfo) of object; 52 52 TGridInfo = class (TObject) 53 53 public 54 Grid : TS tringGrid; //doesn't own object54 Grid : TSortStringGrid; //doesn't own object 55 55 FileNum : string; 56 56 IENS : string; … … 61 61 ApplyBtn : TButton; 62 62 RevertBtn : TButton; 63 end; 63 end; 64 64 65 65 … … 79 79 Panel5: TPanel; 80 80 ApplicationEvents: TApplicationEvents; 81 AdvancedUsersGrid: TS tringGrid;82 BasicUsersGrid: TS tringGrid;81 AdvancedUsersGrid: TSortStringGrid; 82 BasicUsersGrid: TSortStringGrid; 83 83 MainMenu: TMainMenu; 84 84 FileMenu: TMenuItem; … … 92 92 SettingsPageControl: TPageControl; 93 93 tsBasicSettings: TTabSheet; 94 BasicSettingsGrid: TS tringGrid;94 BasicSettingsGrid: TSortStringGrid; 95 95 tsAdvancedSettings: TTabSheet; 96 AdvancedSettingsGrid: TS tringGrid;96 AdvancedSettingsGrid: TSortStringGrid; 97 97 Panel3: TPanel; 98 98 btnSettingsApply: TBitBtn; … … 108 108 PatientsPageControl: TPageControl; 109 109 tsBasicPatients: TTabSheet; 110 BasicPatientGrid: TS tringGrid;110 BasicPatientGrid: TSortStringGrid; 111 111 tsAdvancedPatients: TTabSheet; 112 AdvancedPatientGrid: TS tringGrid;112 AdvancedPatientGrid: TSortStringGrid; 113 113 Panel9: TPanel; 114 114 btnPatientApply: TBitBtn; … … 124 124 AnyFilePageControl: TPageControl; 125 125 TabSheet2: TTabSheet; 126 AnyFileGrid: TS tringGrid;126 AnyFileGrid: TSortStringGrid; 127 127 Panel14: TPanel; 128 128 btnAdvancedApply: TBitBtn; … … 214 214 procedure SetCursorImage(Cursor : TCursor); 215 215 function FileNumForSettingsNode (Node : TTreeNode) : string; 216 function GetVisibleGrid: TS tringGrid;216 function GetVisibleGrid: TSortStringGrid; 217 217 function GetVisibleGridInfo : TGridInfo; 218 function GetInfoForGrid(Grid : TS tringGrid) : TGridInfo;219 function GetInfoIndexForGrid(Grid : TS tringGrid) : integer;220 procedure SetVisibleGridIdx(Grid : TS tringGrid);218 function GetInfoForGrid(Grid : TSortStringGrid) : TGridInfo; 219 function GetInfoIndexForGrid(Grid : TSortStringGrid) : integer; 220 procedure SetVisibleGridIdx(Grid : TSortStringGrid); 221 221 procedure GetUsersList(UsersList : TStringList; HideInactive: boolean); 222 222 procedure GetRecordsList(RecordsList : TStringList; FileNum : string); … … 236 236 //procedure GetAnyfileInfo(FileNum : String; IENS : String; Data : TStringList); 237 237 function FindInStrings(fieldNum : string; Strings : TStringList; var fileNum : string) : integer; 238 procedure CompileChanges(Grid : TS tringGrid; CurrentUserData,Changes : TStringList);239 function PostChanges(Grid : TS tringGrid) : TModalResult;238 procedure CompileChanges(Grid : TSortStringGrid; CurrentUserData,Changes : TStringList); 239 function PostChanges(Grid : TSortStringGrid) : TModalResult; 240 240 function PostVisibleGrid: TModalResult; 241 procedure LoadAnyGrid(Grid : TS tringGrid; BasicMode: boolean; FileNum,IENS : string; CurrentData : TStringList);241 procedure LoadAnyGrid(Grid : TSortStringGrid; BasicMode: boolean; FileNum,IENS : string; CurrentData : TStringList); 242 242 function DisuserChanged(Changes: TStringList) : boolean; 243 243 procedure DrawTab(Control: TCustomTabControl; TabIndex: Integer; const Rect: TRect; Active: Boolean); 244 244 function DoCloneRecord(FileNum, SourceIENS, New01Field : String) : string; 245 245 function DoCloneUser(SourceIENS, New01Field : String) : string; 246 function GetGridHint(Grid : TS tringGrid; FileNum : string; ACol, ARow : integer) : string;247 function FieldHelp(FileNum, FieldNum, HelpStyle : string) : string;248 procedure DoRevert(BasicGrid,AdvancedGrid : TS tringGrid);246 function GetGridHint(Grid : TSortStringGrid; FileNum : string; ACol, ARow : integer) : string; 247 function FieldHelp(FileNum, IENS, FieldNum, HelpStyle : string) : string; 248 procedure DoRevert(BasicGrid,AdvancedGrid : TSortStringGrid); 249 249 public 250 250 { Public declarations } … … 252 252 LastSelTreeNode : TTreeNode; 253 253 DebugMode : boolean; 254 function GetUserLine(CurrentUserData : TStringList; Grid : TS tringGrid; ARow:integer) :integer;255 function GetLineInfo(Grid : TS tringGrid; CurrentUserData : TStringList; ARow: integer) : tFileEntry;254 function GetUserLine(CurrentUserData : TStringList; Grid : TSortStringGrid; ARow:integer) :integer; 255 function GetLineInfo(Grid : TSortStringGrid; CurrentUserData : TStringList; ARow: integer) : tFileEntry; 256 256 function IsSubFile(FieldDef: string ; var SubFileNum : string) : boolean; 257 257 function IsWPField(FileNum,FieldNum : string) : boolean; … … 261 261 Procedure GetBlankFileInfo(FileNum : string; BlankList : TStringList); 262 262 procedure GetOneRecord(FileNum, IENS : string; Data, BlankFileInfo : TStringList); 263 procedure AddGridInfo(Grid: TS tringGrid; Data : TStringList; BasicMode : boolean;263 procedure AddGridInfo(Grid: TSortStringGrid; Data : TStringList; BasicMode : boolean; 264 264 DataLoader : TGridDataLoader; FileNum : string; 265 265 ApplyBtn,RevertBtn : TButton); 266 266 procedure LoadAnyGridFromInfo(GridInfo : TGridInfo); 267 procedure ClearGrid(Grid : TS tringGrid);267 procedure ClearGrid(Grid : TSortStringGrid); 268 268 procedure RegisterGridInfo(GridInfo : TGridInfo); 269 269 procedure UnRegisterGridInfo(GridInfo : TGridInfo); … … 398 398 399 399 400 procedure TMainForm.AddGridInfo(Grid: TS tringGrid;400 procedure TMainForm.AddGridInfo(Grid: TSortStringGrid; 401 401 Data : TStringList; 402 402 BasicMode : boolean; … … 1036 1036 1037 1037 1038 procedure TMainForm.ClearGrid(Grid : TS tringGrid);1038 procedure TMainForm.ClearGrid(Grid : TSortStringGrid); 1039 1039 var i:integer; 1040 1040 begin … … 1048 1048 1049 1049 1050 procedure TMainForm.LoadAnyGrid(Grid : TS tringGrid; //the TStringGrid to load1050 procedure TMainForm.LoadAnyGrid(Grid : TSortStringGrid; //the TSortStringGrid to load 1051 1051 BasicMode: boolean; 1052 1052 FileNum : string; … … 1077 1077 //This assumes that GridInfo already has loaded info. 1078 1078 var 1079 Grid : TS tringGrid; //the TStringGrid to load1079 Grid : TSortStringGrid; //the TSortStringGrid to load 1080 1080 BasicMode: boolean; 1081 1081 FileNum : string; … … 1083 1083 CurrentData : TStringList; 1084 1084 1085 procedure LoadOneLine (Grid : TS tringGrid; oneEntry : string; GridRow : integer);1085 procedure LoadOneLine (Grid : TSortStringGrid; oneEntry : string; GridRow : integer); 1086 1086 var 1087 1087 tempFile,IENS : string; … … 1208 1208 GridFileNum : string; 1209 1209 UserLine : integer; 1210 Grid : TS tringGrid;1210 Grid : TSortStringGrid; 1211 1211 IEN : int64; 1212 1212 IENS : string; … … 1216 1216 begin 1217 1217 if FLoadingGrid then exit; //prevent pseudo-clicks during loading... 1218 Grid := (Sender as TS tringGrid);1218 Grid := (Sender as TSortStringGrid); 1219 1219 GridInfo := GetInfoForGrid(Grid); 1220 1220 if GridInfo=nil then exit; … … 1301 1301 1302 1302 1303 function TMainForm.GetLineInfo(Grid : TS tringGrid; CurrentUserData : TStringList; ARow: integer) : tFileEntry;1303 function TMainForm.GetLineInfo(Grid : TSortStringGrid; CurrentUserData : TStringList; ARow: integer) : tFileEntry; 1304 1304 var fieldNum : string; 1305 1305 oneEntry : string; … … 1327 1327 end; 1328 1328 1329 function TMainForm.GetUserLine(CurrentUserData : TStringList; Grid : TS tringGrid; ARow: integer) : integer;1329 function TMainForm.GetUserLine(CurrentUserData : TStringList; Grid : TSortStringGrid; ARow: integer) : integer; 1330 1330 var fieldNum: string; 1331 1331 tempFileNum : string; … … 1429 1429 end; 1430 1430 1431 function TMainForm.GetVisibleGrid: TS tringGrid;1431 function TMainForm.GetVisibleGrid: TSortStringGrid; 1432 1432 begin 1433 1433 if FVisibleGridIdx > -1 then begin … … 1438 1438 end; 1439 1439 1440 function TMainForm.GetInfoForGrid(Grid : TS tringGrid) : TGridInfo;1440 function TMainForm.GetInfoForGrid(Grid : TSortStringGrid) : TGridInfo; 1441 1441 var i : integer; 1442 1442 begin … … 1450 1450 1451 1451 1452 function TMainForm.GetInfoIndexForGrid(Grid : TS tringGrid) : integer;1452 function TMainForm.GetInfoIndexForGrid(Grid : TSortStringGrid) : integer; 1453 1453 var s : string; 1454 1454 begin … … 1457 1457 end; 1458 1458 1459 procedure TMainForm.SetVisibleGridIdx(Grid : TS tringGrid);1459 procedure TMainForm.SetVisibleGridIdx(Grid : TSortStringGrid); 1460 1460 begin 1461 1461 FVisibleGridIdx := GetInfoIndexForGrid(Grid); … … 1463 1463 1464 1464 1465 procedure TMainForm.CompileChanges(Grid : TS tringGrid; CurrentUserData,Changes : TStringList);1465 procedure TMainForm.CompileChanges(Grid : TSortStringGrid; CurrentUserData,Changes : TStringList); 1466 1466 //Output format: 1467 1467 // FileNum^IENS^FieldNum^FieldName^newValue^oldValue … … 1479 1479 for row := 1 to Grid.RowCount-1 do begin 1480 1480 Entry := GetLineInfo(Grid,CurrentUserData, row); 1481 //Reject any value containing a "^" , ":" , ";"1481 //Reject any value containing a "^" 1482 1482 //Do we need an @ here as well? 1483 if (AnsiPos('^',Entry.newvalue) > 0) or //(AnsiPos(':',Entry.newvalue) > 0) or //elh Taken out because : used in time 1484 (AnsiPos(';',Entry.newvalue) > 0)then begin 1483 if AnsiPos('^',Entry.newvalue) > 0 then begin //or (AnsiPos(':',Entry.newvalue) > 0) or (AnsiPos(';',Entry.newvalue) > 0) //elh Taken out because : used in time 1485 1484 messagedlg('Invalid value entered for ' + Entry.Fieldname + #13 + #10 1486 1485 + #13 + #10 + 'Invalid Entry: ' + Entry.newvalue + #13 + #10 + … … 1514 1513 1515 1514 1516 function TMainForm.PostChanges(Grid : TS tringGrid) : TModalResult;1515 function TMainForm.PostChanges(Grid : TSortStringGrid) : TModalResult; 1517 1516 //Results: mrNone -- no post done (not needed) 1518 1517 // mrCancel -- user pressed cancel on confirmation screen. … … 1729 1728 end; 1730 1729 1731 function TMainForm.FieldHelp(FileNum, FieldNum, HelpStyle : string) : string;1730 function TMainForm.FieldHelp(FileNum, IENS, FieldNum, HelpStyle : string) : string; 1732 1731 var 1733 1732 RPCResult: string; … … 1737 1736 begin 1738 1737 Result := ''; 1739 SrchStr := FileNum + '^' + FieldNum + '^' + HelpStyle ;1738 SrchStr := FileNum + '^' + FieldNum + '^' + HelpStyle + '^' + IENS; 1740 1739 Idx := CachedHelpIdx.IndexOf(SrchStr); 1741 1740 if Idx = -1 then begin … … 1775 1774 end; 1776 1775 1777 function TMainForm.GetGridHint(Grid : TS tringGrid; FileNum : string; ACol, ARow : integer) : string;1776 function TMainForm.GetGridHint(Grid : TSortStringGrid; FileNum : string; ACol, ARow : integer) : string; 1778 1777 var fieldNum : string; 1778 GridInfo : TGridInfo; 1779 1779 begin 1780 1780 Result := ''; 1781 1781 //Result := 'Row=' + IntToStr(ARow) + ', Col='+ IntToStr(ACol); 1782 1782 if ARow > Grid.RowCount-1 then exit; 1783 if (ARow < 0) or (ACol < 0) then exit;1783 if (ARow < 1) or (ACol < 0) then exit; 1784 1784 if ACol=0 then begin 1785 Result := 'This is the database field NUMBER'; 1785 Result := 'This is the database field NUMBER'; 1786 1786 end else if ACol=1 then begin 1787 Result := 'This is the database field NAME'; 1787 Result := 'This is the database field NAME'; 1788 1788 end else begin 1789 1789 fieldNum := Grid.Cells[0,ARow]; … … 1797 1797 result := 'Clicking will open new window...'; 1798 1798 end else begin 1799 Result := FieldHelp(FileNum, fieldNum, '?'); 1800 end; 1799 GridInfo := GetInfoForGrid(Grid); 1800 Result := FieldHelp(FileNum, GridInfo.IENS, fieldNum, '?'); 1801 end; 1801 1802 end; 1802 1803 end; … … 1830 1831 if VisibleGridInfo = nil then exit; 1831 1832 if VisibleGridInfo.Grid = nil then exit; 1832 if (ClassName='TS tringGrid') then begin1833 if (ClassName='TSortStringGrid') then begin 1833 1834 VisibleGridInfo.Grid.MouseToCell(Pos.X,Pos.Y,ACol,ARow); 1834 1835 HintInfo.HintStr := GetGridHint(VisibleGridInfo.Grid,VisibleGridInfo.FileNum,ACol, ARow); … … 1969 1970 ModalResult := PostVisibleGrid; 1970 1971 if ModalResult = mrNo then exit; 1971 FileNum := FileORComboBox.ItemID; 1972 FileNum := FileORComboBox.ItemID; 1972 1973 IEN := RecordORComboBox.ItemID; //get info from selected record 1973 1974 if IEN=0 then exit; … … 2193 2194 2194 2195 2195 procedure TMainForm.DoRevert(BasicGrid,AdvancedGrid : TS tringGrid);2196 procedure TMainForm.DoRevert(BasicGrid,AdvancedGrid : TSortStringGrid); 2196 2197 //BasicGrid doesn't have to be supplied. Can be nil value. 2197 2198 //AdvancedGrid is required.
Note:
See TracChangeset
for help on using the changeset viewer.