本文介绍了在Windows窗体应用程序代码中转换Web应用程序代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家早上好...
以下代码在
中的.aspx页中运行良好Web应用程序.现在,我想在Windows窗体应用程序中做同样的事情.谁能帮我.
该代码用于不保存pdf文件的情况下进行打印.在.aspx页面中效果很好:
Good morning everybody...
The following code works well in .aspx page that is in
web application. Now the same thing i want to do in windows form application. Can anybody help me.
The code is for without saving the pdf file take a print. It works well in .aspx page:
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load("E:\\Report1\\over\\CrystalReport1.rpt");
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load("E:\\Report1\\over\\CrystalReport1.rpt");
MemoryStream oStream; // using System.IO
oStream = (MemoryStream)
cryRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(oStream.ToArray());
Response.End();
在Windows中,不支持Response.Clear
或Response.Buffer
.
错误缺少命名空间或指令正在显示...
In windows form the Response.Clear
or Response.Buffer
is not supported.
Error is missing namespace or directive is displaying...
推荐答案
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShipmentExpress.aspx.cs"
Inherits="Ess.ESuite.Waste.UI.ShipmentExpress" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Shipment Express</title>
<script type="text/javascript" src="../include/e6include.js"></script>
<script type="text/javascript" src="../include/CalendarJS.js"></script>
<link href="../include/Sections.css" type="text/css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="ScriptManager1" EnableScriptGlobalization="true">
</asp:ScriptManager>
<div id="essActBtn">
<table width="100%">
<tr>
<td align="left">
<ess:essActionButtons ID="btnAction" ShowCopy="true" runat="server" />
</td>
</tr>
</table>
</div>
<ess:essTextBox ID="txtShipId" runat="server" Style="display: none" ControlSource="WST_SHPT_ID" />
<ess:essTextBox ID="hidStatusId" runat="server" ControlSource="StatusId" Style="display: none" />
<ess:essTextBox ID="hidStatusDate" runat="server" ControlSource="StatusDate" Style="display: none" />
<ess:essTextBox ID="Action" runat="server" Style="display: none" />
<ess:essSection ID="HeaderSection" Title="Shipment Express" ResourceName="ShipmentExpressLabel"
Width="100%" runat="server">
<Content>
<table class="InputTable">
<tr>
<td class="LabelTD">
<esuite:e6UIValidator runat="server" ControlToValidate="acddGenerator" Required="true"
FieldCaption="Generator" FieldResourceName="ShipmentFormGeneratorLabel" ShowFieldCaption="true" />
:
</td>
<td colspan="3">
<ess:AutoCompleteDropDown ID="acddGenerator" runat="server" ControlSource="GENERT_SITE"
DisplaySource="GENERATORSITE" GetDisplayValueOnDataBind="true" AutoCompleteParameter="SITE_LIKE"
DataTextField="SITE" DataValueField="VLD_SITE_ID" FilterParams="WST_GEN_SITE,-1"
ListSourceXML="_ESSXML/SiteACSel.xml" Width="100%" OnItemSelected="generatorSelected" />
</td>
</tr>
<tr>
<td class="LabelTD">
<esuite:e6UIValidator ShowFieldCaption="true" FieldResourceName="ShipmentDisposalFacilityLabel"
ControlToValidate="acddTSDF" FieldCaption="Disposal Facility" Required="True"
runat="server" />
:
</td>
<td colspan="3">
<ess:AutoCompleteDropDown ID="acddTSDF" runat="server" ControlSource="RECV_SITE_ID"
DisplaySource="TSDFSITE" AutoCompleteParameter="SITE_LIKE" DataTextField="SITE"
DataValueField="VLD_SITE_ID" FilterParams="WST_RECD_SITE,-1;TSD_APPROVED,-1"
ListSourceXML="_ESSXML/SiteACSel.xml" Width="100%" />
</td>
</tr>
<tr>
<td class="LabelTD">
<esuite:e6UIValidator runat="server" Required="true" FieldCaption="Shipment Number"
ShowFieldCaption="true" FieldResourceName="ShipmentShipmentNumberLabel" ControlToValidate="txtShipNum" />
:
</td>
<td width="49%">
<ess:essTextBox ID="txtShipNum" ControlSource="SHPT_NUM" Width="90%" MaxLength="35"
runat="server" />
</td>
<td class="LabelTD">
<ess:essLabel ResourceName="TrackingDocumentLabel" runat="server">Tracking/Document #</ess:essLabel>:
</td>
<td width="49%">
<ess:essTextBox ID="txtManDocNum" ControlSource="MANIFEST_DOC_NUM" Width="150px"
MaxLength="13" runat="server" />
</td>
</tr>
<tr>
<td class="LabelTD">
<ess:essLabel ResourceName="ShipmentManifestFormLabel" runat="Server">Manifest Form</ess:essLabel>:
</td>
<td>
<ess:essDropDownList ID="ddlManifestForm" ControlSource="MANIFEST_FORM" runat="server" />
</td>
<td class="LabelTD">
<ess:essLabel ResourceName="ShipmentFormStatusLabel" runat="Server">Status</ess:essLabel>:
</td>
<td>
<ess:essDropDownList ID="ddlStatus" ControlSource="StatusId" runat="server" />
</td>
</tr>
<tr>
<td class="LabelTD">
<ess:essLabel ResourceName="ShipmentFormShipDateLabel" runat="server">Shipment Date</ess:essLabel>:
</td>
<td>
<ess:essTextBox ID="txtShipDate" ControlSource="SHPT_DATE" IsDate="True" Width="80px"
runat="server" />
<ess:essDatePicker ID="dpShipDate" TargetField="txtShipDate" runat="server" />
<esuite:e6UIValidator FieldResourceName="ShipmentShipmentDateLabel" ControlToValidate="txtShipDate"
FieldCaption="Shipment Date" Type="Date" runat="server" />
</td>
<td class="LabelTD">
<ess:essLabel ResourceName="ShipmentShipmentReceivedDateLabel" runat="server">Received Date</ess:essLabel>:
</td>
<td>
<ess:essTextBox ID="txtReceiveDate" ControlSource="SHPT_RECV_DATE" IsDate="True"
Width="80px" runat="server" />
<ess:essDatePicker TargetField="txtReceiveDate" runat="server" />
<esuite:e6UIValidator FieldResourceName="ShipmentShipmentReceivedDateLabel" ControlToValidate="txtReceiveDate"
FieldCaption="Received Date" Type="Date" runat="server" />
</td>
</tr>
<tr>
<td class="LabelTD">
<ess:essLabel ResourceName="ShipmentShipmentContactLabel" runat="Server">Shipment Contact</ess:essLabel>:
</td>
<td colspan="3">
<ess:AutoCompleteDropDown ID="acddContact" runat="server" ControlSource="SHPT_CONTACT_ID"
GetDisplayValueOnDataBind="true" AutoCompleteParameter="Full Name" DataTextField="CONTACT"
DataValueField="VLD_CONTACT_ID" IDFieldParam="VLD_CONTACT_ID" ListSourceXML="_ESSXML/SiteContactSel.xml"
Width="100%" OnPopulating="contactLoading" />
</td>
</tr>
<tr>
<td colspan="4">
<fieldset class="FieldSet">
<ess:essLegend ID="legendEmergencyContact" Text="Emergency Contact" ResourceName="ShipmentEmergencyContactTitle"
runat="server" />
<table class="InputTable">
<tr>
<td class="LabelTD">
<ess:essLabel ID="lblEmergencyContact" ResourceName="ShipmentContactLabel" runat="Server">Contact</ess:essLabel>:
</td>
<td width="65%">
<ess:AutoCompleteDropDown ID="ddlEmerContact" GetDisplayValueOnDataBind="true" AutoCompleteParameter="Full Name"
DataTextField="CONTACT" DataValueField="VLD_CONTACT_ID" ControlSource="EMER_CONTACT_ID"
ListSourceXML="_ESSXML/Waste/EntityEmergencyContactSel.xml" OnPopulating="contactLoading"
OnItemSelected="emergencyContactSelected" Width="95%" runat="server" />
</td>
<td class="LabelTD">
<ess:essLabel ID="lblEmergencyPhone" ResourceName="ShipmentPhoneLabel" runat="Server">Phone</ess:essLabel>:
</td>
<td width="25%">
<ess:essTextBox ID="txtEmerPhone" ControlSource="SPILL_ASST_24_HR_NUM" Width="120px"
runat="server"></ess:essTextBox>
</td>
</tr>
</table>
</fieldset>
</td>
</tr>
<tr>
<td colspan="4" align="center">
<ess:essHtmlButton ID="btnViewMan" runat="Server" ResourceName="ShipmentViewManifestButton"
OnClick='viewManifest("no");'>
View Manifest</ess:essHtmlButton>
<ess:essHtmlButton ID="btnPrintMan" runat="Server" ResourceName="ShipmentPrintManifestButton"
OnClick='viewManifest("yes");'>
Print Manifest</ess:essHtmlButton>
</td>
</tr>
</table>
</Content>
</ess:essSection>
<ess:essSection ID="TransportersSection" runat="server" Title="Transporters" ResourceName="ShipmentFormTransporterLegend"
Width="100%">
<Content>
<table class="InputTable">
<tr>
<td>
<a id="lnkAddTransporter" href="javascript:void(0);">
<ess:essLabel runat="server" ResourceName="ShipmentFormAddTranLink">Add Transporter</ess:essLabel>
</a>
</td>
</tr>
<tr>
<td>
<ess:DynamicGridMover ID="grdTransporters" DataMember="WST_SHPT_TRAN" runat="server"
OrderFieldName="ORDINAL_NUM">
<ColumnsTemplate>
<ess:DynamicGridColumn ID="colTransporter" Width="50%" HeaderText="Transporter" ResourceName="ShipmentFormTranColHeader"
FieldName="TRANSPORTER" runat="server" />
<ess:DynamicGridColumn ID="colTransEPAId" Width="16%" HeaderText="EPA ID" ResourceName="ShipmentFormTranEPAIDColHeader"
FieldName="EPAID" runat="server" />
<ess:DynamicGridColumn ID="colTransStateId" Width="16%" HeaderText="State ID" ResourceName="ShipmentFormTranStateIDColHeader"
FieldName="TRAN_STATE_ID" runat="server" />
<ess:DynamicGridColumn ID="colTransPhone" Width="16%" HeaderText="Phone" ResourceName="ShipmentFormTranPhoneColHeader"
FieldName="TRANSPHONE" runat="server" />
</ColumnsTemplate>
</ess:DynamicGridMover>
</td>
</tr>
</table>
<ess:DynamicGridDataPanelExtender ID="dpTransporters" runat="server" TargetGridID="grdTransporters"
TargetPanelID="pnlEditTransporter" SaveControlID="btnSaveTransporter" NewControlID="lnkAddTransporter"
OnNew="newTransporter" />
<ess:PopupPanel ID="pnlEditTransporter" runat="server" Title="Transporter" TitleResourceName="TransporterLabel"
Height="220" Width="600" Animation="SlideDownAndRightAnimation" HideControlID="btnCancelTransporter"
PositionControlID="lnkAddTransporter">
<table class="InputTable">
<tr>
<td class="LabelTD">
<ess:essLabel runat="server" ResourceName="TransporterLabel">Transporter</ess:essLabel>:
</td>
<td>
<ess:AutoCompleteDropDown ID="acddTransporter" runat="server" ControlSource="VLD_SITE_ID"
DisplaySource="TRANSPORTER" RenderControlSource="true" TableName="XYZ" DataTextField="SITE"
DataValueField="VLD_SITE_ID" AutoCompleteParameter="SITE_LIKE" FilterParams="TRAN_SITE,-1"
OnItemSelected="transporterSelected" ListSourceXML="_ESSXML/SiteACSel.xml" Width="100%" />
</td>
</tr>
<tr>
<td class="LabelTD">
<ess:essLabel runat="server" ResourceName="CityLabel">City</ess:essLabel>:
</td>
<td>
<ess:essTextBox ID="txtTranCity" runat="server" ControlSource="CITY" ReadOnly="true"
RenderControlSource="true" TableName="XYZ" Width="80%" />
</td>
</tr>
<tr>
<td class="LabelTD">
<ess:essLabel runat="server" ResourceName="ShipmentFormTranPhoneColHeader">Phone</ess:essLabel>:
</td>
<td>
<ess:essTextBox ID="txtTranPhone" runat="server" ControlSource="TRANSPHONE" ReadOnly="true"
RenderControlSource="true" TableName="XYZ" Width="80%" />
</td>
</tr>
<tr>
<td class="LabelTD">
<ess:essLabel runat="server" ResourceName="ShipmentFormTranEPAIDColHeader">EPA ID</ess:essLabel>:
</td>
<td>
<ess:essTextBox ID="txtTranEPAID" runat="server" ControlSource="EPAID" ReadOnly="true"
RenderControlSource="true" TableName="XYZ" Width="80%" />
</td>
</tr>
<tr>
<td class="LabelTD">
<ess:essLabel runat="server" ResourceName="StateIDLabel">State ID</ess:essLabel>:
</td>
<td>
<ess:AJAXDropDown ID="ddlStateId" runat="server" ControlSource="TRAN_STATE_ID" DisplaySource="TRAN_STATE_ID"
ListSourceXML="_ESSXML/Waste/SiteStateRCRAIDSel.xml" DataTextField="IDEN_NUM"
DataValueField="IDEN_NUM" LoadListOnServer="false" RenderControlSource="true"
TableName="XYZ" Width="50%" />
<ess:DependentDropDownExtender ID="ddeStateId" runat="server" FilterControlID="acddTransporter"
FilterParameter="VLD_SITE_ID" TargetControlID="ddlStateId" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<ess:essHtmlButton ID="btnSaveTransporter" runat="server" ResourceName="OKButton"
Text="OK" />
<ess:essHtmlButton ID="btnCancelTransporter" runat="server" ResourceName="CancelButton"
Text="Cancel" />
</td>
</tr>
</table>
<input id='hidTransporterRow' controlsource="RowIndex" type="hidden" />
</ess:PopupPanel>
</Content>
</ess:essSection>
<ess:essSection ID="WasteSection" runat="server" Title="Waste Material Information"
ResourceName="ShipExpressLineItemHeader" Width="100%">
<Content>
<table class="InputTable">
<tr>
<td>
<a id="lnkAddMaterial" href="javascript:void(0);">
<ess:essLabel runat="server" ResourceName="AddMaterialLabel">Add Material</ess:essLabel>
</a>
</td>
</tr>
<tr>
<td>
<ess:DynamicGridMover ID="grdMaterials" DataMember="WST_SHPT_LINE" runat="server"
OrderFieldName="LINE_ITEM_NUM">
<ColumnsTemplate>
<ess:DynamicGridColumn ID="colMaterial" FieldName="MAT_NAME" HeaderText="Material Name"
Width="50%" ResourceName="MaterialsMaterialNameLabel" runat="server" />
<ess:DynamicGridColumn ID="colStreamId" FieldName="STREAM_NUM" HeaderText="Waste Stream No."
Width="20%" ResourceName="WasteStreamNoLabel" runat="server" />
<ess:DynamicGridColumn ID="colContainer" FieldName="NUM_CONTAINERS" HeaderText="Containers"
Width="8%" ResourceName="ARSContainersLabel" runat="server" />
<ess:DynamicGridColumn ID="colContainType" DataSource="CONTAINERCODE" DataType="String"
HeaderText="Container Type" Width="10%" ResourceName="ContainerTypeLabel" runat="server" />
<ess:DynamicGridColumn ID="colQuantity" FieldName="WT_VOL" HeaderText="Quantity"
Width="10%" ResourceName="QuantityLabel" DataType="Double" runat="server" />
<ess:DynamicGridColumn ID="colUnit" FieldName="UNIT_MANIFEST_CODE" HeaderText="Units"
Width="5%" ResourceName="UnitsLabel" runat="server" />
</ColumnsTemplate>
</ess:DynamicGridMover>
</td>
</tr>
</table>
<ess:DynamicGridDataPanelExtender ID="dpMaterials" runat="server" TargetGridID="grdMaterials"
TargetPanelID="pnlEditMaterial" OnBeforeSave="materialsBeforeSave" SaveControlID="btnSaveMaterial"
NewControlID="lnkAddMaterial" />
<ess:PopupPanel ID="pnlEditMaterial" runat="server" Title="Material" TitleResourceName="MaterialHeader"
Height="200" Width="600" Animation="SlideDownAndRightAnimation" HideControlID="btnCancelMaterial"
PositionControlID="lnkAddMaterial">
<table class="InputTable">
<tr>
<td class="LabelTD">
<ess:essLabel runat="server" ResourceName="MaterialLabel" Class="RequiredLabel">Material</ess:essLabel>:
</td>
<td colspan="3">
<ess:AutoCompleteDropDown ID="acddMaterial" runat="server" AutoCompleteParameter="Waste Profile"
ControlSource="MAT_ID" DisplaySource="MAT_NAME" DataTextField="MAT_NAME" DataValueField="MAT_ID"
ListSourceXML="_ESSXML/Waste/WasteProfileLookup.xml" FilterParams="*APPROVED,-1"
RenderControlSource="true" TableName="XYZ" Width="100%" OnPopulating="materialLoading"
OnItemSelected="materialSelected" />
</td>
</tr>
<tr>
<td class="LabelTD">
<ess:essLabel runat="server" ResourceName="WasteStreamNoLabel">Waste Stream No.</ess:essLabel>:
</td>
<td colspan="3">
<input type="text" id="txtProfileNum" class="ReadOnly" readonly="readonly" style="width: 80%"
controlsource="STREAM_NUM" />
</td>
</tr>
<tr>
<td class="LabelTD">
<ess:essLabel runat="server" ResourceName="NumberofContainersLabel">Number of Containers</ess:essLabel>:
</td>
<td width="35%">
<input type="text" id="txtNumContainers" style="width: 80px" controlsource="NUM_CONTAINERS" />
</td>
<td class="LabelTD">
<ess:essLabel runat="server" ResourceName="ContainerTypeLabel">Container Type</ess:essLabel>:
</td>
<td width="63%">
<ess:essDropDownList ID="ddlContType" runat="server" ControlSource="VLD_CONTAINER_MANIFEST_ID"
DisplaySource="CONTAINER_MANIFEST_CODE" DataTextField="CONTAINER_MANIFEST_CODE"
DataValueField="VLD_CONTAINER_MANIFEST_ID" RenderControlSource="true" ListSourceXML="_ESSXML/Validation/Waste/ContainerTypeManifestCodesSel.xml"
TableName="XYZ" />
</td>
</tr>
<tr>
<td class="LabelTD">
<ess:essLabel runat="server" ResourceName="QuantityLabel">Quantity</ess:essLabel>:
</td>
<td width="35%">
<input type="text" id="txtQty" style="width: 80px" controlsource="WT_VOL" />
</td>
<td class="LabelTD">
<ess:essLabel runat="server" ResourceName="UnitsLabel">Units</ess:essLabel>:
</td>
<td>
<ess:essDropDownList ID="ddlUnit" runat="server" ControlSource="WT_VOL_UNIT" DisplaySource="UNIT_MANIFEST_CODE"
DataTextField="UNIT_MANIFEST_CODE" DataValueField="UNIT" FilterParams="NULL_MANIFEST_ID,NOT NULL"
ListSourceXML="_ESSXML/Validation/UnitList.xml" RenderControlSource="true" TableName="XYZ" />
</td>
</tr>
<tr>
<td colspan="4" align="center">
<ess:essHtmlButton ID="btnSaveMaterial" runat="server" ResourceName="OKButton" Text="OK" />
<ess:essHtmlButton ID="btnCancelMaterial" runat="server" ResourceName="CancelButton"
Text="Cancel" />
</td>
</tr>
</table>
<input id='hidMatRow' controlsource="RowIndex" type="hidden" />
</ess:PopupPanel>
</Content>
</ess:essSection>
<ess:essSection ID="SpecHandlingSection" runat="server" Title="Special Handling Instructions"
ResourceName="SpecialHandlingInstructionsTitle" Width="100%">
<Content>
<table class="InputTable">
<tr>
<td class="LabelTD">
<ess:essLabel runat="server" ResourceName="PredefinedHandlingInstructionsLabel">Predefined Handling Instructions</ess:essLabel>:
</td>
<td>
<ess:AJAXDropDown ID="ddlSpecHand" runat="server" DataTextField="HANDLING_INSTRUCTION"
DisplaySource="HANDLING_INSTRUCTION" DataValueField="HANDLING_INSTRUCTION" ListSourceAssembly="Ess.ESuite.Waste.BO"
ListSourceClass="SpecialHandlingBO" OnLoading="instructionsLoading" />
<button id="btnNewSpecHand">
...</button>
<ess:PopupPanel ID="pnlNewSpecHand" runat="server" Width="550px" Height="200px" Title="Special Handling Instructions"
TitleResourceName="SpecialHandlingInstructionsTitle" ShowControlID="btnNewSpecHand"
HideControlID="btnCancelSpecHand" Animation="SlideDownAnimation" PositionControlID="btnNewSpecHand">
<table class="InputTable">
<tr>
<td class="LabelTD" valign="top">
<ess:essLabel runat="server" CssClass="RequiredLabel" ResourceName="SpecialHandlingInstructionLabel">Handling Instruction</ess:essLabel>:
</td>
<td>
<ess:essTextBox ID="txtHandInstruc" runat="server" ControlSource="HANDLING_INSTRUCTION"
RenderControlSource="true" Width="98%" TextMode="MultiLine" Rows="3" />
</td>
</tr>
<tr>
<td class="LabelTD">
<ess:essLabel ID="EssLabel1" runat="server" ResourceName="CodeLabel">Code</ess:essLabel>:
</td>
<td>
<ess:essTextBox ID="txtCode" runat="server" ControlSource="CODE" RenderControlSource="true"
MaxLength="50" Width="300px" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<ess:essHtmlButton ID="btnSaveSpecHand" runat="server" ResourceName="SaveButton"
Text="Save" OnClick="saveSpecialHandling();" />
<ess:essHtmlButton ID="btnCancelSpecHand" runat="server" ResourceName="CancelButton"
Text="Cancel" />
</td>
</tr>
</table>
</ess:PopupPanel>
<ess:essHtmlButton runat="server" OnClick="addInstruction()" Text="Add" ResourceName="AddButton" />
</td>
</tr>
<tr>
<td colspan="2">
<ess:essTextBox ID="txtSpecHand" runat="server" ControlSource="SPECIAL_HANDLE_INSTRUCTIONS"
Width="100%" TextMode="MultiLine" Rows="3" />
</td>
</tr>
</table>
</Content>
</ess:essSection>
</form>
<script type="text/javascript">
function generatorSelected(sender, e) {
var contactDDL =
这篇关于在Windows窗体应用程序代码中转换Web应用程序代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!