首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

Flex+SQL Server做个售票系统,会实现成联打印汽车票么?(票纸张须自定义)

2012-09-04 
Flex+SQL Server做个售票系统,能实现成联打印汽车票么?(票纸张须自定义)Flex+SQL Server做个售票系统,能实

Flex+SQL Server做个售票系统,能实现成联打印汽车票么?(票纸张须自定义)
Flex+SQL Server做个售票系统,能实现成联打印汽车票么?(票纸张须自定义)
为了让Flex支持这种预览和打印报表功能,需要加什么东西?

[解决办法]
可以调用打印功能,只不过这个打印的功能就是浏览器的打印功能。
但是可以选择要打印的目标对象和打印的范围
[解决办法]
可以做打印,PrintDataGrid 组件,当然你也可自定义实现. 

<?xml version="1.0"?>
<!-- printing\DGPrint.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

<mx:Script>
<![CDATA[
import mx.printing.*;

// Create a PrintJob instance.
private function doPrint():void {
// Create an instance of the FlexPrintJob class.
var printJob:FlexPrintJob = new FlexPrintJob();

// Start the print job.
if (printJob.start() != true) return;

// Add the object to print. Do not scale it.
printJob.addObject(myDataGrid, FlexPrintJobScaleType.NONE);

// Send the job to the printer.
printJob.send();
}
]]>
</mx:Script>

<mx:VBox id="myVBox">
<mx:DataGrid id="myDataGrid" width="300">
<mx:dataProvider>
<mx:Object Product="Flash" Code="1000"/>
<mx:Object Product="Flex" Code="2000"/>
<mx:Object Product="ColdFusion" Code="3000"/>
<mx:Object Product="JRun" Code="4000"/>
</mx:dataProvider>
</mx:DataGrid>
<mx:Button id="myButton" 
label="Print" 
click="doPrint();"/>
</mx:VBox>
</mx:Application>



<?xml version="1.0"?>
<!-- printing\DGPrintCustomComp.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
height="450" 
width="550">

<mx:Script>
<![CDATA[
import mx.printing.FlexPrintJob;
import myComponents.MyPrintView;

public function doPrint():void {
// Create a FlexPrintJob instance.
var printJob:FlexPrintJob = new FlexPrintJob();

// Start the print job.
if(printJob.start()) {
// Create a MyPrintView control as a child 
// of the current view.
var formPrintView:MyPrintView = new MyPrintView();
addChild(formPrintView);

// Populate the print control's contact label 
// with the text from the form's name, 
// phone, and e-mail controls.
formPrintView.contact.text = 
"Contact: " + custName.text + " " +
custPhone.text + " " + custEmail.text;

// Set the print control's data grid data provider to be 
// the displayed data grid's data provider.
formPrintView.myDataGrid.dataProvider = 
myDataGrid.dataProvider;

// Add the SimplePrintview control to the print job.
// For comparison, try setting the 
// second parameter to "none".
printJob.addObject(formPrintView);



// Send the job to the printer.
printJob.send();

// Remove the print-specific control to free memory.
removeChild(formPrintView);
}
}
]]>
</mx:Script>

<!-- The form to display-->
<mx:Form id="myForm">
<mx:FormHeading label="Contact Information"/>
<mx:FormItem label="Name: ">
<mx:TextInput id="custName" 
width="200" 
text="Samuel Smith"
fontWeight="bold"/>
</mx:FormItem>
<mx:FormItem label="Phone: ">
<mx:TextInput id="custPhone" 
width="200" 
text="617-555-1212"
fontWeight="bold"/>
</mx:FormItem>
<mx:FormItem label="Email: ">
<mx:TextInput id="custEmail" 
width="200" 
text="sam@sam.com"
fontWeight="bold"/>
</mx:FormItem>

<mx:FormHeading label="Product Information"/>
<mx:DataGrid id="myDataGrid" width="300">
<mx:dataProvider>
<mx:Object Product="Flash" Code="1000"/>
<mx:Object Product="Flex" Code="2000"/>
<mx:Object Product="ColdFusion" Code="3000"/>
<mx:Object Product="JRun" Code="4000"/>
</mx:dataProvider>
</mx:DataGrid>
<mx:Button id="myButton" 
label="Print" 
click="doPrint();"/>
</mx:Form>
</mx:Application>

热点排行