From Clomosy Docs

No edit summary
No edit summary
Line 3: Line 3:
  MyGuideForm : TclGuideForm;
  MyGuideForm : TclGuideForm;


<pre style="background-color:#E14D2A; color:white"> When performing SQL operations, you must write your database information in the code section, otherwise the code will not work. </pre><br>


Let's set up our connection to the sql database.<br>
Let's set up our connection to the sqlite database.<br>
  Clomosy.DBSQLServerConnect('SQL Server','server_name','user_name','user_password','database_name',port);
  Clomosy.DBSQLiteConnect(Clomosy.AppFilesPath + 'DBProductSales.db3', <nowiki>''</nowiki>);


After that, we need to add BasisGuide to reach the desired guide information. After that, we add a listView to the Guide form and connect it to our form.<br>
After that, we need to add BasisGuide to reach the desired guide information. After that, we add a listView to the Guide form and connect it to our form.<br>
Line 15: Line 14:
After that, when we click on the button on the edit we wrote, it goes to the database and finds the value sought here and transfers it to the ListView.<br>
After that, when we click on the button on the edit we wrote, it goes to the database and finds the value sought here and transfers it to the ListView.<br>


'''Procedure OnGuideQryClick;'''
<pre>
  var
procedure OnGuideQryClick;
    clViewDataQuery :TclSQLQuery;
var
  begin
  Qry : TClSQLiteQuery;
      clViewDataQuery:=TclSQLQuery.Create(Nil);
begin
    Try
  try
      clViewDataQuery.Connection := Clomosy.DBSQLServerConnection;
    Qry := Clomosy.DBSQLiteQueryWith('SELECT model AS MAIN_TEXT,operating_system AS SUB_TEXT FROM OperatingSystem WHERE model LIKE '+QuotedStr('%'+searchGuideEdit.text+'%'));
      clViewDataQuery.SQL.Text :='SELECT model AS MAIN_TEXT,operating_system AS SUB_TEXT FROM OperatingSystem WHERE model LIKE '+QuotedStr('%'+searchGuideEdit.text+'%');
    Qry.OpenOrExecute;
      clViewDataQuery.Open;
    if Qry.Found then
       mainListviewGuide.clLoadListViewDataFromDataset(clViewDataQuery);
    begin
     finally
       mainListviewGuide.clLoadListViewDataFromDataset(Qry);
      clViewDataQuery.Free;
     end;
     End;
      
'''End;'''
  except
    ShowMessage('Exception class: '+LastExceptionClassName+' Exception Message: ' +LastExceptionMessage);
  end;
end;
</pre>


Finally, the Guide takes the "MAIN_TEXT" field of the clicked data from the form with the "ReturnItemData" parameter and sends it to the edit on the previous page with the "ReturnItemObject" parameter.<br>
Finally, the Guide takes the "MAIN_TEXT" field of the clicked data from the form with the "ReturnItemData" parameter and sends it to the edit on the previous page with the "ReturnItemObject" parameter.<br>
Line 38: Line 41:


:'''Base Syntax'''
:'''Base Syntax'''
<pre>
var
  MyForm:TclForm;
  MyGuideForm : TclGuideForm;
  mainListviewGuide : TclListView;
  lblTitle,lblListNumber :TClLabel;
  edtListNumber : TclEdit;
  searchGuideEdit :TclProEdit;
  searchRehButton,btnListNumber : TClProButton;
  vertScrollBoxMain : TClVertScrollBox;
  lytContent,lytListNumber:TClLayout;
  searchRehLayout : TClLayout;
 
 
procedure Setup;
begin
  vertScrollBoxMain := MyForm.AddNewVertScrollBox(MyForm,'vertScrollBoxMain');
  vertScrollBoxMain.Align := alClient;
 
  lytContent:= MyForm.AddNewLayout(vertScrollBoxMain,'lytContent');
  lytContent.Align := alTop;
  lytContent.Height :=700;
end;
 
procedure SetCaptionName;
begin
  lblTitle:= MyForm.AddNewLabel(MyForm,'lblTitle','COUNT SCREEN');
  lblTitle.Align:=alMostTop;
  lblTitle.Margins.Left:=100;
  lblTitle.Height :=30;
  lblTitle.StyledSettings := ssFamily;
  lblTitle.TextSettings.Font.Size:= 20;
end;
procedure GuideListView;
begin
  mainListviewGuide := TClListView(MyGuideForm.clFindComponent('FormClListView'));
  mainListviewGuide.Align := alClient;
  mainListviewGuide.Visible := True;
end;


'''Var''' 
procedure OnGuideQryClick;
MyForm:TclForm;
var
MyGuideForm : TclGuideForm;
  Qry : TClSQLiteQuery;
mainListviewGuide : TclListView;
begin
lblTitle,lblListNumber :TClLabel;
  try
edtListNumber : TclEdit;
    Qry := Clomosy.DBSQLiteQueryWith('SELECT model AS MAIN_TEXT,operating_system AS SUB_TEXT FROM OperatingSystem WHERE model LIKE '+QuotedStr('%'+searchGuideEdit.text+'%'));
searchGuideEdit :TclProEdit;
    Qry.OpenOrExecute;
searchRehButton,btnListNumber : TClProButton;
    if Qry.Found then
vertScrollBoxMain : TClVertScrollBox;
    begin
lytContent,lytListNumber:TClLayout;
      mainListviewGuide.clLoadListViewDataFromDataset(Qry);
searchRehLayout : TClLayout;<br>
    end;
'''procedure SetupSqlConnection;'''
   
   begin
   except
     Clomosy.DBSQLServerConnect(<span style="color:red">'SQL Server','server_name','user_name','user_password','database_name',port</span>);
     ShowMessage('Exception class: '+LastExceptionClassName+' Exception Message: ' +LastExceptionMessage);
   end;<br>  
   end;  
  '''procedure Setup;'''
end;
   
   
procedure GuideSearchView;
  begin
  begin
     vertScrollBoxMain := MyForm.AddNewVertScrollBox(MyForm,'vertScrollBoxMain');
     searchRehLayout := MyGuideForm.AddNewLayout(MyGuideForm,'searchRehLayout');
     vertScrollBoxMain.Align := alClient;<br> 
     searchRehLayout.Align:=ALTop;
     lytContent:= MyForm.AddNewLayout(vertScrollBoxMain,'lytContent');
     searchRehLayout.Height := 50;
     lytContent.Align := alTop;
   
    lytContent.Height :=700;
    searchGuideEdit:= MyGuideForm.AddNewProEdit(searchRehLayout,'searchGuideEdit','Search...');
  end;<br>
     clComponent.SetupComponent(searchGuideEdit,'{"Align" : "Client","MarginTop":10,"Width" :180, "Height":50,
'''procedure GuideListView;'''
    "RoundHeight":10,"RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2}');
   
  searchRehButton:= MyGuideForm.AddNewProButton(searchRehLayout,'searchRehButton','');
  clComponent.SetupComponent(searchRehButton,'{"Align" : "Right","Width" :60,"Height":40,
  "RoundHeight":10, "RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2,
    "ImgUrl":"https://images.freeimages.com/fic/images/icons/573/must_have/48/search.png"
  }');
   
  MyGuideForm.AddNewEvent(searchRehButton,tbeOnClick,'OnGuideQryClick');
  end;
procedure OnListBtnClick
  begin
  begin
  mainListviewGuide := TClListView(MyGuideForm.clFindComponent('FormClListView'));
    MyGuideForm := TclGuideForm.Create(Self);
  mainListviewGuide.Align := alClient;
    TClButton(MyGuideForm.ClFindComponent('BtnFormMenu')).Visible := False;
  mainListviewGuide.Visible := True;
    GuideListView;
  end;<br>
    GuideSearchView;
  '''procedure SetCaptionName;'''
    MyGuideForm.ReturnItemData := 'MAIN_TEXT';
  begin
    MyGuideForm.ReturnItemObject := edtListNumber;
   lblTitle:= MyForm.AddNewLabel(MyForm,'lblTitle','COUNT SCREEN');
    MyGuideForm.Run;
   lblTitle.Align:=alMostTop;
  End;
   lblTitle.Margins.Left:=100;
   
   lblTitle.Height :=30;
procedure SetMainView;
   lblTitle.StyledSettings := ssFamily;
begin   
   lblTitle.TextSettings.Font.Size:= 20;
  lytListNumber        := MyForm.AddNewLayout(MyForm,'lytListNumber');
end;<br>
  lytListNumber.Align  := alTop;
'''Procedure OnGuideQryClick;'''
  lytListNumber.Margins.Top := 10;
  lytListNumber.Height := 25;
  lytListNumber.Width := 340;
   
   lblListNumber              := MyForm.AddNewLabel(lytListNumber,'lblListNumber','List Number:');
   lblListNumber.Align       := alMostLeft;
   lblListNumber.Width        := 140;
  lblListNumber.Margins.Left := 10;
   
   edtListNumber      := MyForm.AddNewEdit(lytListNumber,'edtListNumber','List Number');
  edtListNumber.Align := alLeft;
   edtListNumber.Width := 140;
   
   btnListNumber:= MyForm.AddNewProButton(lytListNumber,'btnListNumber','');
  clComponent.SetupComponent(btnListNumber,'{"Align" : "Right","Width" :50,"Height":60,"MarginRight":10,
  "RoundHeight":10, "RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2,
    "ImgUrl":"https://images.freeimages.com/fic/images/icons/573/must_have/48/search.png"
  }');
  MyForm.AddNewEvent(btnListNumber,tbeOnClick,'OnListBtnClick');
end;
 
  procedure SqLiteInsertData;
  begin
    try
      Clomosy.DBSQLiteQuery.Sql.Text := '
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (1, ''Vista'',''Microsoft Windows'',''tablet'', 200);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''XP'',''Microsoft Windows'',''tablet'', 500);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Alpha'',''Microsoft Windows'',''computer'', 104);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Public Beta'',''MacOS'',''computer'', 400);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (2, ''Tiger'',''MacOS'',''tablet'', 350);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Leopard'',''MacOS'',''computer'', 125);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (3, ''Lollipop'',''Android'',''mobile'', 325);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Alpha'',''Android'',''tablet'', 123);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (4, ''Gnome'',''Pardus'',''computer'', 300);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Raspberry'',''Pardus'',''computer'', 175);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (5, ''Tiger'',''MacOS'',''mobile'', 10);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Alpha'',''MacOS'',''ipad'', 104);';
      Clomosy.DBSQLiteQuery.OpenOrExecute;
     
      ShowMessage('Adding data to the table was successful!');
    except
    ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
    end;
  end;
 
  procedure SqLiteConnectionCreateTable;
   var
   var
    clViewDataQuery :TclSQLQuery;
    TableExists: Boolean;
  begin
      clViewDataQuery:=TclSQLQuery.Create(Nil);
    Try
      clViewDataQuery.Connection := Clomosy.DBSQLServerConnection;
      clViewDataQuery.SQL.Text :='<span style="color:red">SELECT model AS MAIN_TEXT,operating_system AS SUB_TEXT FROM OperatingSystem WHERE model LIKE '+QuotedStr('%'+searchGuideEdit.text+'%')</span>;
      clViewDataQuery.Open;
      mainListviewGuide.clLoadListViewDataFromDataset(clViewDataQuery);
    finally
      clViewDataQuery.Free;
    End;
  End;<br>
'''procedure GuideSearchView;'''
   begin
   begin
    searchRehLayout := MyGuideForm.AddNewLayout(MyGuideForm,'searchRehLayout');
    try
    searchRehLayout.Align:=ALTop;
      Clomosy.DBSQLiteConnect(Clomosy.AppFilesPath + 'DBProductSales.db3', '');
    searchRehLayout.Height := 50;<br>   
    searchGuideEdit:= MyGuideForm.AddNewProEdit(searchRehLayout,'searchGuideEdit','Search...');
      // Check if the table exists
    clComponent.SetupComponent(searchGuideEdit,'{"Align" : "Client","MarginTop":10,"Width" :180, "Height":50,
      Clomosy.DBSQLiteQuery.Sql.Text := 'SELECT name FROM sqlite_master WHERE type="table" AND name="OperatingSystem";';
    "RoundHeight":10,"RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2}');<br>   
      Clomosy.DBSQLiteQuery.OpenOrExecute;
    searchRehButton:= MyGuideForm.AddNewProButton(searchRehLayout,'searchRehButton',<nowiki>''</nowiki>);
     
    clComponent.SetupComponent(searchRehButton,'{"Align" : "Right","Width" :60,"Height":40,
      // Check the results
    "RoundHeight":10, "RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2,
      TableExists := not Clomosy.DBSQLiteQuery.Eof;
       "ImgUrl":"https://images.freeimages.com/fic/images/icons/573/must_have/48/search.png"
     
    }');<br>   
      // Create the table if it does not exist
     MyGuideForm.AddNewEvent(searchRehButton,tbeOnClick,'OnGuideQryClick');
      if not TableExists then
   end;<br>
      begin
'''procedure OnListBtnClick'''
        Clomosy.DBSQLiteQuery.Sql.Text := 'CREATE TABLE OperatingSystem (
                                        id INTEGER NOT NULL,
                                        model TEXT NOT NULL,
                                        operating_system TEXT NOT NULL,
                                        device_type TEXT NOT NULL,
                                        sales_figure INTEGER NOT NULL
                                          )';
        Clomosy.DBSQLiteQuery.OpenOrExecute;
       
        ShowMessage('Table successfully added to the database!');
        SqLiteInsertData;
      end else
       begin
        ShowMessage('The Products table already exists.');
      end;
 
     except
    ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
    end;
   end;
 
   begin
   begin
    MyGuideForm := TclGuideForm.Create(Self);
      
    TClButton(MyGuideForm.ClFindComponent('BtnFormMenu')).Visible := False;
     MyForm := TclForm.Create(Self);
    GuideListView;
    MyForm.SetFormColor('#ffffff','#cebade',clGVertical);
    GuideSearchView;
    Setup;
    MyGuideForm.ReturnItemData := 'MAIN_TEXT';
    SetCaptionName;
    MyGuideForm.ReturnItemObject := edtListNumber;
    SetMainView;   
    MyGuideForm.Run;
    SqLiteConnectionCreateTable;
  End;<br>
    MyForm.Run;
'''procedure SetMainView;'''
 
  begin   
  end;
    lytListNumber        := MyForm.AddNewLayout(MyForm,'lytListNumber');
 
    lytListNumber.Align  := alTop;
</pre>
    lytListNumber.Margins.Top := 10;
    lytListNumber.Height := 25;
    lytListNumber.Width  := 340;<br>   
    lblListNumber              := MyForm.AddNewLabel(lytListNumber,'lblListNumber','List Number:');
    lblListNumber.Align        := alMostLeft;
    lblListNumber.Width        := 140;
    lblListNumber.Margins.Left := 10;<br>   
     edtListNumber      := MyForm.AddNewEdit(lytListNumber,'edtListNumber','List Number');
     edtListNumber.Align := alLeft;
    edtListNumber.Width := 140;<br>   
    btnListNumber:= MyForm.AddNewProButton(lytListNumber,'btnListNumber',<nowiki>''</nowiki>);
    clComponent.SetupComponent(btnListNumber,'{"Align" : "Right","Width" :50,"Height":60,"MarginRight":10,
    "RoundHeight":10, "RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2,
      "ImgUrl":"https://images.freeimages.com/fic/images/icons/573/must_have/48/search.png"
    }');
    MyForm.AddNewEvent(btnListNumber,tbeOnClick,'OnListBtnClick');
  end;<br>
'''begin'''
  MyForm:=TclForm.Create(Self);
  MyForm.SetFormColor('#ffffff','#cebade',clGVertical);
  Setup;
  SetCaptionName;
  SetMainView;   
  SetupSqlConnection;
  MyForm.Run;
'''end;'''


:'''TRObject Syntax'''
:'''TRObject Syntax'''
 
<pre>
   Var 
var
    MyForm:TclForm;
   MyForm:TclForm;
    MyGuideForm : TclGuideForm;
  MyGuideForm : TclGuideForm;
    mainListviewGuide : TclListView;
  mainListviewGuide : TclListView;
    lblTitle,lblListNumber :TClLabel;
  lblTitle,lblListNumber :TClLabel;
    edtListNumber : TclEdit;
  edtListNumber : TclEdit;
    searchGuideEdit :TclProEdit;
  searchGuideEdit :TclProEdit;
    searchRehButton,btnListNumber : TClProButton;
  searchRehButton,btnListNumber : TClProButton;
    vertScrollBoxMain : TClVertScrollBox;
  vertScrollBoxMain : TClVertScrollBox;
    lytContent,lytListNumber:TClLayout;
  lytContent,lytListNumber:TClLayout;
    searchRehLayout : TClLayout;
  searchRehLayout : TClLayout;
    
    
  void SetupSqlConnection;
  {
    Clomosy.DBSQLServerConnect('SQL Server','server_name','user_name','user_password','database_name',port);
  }
   
  void Setup;
  {
    vertScrollBoxMain = MyForm.AddNewVertScrollBox(MyForm,'vertScrollBoxMain');
    vertScrollBoxMain.Align = alClient;
   
    lytContent= MyForm.AddNewLayout(vertScrollBoxMain,'lytContent');
    lytContent.Align = alTop;
    lytContent.Height =700;
  }
    
    
  void GuideListView;
void Setup;
  {
{
    mainListviewGuide = TClListView(MyGuideForm.clFindComponent('FormClListView'));
  vertScrollBoxMain = MyForm.AddNewVertScrollBox(MyForm,'vertScrollBoxMain');
    mainListviewGuide.Align = alClient;
  vertScrollBoxMain.Align = alClient;
    mainListviewGuide.Visible = True;
  }
    
    
  void SetCaptionName;
  lytContent= MyForm.AddNewLayout(vertScrollBoxMain,'lytContent');
  {
  lytContent.Align = alTop;
    lblTitle= MyForm.AddNewLabel(MyForm,'lblTitle','COUNT SCREEN');
  lytContent.Height =700;
    lblTitle.Align=alMostTop;
}
    lblTitle.Margins.Left=100;
    lblTitle.Height =30;
    lblTitle.StyledSettings = ssFamily;
    lblTitle.TextSettings.Font.Size= 20;
  }
    
    
   void OnGuideQryClick;
void SetCaptionName;
  var
{
    clViewDataQuery :TclSQLQuery;
  lblTitle= MyForm.AddNewLabel(MyForm,'lblTitle','COUNT SCREEN');
   {
   lblTitle.Align=alMostTop;
    clViewDataQuery=TclSQLQuery.Create(Nil);
  lblTitle.Margins.Left=100;
    Try
  lblTitle.Height =30;
      clViewDataQuery.Connection = Clomosy.DBSQLServerConnection;
  lblTitle.StyledSettings = ssFamily;
      clViewDataQuery.SQL.Text ='SELECT model AS MAIN_TEXT,operating_system AS SUB_TEXT FROM OperatingSystem WHERE model LIKE '+QuotedStr('%'+searchGuideEdit.text+'%');
   lblTitle.TextSettings.Font.Size= 20;
      clViewDataQuery.Open;
}
      mainListviewGuide.clLoadListViewDataFromDataset(clViewDataQuery);
void GuideListView;
     finally
{
       clViewDataQuery.Free;
  mainListviewGuide = TClListView(MyGuideForm.clFindComponent('FormClListView'));
  mainListviewGuide.Align = alClient;
  mainListviewGuide.Visible = True;
}
 
void OnGuideQryClick;
var
  Qry : TClSQLiteQuery;
{
  try
    Qry = Clomosy.DBSQLiteQueryWith('SELECT model AS MAIN_TEXT,operating_system AS SUB_TEXT FROM OperatingSystem WHERE model LIKE '+QuotedStr('%'+searchGuideEdit.text+'%'));
    Qry.OpenOrExecute;
    if (Qry.Found)
     {
       mainListviewGuide.clLoadListViewDataFromDataset(Qry);
     }
     }
  }
   
 
  except
  void GuideSearchView;
    ShowMessage('Exception class: '+LastExceptionClassName+' Exception Message: ' +LastExceptionMessage);
  {
  }  
}
void GuideSearchView;
{
     searchRehLayout = MyGuideForm.AddNewLayout(MyGuideForm,'searchRehLayout');
     searchRehLayout = MyGuideForm.AddNewLayout(MyGuideForm,'searchRehLayout');
     searchRehLayout.Align=ALTop;
     searchRehLayout.Align=ALTop;
Line 218: Line 300:
     "RoundHeight":10,"RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2}');
     "RoundHeight":10,"RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2}');
      
      
    searchRehButton= MyGuideForm.AddNewProButton(searchRehLayout,'searchRehButton',<nowiki>''</nowiki>);
  searchRehButton= MyGuideForm.AddNewProButton(searchRehLayout,'searchRehButton','');
    clComponent.SetupComponent(searchRehButton,'{"Align" : "Right","Width" :60,"Height":40,
  clComponent.SetupComponent(searchRehButton,'{"Align" : "Right","Width" :60,"Height":40,
    "RoundHeight":10, "RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2,
  "RoundHeight":10, "RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2,
    "ImgUrl":"https://images.freeimages.com/fic/images/icons/573/must_have/48/search.png"
    "ImgUrl":"https://images.freeimages.com/fic/images/icons/573/must_have/48/search.png"
    }');
  }');
      
      
    MyGuideForm.AddNewEvent(searchRehButton,tbeOnClick,'OnGuideQryClick');
  MyGuideForm.AddNewEvent(searchRehButton,tbeOnClick,'OnGuideQryClick');
  }
}
 
void OnListBtnClick
  void OnListBtnClick
{
  {
     MyGuideForm = TclGuideForm.Create(Self);
     MyGuideForm = TclGuideForm.Create(Self);
     TClButton(MyGuideForm.ClFindComponent('BtnFormMenu')).Visible = False;
     TClButton(MyGuideForm.ClFindComponent('BtnFormMenu')).Visible = False;
Line 236: Line 317:
     MyGuideForm.ReturnItemObject = edtListNumber;
     MyGuideForm.ReturnItemObject = edtListNumber;
     MyGuideForm.Run;
     MyGuideForm.Run;
  }
}
 
  void SetMainView;
void SetMainView;
  {     
{     
    lytListNumber        = MyForm.AddNewLayout(MyForm,'lytListNumber');
  lytListNumber        = MyForm.AddNewLayout(MyForm,'lytListNumber');
    lytListNumber.Align  = alTop;
  lytListNumber.Align  = alTop;
    lytListNumber.Margins.Top = 10;
  lytListNumber.Margins.Top = 10;
    lytListNumber.Height = 25;
  lytListNumber.Height = 25;
    lytListNumber.Width  = 340;
  lytListNumber.Width  = 340;
      
      
    lblListNumber              = MyForm.AddNewLabel(lytListNumber,'lblListNumber','List Number:');
  lblListNumber              = MyForm.AddNewLabel(lytListNumber,'lblListNumber','List Number:');
    lblListNumber.Align        = alMostLeft;
  lblListNumber.Align        = alMostLeft;
    lblListNumber.Width        = 140;
  lblListNumber.Width        = 140;
    lblListNumber.Margins.Left = 10;
  lblListNumber.Margins.Left = 10;
      
      
    edtListNumber      = MyForm.AddNewEdit(lytListNumber,'edtListNumber','List Number');
  edtListNumber      = MyForm.AddNewEdit(lytListNumber,'edtListNumber','List Number');
    edtListNumber.Align = alLeft;
  edtListNumber.Align = alLeft;
    edtListNumber.Width = 140;
  edtListNumber.Width = 140;
      
      
    btnListNumber= MyForm.AddNewProButton(lytListNumber,'btnListNumber',<nowiki>''</nowiki>);
  btnListNumber= MyForm.AddNewProButton(lytListNumber,'btnListNumber','');
    clComponent.SetupComponent(btnListNumber,'{"Align" : "Right","Width" :50,"Height":60,"MarginRight":10,
  clComponent.SetupComponent(btnListNumber,'{"Align" : "Right","Width" :50,"Height":60,"MarginRight":10,
    "RoundHeight":10, "RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2,
  "RoundHeight":10, "RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2,
     "ImgUrl":"https://images.freeimages.com/fic/images/icons/573/must_have/48/search.png"}');
     "ImgUrl":"https://images.freeimages.com/fic/images/icons/573/must_have/48/search.png"
    MyForm.AddNewEvent(btnListNumber,tbeOnClick,'OnListBtnClick');
  }');
  MyForm.AddNewEvent(btnListNumber,tbeOnClick,'OnListBtnClick');
}
 
  void SqLiteInsertData;
  {
    try
      Clomosy.DBSQLiteQuery.Sql.Text = '
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (1, ''Vista'',''Microsoft Windows'',''tablet'', 200);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''XP'',''Microsoft Windows'',''tablet'', 500);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Alpha'',''Microsoft Windows'',''computer'', 104);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Public Beta'',''MacOS'',''computer'', 400);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (2, ''Tiger'',''MacOS'',''tablet'', 350);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Leopard'',''MacOS'',''computer'', 125);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (3, ''Lollipop'',''Android'',''mobile'', 325);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Alpha'',''Android'',''tablet'', 123);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (4, ''Gnome'',''Pardus'',''computer'', 300);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Raspberry'',''Pardus'',''computer'', 175);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (5, ''Tiger'',''MacOS'',''mobile'', 10);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Alpha'',''MacOS'',''ipad'', 104);';
      Clomosy.DBSQLiteQuery.OpenOrExecute;
     
      ShowMessage('Adding data to the table was successful!');
    except
    ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
    }
   }
   }
    
    
  void SqLiteConnectionCreateTable;
  var
    TableExists: Boolean;
   {
   {
     MyForm=TclForm.Create(Self);
    try
      Clomosy.DBSQLiteConnect(Clomosy.AppFilesPath + 'DBProductSales.db3', '');
      // Check if the table exists
      Clomosy.DBSQLiteQuery.Sql.Text = 'SELECT name FROM sqlite_master WHERE type="table" AND name="OperatingSystem";';
      Clomosy.DBSQLiteQuery.OpenOrExecute;
     
      // Check the results
      TableExists = not Clomosy.DBSQLiteQuery.Eof;
     
      // Create the table if it does not exist
      if not (TableExists)
      {
        Clomosy.DBSQLiteQuery.Sql.Text = 'CREATE TABLE OperatingSystem (
                                        id INTEGER NOT NULL,
                                        model TEXT NOT NULL,
                                        operating_system TEXT NOT NULL,
                                        device_type TEXT NOT NULL,
                                        sales_figure INTEGER NOT NULL
                                          )';
        Clomosy.DBSQLiteQuery.OpenOrExecute;
       
        ShowMessage('Table successfully added to the database!');
        SqLiteInsertData;
      } else
      {
        ShowMessage('The Products table already exists.');
      }
 
    except
    ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
    }
  }
 
  {
   
     MyForm = TclForm.Create(Self);
     MyForm.SetFormColor('#ffffff','#cebade',clGVertical);
     MyForm.SetFormColor('#ffffff','#cebade',clGVertical);
     Setup;
     Setup;
     SetCaptionName;
     SetCaptionName;
     SetMainView;   
     SetMainView;   
     SetupSqlConnection;
     SqLiteConnectionCreateTable;
     MyForm.Run;
     MyForm.Run;
 
   }
   }
</pre>


'''Output:'''<br>
'''Output:'''<br>

Revision as of 11:36, 5 July 2024

Basis Guide is a customized guide for Clomosy. In the application, all the desired data can be accessed from the database. With the customized guide, it only returns data according to the searched request, without reaching all the data.
In another use, the "TclGuideForm" component can be used when it is desired to transfer selected data from a page search to the previous page. Let's create a BasisGuide form now and continue the narrative over it. To create the form, it is necessary to define.

MyGuideForm : TclGuideForm;


Let's set up our connection to the sqlite database.

Clomosy.DBSQLiteConnect(Clomosy.AppFilesPath + 'DBProductSales.db3', '');

After that, we need to add BasisGuide to reach the desired guide information. After that, we add a listView to the Guide form and connect it to our form.

mainListviewGuide := TClListView(MyGuideForm.clFindComponent('FormClListView'));
mainListviewGuide.Align := alClient;
mainListviewGuide.Visible := True;

After that, when we click on the button on the edit we wrote, it goes to the database and finds the value sought here and transfers it to the ListView.

procedure OnGuideQryClick;
var
  Qry : TClSQLiteQuery;
begin
  try
    Qry := Clomosy.DBSQLiteQueryWith('SELECT model AS MAIN_TEXT,operating_system AS SUB_TEXT FROM OperatingSystem WHERE model LIKE '+QuotedStr('%'+searchGuideEdit.text+'%'));
    Qry.OpenOrExecute;
    if Qry.Found then
    begin
      mainListviewGuide.clLoadListViewDataFromDataset(Qry);
    end;
    
  except
    ShowMessage('Exception class: '+LastExceptionClassName+' Exception Message: ' +LastExceptionMessage);
  end; 
end;

Finally, the Guide takes the "MAIN_TEXT" field of the clicked data from the form with the "ReturnItemData" parameter and sends it to the edit on the previous page with the "ReturnItemObject" parameter.

MyGuideForm.ReturnItemData := 'MAIN_TEXT';
MyGuideForm.ReturnItemObject := edtListNumber;

Code:

Base Syntax
 var
  MyForm:TclForm;
  MyGuideForm : TclGuideForm;
  mainListviewGuide : TclListView;
  lblTitle,lblListNumber :TClLabel;
  edtListNumber : TclEdit;
  searchGuideEdit :TclProEdit;
  searchRehButton,btnListNumber : TClProButton;
  vertScrollBoxMain : TClVertScrollBox;
  lytContent,lytListNumber:TClLayout;
  searchRehLayout : TClLayout;
  
  
procedure Setup;
begin
   vertScrollBoxMain := MyForm.AddNewVertScrollBox(MyForm,'vertScrollBoxMain');
   vertScrollBoxMain.Align := alClient;
  
   lytContent:= MyForm.AddNewLayout(vertScrollBoxMain,'lytContent');
   lytContent.Align := alTop;
   lytContent.Height :=700;
end;
  
procedure SetCaptionName;
begin
  lblTitle:= MyForm.AddNewLabel(MyForm,'lblTitle','COUNT SCREEN');
  lblTitle.Align:=alMostTop;
  lblTitle.Margins.Left:=100;
  lblTitle.Height :=30;
  lblTitle.StyledSettings := ssFamily;
  lblTitle.TextSettings.Font.Size:= 20;
end;
procedure GuideListView;
begin
  mainListviewGuide := TClListView(MyGuideForm.clFindComponent('FormClListView'));
  mainListviewGuide.Align := alClient;
  mainListviewGuide.Visible := True;
end;

procedure OnGuideQryClick;
var
  Qry : TClSQLiteQuery;
begin
  try
    Qry := Clomosy.DBSQLiteQueryWith('SELECT model AS MAIN_TEXT,operating_system AS SUB_TEXT FROM OperatingSystem WHERE model LIKE '+QuotedStr('%'+searchGuideEdit.text+'%'));
    Qry.OpenOrExecute;
    if Qry.Found then
    begin
      mainListviewGuide.clLoadListViewDataFromDataset(Qry);
    end;
    
  except
    ShowMessage('Exception class: '+LastExceptionClassName+' Exception Message: ' +LastExceptionMessage);
  end; 
end;
 
 
 
procedure GuideSearchView;
 begin
    searchRehLayout := MyGuideForm.AddNewLayout(MyGuideForm,'searchRehLayout');
    searchRehLayout.Align:=ALTop;
    searchRehLayout.Height := 50;
    
    searchGuideEdit:= MyGuideForm.AddNewProEdit(searchRehLayout,'searchGuideEdit','Search...');
    clComponent.SetupComponent(searchGuideEdit,'{"Align" : "Client","MarginTop":10,"Width" :180, "Height":50,
    "RoundHeight":10,"RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2}');
    
   searchRehButton:= MyGuideForm.AddNewProButton(searchRehLayout,'searchRehButton','');
   clComponent.SetupComponent(searchRehButton,'{"Align" : "Right","Width" :60,"Height":40,
   "RoundHeight":10, "RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2,
     "ImgUrl":"https://images.freeimages.com/fic/images/icons/573/must_have/48/search.png"
   }');
    
   MyGuideForm.AddNewEvent(searchRehButton,tbeOnClick,'OnGuideQryClick');
 end;
procedure OnListBtnClick
 begin
    MyGuideForm := TclGuideForm.Create(Self);
    TClButton(MyGuideForm.ClFindComponent('BtnFormMenu')).Visible := False;
    GuideListView;
    GuideSearchView;
    MyGuideForm.ReturnItemData := 'MAIN_TEXT';
    MyGuideForm.ReturnItemObject := edtListNumber;
    MyGuideForm.Run;
 End;
 
procedure SetMainView;
 begin    
   lytListNumber        := MyForm.AddNewLayout(MyForm,'lytListNumber');
   lytListNumber.Align  := alTop;
   lytListNumber.Margins.Top := 10;
   lytListNumber.Height := 25;
   lytListNumber.Width  := 340;
    
   lblListNumber              := MyForm.AddNewLabel(lytListNumber,'lblListNumber','List Number:');
   lblListNumber.Align        := alMostLeft;
   lblListNumber.Width        := 140;
   lblListNumber.Margins.Left := 10;
    
   edtListNumber       := MyForm.AddNewEdit(lytListNumber,'edtListNumber','List Number');
   edtListNumber.Align := alLeft;
   edtListNumber.Width := 140;
    
   btnListNumber:= MyForm.AddNewProButton(lytListNumber,'btnListNumber','');
   clComponent.SetupComponent(btnListNumber,'{"Align" : "Right","Width" :50,"Height":60,"MarginRight":10,
   "RoundHeight":10, "RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2,
     "ImgUrl":"https://images.freeimages.com/fic/images/icons/573/must_have/48/search.png"
   }');
   MyForm.AddNewEvent(btnListNumber,tbeOnClick,'OnListBtnClick');
 end;

   procedure SqLiteInsertData;
  begin
    try
      Clomosy.DBSQLiteQuery.Sql.Text := '
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (1, ''Vista'',''Microsoft Windows'',''tablet'', 200);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''XP'',''Microsoft Windows'',''tablet'', 500);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Alpha'',''Microsoft Windows'',''computer'', 104);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Public Beta'',''MacOS'',''computer'', 400);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (2, ''Tiger'',''MacOS'',''tablet'', 350);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Leopard'',''MacOS'',''computer'', 125);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (3, ''Lollipop'',''Android'',''mobile'', 325);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Alpha'',''Android'',''tablet'', 123);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (4, ''Gnome'',''Pardus'',''computer'', 300);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Raspberry'',''Pardus'',''computer'', 175);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (5, ''Tiger'',''MacOS'',''mobile'', 10);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Alpha'',''MacOS'',''ipad'', 104);';
      Clomosy.DBSQLiteQuery.OpenOrExecute;
      
      ShowMessage('Adding data to the table was successful!');
    except
     ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
    end;
  end;
  
  procedure SqLiteConnectionCreateTable;
  var
    TableExists: Boolean;
  begin
    try
      Clomosy.DBSQLiteConnect(Clomosy.AppFilesPath + 'DBProductSales.db3', '');
 
      // Check if the table exists
      Clomosy.DBSQLiteQuery.Sql.Text := 'SELECT name FROM sqlite_master WHERE type="table" AND name="OperatingSystem";';
      Clomosy.DBSQLiteQuery.OpenOrExecute;
      
      // Check the results
      TableExists := not Clomosy.DBSQLiteQuery.Eof;
      
      // Create the table if it does not exist
      if not TableExists then
      begin
        Clomosy.DBSQLiteQuery.Sql.Text := 'CREATE TABLE OperatingSystem (
                                        	id INTEGER NOT NULL,
                                        	model TEXT NOT NULL,
                                        	operating_system TEXT NOT NULL,
                                        	device_type TEXT NOT NULL,
                                        	sales_figure INTEGER NOT NULL
                                          )';
        Clomosy.DBSQLiteQuery.OpenOrExecute;
        
        ShowMessage('Table successfully added to the database!');
        SqLiteInsertData;
      end else
      begin
        ShowMessage('The Products table already exists.');
      end;

    except
     ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
    end;
  end;

  begin
    
    MyForm := TclForm.Create(Self);
    MyForm.SetFormColor('#ffffff','#cebade',clGVertical);
    Setup;
    SetCaptionName;
    SetMainView;  
    SqLiteConnectionCreateTable;
    MyForm.Run;
  
  end;

TRObject Syntax
 var
  MyForm:TclForm;
  MyGuideForm : TclGuideForm;
  mainListviewGuide : TclListView;
  lblTitle,lblListNumber :TClLabel;
  edtListNumber : TclEdit;
  searchGuideEdit :TclProEdit;
  searchRehButton,btnListNumber : TClProButton;
  vertScrollBoxMain : TClVertScrollBox;
  lytContent,lytListNumber:TClLayout;
  searchRehLayout : TClLayout;
  
  
void Setup;
{
   vertScrollBoxMain = MyForm.AddNewVertScrollBox(MyForm,'vertScrollBoxMain');
   vertScrollBoxMain.Align = alClient;
  
   lytContent= MyForm.AddNewLayout(vertScrollBoxMain,'lytContent');
   lytContent.Align = alTop;
   lytContent.Height =700;
}
  
void SetCaptionName;
{
  lblTitle= MyForm.AddNewLabel(MyForm,'lblTitle','COUNT SCREEN');
  lblTitle.Align=alMostTop;
  lblTitle.Margins.Left=100;
  lblTitle.Height =30;
  lblTitle.StyledSettings = ssFamily;
  lblTitle.TextSettings.Font.Size= 20;
}
void GuideListView;
{
  mainListviewGuide = TClListView(MyGuideForm.clFindComponent('FormClListView'));
  mainListviewGuide.Align = alClient;
  mainListviewGuide.Visible = True;
}

void OnGuideQryClick;
var
  Qry : TClSQLiteQuery;
{
  try
    Qry = Clomosy.DBSQLiteQueryWith('SELECT model AS MAIN_TEXT,operating_system AS SUB_TEXT FROM OperatingSystem WHERE model LIKE '+QuotedStr('%'+searchGuideEdit.text+'%'));
    Qry.OpenOrExecute;
    if (Qry.Found)
    {
      mainListviewGuide.clLoadListViewDataFromDataset(Qry);
    }
    
  except
    ShowMessage('Exception class: '+LastExceptionClassName+' Exception Message: ' +LastExceptionMessage);
  } 
}
 
 
 
void GuideSearchView;
 {
    searchRehLayout = MyGuideForm.AddNewLayout(MyGuideForm,'searchRehLayout');
    searchRehLayout.Align=ALTop;
    searchRehLayout.Height = 50;
    
    searchGuideEdit= MyGuideForm.AddNewProEdit(searchRehLayout,'searchGuideEdit','Search...');
    clComponent.SetupComponent(searchGuideEdit,'{"Align" : "Client","MarginTop":10,"Width" :180, "Height":50,
    "RoundHeight":10,"RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2}');
    
   searchRehButton= MyGuideForm.AddNewProButton(searchRehLayout,'searchRehButton','');
   clComponent.SetupComponent(searchRehButton,'{"Align" : "Right","Width" :60,"Height":40,
   "RoundHeight":10, "RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2,
     "ImgUrl":"https://images.freeimages.com/fic/images/icons/573/must_have/48/search.png"
   }');
    
   MyGuideForm.AddNewEvent(searchRehButton,tbeOnClick,'OnGuideQryClick');
 }
void OnListBtnClick
 {
    MyGuideForm = TclGuideForm.Create(Self);
    TClButton(MyGuideForm.ClFindComponent('BtnFormMenu')).Visible = False;
    GuideListView;
    GuideSearchView;
    MyGuideForm.ReturnItemData = 'MAIN_TEXT';
    MyGuideForm.ReturnItemObject = edtListNumber;
    MyGuideForm.Run;
 }
 
void SetMainView;
 {    
   lytListNumber        = MyForm.AddNewLayout(MyForm,'lytListNumber');
   lytListNumber.Align  = alTop;
   lytListNumber.Margins.Top = 10;
   lytListNumber.Height = 25;
   lytListNumber.Width  = 340;
    
   lblListNumber              = MyForm.AddNewLabel(lytListNumber,'lblListNumber','List Number:');
   lblListNumber.Align        = alMostLeft;
   lblListNumber.Width        = 140;
   lblListNumber.Margins.Left = 10;
    
   edtListNumber       = MyForm.AddNewEdit(lytListNumber,'edtListNumber','List Number');
   edtListNumber.Align = alLeft;
   edtListNumber.Width = 140;
    
   btnListNumber= MyForm.AddNewProButton(lytListNumber,'btnListNumber','');
   clComponent.SetupComponent(btnListNumber,'{"Align" : "Right","Width" :50,"Height":60,"MarginRight":10,
   "RoundHeight":10, "RoundWidth":10,"BorderColor":"#be92e0","BorderWidth":2,
     "ImgUrl":"https://images.freeimages.com/fic/images/icons/573/must_have/48/search.png"
   }');
   MyForm.AddNewEvent(btnListNumber,tbeOnClick,'OnListBtnClick');
 }

   void SqLiteInsertData;
  {
    try
      Clomosy.DBSQLiteQuery.Sql.Text = '
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (1, ''Vista'',''Microsoft Windows'',''tablet'', 200);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''XP'',''Microsoft Windows'',''tablet'', 500);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Alpha'',''Microsoft Windows'',''computer'', 104);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Public Beta'',''MacOS'',''computer'', 400);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (2, ''Tiger'',''MacOS'',''tablet'', 350);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Leopard'',''MacOS'',''computer'', 125);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (3, ''Lollipop'',''Android'',''mobile'', 325);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Alpha'',''Android'',''tablet'', 123);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (4, ''Gnome'',''Pardus'',''computer'', 300);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Raspberry'',''Pardus'',''computer'', 175);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (5, ''Tiger'',''MacOS'',''mobile'', 10);
    INSERT INTO OperatingSystem (id, model,operating_system,device_type, sales_figure) VALUES (6, ''Alpha'',''MacOS'',''ipad'', 104);';
      Clomosy.DBSQLiteQuery.OpenOrExecute;
      
      ShowMessage('Adding data to the table was successful!');
    except
     ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
    }
  }
  
  void SqLiteConnectionCreateTable;
  var
    TableExists: Boolean;
  {
    try
      Clomosy.DBSQLiteConnect(Clomosy.AppFilesPath + 'DBProductSales.db3', '');
 
      // Check if the table exists
      Clomosy.DBSQLiteQuery.Sql.Text = 'SELECT name FROM sqlite_master WHERE type="table" AND name="OperatingSystem";';
      Clomosy.DBSQLiteQuery.OpenOrExecute;
      
      // Check the results
      TableExists = not Clomosy.DBSQLiteQuery.Eof;
      
      // Create the table if it does not exist
      if not (TableExists)
      {
        Clomosy.DBSQLiteQuery.Sql.Text = 'CREATE TABLE OperatingSystem (
                                        	id INTEGER NOT NULL,
                                        	model TEXT NOT NULL,
                                        	operating_system TEXT NOT NULL,
                                        	device_type TEXT NOT NULL,
                                        	sales_figure INTEGER NOT NULL
                                          )';
        Clomosy.DBSQLiteQuery.OpenOrExecute;
        
        ShowMessage('Table successfully added to the database!');
        SqLiteInsertData;
      } else
      {
        ShowMessage('The Products table already exists.');
      }

    except
     ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
    }
  }

  {
    
    MyForm = TclForm.Create(Self);
    MyForm.SetFormColor('#ffffff','#cebade',clGVertical);
    Setup;
    SetCaptionName;
    SetMainView;  
    SqLiteConnectionCreateTable;
    MyForm.Run;
  
  }

Output:

Also See