Develop report system with PB

zhaozj2021-02-11  197

A system of reporting under the PB development WEB: Flow square Home: http: //liulee.myrice.com

In the process of building an internal information network, involving a large number of DBF files directly converted to an HTML file, other file formats (Excel, Access, and large database queries) also have this requirement, thereby using PB Implement the PSR file generation tool based on ODBC queries. The principle of this generator is: 1. Generate a DataWindow syntax by extracting the SQL syntax of the query, 3, the syntaxfromsql () function generates a DataWindow syntax, 4, create () function generates data window 5, and performs the generated data window Modification, including adding objects, deleting objects, modifying objects, arranging objects, etc., making the landscaping work. 6. Use the Saves () function of the generated data window as the PSR file. 7. Display the PSR file using a plugin method or direct connection in the HTML page. During the implementation, various syntax of the data window function modify () is used to implement modifications to the data window, such as adding a line, adding text, changing format, color, etc. The modified content is as follows: This tool mainly includes the following features: Therefore, simply copy the updated data to the specified location, or add certain conditions when forming the SQL syntax, you can implement automated report processing. When processing, the required report loop will automatically set the ODBC connection parameter (method using the write registry), automatically connect the database, open the data window corresponding to the report, retrieve record, then save as a predetermined PSR file. 2. Practical use of this tool specifically for queries, which can be extended to any data source connected to ODBC, as long as the data source supports standard SQL queries. Especially for the OA or information release, some DBF files in a long-standing Fox system are required, as long as they are in one definition, they can be done by a few buttons. Especially in Notes, simply insert the PSR file as an attachment into the document, you can implement the web release in the client to define the PLUGIN. [Technical Point Reference] 1. Creating a Data Window Object Implementing the Modify () function of Data Window, Syntax: DW_REPORT.MODIFY ('Create Text (Name = UC_Text_001 x = "10" y = "20" width = "300". ... ') By ​​assigning values ​​for specific objects (Static Text, Picture, Rectangle, Line, Compute, etc.) (Note Brackets & Match), such as X, Y, Width, Height, Color, Font, Background.color , Background.Mode, Expression, Format, etc., you can implement object creation. Special attention when creating objects is to join the movable = 1 resizeable = 1 syntax, actually set the object to removable, variable size, this for object Adjustment is more important. Delete objects simply use the following title: DW_REPORT.MODIFY how to implement the way to create objects in the PB development environment?

1. Establish a menu (set Bar's Toolbar's Object Type to menucascade, the item item is to create objects),

2. Write in the Clicked Event of each menu item:

Parent.toolbaritemdown = false // Make the ToolbarItem mf_createObject ('Stop')

Unified call function mf_create_object ([object category]), [object category] can be customized, such as "text", "line", etc.

3, the mf_create_object function is as follows (argument is string object_string)

Window LW_SHEET

LW_SHEET = ParentWindow.GetActiveesheet ()

IF isvalid (lw_sheet) THEN

LW_SHEET.TRIGGEREVENT ('UE_CREATEOBJECT', 0, OBJ_STRING)

END IF

This function gets the currently open Sheet window LW_SHEET and then calls the UE_CREATEOBJECT custom event under the window.

4, in the main window, custom ue_createobject event that the main response is as follows: string PassedString PassedString = String (Message.LongParm, "address") // create the type taken if isnull (passedstring) or passedstring = 'STOP' then m_main .m_objects.toolbaritemdown = false ib_creatingObject = false return end if ib_creatingobject = True // wait for the click event dw_report to trigger is_objectstring = passedstring // inform current trigger objects 5, in the event dw_report clicked in, writes the following syntax: if NOT ib_creating_object then return // instance variables, records are created in the state m_main.m_objects.toolbarItemdown = false // restore ToolbarItem state if isnull (is_objectstring) then return // unexpected judgment ib_creatingobject = false // stop creating choose case is_objectstring ...... [create specific Syntax] 2, selecting objects Generating Windows style selection form mainly includes: radio, ctrl radio, box selection: easy to implement, use the getObjectpointUinter () function in DataWindow's CLICKED event, then taken in This object draws the Rectangle tag four weeks (clear other selected object selection); multi-selection: Decision in the CLICKED event to determine if there is CTRL Press if KeyDown (KeyControl!) Then ... Add Options List (array) Show taggers Select: You need to work with 3 events Clicked: (Mouse Click) Record the position of the left button to press (Pixels), consider the displacement amount generated by the ScrollHorizontal event (Unit) IB_RECT_SELECT = true // box selection start II_Mousex = UnitStopixels (II_HSCROLL_ !! Offset, xunitstopixels) xpos ii_mousey = unitstopixels (ii_vscroll_offset, yunitstopixels) ypos ue_mousemove: (custom events, Evend ID = pbm_dwnmousemove) (mouse movement) // dynamically create a marquee rectangle if NOT ib_rectselect then return int li_height , li_width, x2, y2, x1, y1 x1 = ii_mousex y1 = ii_mousey x2 = unitstopixels (! ii_hscroll, xunitstopixels) xpos y2 = unitstopixels (! ii_vscroll, yunitstopixels) ypos li_height = y2 - y1 li_width = x2 - x1 x1 = Pixelstounits (x1, xpixelstounits!) Y1 =

pixelstounits (y1, ypixelstounits!) hh = pixelstounits (hh, ypixelstounits!) ww = pixelstounits (ww, xpixelstounits!) string ls_mstring ls_mstring = 'create rectangle (band = foreground name = uc_rect_select x = "' string (x1) & '"y ="' string (y1) '"width ="' string (ww) '"height ="' string (hh) '"' & 'brush.hatch =" 7 "brush .COLOR = "553648127" Pen.style = "2" pen.width = "5" ' &' pen.color = "1090519039" Background.Mode = "2" background.color = "255") 'DW_PRE.SetredRAW (false) DW_PRE.MODIFY ('destroy uc_rect_select') // Remove the old rectangular box DW_PRE.MODIFY (LS_MString) // Create a new rectangle DW_PRE.SETREDREDREDRETREDREDRETREDRETREDRETRETREDREDREFTBUTTONUP: (Custom Event, Evend ID = pbm_lbuttonup) // left mouse button to lift the left mouse button raised, if you are in ib_rectselect state, the end of the selected state if NOT ib_rectselect then return dw_pre.setredraw (false) dw_pre.modify ( 'destroy uc_rect_select') dw_pre.setredraw (true) IB_RectSelect = false ... // Processing Select Objects The multi-object box selection can be implemented through the synergy of the above three events. 3, Auto Connect ODBC Auto Connection ODBC means that you do not need to define ODBC connection parameters yourself, automatically implement the connection, on the one hand, simplify the user's operation, on the other hand, make batch custom reports possible. The implementation of the automatic connection ODBC is implemented by writing a registry. The main functions are used, and there are two: registrySet () registryget () through the registryset () function, rewrite the registry primary key and related key value: HKEY_CURRENT_USER / SOFTWARE / ODBC / ODBC.INI / [ODBC Source Name] HKEY_CURRENT_USER / SOFTWARE / ODBC / ODBC.INI / ODBC Data Sources [ODBC Source Name] To create or modify ODBC SOURCE, such as HKEY_CURRENT_USER / SOFTWARE / ODBC / ODBC.INI / SYSTEM This primary key There are several key values ​​to record the parameters of the connection, such as the typical setting of Sybase SQL Anyway 5.0:

Key Value Name Enlightenment AutoStop YES Program After calling, automatically terminating the connection DatabaseFile C: / Program Files / DBF Auto Report /System.db Database Document DatabaseName System Connection Name Description Auto Generate ODBC Description Driver C: / Program Files / DBF News / WOD50T.DLL driver syntax Explanation PWS SQL User Password START C: / Program Files / DBF Auto Report / DBENG50 -C8192 Driver and Parameters - CACHE UID DBA Database User Name This ODBC source with 8192K memory In the primary key: hkey_current_user / soft / odbc / odbc.ini / odbc data source, add the corresponding key value:

Key Value Name Value Meaning System Sybase SQL Anywhere 5.0 ODBC Source Name and Classification

After doing your hand, you can connect directly in the program.

转载请注明原文地址:https://www.9cbs.com/read-3749.html

New Post(0)