Please tail me how Build crystal reports in powerbuild
regards
pravin sali
--
Pravin sali
Fem Care Pharma Ltd
0253-6604440
Brad
"Yoyo Young" <yo...@public1.wx.js.cn> wrote in message
news:477d8db4@forums-1-dub...
> You can't import it but you can see souce code in it.
>
> Yoyo
>
> "pravin" <pravi...@femcareindia.com> wrote in message
> news:4774cfde@forums-1-dub...
forward
global type w_crystalreport from paf_w_base
end type
type ole_crviewer from olecustomcontrol within w_crystalreport
end type
end forward
global type w_crystalreport from paf_w_base
integer width = 2715
integer height = 1928
string title = "Crystal Report Viewer"
event type long ue_postopen ( )
ole_crviewer ole_crviewer
end type
global w_crystalreport w_crystalreport
type variables
OLEObject wi_ole_crx_application // application object
OLEObject wi_ole_crx_report // report object
OLEObject wi_ole_crx_connection_info // database connection properties
String wi_s_selectsql, wi_s_crystalreportdsn, is_file
end variables
forward prototypes
public function integer wf_viewreportbydsn ()
public function integer wf_viewreportbyadoresultset ()
end prototypes
event ue_postopen;call super::ue_postopen;Int li_p, li_p1, li_p2
n_cst_stringservice lnvo_string
// Open the report object
if is_file <> "" then
wi_ole_crx_report = wi_ole_crx_application.OpenReport(is_file)
if wi_s_crystalreportdsn = "" then
wi_s_selectsql = Trim(wi_ole_crx_report.SQLQueryString)
//cut "
lnvo_string = create n_cst_stringservice
wi_s_selectsql = lnvo_string.globalreplace(wi_s_selectsql, '"', '', false)
destroy lnvo_string
//cut table owner
li_p = Pos(wi_s_selectsql, ".dbo.")
do while li_p > 0
li_p1 = LastPos(wi_s_selectsql, " ", li_p)
li_p2 = Pos(wi_s_selectsql, " ", li_p + 1)
if li_p1 > 0 and li_p2 > 0 then
wi_s_selectsql = Replace(wi_s_selectsql, li_p1, li_p2 - li_p1, "")
end if
li_p = Pos(wi_s_selectsql, ".dbo.")
loop
//retrieve report
wf_viewreportbyadoresultset()
else
wf_viewreportbydsn()
end if
//set toolbar button
ole_crviewer.object.EnablePrintButton = false
ole_crviewer.object.EnableExportButton = true
ole_crviewer.object.EnableSearchExpertButton = true
ole_crviewer.object.EnableSelectExpertButton = true
if g_s_usertype = "R" then
ole_crviewer.object.EnableHelpButton = true
end if
end if
return 1
end event
public function integer wf_viewreportbydsn ();String ls_password, ls_user
// Set connection_info to Report ConnectionProperties
wi_ole_crx_connection_info =
wi_ole_crx_report.database.tables[1].ConnectionProperties
// Delete old connections
wi_ole_crx_connection_info.deleteAll
// Add new connection
wi_ole_crx_connection_info.add("DSN", wi_s_crystalreportdsn)
//RegistryGet(gnv_app.of_GetRegistryPath() + "DataSources\" + is_transaction
+ "\","userid", RegString!, ls_user)
//RegistryGet(gnv_app.of_GetRegistryPath() + "DataSources\" + is_transaction
+ "\","password", RegString!, ls_password)
wi_ole_crx_connection_info.add("User ID", ls_user)
wi_ole_crx_connection_info.add("Password", ls_password)
// Verify the database.
wi_ole_crx_report.database.Verify
// Set the report object parameter field by index number
//iole_crx_report.ParameterFields[1].AddCurrentValue(3)
// or use the GetItemByName property to pass the parameter
//wi_ole_crx_report.ParameterFields.GetItemByName("Employee
ID").AddCurrentValue(7)
//wi_ole_crx_report.EnableParameterPrompting = False
// pass report to the viewer
ole_crviewer.object.ReportSource(wi_ole_crx_report)
// view report
ole_crviewer.object.ViewReport
return 1
end function
public function integer wf_viewreportbyadoresultset ();Resultset
lrs_resultset
ADOresultset lrs_ADOresultset
OLEObject loo_ADOrecordset
Long ll_rc
n_Datastore lds_temp
n_cst_helperservice lnvo_helper
lds_temp = create n_datastore
lnvo_helper = create n_cst_helperservice
ll_rc = lnvo_helper.datastorefromsql(wi_s_selectsql, lds_temp, 1)
destroy lnvo_helper
if ll_rc <= 0 then
destroy lds_temp
return -1
end if
ll_rc = lds_temp.GenerateResultSet(lrs_resultset)
if ll_rc <> 1 then
destroy lds_temp
return -1 // report error and return
end if
lrs_ADOresultset = create ADOResultSet
ll_rc = lrs_ADOresultset.SetResultSet(lrs_resultset)
loo_ADOrecordset = create OLEObject
ll_rc = lrs_ADOresultset.GetRecordSet(loo_ADOrecordset)
wi_ole_crx_report.database.SetDataSource(loo_ADOrecordset, 3, 1)
destroy lds_temp
// pass report to the viewer
ole_crviewer.object.ReportSource(wi_ole_crx_report)
// view report
ole_crviewer.object.ViewReport
return 1
end function
on w_crystalreport.create
int iCurrent
call super::create
this.ole_crviewer=create ole_crviewer
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.ole_crviewer
end on
on w_crystalreport.destroy
call super::destroy
destroy(this.ole_crviewer)
end on
event resize;call super::resize;ole_crviewer.Move(0, 0)
ole_crviewer.Resize(newwidth, newheight)
end event
event open;call super::open;this.Event Trigger ue_preopen()
this.Event Post ue_postopen()
return 0
end event
event close;call super::close;if IsValid(wi_ole_crx_application) then
wi_ole_crx_application.DisconnectObject()
destroy wi_ole_crx_application
end if
end event
event ue_print;call super::ue_print;ole_crviewer.object.PrintReport()
return 1
end event
event ue_preopen;call super::ue_preopen;String ls_file
Long ll_row, ll_ret
for ll_row = 1 to UpperBound(wi_nvo_resource.ui_s_resourcedirectory)
ls_file = wi_nvo_resource.ui_s_resourcedirectory[ll_row] + "\" +
wi_s_curprgcode + ".rpt"
if FileExists(ls_file) then
is_file = ls_file
exit
end if
next
//RegistryGet(gnv_app.of_GetRegistryPath() + "DataSources\" + is_transaction
+ "\","crystalreportdsn", RegString!, wi_s_crystalreportdsn)
// create OLE object
wi_ole_crx_application = CREATE OLEObject
// connect to Application
ll_ret =
wi_ole_crx_application.ConnectToNewObject('CrystalRuntime.Application.11')
if ll_ret < 0 then
MessageBox("Error", "Can't connect to Crystal Application Object")
end if
end event
type ole_crviewer from olecustomcontrol within w_crystalreport
event closebuttonclicked ( ref boolean usedefault )
event firstpagebuttonclicked ( ref boolean usedefault )
event lastpagebuttonclicked ( ref boolean usedefault )
event prevpagebuttonclicked ( ref boolean usedefault )
event nextpagebuttonclicked ( ref boolean usedefault )
event gotopagenclicked ( ref boolean usedefault, integer pagenumber )
event stopbuttonclicked ( integer loadingtype, ref boolean usedefault )
event refreshbuttonclicked ( ref boolean usedefault )
event printbuttonclicked ( ref boolean usedefault )
event grouptreebuttonclicked ( boolean ocx_visible )
event zoomlevelchanged ( integer zoomlevel )
event searchbuttonclicked ( string searchtext, ref boolean usedefault )
event drillongroup ( any groupnamelist, integer drilltype, ref boolean
usedefault )
event showgroup ( any groupnamelist, ref boolean usedefault )
event selectionformulabuttonclicked ( ref string selctionformula, ref
boolean usedefault )
event selectionformulabuilt ( string selctionformula, ref boolean
usedefault )
event ocx_clicked ( long ocx_x, long ocx_y, any eventinfo, ref boolean
usedefault )
event dblclicked ( long ocx_x, long ocx_y, any eventinfo, ref boolean
usedefault )
event downloadstarted ( integer loadingtype )
event downloadfinished ( integer loadingtype )
event viewchanging ( long oldviewindex, long newviewindex )
event viewchanged ( long oldviewindex, long newviewindex )
event onreportsourceerror ( string errormsg, long errorcode, ref boolean
usedefault )
event exportbuttonclicked ( ref boolean usedefault )
event searchexpertbuttonclicked ( ref boolean usedefault )
event drillongraph ( long pagenumber, long ocx_x, long ocx_y, ref boolean
usedefault )
event drillonsubreport ( any groupnamelist, string subreportname, string
title, long pagenumber, long index, ref boolean usedefault )
event helpbuttonclicked ( )
event focuschanged ( boolean hasfocus )
event oncontextmenu ( any objectdescription, long ocx_x, long ocx_y, ref
boolean usedefault )
event onchangeobjectrect ( any objectdescription, long ocx_x, long ocx_y,
long ocx_width, long ocx_height )
event onlaunchhyperlink ( ref string hyperlink, ref boolean usedefault )
event viewclosed ( long viewindex )
integer width = 1317
integer height = 768
integer taborder = 10
borderstyle borderstyle = stylelowered!
boolean focusrectangle = false
string binarykey = "w_crystalreport.win"
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
end type
event refreshbuttonclicked(ref boolean usedefault);if wi_s_crystalreportdsn
= "" then
//don't use default refresh action
usedefault = false
wf_viewreportbyadoresultset()
end if
end event
event helpbuttonclicked();//open report designer
n_cst_shell lnvo_shell
if is_file <> "" then
lnvo_shell.of_initialize()
lnvo_shell.of_open(is_file)
end if
end event
"Jim Madderra" <jmad...@astound.net> wrote in message
news:477d97af$1@forums-1-dub...
"Yoyo Young" <yo...@public1.wx.js.cn> wrote in message
news:47819826@forums-1-dub...
Yoyo
"Andrew Giulinn" <NO.osc...@NOSPAM.dsa.com.au> wrote in message
news:47819ff7@forums-1-dub...