Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: tushar Kanvinde
  Where is tushar Kanvinde?
 Kolhapur, Maharastra
 India
 tushar Kanvinde
 To: Anil Sharma
  Where is Anil Sharma?
 ludhiana
 India
 Anil Sharma
 Tags
Subject: RE: Duplicate Bill No.
Thread ID: 209644 Message ID: 209653 # Views: 51 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Windows Vista and VFP
Date: Tuesday, December 30, 2008 9:34:36 AM         
   


> > Dear Friends
> >
> > I am suffering with a very serious problem of bill number duplication.
> >
> > I am using free tables (.dbf) files
> >
> >
> >
> > sele gernal
> > =rlock()
> > sele tranfile
> > set filt to
> > set order to mdisvc
> > fond="N"
> > do while fond="N"
> >   	seek billnumber
> > 	if .not. found()
> >     	fond="Y"
> >   	else
> >   		billnumber=billnumber+1
> > 	endif
> > enddo
> > appe blan
> > =rlock()
> > repl bill with billnumber
> > unlock all
> > 

> >
> > I lock record in "gernal" file so that if any user want to add bill record in "tranfile" he will wait upto unlock. When i complete all the transaction then i issue "unlock all" to free all the tables for all and next user can save.
> >
> > Not often, but daily 1 or 2 bills generated with a duplicate number in multiuser platform.
> >
> > Please suggest me.
> >
> > With regard
> > Anup Singh
> > (M.D.)
> > MARG Compusoft Pvt. Ltd.
> >
> > Email:anupmarg@gmail.com
> > Web:www.margcompusoft.com
>
> Anup Better to make a another table which will store the last billno.
> create a table lets say NumTable. Which have the following Structure
> CREATE TABLE NumTable (BillBookID I,BillNo I)
> Let says our bill book ID No. is 1
> INSERT INTO NUMTABLE (1,0)
>
> Now in your program where u want to get the new bill no. try this
> Local lnMaxBillNo
> lnMaxBillNo =0
> SELECT NUMTABLE
> =SEEK(LocalVariableForBillBookID,'NUMTABLE','BillBookID')
> IF FOUND() AND RLOCK()
> REPLACE NUMTABLE.BillNo with NUMTABLE.BillNo + 1
> FLUSH
> lnMaxBillNo = NUMTABLE.BillNo
> UNLOCK ALL
> ENDIF
>
> =MESSAGEBOX(lnMaxBillNo) && Here is your unique Bill No.
>
> This Logic is blazing fast on network and will table fraction of second to update!.
>
> Anil
> My Blog

I would put the RLOCK in a loop

IF FOUND()
   DO WHILE NOT RLOCK()
   ENDDO
ENDIF


Regards
Tushar

ENTIRE THREAD

Duplicate Bill No. Posted by Anup Singh @ 12/30/2008 8:34:42 AM
RE: Duplicate Bill No. Posted by mike castillo @ 12/30/2008 8:57:00 AM
RE: Duplicate Bill No. Posted by tushar @ 12/30/2008 9:08:55 AM
RE: Duplicate Bill No. Posted by Anil Sharma @ 12/30/2008 9:15:14 AM
RE: Duplicate Bill No. Posted by tushar @ 12/30/2008 9:34:36 AM
RE: Duplicate Bill No. Posted by Anil Sharma @ 12/30/2008 9:44:08 AM
RE: Duplicate Bill No. Posted by tushar @ 12/30/2008 2:29:07 PM
RE: Duplicate Bill No. Posted by mike castillo @ 12/31/2008 2:31:15 AM
RE: Duplicate Bill No. Posted by tushar @ 12/31/2008 6:04:54 AM
RE: Duplicate Bill No. Posted by Anders Altberg @ 12/31/2008 12:37:54 PM
RE: Duplicate Bill No. Posted by Anil Sharma @ 1/2/2009 9:06:24 AM
RE: Duplicate Bill No. Posted by Anders Altberg @ 1/2/2009 11:40:02 AM
RE: Duplicate Bill No. Posted by Anup Singh @ 1/2/2009 9:46:35 AM
RE: Duplicate Bill No. Posted by Jag Pal Sharma @ 2/2/2016 12:32:58 PM
RE: Duplicate Bill No. Posted by Tore Bleken @ 2/2/2016 12:48:00 PM
RE: Duplicate Bill No. Posted by Anders Altberg @ 1/2/2009 2:18:18 PM
RE: Duplicate Bill No. Posted by Anil Sharma @ 1/3/2009 7:58:04 AM
RE: Duplicate Bill No. Posted by anand kulkarni @ 2/4/2016 8:28:08 AM
RE: Duplicate Bill No. Posted by Tore Bleken @ 2/4/2016 8:58:38 AM
RE: Duplicate Bill No. Posted by anand kulkarni @ 2/4/2016 10:49:02 AM