Jump to content

CCH4UNIGUI

Members
  • Posts

    44
  • Joined

  • Last visited

Posts posted by CCH4UNIGUI

  1. Just now, CCH4UNIGUI said:

    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;
     

    Solved. Will work on MainForm.OnCreate event

  2. Just now, CCH4UNIGUI said:

    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 

     

     


     

    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. 2 hours ago, Sherzod said:

    Hello,

    In general, your approach is wrong...

    \FMSoft\Framework\uniGUI\Demos\Desktop\LoginForm

    http://unigui.com/doc/online_help/index.html?best-practices.htm

    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 ?

  5. 54 minutes ago, Ron said:

    You should do all the user credentials checking in the login form, so when you close the login form the user is considered authorized and logged in.

    SO there are two ways out of the login form, and you determine that before you leave the form:

    modalResult:=mrOK - user is logged in

    modalResult:=mrCancel - user failed authorization

    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 ?

  6. 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);

     

  7. 56 minutes ago, epos4u said:

    sorry my bad, was half asleep

    cUserName:string;

    cUserName:=trim(UserNameUniEdit.Text)

    EmployeeTable.CommandText:='select * from employee WHERE ID='+cUserName ; 

    you only need quotedtsr()  function if ID is string

     

    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

  8. 23 minutes ago, epos4u said:

    then change cUsername or use cUsernameID as integer

    cUsernameID := StrToIntDef(trim(UserNameUniEdit.Text), 0);

    then EmployeeTable.CommandText:='select * from employee WHERE ID='+ cUserNameID  ;

    will work

     

    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'>
     

  9. 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.

     

  10. 11 hours ago, epos4u said:

    maybe you need to use QuotedStr()  function

    11 hours ago, epos4u said:

    maybe you need to use QuotedStr()  function

     

    EmployeeTable.CommandText:='select * from employee WHERE ID='+ QuotedStr(cUserName) ;

    
    
    
     

    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.

     


  11. 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

  12. 9 hours ago, CCH4UNIGUI said:

    Hi

    1. Installed D10.33 on a new laptop running W10 Pro

    2. Installed Unigui Trial

    Tried to run the All features mdemo

    Error Reading Form: UniServerModule.AutoCoInitialise:Property AutoCoInitialise does not exist

    Cannot proceed any further...

    Please revert ASAP. TQ

     

     

     

     

     

    Solved. Needed to manually build & installed 4 Unigui packages 😉

     

  13. Hi

    1. Installed D10.33 on a new laptop running W10 Pro

    2. Installed Unigui Trial

    Tried to run the All features mdemo

    Error Reading Form: UniServerModule.AutoCoInitialise:Property AutoCoInitialise does not exist

    Cannot proceed any further...

    Please revert ASAP. TQ

     

     

     

     

     

  14. 35 minutes ago, CCH4UNIGUI said:

    Hi Sherzod

    Have already figured that out 

    Have 2 pages

    DbGrid - placed a TUniPanel plus TUniDBGrid

    VertGrid - Unlike Delphi, cannot access this page at design time to place another TUniPanel + TVerticalGrid 

    How can do this ?

    Problem solved by using TUniPageControl instead of TUniTabControl :-)

  15. 15 minutes ago, Sherzod said:

    Hello,

    Use the Tabs property.

    Hi Sherzod

    Have already figured that out 

    Have 2 pages

    DbGrid - placed a TUniPanel plus TUniDBGrid

    VertGrid - Unlike Delphi, cannot access this page at design time to place another TUniPanel + TVerticalGrid 

    How can do this ?

  16. 12 minutes ago, Sherzod said:

    Hello,

    
    procedure TMainForm.NavTreeClick(Sender: TObject);
    var
      Nd : TUniTreeNode;
      Ts : TUniTabSheet;
      FrC : TUniFrameClass;
      Fr : TUniFrame;
      FClassName, Path: string;
    begin
      Path := UniServerModule.StartPath + 'units\';
      Nd := NavTree.Selected;
      if Nd.Count = 0 then
      begin
        Ts := Nd.Data;
        if not Assigned(Ts) then
        begin
          Ts := TUniTabSheet.Create(Self);
          Ts.PageControl := UniPageControl1;
    
          Ts.Closable := True;
          Ts.OnClose := TabSheetClose;
          Ts.Tag := NativeInt(Nd);
          Ts.Caption := Nd.Text;
          Ts.ImageIndex := Nd.ImageIndex;
    
          FClassName := 'TUni' + FileNames.Values[Nd.Text];
    
          FrC := TUniFrameClass(FindClass(FClassName));
    
          Fr := FrC.Create(Self);
          Fr.Align := alClient;
          Fr.Parent := Ts;
    
          Nd.Data := Ts;
        end;
        UniPageControl1.ActivePage := Ts;
      end;
    end;

    ...

    Hi Sherzod

    Thanks for the speedy response :-)

    Is there a much simpler example ?

    Maybe a simple menu or button and upon clicking will launch another form

     

  17. 2 hours ago, CCH4UNIGUI said:

    Hi Farshad

    Recompiled using User Authentication, the result is worse, the expected login prompt does not appear and nothing is loaded.
    FYI, the standalone version displays a login prompt & upon authentication, the UniDBGrid appears with loaded data.

    What's happening ?

    What do I have to do to get the DLL version to work ?

    After 4/5 days of testing the trial, its kind of demoralising  as basic deployment of as simple DLL don't even work.

    Your assistance is most appreciated.

    Thank you.

     

    Its weird, I am now able to deploy localhost/isapi/ess4ua.dll compiled with User Authentication

    ess4wa compiled with Windows Authentication only display a blank UniDBGrid

×
×
  • Create New...