Ø Use Formula One to implement dynamic reporting technology (3) in .NET
5. After the template saves the database, open this template management module, all existing template names are listed, and the template name is selected to read the template in the F1 control from the current database to display and modify. You can make a script writing in the SELECTEDEXCHANGED event of the box control.
Private void Combotemplate_selectedIndexchanged (Object Sender, System.EventArgs E)
{
IF (ComboteMplate.Text.trim () == "" "
{
Messagebox.show ("There is no template that you can read!");
Return;
}
// Get the BYTE Template from the database
String [] TPLINFO = TemplatesPlit (ComboteMplate.Text.trim ());
String strquery = "SELECT RPT_DATA from report_list_data where rpt_id =" TPLINFO [1] "AND RPT_NAME = '" TPLINFO [0] "'"
DataTable DT = New DataTable ();
Funclib.getTableBysql (DT, True, StrQuery);
IF (dt.rows.count <1)
{
Messagebox.show ("did not find relevant records! Templates in the BLOB form in the database and display failed!");
Return;
}
Else
{
Byte [] Data = (byte []) Dt.Rows [0] ["rpt_data"];
// Create a temporary file
IF (File.Exists ("f1Temp.vts")) File.Delete ("f1Temp.vts");
Using (File.create ("F1Temp.vts", 1024) {}
// read the template stored in Byte [] into the temporary file
ByTetOfile (Data, "F1TEMP.VTS");
// F1 Control Read Template
Axf1book1.readex ("f1temp.vts");
/ / Delete temporary files
File.delete ("f1Temp.vts");
}
}
Note: 1.FunClib.getTableBysql () is filled in the specified DataTable based on the specified SQL generated data.
2. Templatesplit () is a function divided on the template name.
// From the mode "Template Name [1234]" or "Template Name [1234] [5678]", "Template Name" and "1234" are separated.
Private string [] Templatesplit (String STR)
{
String strname = STR;
String [] stratay = new string [2];
Strarray [0] = Strname.Substring (0, strname.indexof ("["));
Str = str.remove (0, str .indexof ("[") 1);
Strarray [1] = Str.Substring (0, str .indexof ("]"));
Return stratay;
}
3. ByTTOFILE () function The function is to write binary streams to the specified file // byte [] -> file
Private vid bytetofile (Byte [] Data, String FileName)
{
Using (filestream fs = file.openwrite (filename))
{
Fs.write (Data, 0, Data.Length);
}
}
6. Delete Template
/ / Delete the current template
Private void btndel_click (Object Sender, System.Eventargs E)
{
IF ("Funclib.handQuestion (" Confirm Delete Current Template? ") == DialogResult.no) Return;
IF (Combotemplate.Text.trim () == "") ComboteMplate.selectedItem = 0;
IF (ComboteMplate.Text.trim () == "") Return;
String [] TPLINFO = TemplatesPlit (ComboteMplate.Text.trim ());
String strdel = "delete from report_list_data where rpt_id =" TPLINFO [1] "AND RPT_NAME = '" TPLINFO [0] "'"
Funclib.executesqlcommand (strdel);
/ / Clear the original data (will clear the template)
AXF1BOOK1.CLARRANGE (-1, -1, -1, -1, ttf160.f1cleartypeConstants.f1clerall);
/ / Delete the drop-down list box current entry
Combotemplate.Items.Remove (Combotemplate.SelectedItem);
}
to sum up
At this point, a template management template is basically completed. It can be seen in .NET or good use of the Formula One control to extend the original report technology, enhance your development efficiency, speed up the project development process!
Reference: "From the .NET client invokes a COM component" Author: Mike Gunderloy