Page 1 of 1

Consulta Urgente Sobre DTPICKER u Otro Canlendario

PostPosted: Sun Dec 09, 2018 6:32 pm
by remtec
Amigos

Muy buenas tardes.

Nuevamente necesito de su ayuda.

Como puedo mandan a llenar un Xbrowse, con la fecha seleccionada en DTPICKER, necesito que al seleccionar una fecha, pueda ir a un Function, en la que se valida si existen datos y luego llenar un Xbrowse. He tratado de hacerlo con Valid y ON CHANGE, y no logro dar con la forma correcta.
He revisado en el Foro, pero no he encontrado nada como lo que necesito.

Desde ya muy agradecido.

Muchos Saludos.

Antonio.

Re: Consulta Urgente Sobre DTPICKER u Otro Canlendario

PostPosted: Mon Dec 10, 2018 4:58 pm
by remtec
Amigos

Alguna sugerencia, estoy un poco complicado, ya que no quieren solo un get que pida que se digite la fecha, necesito que se selecione una fecha del calendario, vaya a una funcion a cargar datos y luego mostrar en el Xbrowse.

Saludos.

Antonio

Re: Consulta Urgente Sobre DTPICKER u Otro Canlendario

PostPosted: Mon Dec 10, 2018 6:04 pm
by karinha
Image

Re: Consulta Urgente Sobre DTPICKER u Otro Canlendario

PostPosted: Mon Dec 10, 2018 6:06 pm
by karinha
Code: Select all  Expand view

#include "fivewin.ch"

static dDate, dBOM, dOffSet
static nMonth, cMonth, nYear
static oBrw, oDate

//----------------------------------------------------------------------------//

function Main()

   local oDlg, oFont, oFontD, oCbx, d
   local aMth[ 12 ]
   local aWeek[ 7 ], oGet3

   SET CENTURY ON
   // SET DATE ITALIAN
   SET DATE BRIT

   AEval( aMth,  { |c,i| aMth[ i ]  := NToCMonth( i ) } )
   AEval( aWeek, { |c,i| aWeek[ i ] := Left( NToCDOW( i ), 3 ) } )

   SetDate( dDate := Date() )

   DEFINE FONT oFont  NAME "Segoe UI" SIZE 0,-20
   DEFINE FONT oFontD NAME "COPPERPLATE GOTHIC BOLD" SIZE 0,-36

   DEFINE DIALOG oDlg SIZE 542,490 PIXEL TRUEPIXEL ;
      FONT oFont TITLE "CALENDAR WITH XBROWSE"

   @ 20, 20 COMBOBOX oCbx VAR nMonth ITEMS aMth SIZE 150,300 PIXEL OF oDlg UPDATE ;
      ON CHANGE ResetCal()

   @ 20,200 GET nYear PICTURE "9999" SIZE 100,34 PIXEL OF oDlg UPDATE ;
      SPINNER MAX 2999 MIN 1900 ;
      ON CHANGE ReSetCal()

   /*
   @ 20,380 GET oDate VAR dDate SIZE 120,34 PIXEL OF oDlg ;
      SPINNER ;
      ; //ON CHANGE SetDate( dDate ) ;
      VALID     SetDate( dDate )
   */


   @ 20,330 GET oDate VAR dDate SIZE 190, 34 PIXEL OF oDlg ;
      BITMAP "..\bitmaps\chkyes.bmp"                       ;
      ACTION( CAMBIA_ACION() )  // SPINNER

   oDate:lBtnTransparent := .t.       // transparent button get oDate
   oDate:lAdjustBtn      := .t.       // Button Get Adjust Witdh oDate
   oDate:lDisColors      := .f.       // Deactive disable color
   oDate:nClrTextDis     := CLR_WHITE // Color text disable status
   oDate:nClrPaneDis     := CLR_BLUE  // Color Pane disable status

   @ 60,20 XBROWSE oBrw SIZE 502,-20 PIXEL OF oDlg ;
      DATASOURCE Array( 6 ) COLUMNS 1,2,3,4,5,6,7 ;
      HEADERS aWeek ;
      NOBORDER

   AEval( oBrw:aCols, { |o| SetupCol( o ) } )

   WITH OBJECT oBrw
      :lRecordSelector  := .f.
      :lHScroll      := .f.
      :lVScroll      := .f.
      :lDisplayZeros := .f.
      :lColChangeNotify := .t.
      :nRowHeight    := 60
      :nwidths       := 70
      :nRowDividerStyle := ;
      :nColDividerStyle := LINESTYLE_LIGHTGRAY
      :oDataFonts    := oFontD
      :nDataStrAligns:= AL_CENTER
      :bChange       := { || dDate := dOffSet + oBrw:nColSel + 7 * ( oBrw:nRowSel - 1 ), oDate:Refresh() }
      //
      :CreateFromCode()
   END

   oDlg:bStart := { || SetDate( dDate ) }

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont, oFontD

return nil

FUNCTION CAMBIA_ACION()

  ? "que desea hacer en argentina? "

RETURN( .T. )

function SetUpCol( oCol )

   local nClrPane := oCol:oBrw:oWnd:nClrPane

   oCol:bEditValue   := { || dOffSet + 7 * ( oCol:oBrw:nArrayAt - 1 ) + oCol:nArrayCol }
   oCol:bStrData     := { |x,o| DAY( o:Value ) }
   if oCol:nArrayCol == 1
      oCol:bClrStd   := { || If( MONTH( oCol:Value ) == nMonth, { CLR_HRED, CLR_WHITE }, ;
                                 {  CLR_HGRAY, nClrPane  } ) }
      oCol:bClrHeader:= { || { CLR_HRED, CLR_WHITE } }
   else
      oCol:bClrStd   := { || If( MONTH( oCol:Value ) == nMonth, { CLR_BLACK, CLR_WHITE }, ;
                                 { CLR_HGRAY, nClrPane } ) }
   endif

return nil

function SetDate( dDate )

   local nDays, nRow, nCol, nLen

   if dBOM != BOM( dDate )
      dBOM     := BOM( dDate )
      dOffSet  := dBOM - DOW( dBOM )
      nMonth   := Month(  dDate )
      cMonth   := CMONTH( dDate )
      nYear    := Year(   dDate )
   endif

   if oBrw != nil
      nDays    := dDate - dOffSet
      nRow     := Int( nDays / 7 ) + 1
      if ( nCol := nDays % 7 ) == 0
         nCol  := 7
         nRow--
      endif
      WITH OBJECT oBrw
         :nRowSel    := ;
         :nArrayAt   := nRow
         :nColSel    := nCol
         nLen        := Ceiling( ( EOM( dDate ) - dOffSet ) / 7 )
         :bKeyCount  := { || nLen }
         :Refresh()
         :oWnd:Update()
         :SetFocus()
      END
   endif

return .t.

function ResetCal()

   local dNewDate := STOD( STRZERO( nYear, 4 ) + STRZERO( nMonth, 2 ) + "01" )

   dDate    := dNewDate + MIN( DAY( dDate ), LASTDAYOM( dNewDate ) ) - 1
   oDate:Refresh()
   SetDate( dDate )

return .t.
 

Re: Consulta Urgente Sobre DTPICKER u Otro Canlendario

PostPosted: Mon Dec 10, 2018 6:09 pm
by karinha

Re: Consulta Urgente Sobre DTPICKER u Otro Canlendario

PostPosted: Mon Dec 10, 2018 6:37 pm
by remtec
Karinha

Maestro, como siempre presente, muchas gracias por tu respuesta.

Probare y te comento.

Muchos Saludos.

Antonio.

Re: Consulta Urgente Sobre DTPICKER u Otro Canlendario

PostPosted: Tue Dec 11, 2018 12:22 am
by remtec
Hola Karinha

Trate de compilar, pero arrojo un error, creo que me falta alguna libreria.

Muchos Saludos

Antonio

Code: Select all  Expand view

c:\util\bcc73\bin\ilink32 -Gn -aa -Tpe -s -v @b32.bc
Turbo Incremental Link 6.80 Copyright (c) 1997-2017 Embarcadero Technologies, Inc.
Error: Unresolved external '_HB_FUN_PRUE1' referenced from C:\UTIL\INFOCAJA\OBJ\INFOCAJA.OBJ
Warning: Public symbol '_HB_FUN_MAIN' defined in both module C:\UTIL\INFOCAJA\OBJ\INFOCAJA.OBJ and C:\UTIL\INFOCAJA\PRUE.OBJ
Error: Unable to perform link
 

Re: Consulta Urgente Sobre DTPICKER u Otro Canlendario

PostPosted: Tue Dec 11, 2018 2:09 am
by remtec
Hola

Muchas gracias, logre compilarlo, pero tamaño del calendario, no puedo disminuirlo, el Dtpicker esta genial, solo que no puedo encontrar la forma que pueda ir a la funcion, una ves que selecciona la fecha.

Muchos Saludos.
Antonio.

Re: Consulta Urgente Sobre DTPICKER u Otro Canlendario

PostPosted: Tue Dec 11, 2018 8:44 pm
by Marcelo Roggeri
Agrega esto

Code: Select all  Expand view
:blDblClick          := {|nRow, nCol, nFlags| MSGINFO(dDate,"Fecha Seleccionada")  }


solo creas tu función

Saludos

Re: Consulta Urgente Sobre DTPICKER u Otro Canlendario

PostPosted: Wed Dec 12, 2018 1:39 pm
by remtec
Hola Marcelo.

Muchas gracias por tu ayuda.

No me queda claro, tu sugerencia, debo aplicarla a DTPICKER ??

Muchos Saludos.

Antonio

Re: Consulta Urgente Sobre DTPICKER u Otro Canlendario

PostPosted: Wed Dec 12, 2018 1:57 pm
by Marcelo Roggeri
De nada Antonio, te pego el codigo entero al que tenias agregando esa linea que te dije asi te das cuenta

Code: Select all  Expand view
#include "fivewin.ch"

static dDate, dBOM, dOffSet
static nMonth, cMonth, nYear
static oBrw, oDate

//----------------------------------------------------------------------------//

function Main()

   local oDlg, oFont, oFontD, oCbx, d
   local aMth[ 12 ]
   local aWeek[ 7 ], oGet3

   SET CENTURY ON
   // SET DATE ITALIAN
   SET DATE BRIT
/*
   AEval( aMth,  { |c,i| aMth[ i ]  := NToCMonth( i ) } )
   AEval( aWeek, { |c,i| aWeek[ i ] := Left( NToCDOW( i ), 3 ) } )
*/


   aMth:={"Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"}
   aWeek:={"Dom","Lun","Mar","Mie","Jue","Vie","Sab"}


   SetDate( dDate := Date() )

   DEFINE FONT oFont  NAME "Segoe UI" SIZE 0,-20
   DEFINE FONT oFontD NAME "COPPERPLATE GOTHIC BOLD" SIZE 0,-36

   DEFINE DIALOG oDlg SIZE 542,490 PIXEL TRUEPIXEL ;
          FONT oFont TITLE "CALENDAR WITH XBROWSE"

          @ 20, 20 COMBOBOX oCbx VAR nMonth ITEMS aMth SIZE 150,300 PIXEL OF oDlg UPDATE ;
             ON CHANGE ResetCal()

          @ 20,200 GET nYear PICTURE "9999" SIZE 100,34 PIXEL OF oDlg UPDATE ;
             SPINNER MAX 2999 MIN 1900 ;
             ON CHANGE ReSetCal()

          /*
          @ 20,380 GET oDate VAR dDate SIZE 120,34 PIXEL OF oDlg ;
             SPINNER ;
             ; //ON CHANGE SetDate( dDate ) ;
             VALID     SetDate( dDate )
          */


          @ 20,330 GET oDate VAR dDate SIZE 190, 34 PIXEL OF oDlg ;
                   BITMAP "..\bitmaps\chkyes.bmp"                       ;
                   ACTION( CAMBIA_ACION() )  // SPINNER

          oDate:lBtnTransparent := .t.       // transparent button get oDate
          oDate:lAdjustBtn      := .t.       // Button Get Adjust Witdh oDate
          oDate:lDisColors      := .f.       // Deactive disable color
          oDate:nClrTextDis     := CLR_WHITE // Color text disable status
          oDate:nClrPaneDis     := CLR_BLUE  // Color Pane disable status

          @ 60,20 XBROWSE oBrw SIZE 502,-20 PIXEL OF oDlg ;
                  DATASOURCE Array( 6 ) COLUMNS 1,2,3,4,5,6,7 ;
                  HEADERS aWeek ;
                  NOBORDER

          AEval( oBrw:aCols, { |o| SetupCol( o ) } )

          WITH OBJECT oBrw
              :lRecordSelector  := .f.
              :lHScroll      := .f.
              :lVScroll      := .f.
              :lDisplayZeros := .f.
              :lColChangeNotify := .t.
              :nRowHeight    := 60
              :nwidths       := 70
              :nRowDividerStyle := ;
              :nColDividerStyle := LINESTYLE_LIGHTGRAY
              :oDataFonts    := oFontD
              :nDataStrAligns:= AL_CENTER
              :bChange       := { || dDate := dOffSet + oBrw:nColSel + 7 * ( oBrw:nRowSel - 1 ), oDate:Refresh() }

              :blDblClick          := {|nRow, nCol, nFlags| MSGINFO(dDate,"Fecha Seleccionada")  }

              //
              :CreateFromCode()
          END



          oDlg:bStart := { || SetDate( dDate ) }

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont, oFontD

return nil

FUNCTION CAMBIA_ACION()

  ? "que desea hacer en argentina? "

RETURN( .T. )

function SetUpCol( oCol )

   local nClrPane := oCol:oBrw:oWnd:nClrPane

   oCol:bEditValue   := { || dOffSet + 7 * ( oCol:oBrw:nArrayAt - 1 ) + oCol:nArrayCol }
   oCol:bStrData     := { |x,o| DAY( o:Value ) }
   if oCol:nArrayCol == 1
      oCol:bClrStd   := { || If( MONTH( oCol:Value ) == nMonth, { CLR_HRED, CLR_WHITE }, ;
                                 {  CLR_HGRAY, nClrPane  } ) }
      oCol:bClrHeader:= { || { CLR_HRED, CLR_WHITE } }
   else
      oCol:bClrStd   := { || If( MONTH( oCol:Value ) == nMonth, { CLR_BLACK, CLR_WHITE }, ;
                                 { CLR_HGRAY, nClrPane } ) }
   endif

return nil

function SetDate( dDate )

   local nDays, nRow, nCol, nLen

   if dBOM != BOM( dDate )
      dBOM     := BOM( dDate )
      dOffSet  := dBOM - DOW( dBOM )
      nMonth   := Month(  dDate )
      cMonth   := CMONTH( dDate )
      nYear    := Year(   dDate )
   endif

   if oBrw != nil
      nDays    := dDate - dOffSet
      nRow     := Int( nDays / 7 ) + 1
      if ( nCol := nDays % 7 ) == 0
         nCol  := 7
         nRow--
      endif
      WITH OBJECT oBrw
         :nRowSel    := ;
         :nArrayAt   := nRow
         :nColSel    := nCol
         nLen        := Ceiling( ( EOM( dDate ) - dOffSet ) / 7 )
         :bKeyCount  := { || nLen }
         :Refresh()
         :oWnd:Update()
         :SetFocus()
      END
   endif

return .t.

function ResetCal()

   local dNewDate := STOD( STRZERO( nYear, 4 ) + STRZERO( nMonth, 2 ) + "01" )

   dDate    := dNewDate + MIN( DAY( dDate ), LASTDAYOM( dNewDate ) ) - 1
   oDate:Refresh()
   SetDate( dDate )

return .t.


Saludos

Re: Consulta Urgente Sobre DTPICKER u Otro Canlendario

PostPosted: Wed Dec 12, 2018 3:17 pm
by jbrita

Re: Consulta Urgente Sobre DTPICKER u Otro Canlendario

PostPosted: Tue Dec 18, 2018 1:34 pm
by remtec
Amigos

Disculpas, estuve con algunos problemas y desconectado.

Mil gracias por su tiempo y ayuda a, Karinha, Marcelo Roggeri y JBrita.

Copie la Solucion que me entrego Marcelo, hice unos ajustes para usar con recurso, esta funcionando.

Muy agradecido de corazon.

Saludos
Antonio.