Jump to content

CCH4UNIGUI

Members
  • Posts

    44
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

CCH4UNIGUI's Achievements

Newbie

Newbie (1/4)

0

Reputation

  1. Solved. Will work on MainForm.OnCreate event
  2. FYI, actual codes procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject); begin EmployeeTable.Active:=False; //opened but no data EmployeeTable.CommandText:='select * from employee WHERE ID='''+ cUserName+'''' ; //works perfectly EmployeeTable.CommandText:='select * from employee WHERE ID='''+ '8180'+'''' ; //opened but no data EmployeeTable.CommandText:='select * from employee WHERE ID='+QuotedStr(cUsername) ; EmployeeTable.CommandText:='select * from employee WHERE ID='+cUsername ; EmployeeTable.Active:=True; end;
  3. Hi Sherzod In MainModule: EmployeeTable.CommandText:='select * from employee WHERE ID='''+ '8180'+'''' <Works perfectly ie EmployeeTable opens and only data where id=8180 is shown> In LoginForm: UniMainModule.cUsername:=UserNameUniEdit.Text; <input as 8180 & value verified in MainForm as 8180> <cUsername declared as public in MainModule> Problem in MainModule EmployeeTable.CommandText:='select * from employee WHERE ID='''+ cUserName+'''' <EmployeeTable opens with no data> EmployeeTable.CommandText:='select * from employee WHERE ID='QutotedStr(cUserName) <EmployeeTable opens with no data> EmployeeTable.CommandText:='select * from employee WHERE ID=cUserName <EmployeeTable does not open at all> Can someone assist in correcting the CommandText syntax
  4. TQ. Have used a TUnilabel.caption on MainForm to verify the cUserId input.
  5. Hi Sherzod I understand the concept in the LoginForm but what I want to do is simple. Once logged in, I want to use the User ID to be used to filter to only show data belonging to the logged in UserId. How do I do that ?
  6. Hi Ron I understand the concept as above but what I want to do is simple. Once logged in, I want to use the User ID to be used to filter to only show data belonging to the logged in UserId. How do I do that ?
  7. Hi Farshad/Sherzod 1. Started new project 2. Added LoginForm via Unigui Wizard 3. Added UniEdit1: TUniEdit; 4. Declared cUserID: string as public 5. Input UniEdit1.Text=8180 in Login Form 5. cUserID:=trim(UniEdit1.Text) ; 6. Press OK to proceed to MainForm 7. ShowMessage( cUserID) in MainForm shows no value (expect to see 8180) Q. Why is public variable cUserID not visible in MainForm ? How can I make public variable cUserID visible in MainForm ? Actual Project Codes unit Login; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, uniGUITypes, uniGUIAbstractClasses, uniGUIClasses, uniGUIRegClasses, uniGUIForm, uniButton, uniEdit, uniPanel, uniGUIBaseClasses, uniLabel, Data.DB, Data.Win.ADODB; type TUniLoginForm1 = class(TUniLoginForm) UniLabel1: TUniLabel; UniLabel2: TUniLabel; UniPanel1: TUniPanel; UniEdit1: TUniEdit; UniEdit2: TUniEdit; UniButton1: TUniButton; UniButton2: TUniButton; procedure UniButton1Click(Sender: TObject); procedure UniButton2Click(Sender: TObject); private { Private declarations } public { Public declarations } cUserID:string ; end; function UniLoginForm1: TUniLoginForm1; implementation {$R *.dfm} uses uniGUIVars, MainModule, uniGUIApplication, Main; function UniLoginForm1: TUniLoginForm1; begin Result := TUniLoginForm1(UniMainModule.GetFormInstance(TUniLoginForm1)); end; procedure TUniLoginForm1.UniButton1Click(Sender: TObject); begin cUserID:=trim(UniEdit1.Text) ; //showmessage(cUserID) ; ModalResult := mrOK; end; procedure TUniLoginForm1.UniButton2Click(Sender: TObject); begin ModalResult := mrCancel; end; initialization RegisterAppFormClass(TUniLoginForm1); unit Main; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, uniGUITypes, uniGUIAbstractClasses, uniGUIClasses, uniGUIRegClasses, uniGUIForm, uniGUIBaseClasses, uniBasicGrid, uniDBGrid, Data.DB, Data.Win.ADODB; type TMainForm = class(TUniForm) UniDBGrid1: TUniDBGrid; EmployeeDS: TDataSource; EmployeeTable: TADODataSet; ADOConnection1: TADOConnection; procedure UniFormCreate(Sender: TObject); private { Private declarations } public { Public declarations } cUserID:string; end; function MainForm: TMainForm; implementation {$R *.dfm} uses uniGUIVars, MainModule, uniGUIApplication, Unit1, Login; function MainForm: TMainForm; begin Result := TMainForm(UniMainModule.GetFormInstance(TMainForm)); end; procedure TMainForm.UniFormCreate(Sender: TObject); begin EmployeeTable.Active:=False; showmessage(cUserid); //Blank value shown EmployeeTable.CommandText:='select * from employee where id=8180'; //EmployeeTable.CommandText:='select * from employee where id='+QuotedStr(cUserId); EmployeeTable.Active:=True; end; initialization RegisterAppFormClass(TMainForm);
  8. There is nothing wrong with your suggested SQL syntax, I have identified the problem. The basic problem is that cUserName:=trim(UserNameUniEdit.Text) in the UniLoginForm , though declared as public is NEVER passed to Main.pass
  9. public { Public declarations } cUserName:string; cUserNameID:integer; cUsernameID:=StrToIntDef(trim(UserNameUniEdit.Text),0) ; <compile ok> EmployeeTable.CommandText:='select * from employee WHERE ID='+cUsernameID ; <D10.3.3 complains incompatible types 'string ' and 'integer'>
  10. Hi U are right, id is integer. But cUsername:=trim(UserNameUniEdit.Text);
  11. Hi Sherzod I have a simple login form created via Uniform Form wizard and 1. assign as public cUsername:string 2. cUsername:=trim(UserNameUniEdit.Text); eg 8180 I checked the value via showmessage at LoginForm and confirm as 8180 But I suspect that though declared as public in both loginForm & MainModule, cUserName is no longer 8180 at MainModule Q. How can I check the value of cUserName at MainModule as showmessage don't work there Please revert. TQ Actual Codes unit login; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, uniGUITypes, uniGUIAbstractClasses, uniGUIClasses, uniGUIRegClasses, uniGUIForm, uniButton, uniPanel, uniEdit, uniGUIBaseClasses, uniLabel; type TUniLoginForm1 = class(TUniLoginForm) UniLabel1: TUniLabel; UserNameUniEdit: TUniEdit; UniLabel2: TUniLabel; UniEdit2: TUniEdit; UniPanel1: TUniPanel; OKUniBtn: TUniButton; CancelUniBtn: TUniButton; procedure CancelUniBtnClick(Sender: TObject); procedure OKUniBtnClick(Sender: TObject); private { Private declarations } public { Public declarations } cUserName:string; end; function UniLoginForm1: TUniLoginForm1; implementation {$R *.dfm} uses uniGUIVars, MainModule, uniGUIApplication, Unit1; function UniLoginForm1: TUniLoginForm1; begin Result := TUniLoginForm1(UniMainModule.GetFormInstance(TUniLoginForm1)); end; procedure TUniLoginForm1.CancelUniBtnClick(Sender: TObject); begin ModalResult := mrCancel; end; procedure TUniLoginForm1.OKUniBtnClick(Sender: TObject); begin cUsername:=trim(UserNameUniEdit.Text); showmessage(cUsername); // ModalResult := mrOK; end; initialization RegisterAppFormClass(TUniLoginForm1); cUserName, declared public = employee id unit MainModule; interface uses uniGUIMainModule, SysUtils, Classes, Data.DB, Data.Win.ADODB; type TUniMainModule = class(TUniGUIMainModule) PlanOTTable: TADODataSet; PlanotDS: TDataSource; BaldatTable: TADODataSet; HrmcodepTable: TADODataSet; TmsdataTable: TADODataSet; LeavedatTable: TADODataSet; HrmdatTable: TADODataSet; EmployeeTable: TADODataSet; ADOConnection1: TADOConnection; HrmcodepDS: TDataSource; TmsdataDS: TDataSource; BaldatDS: TDataSource; LeavedatDS: TDataSource; HrmdatDS: TDataSource; EmployeeDS: TDataSource; procedure UniGUIMainModuleCreate(Sender: TObject); private { Private declarations } public { Public declarations } cUserName:string; end; function UniMainModule: TUniMainModule; implementation {$R *.dfm} uses UniGUIVars, ServerModule, uniGUIApplication, login; function UniMainModule: TUniMainModule; begin Result := TUniMainModule(UniApplication.UniMainModule) end; procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject); begin // // cUserName seems to be empty EmployeeTable.CommandText:='select * from employee WHERE ID='''+ cUserName+'''' ; EmployeeTable.CommandText:='select * from employee WHERE ID='''+ '8180'+'''' ; EmployeeTable.Active:=True; end; initialization RegisterMainModuleClass(TUniMainModule); end.
  12. EmployeeTable.CommandText:='select * from employee WHERE ID='+ QuotedStr(cUserName) ; Hi epos4u Can compile but have same effect as EmployeeTable.CommandText:='select * from employee WHERE ID='''+ cUserName+'''' ; ie EmployeeTable opens but no data shown. Beginning to suspect the value of cUserName is not 8180 though 8180 is input Can compile but have the same effect as Thanks for the speedy response.
  13. Hi Ron Your suggestion can compile but the Employeetable is not opened at all 😞
  14. I have a simple login form created via Uniform Form wizard unit login; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, uniGUITypes, uniGUIAbstractClasses, uniGUIClasses, uniGUIRegClasses, uniGUIForm, uniButton, uniPanel, uniEdit, uniGUIBaseClasses, uniLabel; type TUniLoginForm1 = class(TUniLoginForm) UniLabel1: TUniLabel; UserNameUniEdit: TUniEdit; UniLabel2: TUniLabel; UniEdit2: TUniEdit; UniPanel1: TUniPanel; OKUniBtn: TUniButton; CancelUniBtn: TUniButton; procedure CancelUniBtnClick(Sender: TObject); procedure OKUniBtnClick(Sender: TObject); private { Private declarations } public { Public declarations } cUserName:string; end; function UniLoginForm1: TUniLoginForm1; implementation {$R *.dfm} uses uniGUIVars, MainModule, uniGUIApplication, Unit1; function UniLoginForm1: TUniLoginForm1; begin Result := TUniLoginForm1(UniMainModule.GetFormInstance(TUniLoginForm1)); end; procedure TUniLoginForm1.CancelUniBtnClick(Sender: TObject); begin ModalResult := mrCancel; end; procedure TUniLoginForm1.OKUniBtnClick(Sender: TObject); begin cUsername:=trim(UserNameUniEdit.Text); showmessage(cUsername); // ModalResult := mrOK; end; initialization RegisterAppFormClass(TUniLoginForm1); cUserName, declared public = employee id unit MainModule; interface uses uniGUIMainModule, SysUtils, Classes, Data.DB, Data.Win.ADODB; type TUniMainModule = class(TUniGUIMainModule) PlanOTTable: TADODataSet; PlanotDS: TDataSource; BaldatTable: TADODataSet; HrmcodepTable: TADODataSet; TmsdataTable: TADODataSet; LeavedatTable: TADODataSet; HrmdatTable: TADODataSet; EmployeeTable: TADODataSet; ADOConnection1: TADOConnection; HrmcodepDS: TDataSource; TmsdataDS: TDataSource; BaldatDS: TDataSource; LeavedatDS: TDataSource; HrmdatDS: TDataSource; EmployeeDS: TDataSource; procedure UniGUIMainModuleCreate(Sender: TObject); private { Private declarations } public { Public declarations } cUserName:string; end; function UniMainModule: TUniMainModule; implementation {$R *.dfm} uses UniGUIVars, ServerModule, uniGUIApplication, login; function UniMainModule: TUniMainModule; begin Result := TUniMainModule(UniApplication.UniMainModule) end; procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject); begin // // cUserName seems to be empty EmployeeTable.CommandText:='select * from employee WHERE ID='''+ cUserName+'''' ; EmployeeTable.CommandText:='select * from employee WHERE ID='''+ '8180'+'''' ; EmployeeTable.Active:=True; end; initialization RegisterMainModuleClass(TUniMainModule); end. Please note cUserName=8180 cUsername:=trim(UserNameUniEdit.Text); BUT this commandtext dont't work EmployeeTable.CommandText:='select * from employee WHERE ID='''+ cUserName+'''' ; don't work at all, no data shown But, it hardcode '8180' as in:- EmployeeTable.CommandText:='select * from employee WHERE ID='''+ '8180'+'''' ; WORKS perfectly Can anyone assist ? TQ
×
×
  • Create New...