Don’t want to convert your existing VFP report to .NET? It is Ok. Now you don’t need it!

已查看 585 次
跳至第一个未读帖子

Marat Chariev

未读,
2015年3月4日 10:33:172015/3/4
收件人 frx...@googlegroups.com

Use following snippet C# code to call FoxPro app which will  convert your VFP report into all available output formats!

 

 

    protected void btnOK_Click(object sender, EventArgs e)

    {

        this.PrintPanel.Visible = false;

 

        String _path = Convert.ToString(Session["ReportPath"]);

        String nwstr = Convert.ToString(Session["SOOrderID"]);

        String generalchk = Convert.ToInt16(this.GeneralCheck.Checked).ToString();

        String newchk = Convert.ToInt16(this.NewCheck.Checked).ToString();

        String moneychk = Convert.ToInt16(this.ExcludeCheck.Checked).ToString();

        String shipkey = this.ShipList.SelectedValue;

 

        String parms = "'" + @nwstr + "','" + @generalchk + "','" + @newchk + "','" + @moneychk + "','" + @shipkey + "'";

        System.Diagnostics.Process p = new System.Diagnostics.Process();

        p.StartInfo.WorkingDirectory = @_path;

        p.StartInfo.FileName = "run_reports.exe";

        p.StartInfo.Arguments = "single_ordr_prnt " + parms;

        p.StartInfo.ErrorDialog = true;

        p.StartInfo.UseShellExecute = true;

        p.Start();

    }

 

 

Where run_reports.exe  compiled as EXE one of the sample FRX2Any prgs

 

 

FoxPro code:

 

LPARAMETERS Rptname AS STRING, paramstr AS STRING

 

** The procedures for the report forms are in a separate procedures.prg

 

 

PUBLIC m.configstr, txtCompanyName, strexec

STORE '' TO m.configstr, txtCompanyName, strexec

 

_SCREEN.VISIBLE = .T.

 

_SCREEN.THEMES = .T.

_SCREEN.ICON = 'nwicon4.ICO'

 

PUBLIC m.appsdrive

m.appsdrive = CURDIR()

 

PUBLIC m.formdrive

m.formdrive = m.appsdrive + 'forms\'

 

PUBLIC m.rptdrive

m.rptdrive = m.appsdrive + 'ReportForms\'

 

PUBLIC nhandle

STORE 0 TO nhandle

 

SET REPORTBEHAVIOR 80

 

SELECT 0

USE 'sysconfig' ALIAS sysconfig

_SCREEN.CAPTION = 'Profit-able Reports Print ' + '(' +

ALLTRIM(sysconfig.txtDesc) + ')'

 

m.tempdrive = ALLTRIM(sysconfig.tempdrive)

tmp = SUBSTR(m.tempdrive, 1, LEN(m.tempdrive) - 1)

 

IF NOT DIRECTORY(ALLTRIM(tmp))

      MKDIR ALLTRIM(tmp)

ENDIF

 

**Base Connection String

m.configstr = 'Driver=SQL Server; Database=' + ALLTRIM(sysconfig.txtdb) + '; Server=' + ALLTRIM(sysconfig.txtserver) + '; UID=' + ALLTRIM(sysconfig.txtuserid) + '; Pwd=' + ALLTRIM(sysconfig.txtpasswrd)

 

txtCompanyName = sysconfig.txtDesc

 

SELECT sysconfig

USE

 

SET PROCEDURE TO 'procedures.prg'

 

SET NOTIFY CURSOR OFF

SET EXCLUSIVE OFF

SET SYSMENU OFF

SET NEAR OFF

SET CPDIALOG OFF

SET EXACT ON

SET ESCAPE OFF

SET ENGINEBEHAVIOR 90

SET TALK OFF

SET DELETED ON

SET CENTURY ON

SET REPORTBEHAVIOR 80

 

strrpt = ALLTRIM(Rptname)

strparams = ALLTRIM(paramstr)

 

strexec = strrpt + ' WITH ' + strparams

 

DO &strexec

 

DO Shut_Down

 

********************************Connections*********************************

PROCEDURE Shut_Down

**Close Program

      IF nhandle > 0

            =SQLDISCONNECT(nhandle)

            CLOSE ALL

            CLEAR ALL

            CLEAR

            QUIT

      ENDIF

ENDPROC

 

***Basic Connection

PROCEDURE sql_connect

*Set up the connection

      IF nhandle = 0

            nhandle = SQLSTRINGCONNECT(ALLTRIM(m.configstr))

            IF nhandle < 0

                  WAIT WINDOW 'Connection Is Not Valid!' TIMEOUT 5

                  RETURN .F.

            ENDIF

      ENDIF

ENDPROC

 

PROCEDURE sql_disconnect

      IF nhandle > 0

            =SQLDISCONNECT(nhandle)

            nhandle = 0

      ENDIF

ENDPROC

 

****************************************************************************

PROCEDURE ins_error

      =STRTOFILE(InsSQL, m.tempdrive + 'profit_ins.txt')

ENDPROC

 

PROCEDURE upd_error

      =STRTOFILE(UpdSQL, m.tempdrive + 'profit_upd.txt')

ENDPROC

 

PROCEDURE sel_error

      =STRTOFILE(SelSQL, m.tempdrive + 'profit_sel.txt')

ENDPROC

 

PROCEDURE del_error

      =STRTOFILE(DelSQL, m.tempdrive + 'profit_del.txt')

ENDPROC

 

已删除帖子

Marat Chariev

未读,
2015年3月4日 20:01:072015/3/4
收件人 frx...@googlegroups.com
Here is the original post: http://stackoverflow.com
回复全部
回复作者
转发
0 个新帖子