To Nages : Explain me how I must make this tdatabase

Re: To Nages : Explain me how I must make this tdatabase

Postby James Bott » Wed Mar 06, 2019 4:45 pm

( only for the first point) this is not true, initially he told me that tdata works very well with the listbox (wbrowse)...

I searched all my old emails to you and there are no references to listbox or wbrowse. The only reference to listbox was in an email FROM you:

I saw thre oldest source ( i sent you a picture) for dental application it use tdb but the source is the same of mine and it use calias

// Browse con los datos
@ 00, 00 LISTBOX ::oLbx FIELDS ;
::oPaciente:Codigo, ::oPaciente:nombre, ...


...in fact if you remember we had to put a SetoDBF (odbf) or a calias because the tdata latrimenti did not work

This is like saying that unless you program it right, it doesn't work. The same can be said about using a non-object database. There were no bugs in the datbase class, it was a missing statement in the code to use the database class. A combobox, dialog, or window doesn't work either--unless you program it right.

You also keep confusing the issue of converting to multi-user with using database objects. Database objects do handle opening in shared mode, locking and unlocking records with automatic-retrys, etc. that are needed for multi-user apps. But there are other issues, such as reindexing, zapping, and packing that can't be done like they were in a single-user app whether you are using database objects or not. In your app these were used a lot, and that code has to be re-written.

You are also confusing bugs in the code to use database objects with the database objects not working. The database objects are working and they have been in use for many years.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: To Nages : Explain me how I must make this tdatabase

Postby nageswaragunupudi » Thu Apr 25, 2019 8:52 pm

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

REQUEST DBFCDX

static cPath      // give here your path

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

function Main()

   local oClients

   DEFAULT cPath  := cFilePath( ExeName() )

   CreateDBF()

   oClients := TClients():New()

   BrowseClients()

return nil

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

function BrowseClients()

   local oClients
   local oDlg, oFont, oBrw

   oClients := TClients():New()

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 500,500 PIXEL TRUEPIXEL FONT oFont

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oClients AUTOCOLS ;
      CELL LINES NOBORDER FASTEDIT

   oBrw:CreateFromCode()

   @ 20, 20 BTNBMP PROMPT "New"    SIZE 100,35 PIXEL OF oDlg FLAT ;
      ACTION oBrw:EditSource( .T. )

   @ 20,140 BTNBMP PROMPT "Edit"   SIZE 100,35 PIXEL OF oDlg FLAT ;
      ACTION oBrw:EditSource()

   @ 20,260 BTNBMP PROMPT "Delete" SIZE 100,35 PIXEL OF oDlg FLAT ;
      ACTION oBrw:Delete()

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   oClients:Close()

return nil

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

CLASS TClients FROM TDatabase

   DATA oControl

   METHOD New() CONSTRUCTOR
   METHOD NextID() INLINE STRZERO( ::oControl:NextVal(), 4 )
   METHOD ResetID( nID ) INLINE ::oControl:Reset( nID )
   METHOD Close()  INLINE ( ::oControl:Close(), ::Super:Close() )
   METHOD EditDlg( oRec )

ENDCLASS

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

METHOD New() CLASS TClients

   ::Super:Open( , cPath + "SCLIENTS.DBF", "DBFCDX", .T. )
   ::oControl  := IDControl():New()
   ::bEdit     := { |oRec| ::EditDlg( oRec ) }

return Self

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

METHOD EditDlg( oRec ) CLASS TClients

   local oSelf := Self
   local oDlg, oFont, nID
   local lExit    := .f.

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 500,220 PIXEL TRUEPIXEL FONT oFont ;
      TITLE If( oRec:RecNo == 0, "NEW CLIENT", "EDIT CLIENT" )

   If oRec:RecNo == 0
      nID      := ::NextID()
      oRec:SetDefault( "ID", nID )
   endif

   @  40, 40 SAY "ID     :" GET oRec:ID   SIZE 300,26 PIXEL OF oDlg READONLY
   @  70, 40 SAY "Name   :" GET oRec:Name SIZE 300,26 PIXEL OF oDlg
   @ 100, 40 SAY "City   :" GET oRec:City SIZE 300,26 PIXEL OF oDlg

   @ 150, 40 BTNBMP PROMPT "SAVE"  SIZE 100,35 PIXEL OF oDlg FLAT WHEN oRec:Modified() ;
      ACTION ( oRec:Save(), lExit := .t., oDlg:End() )

   @ 150,200 BTNBMP PROMPT "CANCEL" SIZE 100,35 PIXEL OF oDlg FLAT ;
      ACTION ( If( oRec:RecNo == 0, oSelf:ResetID( Val( oRec:ID ) ), ), ;
               lExit := .t., oDlg:End() )

   ACTIVATE DIALOG oDlg CENTERED VALID ( lExit )
   RELEASE FONT oFont

return nil

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

CLASS IDControl FROM TDatabase

   METHOD New() CONSTRUCTOR
   METHOD NextVal()
   METHOD Reset( nId )

ENDCLASS

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

METHOD New() CLASS IDControl

   ::Super:Open( , cPath + "CONTROL.DBF", "DBFCDX", .T. )

return Self

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

METHOD NextVal() CLASS IDControl

   field ID, UNUSED
   local nID, bAction

   bAction  := <||
      local a := UNUSED
      local nRet
      if !Empty( a )
         nRet  := ATail( a )
         a     := ASize( a, Len( a ) - 1 )
         UNUSED := a
      else
         ID    := ID + 1
         nRet  := ID
      endif
      DBCOMMIT()
      return nRet
      >

   do while .not. ::RecLock()
   enddo

   nID   := ::Exec( bAction )

   ::Unlock()
   ::Load()

return nID

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

METHOD Reset( nID ) CLASS IDControl

   field ID, UNUSED
   local bAction

   bAction := <||
      local a
      if nID == ID
         ID := ID - 1
      else
         a  := UNUSED
         AAdd( a, nID )
         UNUSED   := a
      endif
      DBCOMMIT()
      return nil
   >

   do while .not. ::RecLock()
   enddo

   ::Exec( bAction )

   ::Unlock()
   ::Load()

return nil

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

function CreateDBF()

   if !File( cPath + "CONTROL.DBF" )
      DBCREATE( cPath + "CONTROL.DBF", { ;
         { "ID",     "N", 4, 0 }, ;
         { "UNUSED", "M",10, 0 }  }, ;
         "DBFCDX", .T., "CTR" )
      DBAPPEND()
      FIELD->ID := 0
      FIELD->UNUSED := {}
      CLOSE CTR
   endif

   if !File( cPath + "SCLIENTS.DBF" )
      DBCREATE( cPath + "SCLIENTS.DBF", { ;
         { "ID",     "C", 4, 0 }, ;
         { "NAME",   "C",20, 0 }, ;
         { "CITY",   "C",20, 0 }  }, ;
         "DBFCDX", .T., "SD" )

      FW_CdxCreate()
      CLOSE SD
   endif

return nil

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


Mr. Silvio

Please test this sample.
This displays the ID for new record. It is guaranteed that no other user will save a record with the same ID.
If you like this approach, you may adopt to your situation.
If you do not like, ignore this.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: To Nages : Explain me how I must make this tdatabase

Postby TimStone » Thu Apr 25, 2019 9:38 pm

THIS IS SUPPOSED TO BE A PROFESSIONAL FORUM. where competent programmers meet to work through issues.

The posts by Silvio here are very insulting, and he makes assertions about code that others of us use very successfully, and it works 100% as claimed.

I have put up with this person's insults by private email for many weeks now. If we are now to see this type of material posted on the forum then we abandon all claims to be professionals.

Might I suggest we remove ( once again ) posts that attack other programmers personally or claim their work is faulty. I believe Antonio had to address the same type of behavior previously with Silvio regarding others who have created programs he claimed were faulty ( but many used successfully ). Professionals do not need to be rude, insulting, or use hysterics.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: To Nages : Explain me how I must make this tdatabase

Postby TimStone » Fri Apr 26, 2019 5:20 am

To those who may have read my last comment and the reply it received. I did not see any humor in the cartoons that were posted in this thread, and perhaps that was in light of the series of very offensive emails I received from the person who posted them.

I would like to clarify the core issue here. One of our members, who spends a tremendous amount of time providing assistance to many of us on this forum, and through direct correspondence, created a small library that inherited from the tDatabase class, and the method enhancements provided in the class simplified multi-user operations and enhanced the benefits of using data objects. Some steps were automated. The class dated back to the earlier days of tDatabase when it could be used with Clipper, plus FW to build 16 bit windows programs.

When Harbour and xHarbour were created to provide a 32 bit replacement to Clipper, the DBFCDX RDD worked in the same way, and tDatabase needed little change. As a result, tData also needed little change. This persisted until ADO and SQL capabilities were added, when enhancements were made as needed in the tDatabase class. Again, this was a "supplemental class that inherited from tDatabase" and was NEVER a replacement for the FW class. It also was limited in scope.

With the guidance of that same individual, I learned the principles of true OOP business classes, and re-wrote my primary program ( a rather huge, and comprehensive, fully integrated, management system for small businesses ) using those principles. The tData/tDatabase objects were a part of that process where each class used data objects. The result was about a 50% reduction in code, and error free operations.

The tData class has been used successfully by a number of FW developers over the years. In my case, it was utilized in systems obtained by hundreds of companies, using from 1 to 20 computers in their individual networks, working 6 days a week, about 12 hours per day, and NEVER did I have anyone encounter a problem related to that class.

As for me, I was a licensed psychologist when I became involved with computers in 1982, and I learned programming from the people who wrote the dBase code at Ashton Tate, and from those heavily involved in the development of Clipper. Both companies were located within an hour of my home, and thus our community of developers was very active in those early days. Yes, I am about to celebrate my 73rd birthday, but I am not retired. I have clients who still pay me to provide support and enhancements to the software for over 36 years. And yes, time with my 15 grandkids is very important to me, and I'm with them all of the time. Life is too precious to not spend time with those you love.

Finally, it must be said that I have always appreciated the work started by Antonio, and enhanced by others, and have not disparaged that work, or those people, in any way. I'm of the firm belief if a product doesn't work for me, then I should use something else. The fact that I have used this product, and the guidance provided by the people on this forum, for so many years should be ample evidence of my faith in the work these men have done, but in addition I do try to reinforce that with my comments from time to time. And with this said, I shall relax with a glass of wine and then a good nights sleep. May you have continued success with your programming work, and I do encourage all of you to consider ways to improve your coding with true OOPS principles if you are not using them already.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 94 guests