Click here to Skip to main content
15,899,126 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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:
C#
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();

In windows form the Response.Clear or Response.Buffer is not supported.
Error is missing namespace or directive is displaying...
Posted
Updated 19-Jul-22 19:48pm
v2
Comments
Rajesh Sajjanar 4-Oct-10 14:44pm    
you cannot convert the asp.net webpage directly into windows form. you have to rewrite the code for windows form that you wrote in asp.net

Hi check here for printing .rpt file in windows form
http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-print.htm[^]
 
Share this answer
 
Comments
Espen Harlinn 7-Jul-11 17:17pm    
My 5 - shows how to print a cs report from a windows forms based application
XML
<%@ 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 = $find('HeaderSection_acddContact');
            if (contactDDL) { contactDDL.reset(); }
            var txtShipNum = $get('HeaderSection_txtShipNum');
            //if (txtShipNum.value == '') - Allow the auto number to be changed even if already populated
            //{
            var siteId = sender.getValue();
            var param = { SiteID: siteId, SequenceName: 'SHIPMENT' };
            Sys.Net.WebServiceProxy.invoke("WasteService.asmx", "GetNextAutoNumber", false, param, autoNumberCallback, null);
            //}
        }
        function autoNumberCallback(result) {
            var txtShipNum = $get('HeaderSection_txtShipNum');
            txtShipNum.value = result;
        }
        function getGenSiteId() {
            var genSiteDDL = $find('HeaderSection_acddGenerator');
            var genSiteId = -1;
            if (genSiteDDL) { genSiteId = genSiteDDL.getValue(); }
            return genSiteId;
        }
        function contactLoading(sender, e) {
            var genSiteId = getGenSiteId();
            if (genSiteId && genSiteId != -1) {
                sender.addQueryParameter('VLD_SITE_ID', genSiteId);
            }
            else {
                e.set_cancel(true);
            }

        }
        function instructionsLoading(sender, e) {
            var genSiteId = getGenSiteId();
            if (genSiteId && genSiteId != -1) {
                sender.addFilter('VLD_SITE_ID', genSiteId);
            }
            else {
                e.set_cancel(true);
            }

        }
        function emergencyContactSelected(sender, e) {
            // populate emergency phone number
            $get('HeaderSection_txtEmerPhone').value = sender._currentItem.CONTACT_24_HR_PHONE_NUM;
        }
        function newTransporter(sender, e) {
            var stateIdDDL = $find('TransportersSection_ddlStateId');
            if (stateIdDDL) { stateIdDDL.clearList(); }
        }
        function transporterSelected(sender, e) {
            $get('TransportersSection_txtTranCity').value = e.itemData["CITY"];
            $get('TransportersSection_txtTranPhone').value = e.itemData["SITE_PHONE_NUM"];
            $get('TransportersSection_txtTranEPAID').value = e.itemData["EPA_ID"];
        }
        function materialSelected(sender, e) {
            $get('txtProfileNum').value = e.itemData["PROFILE_NUM"];
        }
        function materialLoading(sender, e) {
            var genSiteDDL = $find('HeaderSection_acddGenerator');
            var genSiteId = -1;
            if (genSiteDDL) { genSiteId = genSiteDDL.getValue(); }
            if (!genSiteId) genSiteId = -1;
            sender.addQueryParameter('*VLD_SITE_ID', genSiteId);
        }
        function addInstruction() {
            var ddl = $get('SpecHandlingSection_ddlSpecHand');
            var txt = $get('SpecHandlingSection_txtSpecHand');
            if (ddl.value) {
                if (txt.value != '') txt.value += ', ';
                txt.value += ddl.value;
            }
        }
        function viewManifest(print) {
            var url;
            var id;
            var manifest;
            var ddl;
            id = $get('txtShipId').value;
            if (id == '' || id == '-1') return;
            ddl = $get('HeaderSection_ddlManifestForm');
            if (ddl.selectedIndex > -1) {
                manifest = '&manifest=' + ddl.options[ddl.selectedIndex].value;
            }
            else {
                manifest = '';
            }
            url = '../Waste/ViewManifest.aspx?shipid=' + id + manifest + '&print=' + print;
            openWindowCenter(AddSessionParamsToUrl(url), 'Manifest', 800, 600, 'toolbar=no,location=no,directories=no,resizable=yes,menubar=no,scrollbars=yes');

        }

        function materialsBeforeSave(sender, e) {
            e.dataObj.CONTAINERCODE = e.dataObj.CONTAINER_MANIFEST_CODE;
        }

        function reloadSpecialHandling(instruction) {
            var panel = $find('SpecHandlingSection_pnlNewSpecHand');
            panel.hidePanel();
            $find('SpecHandlingSection_ddlSpecHand').loadList(true);
            $get('SpecHandlingSection_ddlSpecHand').value = instruction;
        }

        function saveSpecialHandling() {
            var panel = $find('SpecHandlingSection_pnlNewSpecHand');
            var dataPanel = $create(Ess.Framework.ClientDataPanel, null, null, null, panel.get_element());
            var data = dataPanel.getDataObject();
            dataPanel.dispose();

            var genSiteId = getGenSiteId();
            if (!genSiteId || genSiteId == -1) {
                return;
            }

            var params = {};
            params.entityId = genSiteId;
            params.instruction = data.HANDLING_INSTRUCTION;
            params.code = data.CODE;
            var error = Function.createDelegate(window, errorCallback);
            var callback = Function.createDelegate(window, reloadSpecialHandling);

            // call webservice
            Sys.Net.WebServiceProxy.invoke(getSiteRootAddress() + "/Waste/WasteService.asmx",
                    "SaveSpecialHandling",
                    false, params, callback, error);
        }
        function errorCallback(msg, isString) {
            var error;
            if (isString) {
                error = msg;
            }
            else {
                error = msg.get_message();
            }
            alert(error);
        }

    </script>
</body>
</html>
 
Share this answer
 
Comments
Christian Graus 7-Jul-11 17:06pm    
You posted a huge ASP.NET page, how can that help him ?
Do you understand what the Response object is ? If not, how can you possibly work with a web app code ? The response object is used to interact to create the response when a webpage is written, for example, Response.Write will write text to the output stream. So, this code is taking the bytes of a PDF, and writing them to the user. If you take the first bit, which creates the bytes of a PDF, in a windows app, you can write them to the file system, and show them ( using Process.Start ), or you can prompt the user and save the bytes where-ever they want them.

Of course, as someone else said, you have more control in windows, there's not a need to create a PDF, if you have a crystal report, you should explore your options for printing directly, not assume that the steps a web app had to take, are steps you need to take in Windows.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900