Hi,
// I click this button.
procedure TframeRapor1.btnKopyalaCopyGroupClick(Sender: TObject);
begin
try
// DB Update Process
CopyGroupCalculate(MainDataModule.dsetGetICMUserSymbolCopyGroupValue.Value);
// Refresh the grid with DB
GetICMReportMaster(UniMainModule.UserID.ToString,
String(MainDataModule.dsetAccountAccount.Value));
isCalculateCopyGroup := true;
except
on E: Exception do
ShowMessage(E.ClassName + ' error raised, with message : ' + E.Message);
end;
end;
procedure TframeRapor1.CopyGroupCalculate(ICMUserSymbolCopyGroupValue: string);
begin
MainDataModule.dsetGeneral.Close;
MainDataModule.dsetGeneral.SQL.Clear;
MainDataModule.dsetGeneral.SQL.Add
('EXEC spSetICMReportCalculateCopyGroup @ICMReportUserSymbolIDs = :ICMReportUserSymbolIDs');
MainDataModule.dsetGeneral.ParamByName('ICMReportUserSymbolIDs').Value :=
MainDataModule.dsetGetICMUserSymbolCopyGroupValue.Value;
MainDataModule.dsetGeneral.Execute;
MainDataModule.dsetGeneral.Close;
end;
procedure TframeRapor1.GetICMReportMaster(UserID: string; Account: string);
var
isCorrectSymbol: Boolean;
ICMReportMasterRecNo: Integer;
begin
try
if (NOT MainDataModule.dsetGetICMReportMaster.IsEmpty) then
begin
ICMReportMasterRecNo := MainDataModule.dsetGetICMReportMaster.RecNo;
end;
dbGridGetICMReportMaster.BeginUpdate;
MainDataModule.dsetGetICMReportMaster.Active := false;
MainDataModule.dsetGetICMReportMaster.SQL.Clear;
MainDataModule.dsetGetICMReportMaster.SQL.Add
('EXEC spGetICMReportMaster @UserID = :UserID, @Account = :Account');
MainDataModule.dsetGetICMReportMaster.ParamByName('UserID').Value :=
UniMainModule.UserID;
MainDataModule.dsetGetICMReportMaster.ParamByName('Account').Value :=
MainDataModule.dsetAccountAccount.Value;
MainDataModule.dsetGetICMReportMaster.Active := true;
dbGridGetICMReportMaster.EndUpdate;
selectedSymbol := '';
selectedSide := '';
MainDataModule.dsetGetICMReportMaster.RecNo := ICMReportMasterRecNo;
dbGridShow(TGrid.GetICMReportMaster);
except
on E: Exception do
ShowMessage(E.ClassName + ' error raised, with message : ' + E.Message);
end;
end;
// OnAfterLoad
procedure TframeRapor1.dbGridGetICMReportMasterAfterLoad(Sender: TUniDBGrid);
begin
if (isCalculateCopyGroup) then
begin
isCalculateCopyGroup := false;
GetSelectRecordDbGridByICMReportUserSymbolID
(MainDataModule.dsetGetICMUserSymbolCopyGroupValue.Value, 10);
end;
end;
// Select DBGrid Row and Get Selected Row Info
procedure TframeRapor1.GetSelectRecordDbGridByICMReportUserSymbolID
(ICMReportUserSymbolIDs: string; setTime: Integer);
var
I: Integer;
currentRecNo: Integer;
List: TStrings;
_RecNo: Integer;
JScript: string;
rowInfo: string;
begin
if NOT MainDataModule.dsetGetICMUserSymbolCopyGroupValue.IsNull then
begin
dbGridGetICMReportMaster.BeginUpdate;
List := TStringList.Create;
ICMReportUserSymbolIDToRecNos := FindICMReportUserSymbolIDToRec
(ICMReportUserSymbolIDs);
JScript := CONCAT('setTimeout(function(){ console.log("setTime"); },',
setTime.ToString, ');');
JScript := CONCAT(JScript, 'setTimeout(function(){ ',
dbGridGetICMReportMaster.JSName,
'.getSelectionModel().deselectAll()}, 50);');
with MainDataModule.dsetGetICMReportMaster do
begin
ExtractStrings([','], [], PChar(ICMReportUserSymbolIDToRecNos), List);
for I := 0 to List.count - 1 do
begin
_RecNo := StrToInt(List[I]);
if (I = (List.count - 1)) then
begin
rowInfo := CONCAT(rowInfo, GetGridInfoWithRecNo(_RecNo));
end
else
begin
rowInfo := CONCAT(rowInfo, GetGridInfoWithRecNo(_RecNo), #13#10);
end;
if (_RecNo > 0) then
begin
_RecNo := _RecNo - 1;
end;
JScript := CONCAT(JScript, 'setTimeout(function(){ ',
dbGridGetICMReportMaster.JSName, '.getSelectionModel().select(',
dbGridGetICMReportMaster.JSName, '.getStore().data.indexOfKey(',
IntToStr(_RecNo) + '), true)}, 50);');
end;
memoClipboard.Lines.Clear;
memoClipboard.Lines.Add(rowInfo);
UniSession.SendResponse(JScript);
// UniSession.AddJS(JScript);
FreeAndNil(List);
end;
dbGridGetICMReportMaster.EndUpdate;
end;
end;
// Get Row Info
function TframeRapor1.GetGridInfoWithRecNo(RecordNo: Integer): string;
var
size: Integer;
Symbol: string;
Side: Char;
Quantity: string;
Price: string;
str: string;
currentRecNo: Integer;
begin
try
if NOT MainDataModule.dsetGetICMReportMaster.IsEmpty then
begin
if (MainDataModule.dsetGetICMReportMaster.RecordCount > 0) then
begin
dbGridGetICMReportMaster.BeginUpdate;
with MainDataModule.dsetGetICMReportMaster do
begin
currentRecNo := RecNo;
RecNo := RecordNo;
if (Trim(FindField('SideKey').AsString) = '1') then
begin
Side := '+';
end
else
begin
Side := '-';
end;
if (NOT FindField('Symbol').IsNull) then
Symbol := FindField('Symbol').AsString;
if (NOT FindField('QtyDiff').IsNull) then
Quantity := FindField('QtyDiff').AsString;
if (NOT FindField('AvgPxDiff').IsNull) then
Price := FindField('AvgPxDiff').AsString;
size := 0;
if (Length(Symbol) > size) then
size := Length(Symbol);
if (Length(Quantity) > size) then
size := Length(Quantity);
if (Length(Price) > size) then
size := Length(Price);
size := size * 2;
str := format(CONCAT('%s', SetSpace(size - Length(Symbol)), '%s',
SetSpace(size - Length(Side)), '%s',
SetSpace(size - Length(Quantity)), '%s'),
[Symbol, Side, Quantity, Price]);
str := str.Replace('.E', '');
RecNo := currentRecNo;
end;
dbGridGetICMReportMaster.EndUpdate;
end;
end;
finally
Result := str;
end;
end;
When I run with the above code the grid gets stuck in Loading mode!
what an I doing wrong?
Thank you for your help.
Best regards.