Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid Sorting
Message
 
 
À
05/06/2002 20:47:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00665227
Message ID:
00665237
Vues:
21
>Hi,
>
>I have a cursor which contains cSplit c(1),nItem_no,cProd c(5),cBatch c(5)
>I have product with many batch no. I display the records into Grid. In Grid, 1st column is a button, field is cSplit,the 2nd is nItem_no,cProd,cBatch. When Click on the split button, I want the 1 record to be duplicated, and nItem_No will increased by one, then the following record nItem_no will increase by one as well. Such as
>
>cSplit,nItem_No,cProd,cBatch
>        1       A
>        2       A     B12     ----> Record Added
>        3       B
>        4       C
>        5       D
>
>When I click on Split Button at 1st column of grid, I will call Split method
>From the Split Method I call method Sort_No for sorting. It seek work ok but only for once time, It doesnt work when i add the second record for the same record. Any Suggestion?
>
>In Method Sort_No
> SELECT myCursor
> INDEX ON cProd+STR(cno,2) TO cSort
> SET ORDER TO cSort
>
> SELECT myCursor
> no_rec = 0
> Go Top
> Do While !EOF()
>  no_rec = no_rec + 1
>  Repl cno WITH no_rec
>  Select MyCursor
>  Skip
> Endd
>
> Click Method in split Button
>
> SELECT myCursor
> GO Thisform.recordno
> IF cSplit = 'M'
>  Replace cno WITH cno+1
>  ln_no    = cNO
>  lc_Prod  = cProd
>  lc_split = cSplit
>
>  SELECT myCursor
>  Append Blank
>  Replace cNo    WITH ln_no+1
>  REPLACE cprod  WITH lc_prod
>  Replace cBatch with space(5)
>  replace cSplit WITH 'C'
>  Thisform.ShowGrid()
> Endif
> Thisform.Sort_no()
> Thisform.Grid1.Refresh()
Ok, try this method instead:
local lnCurNo, lnCurRecNo
lnCurNo = myCursor.cNo && This record would be duplicated
lnCurRecno = recno('myCursor')
replace cNo with cNo+2 for cNo > m.lnCurNo in myCursor && increase all numbers by 2 since a new record would be inserted
select myCursor
goto m.lnCurRecno && Go back on the current record
scatter memvar memo && create memvars with the same values
cNo=cNo+1 && Number should be increased by 1 for the new record
insert into myCursor from memvar
thisform.grid1.refresh()
This is of the top of my head and not tested, but should give you the idea.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform