check existing first and last on customer - RESOLVED !!!

Re: check existing first and last on customer

Postby nageswaragunupudi » Tue Jun 15, 2021 3:37 pm

I didn't find the Lookup() method in TDatabase because I was looking a the sorted methods in my editor and the actual method name is TD_LOOKUP, so it was under the T's not the L's.


Method LookUp exists:
Code: Select all  Expand view
  METHOD LookUp( uSeek, cOrder, bcExpr, lTrigger ) INLINE ( ::cAlias )->( ::td_LookUp( uSeek, cOrder, bcExpr, lTrigger ) )
 


The original question in the first post was how to find if a combination of two fields already exists in the table. I provided a simple and straight answer for that which works irrespective of the indexes.
Regards

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

Re: check existing first and last on customer

Postby James Bott » Tue Jun 15, 2021 4:06 pm

Nages,

The original question in the first post was how to find if a combination of two fields already exists in the table. I provided a simple and straight answer for that which works irrespective of the indexes
.

Sorry, I never meant to imply otherwise.

I was just pointing out that using primary keys solves this and many other problems Silvio has been having. When using primary keys, Silvio won't need to do this lookup. However, your technique will be useful in other situations. Thanks for providing it--I already have it in my notes file.

James
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: check existing first and last on customer

Postby Silvio.Falconi » Tue Jun 15, 2021 6:32 pm

cNomeintero was only a test.
I wish use the same fields i pubblish
clicognome as First
clinome as last
of 20 characters
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7016
Joined: Thu Oct 18, 2012 7:17 pm

Re: check existing first and last on customer

Postby Silvio.Falconi » Wed Jun 16, 2021 9:37 am

James Bott wrote:Nages,

The original question in the first post was how to find if a combination of two fields already exists in the table. I provided a simple and straight answer for that which works irrespective of the indexes
.

Sorry, I never meant to imply otherwise.

I was just pointing out that using primary keys solves this and many other problems Silvio has been having. When using primary keys, Silvio won't need to do this lookup. However, your technique will be useful in other situations. Thanks for providing it--I already have it in my notes file.

James


But which primaries should I use?
the clienti.dbf file has these indexes

INDEX ON UPPER(CLICOGNOME) TAG CLICOGNOME
INDEX ON UPPER(CLINOME) TAG CLINOME
INDEX ON UPPER(CLIFISCALE) TAG CLIFISCALE
INDEX ON UPPER(CLIPARTIVA) TAG CLIPARTIVA
INDEX ON UPPER(CLIINDIRIZ) TAG CLIINDIRIZ
INDEX ON UPPER(CLIPAESE) TAG CLIPAESE
INDEX ON UPPER(CLICAP) TAG CLICAP
INDEX ON UPPER(CLIPROV) TAG CLIPROV
INDEX ON UPPER(CLIREGIONE) TAG CLIREGIONE
INDEX ON UPPER(CLITELEF1) TAG CLITELEF1
INDEX ON UPPER(CLITELEF2) TAG CLITELEF2
INDEX ON UPPER(CLIEMAIL) TAG CLIEMAIL
INDEX ON UPPER(CLISITOWEB) TAG CLISITOWEB
INDEX ON UPPER(CLIAPPUNTI) TAG CLIAPPUNTI
INDEX ON DELETED() TAG DELETED


and the fields are these
Code: Select all  Expand view
local aFields := { { "CLICOGNOME", "C", 20, 0 },;
                   { "CLINOME", "C", 20, 0 },;
                   { "CLIFISCALE", "C", 16, 0 },;
                   { "CLIPARTIVA", "C", 11, 0 },;
                   { "CLIINDIRIZ", "C", 30, 0 },;
                   { "CLIPAESE", "C", 30, 0 },;
                   { "CLICAP", "C", 5, 0 },;
                   { "CLIPROV", "C", 2, 0 },;
                   { "CLIREGIONE", "C", 20, 0 },;
                   { "CLITELEF1", "C", 14, 0 },;
                   { "CLITELEF2", "C", 14, 0 },;
                   { "CLIEMAIL", "C", 40, 0 },;
                   { "CLISITOWEB", "C", 40, 0 },;
                   { "CLIAPPUNTI", "C", 200, 0 } }



the idea of using only one field (FULLNAME) was just a test I did but in reality I need a field for the Surname and a field for the name.
There are many customers with the same surname just think that entire families go to the sea. There is the possibility of having the same surname and the same name

nages suggestion only works on the first try i.e:
1) I enter the surname and then the name for example "Vitali" "Pietro"
I only put control on the name
2) the procedure tells me that the name "Peter" already exists so I 3) deletes the contents of the get control and sets focus on the get, so the cusor is stopped on the get control of the name
3) I insert in place of "Pietro", my name "Silvio" which in reality is not in the archive, the procedure does not make me go ahead to enter the other fields and makes a error

this error
Code: Select all  Expand view
Error description: Error BASE/1066  Argument error: conditional
   Args:
     [   1] = U  

Stack Calls
===========
   Called from: test.prg => CLCLAVE( 305 )
   Called from: test.prg => (b)CLEDITA( 206 )
   Called from: .\source\classes\TGET.PRG => TGET:LVALID( 2282 )


is there a solution please?
I'll post the valid function I made

@ 26, 10 SAY "Nome :" OF oDlg SIZE 22, 8 PIXEL FONT oFont
@ 24, 67 GET aGet[2] VAR oCliente:Clinome OF oDlg SIZE 100, 12 PIXEL FONT oFont ;
VALID CLClave( oCliente:Clicognome, aGet[2], 1,oDbf,oCliente:Clinome )


Code: Select all  Expand view
function CLClave( cCognome, oGet, nMode,oDbf,cNome )
   local lreturn  := .f.
   local nRecno   := oDbf:RecNo()
   local nOrder   := oDbf:OrdNumber()
   local nArea    := Select()


 if Empty( cNome )
      if nMode == 4
         return .t.
      else
         MsgStop("E' obbligatorio questo campo.")
         return .f.
      endif
   endif

*oDbf:SetOrder( 1 )  //CLICOGNOME
*   oDbf:GoTop()

 IF  oDbf:LookUp( UPPER( PADR( cCognome, 20 ) + PADR( cNome, 20 ) ), ;
                   "UPPER(CLICOGNOME+CLINOME)", { || FOUND() } )


 DO CASE
         Case nMode == 1 .OR. nMode == 3   // new or duplicate
            lreturn := .f.
            MsgStop("Nominativo esistente.")
         Case nMode == 2   // modify
            if oDbf:Recno()  == nRecno
               lreturn := .t.
            else
               lreturn := .f.
               MsgStop("Nominativo esistente.")
            endif
         Case nMode == 4     //selection dialog
            lreturn := .t.
         END CASE

 ELSE

      if nMode < 4
         lreturn := .t.
      else
         if MsgYesNo("Nominativo inesistente. ¿ Desideri inserirlo ora? ")   // on selection dialog ask to add the new record
            lreturn := ClEdita( , 1, , , @cCognome )
         else
            lreturn := .f.
         endif
      endif
   endif



 if lreturn == .f.
    oGet:cText( space(20) )
   endif

  oDbf:SetOrder( nOrder )
  oDbf:GoTo( nRecno )

   Select (nArea)

   return lreturn
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7016
Joined: Thu Oct 18, 2012 7:17 pm

Re: check existing first and last on customer

Postby nageswaragunupudi » Wed Jun 16, 2021 5:32 pm

Please change this line
Code: Select all  Expand view
IF  oDbf:LookUp( UPPER( PADR( cCognome, 20 ) + PADR( cNome, 20 ) ), ;
                   "UPPER(CLICOGNOME+CLINOME)", { || FOUND() } )
 


AS

Code: Select all  Expand view
IF  oDbf:LookUp( UPPER( PADR( cCognome, 20 ) + PADR( cNome, 20 ) ), ;
                   "UPPER(CLICOGNOME+CLINOME)", { || FOUND() } ) == .T.
 
Regards

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

Re: check existing first and last on customer

Postby Silvio.Falconi » Wed Jun 16, 2021 6:15 pm

thanks Rao , run good!!!
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7016
Joined: Thu Oct 18, 2012 7:17 pm

Re: check existing first and last on customer - RESOLVED !!!

Postby nageswaragunupudi » Wed Jun 16, 2021 7:18 pm

Offtopic:

Is it a practice or tradition in your country to name children after their grandfather/grandmother's name?

I am curious because it is a tradition to give the first son his paternal grandfather's name and the first daughter her paternal grandmother's name in our region of our country. Same way, the second son and daughter get maternal grandfather and grandmothers' names. Of course, the present generation is mostly ignoring the tradition.
Regards

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

Re: check existing first and last on customer - RESOLVED !!!

Postby Silvio.Falconi » Thu Jun 17, 2021 8:47 am

nageswaragunupudi wrote:Offtopic:

Is it a practice or tradition in your country to name children after their grandfather/grandmother's name?

I am curious because it is a tradition to give the first son his paternal grandfather's name and the first daughter her paternal grandmother's name in our region of our country. Same way, the second son and daughter get maternal grandfather and grandmothers' names. Of course, the present generation is mostly ignoring the tradition.


I am the first child so my name is my grandfather.

My brother is called Massimiliano and now he has a son who bears the name of the father of my brother's wife.

Generally the first child is called by the same name, but this custom is no longer fashionable.

In my city there are many people who are called like me (name and surname) but we are not relatives,
one in particular is the same age as me but was born the day before me, so even the tax code is almost the same
and a few weeks ago his grandfather died who was named like us and everyone thought he was my grandfather and everyone gave me condolences
but my grandfather died 35 years ago when i was 19.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7016
Joined: Thu Oct 18, 2012 7:17 pm

Re: check existing first and last on customer - RESOLVED !!!

Postby nageswaragunupudi » Thu Jun 17, 2021 3:41 pm

Thanks for the information. We have similar traditions.
Regards

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

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 59 guests

cron