打印按钮不适用于ASP.net到Crystal Reports [英] Print button not working for ASP.net to Crystal Reports

查看:60
本文介绍了打印按钮不适用于ASP.net到Crystal Reports的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个打印按钮,我试图打印我制作的水晶报告。报告应按会议打印。如何通过aspx页面上的打印按钮打印水晶报告?



这是带有打印按钮的aspx页面:

 使用系统; 
使用 System.Web;
使用 System.Web.Security;
使用 System.Web.UI;
使用 System.Web.UI.HtmlControls;
使用 System.Web.UI.WebControls;
使用 System.Web.UI.WebControls.WebParts;
使用 System.Xml.Linq;
使用 System.Data;
使用 System.Data.SqlClient;
使用 System.Drawing;
使用 System.Text;
使用 System.Collections;
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Configuration;
使用 System.Drawing.Printing;
使用 System.IO;
使用 System.Web.SessionState;
使用 CrystalDecisions.CrystalReports.Engine;
使用 CrystalDecisions.Shared;

受保护 void Page_Load( object sender,EventArgs e)
{
TextBoxINST_ID.Text = Session [ INST_ID]的ToString();
}
受保护 void ButtonPrint_Click( object sender,EventArgs e)
{
ReportDocument crystalReport = new ReportDocument();
crystalReport.Load(Server.MapPath( ReportFormA.aspx));
}





这是包含Crystal Report Viewer的页面。



 使用系统; 
使用 System.Collections.Generic;
使用 System.Collections;
使用 System.Linq;
使用 System.Web;
使用 System.Web.UI;
使用 System.Web.UI.WebControls;
使用 System.Web.UI.HtmlControls;
使用 System.Web.UI.WebControls;
使用 System.Web.UI.WebControls.WebParts;
使用 CrystalDecisions.CrystalReports.Engine;
使用 CrystalDecisions.Shared;
使用 System.Data;
使用 System.Data.SqlClient;
使用 System.Configuration;
使用 System.Xml.Linq;


命名空间 SACSCOCLogin1._1
{
public partial class ReportFormA:System.Web.UI.Page
{
受保护 void Page_Load( object sender ,EventArgs e)
{
TextBoxINST_ID.Text = Session [ inst_id ]的ToString();
CrystalReportViewer1.Visible = false ;
}



}
}





我也不想在打印时显示查看器。



以下是用户使用会话ID填写的Web表单的代码。



 使用系统; 
使用 System.Web;
使用 System.Web.Security;
使用 System.Web.UI;
使用 System.Web.UI.HtmlControls;
使用 System.Web.UI.WebControls;
使用 System.Web.UI.WebControls.WebParts;
使用 System.Xml.Linq;
使用 System.Data;
使用 System.Data.SqlClient;
使用 System.Drawing;
使用 System.Text;
使用 System.Collections;
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Configuration;
使用 System.Drawing.Printing;
使用 System.IO;
使用 System.Web.SessionState;
使用 CrystalDecisions.CrystalReports.Engine;
使用 CrystalDecisions.Shared;




public partial class FinancialProfileFormA:System.Web.UI.Page
{
ReportDocument doc = new ReportDocument();
受保护 void Page_Load( object sender,EventArgs e)
{

// this.lblYEAR.Text = DateTime.Today.ToString(yyyy);
// this.lblYEAR2。 Text = DateTime.Today.ToString(yyyy);
this .lblTime.Text = System.DateTime.Now.ToShortTimeString() ;
this .TextBoxDATE.Text = DateTime.Today.ToString( DD-MMM-YY);
TextBoxTROA.Focus();

SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings [ HotConnectionString]。ConnectionString);
con.Open();
SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings [ HotConnectionString]的ConnectionString)。
con2.Open();
SqlConnection con3 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings [ HotConnectionString]的ConnectionString)。
con3.Open();

TextBoxINST_ID.Text = Session [ inst_id]。ToString() ;
SqlCommand scmd = new SqlCommand( 选择表1中的INST_ID,LongName,City,State INST_ID =' + TextBoxINST_ID.Text + ' ,con);
SqlCommand scmd2 = new SqlCommand( 选择INST_ID = INST_ID,TOTAL_REVE,FINYR,INSTRUCTIO,RESEARCH,PUBLIC_SER,ACADEMIC_S,STUDENT_SE,INSTITUTIO,PHYSICAL_P,SCHOLARSHI,AUXILIARY_,HOSPITALS,INDEPENDEN,OTHEREXP,TOTASSETS,TOTLIABILITY,NoNEXPPERMRESASSETS,UNRNETASSETS,TOTALREV,TUITFEES,CURRDEBT,LONGTERMDEBT from Table2其中INST_ID = ' + TextBoxINST_ID.Text + ',con2);
SqlCommand scmd3 = new SqlCommand( 选择INST_ID,来自Table88的accessLevel,其中INST_ID =' + TextBoxINST_ID.Text + ' ,con3);
SqlDataReader dr = scmd.ExecuteReader();
SqlDataReader dr2 = scmd2.ExecuteReader();
SqlDataReader dr3 = scmd3.ExecuteReader();

if (dr.Read())
if ( dr2.Read())
if (dr3.Read())
{
TextBoxaccessLevel.Text = dr3 [ accessLevel]。ToString();
lblCity.Text = dr [ City]。ToString();
lblLYEAR.Text = dr2 [ FINYR]。ToString();
lblLYEAR2.Text = dr2 [ FINYR]。ToString();
lblState.Text = dr [ State]。ToString();
lblSchool.Text = dr [ LongName]。ToString();
lblSchool2.Text = dr [ LongName]。ToString();
TextBoxLYInstr.Text = dr2 [ INSTRUCTIO]。ToString();
TextBoxLYRes.Text = dr2 [ RESEARCH]。ToString();
TextBoxLYPubS.Text = dr2 [ PUBLIC_SER]。ToString();
TextBoxLYAcad.Text = dr2 [ ACADEMIC_S]。ToString();
TextBoxLYStudS.Text = dr2 [ STUDENT_SE]。ToString();
TextBoxLYInstiS.Text = dr2 [ INSTITUTIO]。ToString();
TextBoxLYOperM.Text = dr2 [ PHYSICAL_P]。ToString();
TextBoxLYSFEDA.Text = dr2 [ SCHOLARSHI]。ToString();
TextBoxLYAuxE.Text = dr2 [ AUXILIARY _]。ToString();
TextBoxLYHosS.Text = dr2 [ HOSPITALS]。ToString();
TextBoxLYIndeO.Text = dr2 [ INDEPENDEN]。ToString();
TextBoxLYOED.Text = dr2 [ OTHEREXP]。ToString();
TextBoxLYTA.Text = dr2 [ TOTASSETS]。ToString();
TextBoxLYTL.Text = dr2 [ TOTLIABILITY]。ToString();
TextBoxLYNPRNA.Text = dr2 [ NoNEXPPERMRESASSETS]。ToString();
TextBoxLYTUNA.Text = dr2 [ UNRNETASSETS]。ToString();
TextBoxLYTR.Text = dr2 [ TOTALREV]。ToString();
TextBoxLYTFN.Text = dr2 [ TUITFEES]。ToString();
TextBoxLYCD.Text = dr2 [ CURRDEBT]。ToString();
TextBoxLYLTD.Text = dr2 [ LONGTERMDEBT]。ToString();
TextBoxLYTROA.Text = dr2 [ TOTAL_REVE]。ToString();


}
dr.Close();
con.Close();
dr2.Close();
con2.Close();
dr3.Close();
con3.Close();

if (TextBoxINST_ID.Text.Trim()。Length > < span class =code-digit> 0

{
SqlConnection con4 = new SqlConnection(System.Configuration.ConfigurationManager。 ConnectionStrings [ HotConnectionString]。ConnectionString);
con4.Open();

SqlCommand scmd4 = new SqlCommand( 选择TOTAL_REVE,DATE,FINYR,INSTRUCTIO,RESEARCH,PUBLIC_SER,ACADEMIC_S,STUDENT_SE,INSTITUTIO,PHYSICAL_P,SCHOLARSHI,AUXILIARY_,HOSPITALS,INDEPENDEN,OTHEREXP,TOTASSETS,TOTLIABILITY,NoNEXPPERMRESASSETS,EXPENDABLE,UNRNETASSETS,TOTALREV,TUITFEES,CURRDEBT,表23中的LONGTERMDEBT,TOTALNETASSET,其中INST_ID =' + TextBoxINST_ID.Text + ' ,con4);
SqlDataReader dr4 = scmd4.ExecuteReader();
if (dr4.Read())
{
TextBoxTROA.Text = dr4 [ TOTAL_REVE]。ToString();
TextBoxInstr.Text = dr4 [ INSTRUCTIO]。ToString();
TextBoxRes.Text = dr4 [ RESEARCH]。ToString();
TextBoxPubS.Text = dr4 [ PUBLIC_SER]。ToString();
TextBoxAcad.Text = dr4 [ ACADEMIC_S]。ToString();
TextBoxStudS.Text = dr4 [ STUDENT_SE]。ToString();
TextBoxInstiS.Text = dr4 [ INSTITUTIO]。ToString();
TextBoxOperM.Text = dr4 [ PHYSICAL_P]。ToString();
TextBoxSFEDA.Text = dr4 [ SCHOLARSHI]。ToString();
TextBoxAuxE.Text = dr4 [ AUXILIARY _]。ToString();
TextBoxHosS.Text = dr4 [ HOSPITALS]。ToString();
TextBoxIndeO.Text = dr4 [ INDEPENDEN]。ToString();
TextBoxOED.Text = dr4 [ OTHEREXP]。ToString();
TextBoxTA.Text = dr4 [ TOTASSETS]。ToString();
TextBoxTL.Text = dr4 [ TOTLIABILITY]。ToString();
TextBoxNPRNA.Text = dr4 [ NoNEXPPERMRESASSETS]。ToString();
TextBoxETRNA.Text = dr4 [ EXPENDABLE]。ToString();
TextBoxTUNA.Text = dr4 [ UNRNETASSETS]。ToString();
TextBoxTR.Text = dr4 [ TOTALREV]。ToString();
TextBoxTFN.Text = dr4 [ TUITFEES]。ToString();
TextBoxCD.Text = dr4 [ CURRDEBT]。ToString();
TextBoxLTD.Text = dr4 [ LONGTERMDEBT]。ToString();
TextBoxTNA.Text = dr4 [ TOTALNETASSETS]。ToString();
}
con4.Close();
dr4.Close();
}
}

受保护 void ButtonSubmit_Click( object sender,EventArgs e)
{

SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings [ HotConnectionString]。ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand( Insert到表22(INST_ID,TOTAL_REVE,DATE,FINYR,INSTRUCTIO,RESEARCH,PUBLIC_SER,ACADEMIC_S,STUDENT_SE,INSTITUBLTI,PHYSICAL_P,SCHOLARSHI,AUXILIARY_,HOSPITALS,INDEPENDEN,OTHEREXP,TOTASSETS,TOTLIABILITY,NoNEXPPERMRESASSETS,EXPENDABLE,UNRNETASSETS,TOTALREV,TUITFEES,CURRDEBT ,LONGTERMDEBT,TOTALNETASSETS)值(@ INST_ID,@ TOTAL_REVE,@ DATE,@ FINYR,@ INSTRUCTIO,@ RESEARCH,@ Public_SER,@ ACADEMIC_S,@ STUDENT_SE,@ INSTITUTIO,@ PHYSICAL_P,@ SCHOLARSHI,@ AUXILIARY _,@ HEALTHPITALS,@ INDEPENDEN,@ OTEXEXP,@ TOTASSETS,@ TOTLIABILITY,@ NoNEXPPERMRESASSETS,@ EXPENDABLE,@ UNRNETASSETS,@ TOTALREV,@ TITITES,@ CURRDEBT,@ LongterMDEBT,@ TOTALNETASSETS)插入表23(INST_ID,TOTAL_REVE,DATE,FINYR,INSTRUCTIO,RESEARCH ,PUBLIC_SER,ACADEMIC_S,STUDENT_SE,INSTITUTIO,PHYSICAL_P,SCHOLARSHI,AUXILIARY_,HOSPITALS,INDEPENDEN,OTHEREXP,TOT资产,可匹配性,NoNEXPPERMRESASSETS,可用,UNRNETASSETS,TOTALREV,TITITFEES,CURRDEBT,LONGTERMDEBT,TOTALNETASSETS)值(@ INST_ID,@ TOTAL_REVE,@ DATE,@ FINYR,@ INSTRUCTIO,@ RESEARCH,@ Public_SER,@ ACADEMIC_S,@ STUDENT_SE,@机构,@ PHYSICAL_P,@ SCHOLARSHI,@ AUXILIARY_,@ HEALTHPITALS,@ INDEPENDEN,@ OTEXEXP,@ TOTASSETS,@ TOTLIABILITY,@ NoNEXPPERMRESASSETS,@ EXPENDABLE,@ UNRNETASSETS,@ TOTALREV,@ TUITFEES,@ CURRDEBT,@ LongterMDEBT,@ TOTALNETASSETS) ,con);
cmd.CommandType = CommandType.Text;

cmd.Parameters.AddWithValue( @ INST_ID,TextBoxINST_ID.Text );
cmd.Parameters.AddWithValue( @ TOTAL_REVE,TextBoxTROA.Text);
cmd.Parameters.AddWithValue( @ INSTRUCTIO,TextBoxInstr.Text);
cmd.Parameters.AddWithValue( @ RESEARCH,TextBoxRes.Text);
cmd.Parameters.AddWithValue( @ PUBLIC_SER,TextBoxPubS.Text);
cmd.Parameters.AddWithValue( @ ACADEMIC_S,TextBoxAcad.Text);
cmd.Parameters.AddWithValue( @ STUDENT_SE,TextBoxStudS.Text);
cmd.Parameters.AddWithValue( @ INSTITUTIO,TextBoxInstiS.Text);
cmd.Parameters.AddWithValue( @ PHYSICAL_P,TextBoxOperM.Text);
cmd.Parameters.AddWithValue( @ SCHOLARSHI,TextBoxSFEDA.Text);
cmd.Parameters.AddWithValue( @ AUXILIARY _,TextBoxAuxE.Text);
cmd.Parameters.AddWithValue( @ HOSPITALS,TextBoxHosS.Text);
cmd.Parameters.AddWithValue( @ INDEPENDEN,TextBoxIndeO.Text);
cmd.Parameters.AddWithValue( @ OTHEREXP,TextBoxOED.Text);
cmd.Parameters.AddWithValue( @ TOTASSETS,TextBoxTA.Text);
cmd.Parameters.AddWithValue( @ TOTLIABILITY,TextBoxTL.Text);
cmd.Parameters.AddWithValue( @NoNEXPPERMRESASSETS,TextBoxNPRNA.Text);
cmd.Parameters.AddWithValue( @ EXPENDABLE,TextBoxETRNA.Text);
cmd.Parameters.AddWithValue( @ UNRNETASSETS,TextBoxTUNA.Text);
cmd.Parameters.AddWithValue( @ TOTALREV,TextBoxTR.Text);
cmd.Parameters.AddWithValue( @ TUITFEES,TextBoxTFN.Text);
cmd.Parameters.AddWithValue( @ CURRDEBT,TextBoxCD.Text);
cmd.Parameters.AddWithValue( @ LONGTERMDEBT,TextBoxLTD.Text);
cmd.Parameters.AddWithValue( @ FINYR,lblYEAR.Text);
cmd.Parameters.AddWithValue( @ DATE,TextBoxDATE.Text);
cmd.Parameters.AddWithValue( @ TOTALNETASSETS,TextBoxTNA.Text);


cmd.ExecuteNonQuery();
ScriptManager.RegisterStartupScript( this this .GetType(), script 警告('您已成功提交财务资料'); true );

if (Page.IsValid)
{
SqlCommand level = SqlCommand( 从表88中选择accessLevel,INST_ID,其中INST_ID = @INST_ID AND accessLevel = @accessLevel,con);
level.Parameters.Add( new SqlParameter( INST_ID,TextBoxINST_ID.Text));
level.Parameters.Add( new SqlParameter( accessLevel,TextBoxaccessLevel.Text));

SqlDataReader reader = level.ExecuteReader();
DataTable dt1 = new DataTable();
dt1.Load(读者);

foreach (DataRow dr1 in dt1.Rows)
{
int returnedLevel = Convert.ToInt32(dr1 [ 0 ]。ToString());
int accessLevel = Convert.ToInt32(dr1 [ 1 ]。ToString());
会话[ accessLevel] = accessLevel;

if (returnedLevel == 1
{
Response.Redirect( FormAPublic.aspx);
}
else if (returnedLevel == 2
{
Response.Redirect( FormCPrivateNon.aspx );
}
else if (returnedLevel == 3
{
Response.Redirect( FormDPrivateFor.aspx );
}
else if (returnedLevel == 11
{
Response.Redirect( FormAPublicL.aspx );
}
else if (returnedLevel == 21
{
Response.Redirect( FormCPrivateNonL.aspx );
}
else if (returnedLevel == 31
{
Response.Redirect( FormDPrivateForL.aspx );
}
else if (returnedLevel == 7
{
Response.Redirect( CEOPage.aspx );
}
else
{
ScriptManager.RegisterStartupScript( this this .GetType(), script alert('您已成功提交财务资料');,< span class =code-keyword> true
);
}
con.Close();
TextBoxTROA.Text = string .Empty;
TextBoxInstr.Text = string .Empty;
TextBoxRes.Text = string .Empty;
TextBoxPubS.Text = string .Empty;
TextBoxAcad.Text = string .Empty;
TextBoxStudS.Text = string .Empty;
TextBoxInstiS.Text = string .Empty;
TextBoxOperM.Text = string .Empty;
TextBoxSFEDA.Text = string .Empty;
TextBoxAuxE.Text = string .Empty;
TextBoxHosS.Text = string .Empty;
TextBoxIndeO.Text = string .Empty;
TextBoxOED.Text = string .Empty;
TextBoxTA.Text = string .Empty;
TextBoxTL.Text = string .Empty;
TextBoxNPRNA.Text = string .Empty;
TextBoxETRNA.Text = string .Empty;
TextBoxTUNA.Text = string .Empty;
TextBoxTR.Text = string .Empty;
TextBoxTFN.Text = string .Empty;
TextBoxCD.Text = string .Empty;
TextBoxLTD.Text = string .Empty;
TextBoxFullN.Text = string .Empty;
TextBoxTitle.Text = string .Empty;
TextBoxMA.Text = string .Empty;
TextBoxTN.Text = string .Empty;
TextBoxFN.Text = string .Empty;
TextBoxEA.Text = string .Empty;
TextBoxTNA.Text = string .Empty;

}
}
}

受保护 void TextBoxTL_TextChanged( object sender,EventArgs e)
{
int a = Convert.ToInt32(TextBoxTA.Text);
int b = Convert.ToInt32(TextBoxTL.Text);
TextBoxTNA.Text = Convert.ToString(a - b);
TextBoxNPRNA.Focus();
}

受保护 void TextBoxTUNA_TextChanged( object sender,EventArgs e)
{
int a = Convert.ToInt32(TextBoxNPRNA.Text);
int b = Convert.ToInt32(TextBoxETRNA.Text);
int c = Convert.ToInt32(TextBoxTUNA.Text);
TextBoxTNA2.Text = Convert.ToString(a + b + c);
TextBoxTR.Focus();
}

受保护 void ButtonPrint_Click( object sender,EventArgs e)
{
Session [ inst_id] = TextBoxINST_ID;
ClientScript.RegisterStartupScript( this .GetType(), onclick < script language = javascript> window.open('ReportFormA.aspx , 'PrintMe', '身高= 300像素,宽300像素=,滚动条= 1');< /脚本>中);
}
}

解决方案

Crystal报表,无预览打印...... [ ^ ]

http://stackoverflow.com/questions/17377281/how-to-directly-print-report-without-going-through -crystal-reports-viewer [ ^ ]


查看此文章

显示,导出和打印Crystal Reports在ASP.NET [ ^ ]

I have a print button that I am trying to get to print the crystal report that I made. The report should print out by Session. How can I print a crystal report by way of the print button on a aspx page?

This is the aspx page that has the print button:

using System;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using System.Drawing.Printing;
using System.IO;
using System.Web.SessionState;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

protected void Page_Load(object sender, EventArgs e)
    {
       TextBoxINST_ID.Text = Session["inst_id"].ToString();
    }
 protected void ButtonPrint_Click(object sender, EventArgs e)
    {
        ReportDocument crystalReport = new ReportDocument();
        crystalReport.Load(Server.MapPath("ReportFormA.aspx"));
    }



This is the page that has the Crystal Report Viewer.

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Xml.Linq;


namespace SACSCOCLogin1._1
{
    public partial class ReportFormA : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            TextBoxINST_ID.Text = Session["inst_id"].ToString();
            CrystalReportViewer1.Visible = false;
        }

        
        
    }
}



I also don't want to show the viewer when printing.

Here is the code for the web form the user fills out with the session id.

using System;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using System.Drawing.Printing;
using System.IO;
using System.Web.SessionState;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;




public partial class FinancialProfileFormA : System.Web.UI.Page
{
    ReportDocument doc = new ReportDocument();
    protected void Page_Load(object sender, EventArgs e)
    {

        //this.lblYEAR.Text = DateTime.Today.ToString("yyyy");
        //this.lblYEAR2.Text = DateTime.Today.ToString("yyyy");
        this.lblTime.Text = System.DateTime.Now.ToShortTimeString();
        this.TextBoxDATE.Text = DateTime.Today.ToString("dd-MMM-yy");
        TextBoxTROA.Focus();
        
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
        con.Open();
        SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
        con2.Open();
        SqlConnection con3 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
        con3.Open();

        TextBoxINST_ID.Text = Session["inst_id"].ToString();
        SqlCommand scmd = new SqlCommand("Select INST_ID, LongName, City, State from Table1 where INST_ID = '" + TextBoxINST_ID.Text + "'", con);
        SqlCommand scmd2 = new SqlCommand("Select INST_ID, TOTAL_REVE, FINYR, INSTRUCTIO, RESEARCH, PUBLIC_SER, ACADEMIC_S, STUDENT_SE, INSTITUTIO, PHYSICAL_P, SCHOLARSHI, AUXILIARY_, HOSPITALS, INDEPENDEN, OTHEREXP, TOTASSETS, TOTLIABILITY, NoNEXPPERMRESASSETS, UNRNETASSETS, TOTALREV, TUITFEES, CURRDEBT, LONGTERMDEBT from Table2 where INST_ID = '" + TextBoxINST_ID.Text + "'", con2);
        SqlCommand scmd3 = new SqlCommand("Select INST_ID, accessLevel from Table88 where INST_ID = '" + TextBoxINST_ID.Text + "'", con3);
        SqlDataReader dr = scmd.ExecuteReader();
        SqlDataReader dr2 = scmd2.ExecuteReader();
        SqlDataReader dr3 = scmd3.ExecuteReader();

        if (dr.Read())
            if (dr2.Read())
                if (dr3.Read())
                {
                    TextBoxaccessLevel.Text = dr3["accessLevel"].ToString();
                    lblCity.Text = dr["City"].ToString();
                    lblLYEAR.Text = dr2["FINYR"].ToString();
                    lblLYEAR2.Text = dr2["FINYR"].ToString();
                    lblState.Text = dr["State"].ToString();
                    lblSchool.Text = dr["LongName"].ToString();
                    lblSchool2.Text = dr["LongName"].ToString();
                    TextBoxLYInstr.Text = dr2["INSTRUCTIO"].ToString();
                    TextBoxLYRes.Text = dr2["RESEARCH"].ToString();
                    TextBoxLYPubS.Text = dr2["PUBLIC_SER"].ToString();
                    TextBoxLYAcad.Text = dr2["ACADEMIC_S"].ToString();
                    TextBoxLYStudS.Text = dr2["STUDENT_SE"].ToString();
                    TextBoxLYInstiS.Text = dr2["INSTITUTIO"].ToString();
                    TextBoxLYOperM.Text = dr2["PHYSICAL_P"].ToString();
                    TextBoxLYSFEDA.Text = dr2["SCHOLARSHI"].ToString();
                    TextBoxLYAuxE.Text = dr2["AUXILIARY_"].ToString();
                    TextBoxLYHosS.Text = dr2["HOSPITALS"].ToString();
                    TextBoxLYIndeO.Text = dr2["INDEPENDEN"].ToString();
                    TextBoxLYOED.Text = dr2["OTHEREXP"].ToString();
                    TextBoxLYTA.Text = dr2["TOTASSETS"].ToString();
                    TextBoxLYTL.Text = dr2["TOTLIABILITY"].ToString();
                    TextBoxLYNPRNA.Text = dr2["NoNEXPPERMRESASSETS"].ToString();
                    TextBoxLYTUNA.Text = dr2["UNRNETASSETS"].ToString();
                    TextBoxLYTR.Text = dr2["TOTALREV"].ToString();
                    TextBoxLYTFN.Text = dr2["TUITFEES"].ToString();
                    TextBoxLYCD.Text = dr2["CURRDEBT"].ToString();
                    TextBoxLYLTD.Text = dr2["LONGTERMDEBT"].ToString();
                    TextBoxLYTROA.Text = dr2["TOTAL_REVE"].ToString();


                }
        dr.Close();
        con.Close();
        dr2.Close();
        con2.Close();
        dr3.Close();
        con3.Close();

        if (TextBoxINST_ID.Text.Trim().Length > 0)
        {
            SqlConnection con4 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
            con4.Open();

            SqlCommand scmd4 = new SqlCommand("Select TOTAL_REVE, DATE, FINYR, INSTRUCTIO, RESEARCH, PUBLIC_SER, ACADEMIC_S, STUDENT_SE, INSTITUTIO, PHYSICAL_P, SCHOLARSHI, AUXILIARY_, HOSPITALS, INDEPENDEN, OTHEREXP, TOTASSETS, TOTLIABILITY, NoNEXPPERMRESASSETS, EXPENDABLE, UNRNETASSETS, TOTALREV, TUITFEES, CURRDEBT, LONGTERMDEBT, TOTALNETASSETS from Table23 where INST_ID = '" + TextBoxINST_ID.Text + "'", con4);
            SqlDataReader dr4 = scmd4.ExecuteReader();
            if (dr4.Read())
            {
                TextBoxTROA.Text = dr4["TOTAL_REVE"].ToString();
                TextBoxInstr.Text = dr4["INSTRUCTIO"].ToString();
                TextBoxRes.Text = dr4["RESEARCH"].ToString();
                TextBoxPubS.Text = dr4["PUBLIC_SER"].ToString();
                TextBoxAcad.Text = dr4["ACADEMIC_S"].ToString();
                TextBoxStudS.Text = dr4["STUDENT_SE"].ToString();
                TextBoxInstiS.Text = dr4["INSTITUTIO"].ToString();
                TextBoxOperM.Text = dr4["PHYSICAL_P"].ToString();
                TextBoxSFEDA.Text = dr4["SCHOLARSHI"].ToString();
                TextBoxAuxE.Text = dr4["AUXILIARY_"].ToString();
                TextBoxHosS.Text = dr4["HOSPITALS"].ToString();
                TextBoxIndeO.Text = dr4["INDEPENDEN"].ToString();
                TextBoxOED.Text = dr4["OTHEREXP"].ToString();
                TextBoxTA.Text = dr4["TOTASSETS"].ToString();
                TextBoxTL.Text = dr4["TOTLIABILITY"].ToString();
                TextBoxNPRNA.Text = dr4["NoNEXPPERMRESASSETS"].ToString();
                TextBoxETRNA.Text = dr4["EXPENDABLE"].ToString();
                TextBoxTUNA.Text = dr4["UNRNETASSETS"].ToString();
                TextBoxTR.Text = dr4["TOTALREV"].ToString();
                TextBoxTFN.Text = dr4["TUITFEES"].ToString();
                TextBoxCD.Text = dr4["CURRDEBT"].ToString();
                TextBoxLTD.Text = dr4["LONGTERMDEBT"].ToString();
                TextBoxTNA.Text = dr4["TOTALNETASSETS"].ToString();
            }
            con4.Close();
            dr4.Close();
        }
    }

    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {

        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
        con.Open();
        SqlCommand cmd = new SqlCommand("Insert into Table22 (INST_ID, TOTAL_REVE, DATE, FINYR, INSTRUCTIO, RESEARCH, PUBLIC_SER, ACADEMIC_S, STUDENT_SE, INSTITUTIO, PHYSICAL_P, SCHOLARSHI, AUXILIARY_, HOSPITALS, INDEPENDEN, OTHEREXP, TOTASSETS, TOTLIABILITY, NoNEXPPERMRESASSETS, EXPENDABLE, UNRNETASSETS, TOTALREV, TUITFEES, CURRDEBT, LONGTERMDEBT, TOTALNETASSETS) values (@INST_ID, @TOTAL_REVE, @DATE, @FINYR, @INSTRUCTIO, @RESEARCH, @PUBLIC_SER, @ACADEMIC_S, @STUDENT_SE, @INSTITUTIO, @PHYSICAL_P, @SCHOLARSHI, @AUXILIARY_, @HOSPITALS, @INDEPENDEN, @OTHEREXP, @TOTASSETS, @TOTLIABILITY, @NoNEXPPERMRESASSETS, @EXPENDABLE, @UNRNETASSETS, @TOTALREV, @TUITFEES, @CURRDEBT, @LONGTERMDEBT, @TOTALNETASSETS)Insert into Table23 (INST_ID, TOTAL_REVE, DATE, FINYR, INSTRUCTIO, RESEARCH, PUBLIC_SER, ACADEMIC_S, STUDENT_SE, INSTITUTIO, PHYSICAL_P, SCHOLARSHI, AUXILIARY_, HOSPITALS, INDEPENDEN, OTHEREXP, TOTASSETS, TOTLIABILITY, NoNEXPPERMRESASSETS, EXPENDABLE, UNRNETASSETS, TOTALREV, TUITFEES, CURRDEBT, LONGTERMDEBT, TOTALNETASSETS) values (@INST_ID, @TOTAL_REVE, @DATE, @FINYR, @INSTRUCTIO, @RESEARCH, @PUBLIC_SER, @ACADEMIC_S, @STUDENT_SE, @INSTITUTIO, @PHYSICAL_P, @SCHOLARSHI, @AUXILIARY_, @HOSPITALS, @INDEPENDEN, @OTHEREXP, @TOTASSETS, @TOTLIABILITY, @NoNEXPPERMRESASSETS, @EXPENDABLE, @UNRNETASSETS, @TOTALREV, @TUITFEES, @CURRDEBT, @LONGTERMDEBT, @TOTALNETASSETS)", con);
        cmd.CommandType = CommandType.Text;

        cmd.Parameters.AddWithValue("@INST_ID", TextBoxINST_ID.Text);
        cmd.Parameters.AddWithValue("@TOTAL_REVE", TextBoxTROA.Text);
        cmd.Parameters.AddWithValue("@INSTRUCTIO", TextBoxInstr.Text);
        cmd.Parameters.AddWithValue("@RESEARCH", TextBoxRes.Text);
        cmd.Parameters.AddWithValue("@PUBLIC_SER", TextBoxPubS.Text);
        cmd.Parameters.AddWithValue("@ACADEMIC_S", TextBoxAcad.Text);
        cmd.Parameters.AddWithValue("@STUDENT_SE", TextBoxStudS.Text);
        cmd.Parameters.AddWithValue("@INSTITUTIO", TextBoxInstiS.Text);
        cmd.Parameters.AddWithValue("@PHYSICAL_P", TextBoxOperM.Text);
        cmd.Parameters.AddWithValue("@SCHOLARSHI", TextBoxSFEDA.Text);
        cmd.Parameters.AddWithValue("@AUXILIARY_", TextBoxAuxE.Text);
        cmd.Parameters.AddWithValue("@HOSPITALS", TextBoxHosS.Text);
        cmd.Parameters.AddWithValue("@INDEPENDEN", TextBoxIndeO.Text);
        cmd.Parameters.AddWithValue("@OTHEREXP", TextBoxOED.Text);
        cmd.Parameters.AddWithValue("@TOTASSETS", TextBoxTA.Text);
        cmd.Parameters.AddWithValue("@TOTLIABILITY", TextBoxTL.Text);
        cmd.Parameters.AddWithValue("@NoNEXPPERMRESASSETS", TextBoxNPRNA.Text);
        cmd.Parameters.AddWithValue("@EXPENDABLE", TextBoxETRNA.Text);
        cmd.Parameters.AddWithValue("@UNRNETASSETS", TextBoxTUNA.Text);
        cmd.Parameters.AddWithValue("@TOTALREV", TextBoxTR.Text);
        cmd.Parameters.AddWithValue("@TUITFEES", TextBoxTFN.Text);
        cmd.Parameters.AddWithValue("@CURRDEBT", TextBoxCD.Text);
        cmd.Parameters.AddWithValue("@LONGTERMDEBT", TextBoxLTD.Text);
        cmd.Parameters.AddWithValue("@FINYR", lblYEAR.Text);
        cmd.Parameters.AddWithValue("@DATE", TextBoxDATE.Text);
        cmd.Parameters.AddWithValue("@TOTALNETASSETS", TextBoxTNA.Text);


        cmd.ExecuteNonQuery();
        ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('You Have Successfully Submitted the Financial Profile');", true);

        if (Page.IsValid)
        {
            SqlCommand level = new SqlCommand("select accessLevel, INST_ID from Table88 where INST_ID = @INST_ID AND accessLevel = @accessLevel", con);
            level.Parameters.Add(new SqlParameter("INST_ID", TextBoxINST_ID.Text));
            level.Parameters.Add(new SqlParameter("accessLevel", TextBoxaccessLevel.Text));

            SqlDataReader reader = level.ExecuteReader();
            DataTable dt1 = new DataTable();
            dt1.Load(reader);

            foreach (DataRow dr1 in dt1.Rows)
            {
                int returnedLevel = Convert.ToInt32(dr1[0].ToString());
                int accessLevel = Convert.ToInt32(dr1[1].ToString());
                Session["accessLevel"] = accessLevel;

                if (returnedLevel == 1)
                {
                    Response.Redirect("FormAPublic.aspx");
                }
                else if (returnedLevel == 2)
                {
                    Response.Redirect("FormCPrivateNon.aspx");
                }
                else if (returnedLevel == 3)
                {
                    Response.Redirect("FormDPrivateFor.aspx");
                }
                else if (returnedLevel == 11)
                {
                    Response.Redirect("FormAPublicL.aspx");
                }
                else if (returnedLevel == 21)
                {
                    Response.Redirect("FormCPrivateNonL.aspx");
                }
                else if (returnedLevel == 31)
                {
                    Response.Redirect("FormDPrivateForL.aspx");
                }
                else if (returnedLevel == 7)
                {
                    Response.Redirect("CEOPage.aspx");
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('You Have Successfully Submitted the Financial Profile');", true);
                }
                con.Close();
                TextBoxTROA.Text = string.Empty;
                TextBoxInstr.Text = string.Empty;
                TextBoxRes.Text = string.Empty;
                TextBoxPubS.Text = string.Empty;
                TextBoxAcad.Text = string.Empty;
                TextBoxStudS.Text = string.Empty;
                TextBoxInstiS.Text = string.Empty;
                TextBoxOperM.Text = string.Empty;
                TextBoxSFEDA.Text = string.Empty;
                TextBoxAuxE.Text = string.Empty;
                TextBoxHosS.Text = string.Empty;
                TextBoxIndeO.Text = string.Empty;
                TextBoxOED.Text = string.Empty;
                TextBoxTA.Text = string.Empty;
                TextBoxTL.Text = string.Empty;
                TextBoxNPRNA.Text = string.Empty;
                TextBoxETRNA.Text = string.Empty;
                TextBoxTUNA.Text = string.Empty;
                TextBoxTR.Text = string.Empty;
                TextBoxTFN.Text = string.Empty;
                TextBoxCD.Text = string.Empty;
                TextBoxLTD.Text = string.Empty;
                TextBoxFullN.Text = string.Empty;
                TextBoxTitle.Text = string.Empty;
                TextBoxMA.Text = string.Empty;
                TextBoxTN.Text = string.Empty;
                TextBoxFN.Text = string.Empty;
                TextBoxEA.Text = string.Empty;
                TextBoxTNA.Text = string.Empty;
                
            }
        }
    }

    protected void TextBoxTL_TextChanged(object sender, EventArgs e)
    {
        int a = Convert.ToInt32(TextBoxTA.Text);
        int b = Convert.ToInt32(TextBoxTL.Text);
        TextBoxTNA.Text = Convert.ToString(a - b);
        TextBoxNPRNA.Focus();
    }

    protected void TextBoxTUNA_TextChanged(object sender, EventArgs e)
    {
        int a = Convert.ToInt32(TextBoxNPRNA.Text);
        int b = Convert.ToInt32(TextBoxETRNA.Text);
        int c = Convert.ToInt32(TextBoxTUNA.Text);
        TextBoxTNA2.Text = Convert.ToString(a + b + c);
        TextBoxTR.Focus();
    }

    protected void ButtonPrint_Click(object sender, EventArgs e)
    {
        Session["inst_id"] = TextBoxINST_ID;
        ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('ReportFormA.aspx','PrintMe','height=300px,width=300px,scrollbars=1');</script>");
    }
}   

解决方案

Crystal report , printing without preview...[^]
http://stackoverflow.com/questions/17377281/how-to-directly-print-report-without-going-through-crystal-reports-viewer[^]


Check this article
Displaying , Exporting and Printing Crystal Reports in ASP.NET[^]


这篇关于打印按钮不适用于ASP.net到Crystal Reports的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆