From Clomosy Docs

Revision as of 13:37, 27 March 2023 by ClomosyManager (talk | contribs) (Created page with "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.<br> 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,...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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;
 When performing SQL operations, you must write your database information in the code section, otherwise the code will not work. 


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

Clomosy.DBSQLServerConnect('SQL Server','server_name','user_name','user_password','database_name',port);

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
    clViewDataQuery :TclSQLQuery;
  begin
      clViewDataQuery:=TclSQLQuery.Create(Nil);
    Try
      clViewDataQuery.Connection := Clomosy.DBSQLServerConnection;
      clViewDataQuery.SQL.Text :='SELECT model AS MAIN_TEXT,operating_system AS SUB_TEXT FROM OperatingSystem WHERE model LIKE '+QuotedStr('%'+searchGuideEdit.text+'%');
     clViewDataQuery.Open;
     mainListviewGuide.clLoadListViewDataFromDataset(clViewDataQuery);
   finally
     clViewDataQuery.Free;
   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:

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 SetupSqlConnection; begin Clomosy.DBSQLServerConnect('SQL Server','server_name','user_name','user_password','database_name',port); end;
procedure Setup; begin vertScrollBoxMain := MyForm.AddNewVertScrollBox(MyForm,'vertScrollBoxMain'); vertScrollBoxMain.Align := alClient;
lytContent:= MyForm.AddNewLayout(vertScrollBoxMain,'lytContent'); lytContent.Align := alTop; lytContent.Height :=700; end;
procedure GuideListView; begin mainListviewGuide := TClListView(MyGuideForm.clFindComponent('FormClListView')); mainListviewGuide.Align := alClient; mainListviewGuide.Visible := True; 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 OnGuideQryClick; var clViewDataQuery :TclSQLQuery; begin clViewDataQuery:=TclSQLQuery.Create(Nil); Try clViewDataQuery.Connection := Clomosy.DBSQLServerConnection; clViewDataQuery.SQL.Text :='SELECT model AS MAIN_TEXT,operating_system AS SUB_TEXT FROM OperatingSystem WHERE model LIKE '+QuotedStr('%'+searchGuideEdit.text+'%'); clViewDataQuery.Open; mainListviewGuide.clLoadListViewDataFromDataset(clViewDataQuery); finally clViewDataQuery.Free; 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;
begin MyForm:=TclForm.Create(Self); MyForm.SetFormColor('#ffffff','#cebade',clGVertical); Setup; SetCaptionName; SetMainView; SetupSqlConnection; MyForm.Run; end;


Output: