Hack Forums
[Delphi] DBGrid sorting on title click + Shut down program remotely - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: [Delphi] DBGrid sorting on title click + Shut down program remotely (/showthread.php?tid=5977835)



DBGrid sorting on title click + Shut down program remotely - gua - Jun 8, 2019

Hi guys. I have DBGRID with some columns in it. I want to sort resoults 'ASC' or 'DESC' when i click on particular column title..

Im using this code to sort


PHP Code

<?php 
procedure TForm1
.DBGrid1TitleClick(Column: TColumn);
begin
  with TCustomADODataSet
(DBGrid1.DataSource.DataSet) do
  
begin
    Sort 
:= Column.Field.FieldName;
  
end;

end; 

Problem is that this code only sorts on ASC order , i tried to do something like

PHP Code

<?php 
var
asc: boolean

begin
asc
:= true;
if 
asc then
Sort 
:= Column.Field.FieldName + 'asc';
asc:= false;
exit;

if 
not asc then
Sort 
:= Column.Field.FieldName + 'desc';
asc:= true;
exit; 


but code is not working, so can u guys help me how to sort it on click.. Basically what i need is if column is sorted asc on click sort it desc and if it is desc on click sort it asc



Next questions was about turning off program remotely. My clients should pay me every month for maintenance + hostings + all that stuff.. I want to shut down their desktop app remotely if they dont pay me on the end of the month..

I was thinking to make some sort of timer that sends web request to server every 5sec for example , and if server respond true program will continue running , if web server respond false program will close itself and make changes in registry.

When they start program again program will close cuz it will check registry.. I know that they can operate offline using this method but that is what i was my idea, maybe you guys have some better ideas ? Thanks ✌