[Gambas-user] File Chooser

Steven Lobbezoo steven at ...1652...
Tue Oct 2 18:28:04 CEST 2007


Of course, here it is.

Steven





Le lundi 1 octobre 2007 20:35, Benoit Minisini a écrit :
> On mardi 25 septembre 2007, Steven Lobbezoo wrote:
> > Hi Benoit,
> >
> > I cannot send you the project, since your mail box does not accept large
> > files ;-) (known problem).
> > But attached is the form and the code.
> > It is called with a showmodal.
> > In the mean time i went back to the previous trunk, and it works just
> > fine now.
> >
> > Kindest regards,
> >
> > Steven
>
> I need a module named "MGlobal". Can you send it to me?
-------------- next part --------------
' Gambas module file

PUBLIC db AS NEW Connection
PUBLIC rs AS Result
PUBLIC rs1 AS Result

PUBLIC btnok AS String
PUBLIC btnno AS String
PUBLIC Connected AS Integer

' the tree fields of the question form
PUBLIC QFld1 AS String
PUBLIC QFld2 AS String
PUBLIC QFld3 AS String

' these fields define the current user !
PUBLIC U_No AS Integer
PUBLIC U_Nom AS String
PUBLIC U_Agency AS Integer
PUBLIC U_AgenNom AS String
PUBLIC U_AgenRep AS String
PUBLIC U_AgenChef AS Integer ' the boss of the person logged in
PUBLIC U_Level AS Integer ' the level code of the person logged in
PUBLIC U_Mail AS String ' the e-mail of the user
PUBLIC U_Cell AS String ' the portable phone number
PUBLIC U_AgenStreet AS String ' the street adress of the agency
PUBLIC U_AgenPlz AS String  ' and the postcode
PUBLIC U_AgenVille AS String  ' and the town
PUBLIC U_AgenFax AS String  ' and the fax number
PUBLIC U_AgenTel AS String  ' and the agency's telephone number

PUBLIC V_Code AS Integer ' the current ville, selected from villes
PUBLIC M_Code AS String ' the current mandat code (new ?)
PUBLIC M_Sel_X AS Integer
PUBLIC M_Sel_Y AS Integer

PUBLIC F_Ch AS NEW String[]

PUBLIC FPath AS String = USER.Home ' the last path of the fileselector, remember this

PUBLIC JobTbl AS NEW Collection ' all Jobs available

PUBLIC Rev_Web AS String ' base path to the revimmo website

PUBLIC ParmsGen AS result ' the resultset of the read general parms

''''''''''''''''''''''''''''''''''
''sub to connect to mysql server''
''''''''''''''''''''''''''''''''''
PUBLIC FUNCTION conn(host AS String, lgn AS String, pass AS String) AS Boolean
  db.close
  db.Type = "mysql"
  Connected = FALSE
  db.Host = Host
  db.Login = lgn
  db.Password = pass
  db.Open
  Connected = TRUE
  RETURN TRUE
CATCH
  Message.error(error.text)
  RETURN FALSE
END

''''''''''''''''''''''''''''''''''''''''
''sub to fill the tableview w/ records''
''''''''''''''''''''''''''''''''''''''''
PUBLIC SUB fill_view(tbv AS GridView, qry AS String)
DIM i AS Float
  rs1 = db.exec(qry)
  WITH rs1
    tbv.rows.count = 0
    IF .count <> 0 THEN
      tbv.columns.count = .fields.count
      tbv.rows.count = .count
    END IF
  END WITH
END

PUBLIC SUB set_jobs()
     Mglobal.JobTbl.Add("1", "Négociatrice")
     Mglobal.JobTbl.Add("2", "Chef d'agence")
     Mglobal.JobTbl.Add("3", "Chef secteur")
     Mglobal.JobTbl.Add("4", "Directeur")
     Mglobal.JobTbl.Add("5", "Suppliant")
     Mglobal.JobTbl.Add("6", "Carte seul")
     Mglobal.JobTbl.Add("7", "Sécretaire")
     Mglobal.JobTbl.Add("8", "Comptable")
     Mglobal.JobTbl.Add("9", "Diverse")
END

PUBLIC FUNCTION MyVal(S AS String) AS Float
  IF S THEN
    RETURN Val(Replace(Replace(Replace(Replace(Replace(S, " ", ""), "€", ""), ")", ""), "(", ""), ".", ","))
  ELSE 
    RETURN 0
  END IF
END 

PUBLIC FUNCTION Authorize(Level AS Integer) AS Integer
  ' we say if someone is authorised (we take the person level from U_.....
  ' There are 3 levels to be asked :
  ' 0: Négociatrices
  ' 1: respnsables agences et sécretaires
  ' 2: direction et compta
  IF Level = 2 THEN 
    IF U_Level = 4 OR U_Level = 8 THEN 
      RETURN TRUE
    ELSE 
      RETURN FALSE
    ENDIF 
  ELSE IF Level = 1 THEN 
    IF (U_Level > 1) AND (U_Level <> 6) AND (U_Level <> 9) THEN 
      RETURN TRUE
    ELSE 
      RETURN FALSE
    ENDIF 
  ELSE IF Level = 0 THEN
    IF U_Level <> 6 AND U_Level <> 9 THEN 
      RETURN TRUE
    ELSE 
      RETURN FALSE
    ENDIF 
  END IF
  RETURN FALSE
END

PUBLIC FUNCTION GetComm(VenteNo AS Integer, Type AS String) AS String[]
  ' we fix the nego, son agence and the comm on a vente
  ' Type can be 'Vente', 'Mandat', 'Chef'

DIM hSql AS String
DIM rSet AS Result
DIM Rstr AS String[3]

  IF Type = "Vente" THEN
    hSql = "SELECT ((Jobs.comven * (Ventes.Comm_Vendue) / 1.196 - (Ifnull(Ded_1, 0) + Ifnull(Ded_2, 0) + Ifnull(Ded_3, 0))) / 100) " & 
          "* Mandats.ComFacteur AS commision, agents.agent as negolala, agences.repertoire as filia FROM Ventes, agents, agences, Jobs, Mandats " &
          "where Ventes.No = " & Str(VenteNo) & " AND Ventes.Commercial = agents.id AND Jobs.Nego = Ventes.Commercial AND " & 
          "Jobs.Start < Ventes.Date AND " &
          "(Jobs.End > Ventes.Date OR Ifnull(Jobs.End, 0) = 0) AND agences.no = Jobs.Filiale AND Mandats.Code = Ventes.Code_Mandat"
  ELSE IF Type = "Mandat" THEN 
  
  ELSE IF Type = "Chef" THEN 
  
  END IF
  rSet = db.Exec(hSql)
  IF rSet.Available THEN 
    Rstr[0] = Format(rSet!Commision, "($,#.##)")
    Rstr[1] = rSet!negolala
    Rstr[2] = rSet!filia
  END IF
  RETURN Rstr
END

PUBLIC FUNCTION getmois(No AS Integer) AS String
DIM tmp AS String
  SELECT CASE No
  CASE 1 
    tmp = "Janvier"  
  CASE 2 
    tmp = "Février"  
  CASE 3 
    tmp = "Mars"  
  CASE 4 
    tmp = "Avril"  
  CASE 5 
    tmp = "Mai"  
  CASE 6 
    tmp = "June"  
  CASE 7 
    tmp = "Juillet"  
  CASE 8 
    tmp = "Aôut"  
  CASE 9 
    tmp = "Septembre"  
  CASE 10 
    tmp = "Octobre"  
  CASE 11 
    tmp = "Novembre"  
  CASE 12 
    tmp = "Décembre"    
  END SELECT
  RETURN tmp
END



More information about the User mailing list