Greetings everyone,
in my endevour of switching the way or employees view Crystal Reports to a browser based solution I have hit another major roadblock.
Using VS2010 I have created a web portal and most reports display fine (thanks to Ludec for helping me with the sorting reports).
Now I have a few reports I'm trying to add to the portal that normally run a VFP executable first, which creates a custom table. That table then becomes the data souirce for the report. I have looked into creating datasets in VS, but because the FoxPro code puts data in temporary cursors, I'm not quite sure how to set up the Datasets, or if they are even they right way to go about it.
Below is a sample of the VFP code that creates teh custom table:
Close All
Set Excl Off
Use F:\TIW\KOKAC\slheader In 0
Set TABLEVALIDATE To 0
Use F:\TIW\KOKAC\sllines In 0
Set TABLEVALIDATE To 0
Use F:\TIW\KOKAC\slcust In 0
Set TABLEVALIDATE To 0
Use F:\TIW\KOKAC\imlocn In 0
Set TABLEVALIDATE To 0
Use F:\TIW\KOKAC\apheader In 0
Set TABLEVALIDATE To 0
Use F:\TIW\KOKAC\aplines In 0
Set TABLEVALIDATE To 0
Use F:\TIW\KOKWS\SOHEADER In 0
Set TABLEVALIDATE To 0
Use F:\TIW\KOKAC\IMMASTER In 0
Set TABLEVALIDATE To 0
Use F:\TIW\KOKAC\imheader In 0
Set TABLEVALIDATE To 0
Use F:\TIW\KOKAC\imlines In 0
Set TABLEVALIDATE To 0
Select sllines.Item As Item,;
'p' As progress,;
sllines.Descrip As Description,;
sllines.docid As orderno,;
'salesno' As salesno,;
sllines.lineseq As Lineno,;
sllines.linetype As linetype,;
slheader.billto As account,;
slheader.terms As terms,;
slheader.coname As coname,;
slheader.salesman As salesrep,;
sllines.needby As needby,;
MTON(sllines.orderqty) As oqty,;
MTON(sllines.shipqty) As sqty,;
imlocn.locid As locid,;
MTON(imlocn.woalloc) As woalloc,;
MTON(imlocn.woorder) As woorder,;
MTON(imlocn.soalloc) As soalloc,;
MTON(imlocn.poorder) As poorder,;
MTON(imlocn.onhand) As onhand,;
sllines.doctype As Type,;
slheader.ordrstat As orderstat,;
sllines.linestat As linestat,;
sllines.delmark As delmark,;
slcust.code1 As rank,;
slheader.created As plandate,;
PADR(sllines.picknote,10) As picknote,;
immaster.misc02 As contract;
FROM slheader INNER Join sllines On (slheader.docid + slheader.doctype=sllines.docid + sllines.doctype);
LEFT Outer Join imlocn On sllines.Item=imlocn.Item ;
INNER Join slcust On (slheader.billto + slheader.billlocn=slcust.coid + slcust.locid);
INNER JOIN immaster ON sllines.item = immaster.item;
INTO Cursor C1 Where(slheader.ordrstat='A' Or slheader.ordrstat='P') And Leftc(sllines.doctype,1)='S' And sllines.shipfrom="MAIN" And imlocn.locid = 'MAIN'
Select aplines.Item As Item,;
'x' As progress,;
aplines.Descrip As Description,;
aplines.docid As orderno,;
'salesno' As salesno,;
aplines.lineseq As Lineno,;
aplines.linetype As linetype,;
apheader.poto As account,;
apheader.terms As terms,;
apheader.coname As coname,;
'Supl ' As salesrep,;
aplines.needby As needby,;
MTON(aplines.orderqty) As oqty,;
MTON(aplines.recvqty) As sqty,;
apheader.recvlocn As locid,;
MTON(imlocn.woalloc) As woalloc,;
MTON(imlocn.woorder) As woorder,;
MTON(imlocn.soalloc) As soalloc,;
MTON(imlocn.poorder) As poorder,;
MTON(imlocn.onhand) As onhand,;
aplines.doctype As Type,;
apheader.ordrstat As orderstat,;
aplines.linestat As linestat,;
aplines.delmark As delmark,;
'Rank' As rank,;
apheader.created As plandate,;
SPACE(10) As picknote,;
immaster.misc02 As contract;
FROM apheader INNER Join aplines On (apheader.docid + apheader.doctype=aplines.docid + aplines.doctype);
INNER Join imlocn On aplines.Item=imlocn.Item;
INNER JOIN immaster ON imlocn.item = immaster.item;
INTO Cursor C2 Readwrite Where imlocn.locid = 'MAIN' And (apheader.ordrstat='A' Or apheader.ordrstat='P')
Select imlines.Item As Item,;
'x' As progress,;
imlines.Descrip As Description,;
imlines.docid As orderno,;
'salesno' As salesno,;
imlines.linenum As Lineno,;
'transfer' As linetype,;
'Kokatat' As account,;
'Terms' As terms,;
'Kokatat' As coname,;
'Supl ' As salesrep,;
imlines.needby As needby,;
MTON(imlines.orderqty) As oqty,;
MTON(imlines.shipqty) As sqty,;
imheader.shiplocn As locid,;
MTON(imlocn.woalloc) As woalloc,;
MTON(imlocn.woorder) As woorder,;
MTON(imlocn.soalloc) As soalloc,;
MTON(imlocn.poorder) As poorder,;
MTON(imlocn.onhand) As onhand,;
'TO' As Type,;
imheader.ordrstat As orderstat,;
imlines.linestat As linestat,;
imlines.delmark As delmark,;
'Rank' As rank,;
imheader.acptdate As plandate,;
SPACE(10) As picknote,;
immaster.misc02 As contract;
FROM imheader INNER Join imlines On imheader.docid =imlines.docid;
INNER Join imlocn On imlines.Item=imlocn.Item;
INNER JOIN immaster ON imlines.Item = immaster.item;
INTO Cursor C3 Readwrite Where imlocn.locid = 'MAIN' And imheader.shiplocn = "MAIN" And (imheader.ordrstat='A' Or imheader.ordrstat='P')
Select SOHEADER.partno As Item,;
SOHEADER.inprog As progress,;
SOHEADER.part_desc As Description,;
(SOHEADER.sono +" ") As orderno,;
SOHEADER.salesno As salesno,;
SOHEADER.solineno As Lineno,;
'R' As linetype,;
'Kok ' As account,;
'Pre'+ Space(7) As terms,;
'Production' + Space(25) As coname,;
'Kok'+ Space(3) As salesrep,;
SOHEADER.need_date As needby,;
VAL(SOHEADER.cqty) As oqty,;
VAL(SOHEADER.fqty)As sqty,;
SOHEADER.fgloc As locid,;
MTON(imlocn.woalloc) As woalloc,;
MTON(imlocn.woorder) As woorder,;
MTON(imlocn.soalloc) As soalloc,;
MTON(imlocn.poorder) As poorder,;
MTON(imlocn.onhand) As onhand,;
'WO' As Type,;
'A' As orderstat,;
'A' As linestat,;
SOHEADER.canceled As delmark,;
"Rank" As rank,;
SOHEADER.plandate As plandate,;
SPACE(10) As picknote,;
immaster.misc02 As contract;
FROM SOHEADER INNER Join imlocn On SOHEADER.partno=imlocn.Item;
INNER JOIN immaster ON imlocn.item = immaster.item;
INTO Cursor C4 Readwrite Where imlocn.locid = 'MAIN'
If File("C:\Temp\itemproj.DBF" )
Delete File ("C:\Temp\itemproj.DBF")
Endif
Select * From C1;
UNION Select * From C2;
INTO Cursor W1
Select slheader
Use
Select sllines
Use
Select slcust
Use
Select aplines
Use
Select apheader
Use
Select imlocn
Use
Select SOHEADER
USE
SELECT IMMASTER
USE
Select imlines
Use
Select imheader
Use
Select * From C3;
UNION Select * From C4;
INTO Cursor W2
Select * From W1;
UNION Select * From W2;
INTO Cursor W3
Copy To "C:\Temp\itemproj.DBF" Type Fox2x
I hope pasting the code like that is ok, I couldn't find a "Insert Code" option. Anyway, so this creates the itemproj.dbf table, which our report uses to get the data. Currently this code is run every time the report is run, making sure the data in the table is up to date.
How could I achieve this in VS 2010 so that when an employee browses to the page with the report, the code is run and the table gets updated?
Thanks in advance for your help and feel free to ask if you need any more information,
Chris