[Gambas-user] showmodal

Ignatius Syofian isy21 at ...1082...
Wed Dec 21 08:34:37 CET 2005


hi all,

I have another question about calling sub form in gambas.
If i klik gbtn button, then i check password and if ok i call fmainmenu form.
fmainmenu form is my application menu, from here i can choose any transaction 
i want (in example, i can choose create new invoice, create payment etc)

The problem is, if i debug to see what running obj, if found my first file 
fconn (where i use to check password), not close, why ?

If i choose one of my menu in fmainmenu and then i close that subform then i 
not see list of that object again in debug. I think it's ok
But why fconn always show in debug ?. 

I paste the source code here.
maybe i wrong calling mainmenu from gbtn_keypress ?


My Source code of form fconn :

' Gambas class file

PUBLIC SUB Form_Open()
  ME.center
  txtuser.Text=system.User
  label7.text="Your ip address"
  label8.Text=application.Version
END

PUBLIC SUB ginput_KeyPress()
  IF Key.code=Key.enter OR Key.code=Key.return THEN
    SELECT CASE LAST.tag
      CASE 3
           txtpassword.setfocus
        
      CASE 4
           my_connect
    END SELECT
  END IF
END

PUBLIC SUB gbtn_Click()
  My_Connect
  'validation of chg password
END

PUBLIC SUB My_Connect()
  DIM dbname AS String 'Database name
  DIM tbname AS String 'Table name
  DIM htable AS Table

  SELECT CASE LAST.tag
    CASE 1,4  'connect button
      dbname="dolphin"
      tbname="temployee"
      WITH Mglobal
        .btnok="&Yes"
        .btnno="&No"
        'check if the logins corrects or not
        IF .conn(txthost.text, txtuser.text, 
txtpassword.text,txtport.Text)=TRUE THEN
          'create the database and tables if not exist yet
          IF NOT .db.Databases.Exist(dbname) THEN 
            .db.Databases.Add(dbname)
            .db.Close
            .db.Name=dbname
            .db.Open
            'create the tables if it isn't exist yet
            IF NOT .db.Tables.Exist(tbname) THEN
              htable=.db.Tables.Add(tbname)
              htable.Fields.Add("femployee", gb.String, 14)
              htable.Fields.Add("ffullname", gb.String, 35)
              htable.PrimaryKey=["femployee"]
              htable.Update
            END IF
          ELSE
            'use the database
            .db.Close
            .db.Name=dbname
            .db.Open
          END IF
          
          'open system file
          .rs=.db.Exec("select * from taccessoutlet where fuser='" & 
txtuser.Text & "'")
          IF .rs.Count=0 THEN
             'means no access
             RETURN
          ELSE 
             IF .rs.Count=1 THEN 
                'means only 1 outlet allowed
                .sys_myoutlet=.rs!foutlet
             ELSE
                .sys_myoutlet=900 'means more than 1 outlet allowed
             ENDIF 
          ENDIF
          
          'get system parameter
          '1. report path
          .rs=.db.Exec("select * from tparameter where findex=0")
          IF .rs.Count=0 THEN
             .sys_MyReportPath="/home/"
          ELSE
             .sys_MyReportPath=.rs!fparamc1
          ENDIF

          '2. image path
          .rs=.db.Exec("select * from tparameter where findex=1")
          IF .rs.Count=0 THEN
             .sys_MyImagePath="/home/"
          ELSE
             .sys_MyImagePath=.rs!fparamc1
          ENDIF
          
          'update logon date
          .rsTemp=.db.Exec("update tuserlog set flogin=now() where fuser='" & 
txtuser.Text & "'")
          
          ME.close
          Fmainmenu.ShowModal
        
        ELSE
           'login bad
           .rsTemp=.db.Exec("update tuserlog set fbad=now() where fuser='" & 
txtuser.Text & "'")
        END IF
      END WITH

    CASE 2  'cancel button
         ME.close
  END SELECT

CATCH
  Message.Error(Error.Text)
END

-- 
Regards,

Ignatius Syofian




More information about the User mailing list