xBrowse - edits of dbf doesn't stick

Post Reply
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

xBrowse - edits of dbf doesn't stick

Post by hua »

What am I missing?
i. Whatever value I keyed-in doesn't stick (in other words, not saved).
ii. The combobox displays 'Sunday' as 'Su' only.

Here's a self-contained sample.

Code: Select all

#include "fivewin.ch"
#include "xbrowse.ch"

function test()
  local bColor
  local aDay := {"None","Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
  local obrw, obold, obtncnl, oDlg


  dbcreate("person", {{"empno"  , "c", 8, 0}, ;
                      {"name"   , "c",40, 0}, ;
                      {"proxyno", "c",20, 0}, ;
                      {"timein" , "c", 5, 0}, ;
                      {"timeout", "c", 5, 0}, ;
                      {"tea_m"  , "n", 2, 0}, ;
                      {"lunch_min", "n", 2, 0}, ;
                      {"tea_a"  , "n", 2, 0}, ;
                      {"others_min","n", 2, 0}, ;
                      {"weekend1","c", 9, 0}, ;
                      {"weekend2","c", 9, 0}, ;
                      {"halfday" ,"c", 9, 0}  ;
                     }                        ;
          )

  use person new exclusive
  append blank
  person->empno    := "E0000001"
  person->name     := "John Doe"
  person->proxyno  := "00123"
  person->timein   := "09:00"
  person->timeout  := "18:00"
  person->lunch_min := 60
  person->weekend1 := "Sunday"
  person->weekend2 := "Saturday"

  append blank
  person->empno    := "E0000002"
  person->name     := "Jane Doe"
  person->proxyno  := "00122"
  person->timein   := "09:00"
  person->timeout  := "18:00"
  person->lunch_min := 60
  person->weekend1 := "Sunday"
  person->weekend2 := "Saturday"



  DEFINE FONT oBold NAME 'VERDANA' SIZE 0,-14 BOLD

  DEFINE DIALOG oDlg RESOURCE "SETTINGS"

  redefine xbrowse oBrw id 13 of oDlg ;
     fields person->(recno()), person->empno, person->name, person->proxyno, ;
            person->timeIn, person->timeOut, person->tea_m, person->lunch_min, ;
            person->tea_a, person->others_min, person->weekend1, person->weekend2, ;
            person->halfday                                   ;
     headers "No", "Code", "Name", " Proxy Card Number", "In", "Out", "Morning"+CRLF+"Tea", ;
             "Lunch", "Afternoon"+CRLF+"Tea", "Others", "WeekEnd1", "WeekEnd2", "Half-Day"  ;
     pictures ,,,replicate("9", len(person->proxyno)),"99:99","99:99","99","99","99","99" ;
     alias ('person') fastedit lines cell //update

     oBrw:lAllowColSwapping := .f.
     AEval( oBrw:aCols, { |o| o:nEditType := EDIT_GET }, 4 )

     oBrw:aCols[5]:bEditValid := {|oGet, oCol| verifyTime(oGet:value())}
     oBrw:aCols[6]:bEditValid := {|oGet, oCol| verifyTime(oGet:value())}

     with object oBrw:WeekEnd1
      :nEditType        := EDIT_LISTBOX
      :aEditListTxt     := aDay
     end

     with object oBrw:WeekEnd2
      :nEditType        := EDIT_LISTBOX
      :aEditListTxt     := aDay
     end

     oBrw:aCols[13]:nEditType    := EDIT_LISTBOX
     oBrw:aCols[13]:aEditListTxt := aDay


  oBrw:SetGroupHeader("Employee", 2, 3, oBold)
  oBrw:SetGroupHeader("Time", 5, 6, oBold)
  oBrw:SetGroupHeader("In minutes", 7, 10, oBold)


  REDEFINE BUTTON oBtnCnl ID 62 OF oDlg action oDlg:end()


  ACTIVATE DIALOG oDlg center on init oBrw:gotop()

return nil
//----------------------------------------------------------------------
function verifytime(cTime)
  local hrs := val(left(cTime,2)), mins := val(right(cTime,2))
  local lRet := .t.
  if hrs < 0 .or. hrs > 23
     lRet := .f.
  else
     if mins < 0 .or. mins > 59
        lRet := .f.
     endif
  endif
  if !lRet
     msgalert("Valid time values are from 00:00 to 23:59 only!")
  endif
return lRet
 
The rc.

Code: Select all

SETTINGS DIALOG 9, 60, 400, 271
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Employees' Settings"
FONT 10, "System"
{
 CONTROL "", 13, "TXBrowse", 0 | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | WS_BORDER | WS_TABSTOP, 0, 0, 396, 250
 CONTROL "E&xit", 62, "button", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE, 196, 255, 60, 14
}
 
Image that shows 'Sunday' being shown as 'Su' only
Image

TIA.
Last edited by hua on Wed May 19, 2010 3:43 am, edited 2 times in total.
FWH 11.08/FWH 19.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
Patrizio
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy
Contact:

Re: xBrowse - edits of dbf doesn't stick

Post by Patrizio »

hua wrote:ii. The combobox displays 'Sunday' as 'Su' only.

Code: Select all

 
fields person->(recno()), person->empno, person->name, person->proxyno, ;
            person->timeIn, person->timeOut, person->tea_m, person->lunch_min, ;
            person->tea_a, person->others_min, person->weekend1, person->weekend2, ;
            person->halfday
     pictures ,,,replicate("9", len(person->proxyno)),"99:99","99:99","99","99","99","99","99" ;
 
"WeekEnd1" has picture "99"
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Re: xBrowse - edits of dbf doesn't stick

Post by hua »

Thanks Patrizio. That's an embarrassing mistake :oops: . Just shows the more one rush the later will it be finished :).

Anyone has any answer for the first question?

TIA
FWH 11.08/FWH 19.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Re: xBrowse - edits of dbf doesn't stick (solved)

Post by hua »

Coded the xBrowse part this way

Code: Select all

  redefine xbrowse oBrw id 13 of oDlg ;
     columns 'empno', 'name', 'proxyno', 'timeIn', ;
             'timeOut', 'tea_m', 'lunch_min', 'tea_a', 'others_min', ;
             'weekend1','weekend2', 'halfday'                                   ;
     headers "Code", "Name", " Proxy Card Number", "In", ;
             "Out", "Morning"+CRLF+"Tea", "Lunch", "Afternoon"+CRLF+"Tea", "Others", ;
             "WeekEnd1", "WeekEnd2", "Half-Day"  ;
     pictures ,,replicate("9", len(person->proxyno)),"99:99", ;
              "99:99","99","99","99","99" ;
     alias 'person' fastedit lines cell //update

     WITH OBJECT oBrw:InsCol( 1 )
         :bEditValue    := { || oBrw:KeyNo() }
         :cEditPicture  := '9999'
         :cHeader       := 'No'
     END
     oBrw:lAllowColSwapping := .f.
     AEval( oBrw:aCols, { |o| o:nEditType := EDIT_GET }, 4 )

     oBrw:aCols[5]:bEditValid := {|oGet, oCol| verifyTime(oGet:value())}
     oBrw:aCols[6]:bEditValid := {|oGet, oCol| verifyTime(oGet:value())}

     with object oBrw:WeekEnd1
      :nEditType        := EDIT_LISTBOX
      :aEditListBound   := ;
      :aEditListTxt     := aDay
     end

     with object oBrw:WeekEnd2
      :nEditType        := EDIT_LISTBOX
      :aEditListTxt     := aDay
     end

     oBrw:aCols[13]:nEditType    := EDIT_LISTBOX
     oBrw:aCols[13]:aEditListTxt := aDay


  oBrw:SetGroupHeader("Employee", 2, 3, oBold)
  oBrw:SetGroupHeader("Time", 5, 6, oBold)
  oBrw:SetGroupHeader("In minutes", 7, 10, oBold)
 
FWH 11.08/FWH 19.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
Post Reply