Ver Nuevo Registro Browse

Ver Nuevo Registro Browse

Postby mustafa » Thu Dec 10, 2020 4:42 pm

Hola amigos: :P

Estoy probando FiveTouch

1º - En un Sample con Browse
Establezco Mediante Botones Altas, Modificar y Borrar

Como puedo ver el Nuevo Registro ,
Modificación o borrado al instante al final
del Browse ?

que código puedo utilizar?

2º en un Browse
Code: Select all  Expand view

 @ 30,12 BROWSE oBrw OF oDlgBrw ;
   SIZE 450, 438 ;  
   HEADERS "Id", "Nombre","Telefono","Fecha"  ;
   FIELDS FIELD->USR_ID,FIELD->USR_NAME, ;
   FIELD->USR_TELEF,DTOC(FIELD->USR_DATE)
 


Para ver con 4 Botones el Principio, Retroceso
Avance, Final de este Browse

DbSkip() está dando Error hay otro código ?

principio := oBrw:scrollToTop() //<== Ok
retroceso := DbSkip(-1) // <== Error
avance := DbSkip(+1) // <== Error
final := oBrw:scrollToBottom() //<== Ok

De antemano gracias
Un cordial Saludo
Mustafa
mustafa
 
Posts: 2
Joined: Tue Dec 08, 2020 3:41 pm

Re: Ver Nuevo Registro Browse

Postby Antonio Linares » Thu Dec 10, 2020 5:52 pm

Mustafa,

Nuestro producto mod_harbour supera en mucho a FiveTouch, ya que la misma app funciona en todos los dispositivos:

https://github.com/FiveTechSoft/mod_harbour

Debido a esto, FiveTouch ya no tiene continuidad, además de que depende de QT que cambia constantemente, etc

Si publicas aqui ó me envías por email el PRG que estás probando, lo revisaremos por si podemos ayudarte
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Ver Nuevo Registro Browse

Postby mustafa » Fri Dec 11, 2020 1:44 pm

Gracias Antonio
por tu amable respuesta
El Sample es una modificación de Juan Navas (jnavas)
viewtopic.php?f=33&t=30502

Code: Select all  Expand view


#include "FiveTouch.ch"

#xcommand DEFAULT <uVar1> := <uVal1> ;
[, <uVarN> := <uValN> ] => ;
<uVar1> := If( <uVar1> == nil, <uVal1>, <uVar1> ) ;;
[ <uVarN> := If( <uVarN> == nil, <uValN>, <uVarN> ); ]

*--------------------------------------------------------------------*
* Original Code => jnavas - Juan Navas - Modificado by Mustafa Lopez  
* http://forums.fivetechsupport.com/viewtopic.php?f=33&t=30502
*--------------------------------------------------------------------*

*------------------------------------*
FUNCTION Main()  
*------------------------------------*
LOCAL oBtnCancelJ                                                        
LOCAL aBtnText:={ "  Imcluir  " , " Modificar ","  Eliminar ","   Home   ","   Salir   " }
LOCAL aBtn := ARRAY(LEN(aBtnText))

PRIVATE oDlgBrw,oBrw,oBtn1,oBtn2,oBtn3,oBtn4
PRIVATE aGrid := {}
PUBLIC  CUAN , hCtrl , picxel , picx , idxZ
PUBLIC  idxS , nAmeT , wNum := 0

*------------------------------------*
 
  REQUEST DBFCDX , DBFFPT , DBFDBT
  RDDSETDEFAULT( "DBFCDX" )

  REQUEST HB_CODEPAGE_ESWIN    
  SET( _SET_CODEPAGE ,"ESWIN" )  
  SET DELETE ON
  SET CENTURY ON
  SET DATE FRENCH
  SET DATE FORMAT TO 'dd/mm/yyyy'
*------------------------------------*
  IF ! HB_DirExists( "images")
       DirMake( "images")        
  ENDIF
*------------------------------------*
 FT_CREATE_TABLES()

 USE ("FT_USER.DBF")
 dbGoTop()  
 
 DEFINE DIALOG oDlgBrw TITLE SPACE(05) + "Base Telefonica" ;
 SIZE 715, 570  
 oDlgBrw:setwindowicon( QIcon( ".\images\Eye_Six.png" ) )

 @ 30,12 BROWSE oBrw OF oDlgBrw ;
   SIZE 450, 438 ;  
   HEADERS "Id", "Nombre","Telefono","Fecha"  ;
   FIELDS FIELD->USR_ID,FIELD->USR_NAME,FIELD->USR_TELEF,DTOC(FIELD->USR_DATE)  
 
 @ 0, BCOL(1) BUTTON aBtn[1] PROMPT aBtnText[1] OF oDlgBrw ;
   ACTION FT_EDITUSER(NIL)

 @ 0, BCOL(2) BUTTON aBtn[2] PROMPT aBtnText[2] OF oDlgBrw ;
   ACTION Modificare()  

 @ 0, BCOL(3) BUTTON aBtn[3] PROMPT aBtnText[3] OF oDlgBrw ;
   ACTION DeleClick()

 @ 0, BCOL(4) BUTTON aBtn[4] PROMPT aBtnText[4] OF oDlgBrw ;
   ACTION MsgInfo("          Sample FiveTouch    " + CRLF + CRLF +;
     "Código Original jnavas - Juan Navas   " + CRLF + CRLF +;  
     "Modificado By  Mustafa López " + CRLF + CRLF +;
     "            Diciembre 2020" , "Sample FiveTouch ")

 @ 0, BCOL(5) BUTTON aBtn[5] PROMPT aBtnText[5] OF oDlgBrw ;
   ACTION oDlgBrw:End()
 
 dbGotop()

 IF (FIELD->USR_PIC) > SPACE(1)
  picxel := "./images/"+ SUBSTR( ALLTRIM(FIELD->USR_PIC) ,10,8)
 ELSE
  picxel := "./images/0000.png"
 ENDIF
 
 @ 080, 490 IMAGE hCtrl FILE picxel SIZE 200,200 OF oDlgBrw
 hCtrl:setStyleSheet( "border: 2px solid  White ;" )  

*------------------------------------------------------------*
@  500, 020 BUTTON oBtn1 PROMPT "Primero" OF oDlgBrw ;
   ACTION Inizio( oBrw )   SIZE 90,26

@  500, 130 BUTTON oBtn2 PROMPT "Anterior" OF oDlgBrw ;
   ACTION  MenosUno( oBrw )  SIZE 90,26

@  500, 230 BUTTON oBtn3 PROMPT "Siguiente" OF oDlgBrw ;
   ACTION  MasUno( oBrw) SIZE 90,26

@  500, 330 BUTTON oBtn4 PROMPT "Ultimo" OF oDlgBrw ;
  ACTION Fine( oBrw )  SIZE 90,26

@  340, 544 BUTTON oBtn5 PROMPT "Pic View" OF oDlgBrw ;
  ACTION  PicPlus() SIZE 90,26

*--------------------------------------------------------------*
  USE ("FT_USER.DBF")
  cuan := LASTREC()

  picx:= " Photo Num: " + SUBSTR( FIELD->USR_PIC ,10,8)+ SPACE(2)    

 @ 050, 515 SAY idxZ PROMPT picx  OF oDlgBrw
 idxZ:SetStyleSheet( " background: #F4F4F0; font-size: 13px; font-weight: bold; color: #ff0000;" )

  nAmeT := SPACE(2) + "Id: "+ ALLTRIM( FIELD->USR_ID )+ SPACE(3) +;
 "Name: " +ALLTRIM( FIELD->USR_NAME )+ SPACE(5)
 
@ 300, 494 SAY idxS PROMPT nAmeT OF oDlgBrw
 idxS:SetStyleSheet( " background: #F4F4F0; font-size: 12px; font-weight: bold; color: #ff0000;" )

@ 400, 540 SAY idxQ PROMPT "  Records:   "  + ALLTRIM( STR(cuan)) + SPACE(2) OF oDlgBrw
 idxQ:SetStyleSheet( " background: #F4F4F0; font-size: 13px; font-weight: bold; color: #ff0000;" )

  ACTIVATE DIALOG oDlgBrw CENTERED

CLOSE ALL

RETURN NIL
*--------------------------------------*  
FUNCTION BCOL(nCol)
*--------------------------------------*  
RETURN 81*(nCol-1)+10  

*--------------------------------------*
FUNCTION FT_EDITUSER(cId_User)
*--------------------------------------*
LOCAL oDlg,I,oBtnOk,oBtnCancel
LOCAL oSay:=ARRAY(5)

PRIVATE oId,oName,oTele,oDate,cIdX , oIma, picxely      
PRIVATE cId:=SPACE(03),cName:=SPACE(050),cTele:=SPACE(012),dDate:=DTOC(DATE()),cPic := SPACE(4)
PRIVATE aSay :={"Id" ,"Nombre","Telefono","Fecha","Photo"}
PRIVATE aVars:={"cId","cName" ,"cTele","dDate","cPic"}

IF !Empty(cId_User)
    USE ("FT_USER.DBF")
    dbGoTop()  
    LOCATE FOR FIELD->USR_ID=cId_User
    cId    :=FIELD->USR_ID
    cName  :=FIELD->USR_NAME
    cTele  :=FIELD->USR_TELEF
    dDate  :=CTOD(FIELD->USR_DATE)
    cPic   :=FIELD->USR_PIC            
ENDIF

DEFINE DIALOG oDlg TITLE "Crear Nuevo Usuario" ;
SIZE 330, 220    

FOR I =1 TO LEN(aSay)
@ CROW(I),15 SAY oSay[I] PROMPT aSay[I] OF oDlg
NEXT I

USE FT_USER
dbGoBottom()

cIdX := VAL(FT_USER->USR_ID) + 1
cId  := ALLTRIM(STR(cIdX))

@ CROW(1),065 GET oId VAR cId OF oDlg
oId:setFixedSize(30,24)


@ CROW(2),065 GET oName VAR cName OF oDlg
oName:setFixedSize(120,24)

@ CROW(3),065 GET oTele VAR cTele OF oDlg
oTele:setFixedSize(120,24)
oTele:setInputMask("999999999999")

@ CROW(4),065 GET oDate VAR dDate OF oDlg
oDate:setFixedSize(80,24)
oDate:setInputMask("00/00/0000")

cPic := "0000"
@ CROW(5),065 GET oPic VAR cPic OF oDlg
oPic:setFixedSize(120,24)
oPic:setInputMask("9999")

 picxely := "./images/" + "camara2.png"  
 
 @ CROW(1)+06,208 IMAGE oIma FILE picxely SIZE 100,086 OF oDlg
 oIma:setStyleSheet( "border: 2px solid  White ;" )

@ CROW(5)-07 , 220 BUTTON oBtnPho PROMPT "   Photo  " OF oDlg ;
ACTION SelePhoto()

@ CROW(6)+ 10 , 110 BUTTON oBtnOk PROMPT "Ok" OF oDlg ;
ACTION FT_SAVEUSR(oDlg)

@ CROW(6)+10 ,200 BUTTON oBtnCancel PROMPT "Cancel" OF oDlg ;
ACTION oDlg:End()

ACTIVATE DIALOG oDlg CENTERED

Return nil

*--------------------------------*
FUNCTION SelePhoto()
*--------------------------------*

   LOCAL oFileDialog, cListOfFiles, cFileName

   oFileDialog  := QFileDialog()
   oFileDialog:exec()
   cListOfFiles := oFileDialog:selectedFiles()
   cFileName    := cListOfFiles:At( 0 )
   oIma:SetPixmap( QPixmap( cFileName ) )
   oIma:resize(100,086)
*------------------------------------------------------------------------*
   ficherAaX := RIGHT( cFileName , LEN(cFileName) - RAT("\", cFileName ))
   Nuevo0    := LEFT (ficherAaX, LEN( ficherAaX ) - 4 )
   Nuevo1    := SUBSTR(Nuevo0,-4)
*------------------------------------------------------------------------*
   oPic:setInputMask( Nuevo1 )

Return Nil

*------------------------------------*
FUNCTION Modificare()
*------------------------------------*
 LOCAL mirux
 LOCAL idx,nam,tel ,dat

 oBrw:currentIndex(1):row()       //<== Indica Numero de la Linea
 mirux := oBrw:currentIndex(1):row()

 USE ("
FT_USER.DBF")
 GoTo mirux + 1

 cId   := ALLTRIM(FT_USER->USR_ID)
 cName := ALLTRIM(FT_USER->USR_NAME)
 cTele := ALLTRIM(FT_USER->USR_TELEF)
 dDate := DTOC(FT_USER->USR_DATE)    
 cPic  := SUBSTR( ALLTRIM(FT_USER->USR_PIC) , 10, 4)  
 
 DEFINE DIALOG oDlg TITLE "
Modificar Usuario  => Id: " +SPACE(2)+ cId ;
    SIZE 330, 220      

  @ CROW(1),15 SAY idx PROMPT "
Id"       OF oDlg
  @ CROW(2),15 SAY nam PROMPT "
Nombre"   OF oDlg
  @ CROW(3),15 SAY tel PROMPT "
Telefono" OF oDlg
  @ CROW(4),15 SAY dat PROMPT "
Fecha"    OF oDlg
  @ CROW(5),15 SAY dat PROMPT "
Photo"    OF oDlg

  @ CROW(1),065 GET oId VAR cId OF oDlg
    oId:setFixedSize(30,24)
 
  @ CROW(2),065 GET oName VAR cName OF oDlg
    oName:setFixedSize(120,24)
 
  @ CROW(3),065 GET oTele VAR cTele OF oDlg
    oTele:setFixedSize(120,24)
    oTele:setInputMask("
999999999999")

  @ CROW(4),065 GET oDate VAR dDate OF oDlg
    oDate:setFixedSize(80,24)
    oDate:setInputMask("
00/00/0000")

  @ CROW(5),065 GET oPic VAR cPic OF oDlg
    oPic:setFixedSize(120,24)
    oPic:setInputMask("
9999")

  picxely := "
./images/" + "camara2.png"  
 
  @ CROW(1)+06,208 IMAGE oIma FILE picxely SIZE 100,086 OF oDlg
    oIma:setStyleSheet( "
border: 2px solid  White ;" )

  @ CROW(5)-07 , 220 BUTTON oBtnPho PROMPT "
  Photo  " OF oDlg ;
    ACTION SelePhotoM()

  @ CROW(6)+ 10 , 110 BUTTON oBtnOk PROMPT "
Ok" OF oDlg ;
    ACTION FT_SAVEMO(oDlg)  

  @ CROW(6)+10 ,200 BUTTON oBtnCancel PROMPT "
Cancel" OF oDlg ;
    ACTION oDlg:End()

  ACTIVATE DIALOG oDlg CENTERED
 
Return nil
*--------------------------------*
FUNCTION SelePhotoM
*--------------------------------*

   LOCAL oFileDialog, cListOfFiles, cFileName

   oFileDialog  := QFileDialog()
   oFileDialog:exec()
   cListOfFiles := oFileDialog:selectedFiles()
   cFileName    := cListOfFiles:At( 0 )
   oIma:SetPixmap( QPixmap( cFileName ) )
   oIma:resize(100,086)
*------------------------------------------------------------------------*
   ficherAaX := RIGHT( cFileName , LEN(cFileName) - RAT("
\", cFileName ))
   Nuevo0    := LEFT (ficherAaX, LEN( ficherAaX ) - 4 )
   Nuevo1    := SUBSTR(Nuevo0,-4)
*------------------------------------------------------------------------*
   oPic:setInputMask( Nuevo1 )

Return Nil

*--------------------------------------*  
FUNCTION DeleClick()
*--------------------------------------*

  LOCAL vRecno := FT_USER->USR_ID  
  LOCAL miru

  oBrw:currentIndex(1):row()       //<== Indica Numero de la Linea
  miru := oBrw:currentIndex(1):row()

  USE ("
FT_USER.DBF")

  GoTo miru +1
 
  IF MSGYESNO( "
Delete This Record?"   + CRLF + CRLF +;
     "
Code:       " + ALLTRIM(FT_USER->USR_ID)+ CRLF +;
     "
Name:       " + ALLTRIM(FT_USER->USR_NAME) , "Confirmation" )
     DELETE
     PACK
     SKIP -1
  ENDIF
 
   
  FT_CREATE_TABLES()

  Fine( oBrw )
 
   RETURN NIL
   
*------------------------------------*
FUNCTION CROW(nRow)
*------------------------------------*
RETURN 30*(nRow-1)+20

 
*------------------------------------*
/*
// Guardar Registro
*/
*------------------------------------*
FUNCTION FT_SAVEUSR(oDlg)
*------------------------------------*
 LOCAL cMsg:="
",i,uValue

  FOR I=1 TO LEN(aVars)
    IF Empty(&(aVars[I]))
       cMsg:=cMsg+IF(Empty(cMsg),"
",CRLF)+aSay[I]
    ENDIF
  NEXT I

  IF !Empty(cMsg)
      MsgInfo(cMsg,"
Falta campo(s)")
      RETURN .F.
  ENDIF

 USE ("
FT_USER.DBF")
 dbGoTop()  

 LOCATE FOR FIELD->USR_ID=cId

  IF !FOUND()
      dbAppend()  
  ENDIF

 REPLACE FIELD->USR_ID     WITH cId
 REPLACE FIELD->USR_NAME   WITH ALLTRIM(UPPER(cName))
 REPLACE FIELD->USR_TELEF  WITH ALLTRIM(cTele)
 REPLACE FIELD->USR_DATE   WITH CTOD(dDate)
 REPLACE FIELD->USR_PIC    WITH  "
./images/" + ALLTRIM(cPic) + ".png"

 COMMIT
 FT_CREATE_TABLES()
 
 Inizio( oBrw )
 Fine( oBrw )

 SysRefresh()   

 oBrw:SetFocus()
 oDlg:End()

RETURN NIL

*------------------------------------*
FUNCTION FT_SAVEMO(oDlg)
*------------------------------------*

 REPLACE FIELD->USR_ID     WITH cId
 REPLACE FIELD->USR_NAME   WITH ALLTRIM(UPPER(cName))
 REPLACE FIELD->USR_TELEF  WITH ALLTRIM(cTele)
 REPLACE FIELD->USR_DATE   WITH CTOD(dDate)
 REPLACE FIELD->USR_PIC    WITH "
./images/" + ALLTRIM(cPic) + ".png"

 COMMIT
 
 FT_CREATE_TABLES()
 
 Fine( oBrw )

 SysRefresh()   
 oBrw:SetFocus()
 oDlg:End()

RETURN NIL


*------------------------------------*
FUNCTION FT_CREATE_TABLES()
*------------------------------------*
LOCAL I
LOCAL aTables:={}
LOCAL aStruct:={}
LOCAL aIndex :={}

AADD(aStruct,{"
USR_ID"    ,"C",003,0})
AADD(aStruct,{"
USR_NAME"  ,"C",030,0})
AADD(aStruct,{"
USR_TELEF" ,"C",012,0})
AADD(aStruct,{"
USR_DATE"  ,"D",008,0})
AADD(aStruct,{"
USR_PIC"   ,"C",017,0})

AADD(aTables,{"
FT_USER.DBF",aStruct,aIndex})

  FOR I=1 TO LEN(aTables)
      IF !FILE(aTables[I,1])
          dbcreate(aTables[I,1],aTables[I,2])
          dbCloseall()
          USE ("
FT_USER.DBF")
          dbAppend()
          REPLACE FIELD->USR_ID     WITH "
1"
          REPLACE FIELD->USR_NAME   WITH ALLTRIM(UPPER("
LOPEZ , MUSTAFA"))
          REPLACE FIELD->USR_TELEF  WITH ALLTRIM("
123456789")
          REPLACE FIELD->USR_DATE   WITH DATE()  
          REPLACE FIELD->USR_PIC    WITH "
./images/0000.png"
      ENDIF
  NEXT I

RETURN NIL


* --- Posizione Top del Browse
*------------------------------------*
FUNCTION Inizio( oBrw )   // Ok
*------------------------------------*
 oBrw:scrollToTop()
 PicPlus()
 oBrw:setFocus()
RETURN NIL

*------------------------------------*
FUNCTION MenosUno( oBrw )
*------------------------------------*

 dbSkip(-1)

 hCtrl:SetPixmap( QPixmap( AllTrim(FIELD->USR_PIC ) ) )
 picx:= "
Photo Num: " + SUBSTR( FIELD->USR_PIC ,10,8)+ SPACE(2)  
 idxZ:setText( picx )

 nAmeT := SPACE(2) + "
Id: "+ ALLTRIM( FIELD->USR_ID )+ SPACE(3) +;
  "
Name: " +ALLTRIM( FIELD->USR_NAME )+ SPACE(5)

  idxS:setText( nAmeT )
  oBrw:setFocus()

RETURN NIL

*------------------------------------*
FUNCTION MasUno( oBrw )
*------------------------------------*

 dbSkip(+1)
 
 hCtrl:SetPixmap( QPixmap( AllTrim(FIELD->USR_PIC ) ) )
 picx:= "
Photo Num: " + SUBSTR( FIELD->USR_PIC ,10,8)+ SPACE(2)  
 idxZ:setText( picx )

  nAmeT := SPACE(2) + "
Id: "+ ALLTRIM( FIELD->USR_ID )+ SPACE(3) +;
  "
Name: " +ALLTRIM( FIELD->USR_NAME )+ SPACE(5)

  idxS:setText( nAmeT )
  oBrw:setFocus()

RETURN NIL

* --- Posizione Bottom del Browse
*------------------------------------*
FUNCTION Fine( oBrw )      //Ok
*------------------------------------*
 oBrw:scrollToBottom()
 PicPlus()
 oBrw:setFocus()
RETURN NIL

*---------------------------------------------------------*
FUNCTION PicPlus()
*---------------------------------------------------------*
 oBrw:currentIndex(1):row()      
 wNum := oBrw:currentIndex(1):row()

 USE ("
FT_USER.DBF")
 GoTo  wNum + 1
 picxel := ALLTRIM(FIELD->USR_PIC )
 picx:= "
Photo Num: " + SUBSTR( FIELD->USR_PIC ,10,8)+ SPACE(2)  

 hCtrl:SetPixmap( QPixmap( picxel):Scaled( 200,200 ) )
 
 idxZ:setText( picx  )

  nAmeT := SPACE(2) + "
Id: "+ ALLTRIM( FIELD->USR_ID )+ SPACE(3) +;
  "
Name: " +ALLTRIM( FIELD->USR_NAME )+ SPACE(5)
 
  idxS:setText( nAmeT )
 
Return Nil

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
 


PD: las Fotos dentro Carpeta ./images/ son Fotos con formato png de 200 x 200 ejemplo => 0001.png

Pantallazo y Sample en :
https://hmgsamples.wordpress.com/

Teneís todo el Sample con las Imágenes en:
https://www.mediafire.com/file/spv5xy46 ... h.zip/file

Solo quería saber las dos preguntas anteriores

Como actualizar Pantalla cuando ingreso, Nuevo Registro, Modifico , Borro
es decir que se vea al Instante en el Browse

Cuando avanzo o retrocedo en el Browse no se ve los saltos de Registros

Un saludo
Mustafa
mustafa
 
Posts: 2
Joined: Tue Dec 08, 2020 3:41 pm


Return to FiveTouch

Who is online

Users browsing this forum: No registered users and 4 guests