using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FineUIPro.Web.Common.ReportPrint
{
    public partial class ReadExReportFile : PageBase
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.ShowReportContent();
        }

        /// <summary>
        /// 获取报表对应模板信息
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public DataTable GetData(string str)
        {
            DataTable dt = new DataTable();
            try
            {
                string strSql = "SELECT * FROM dbo.Common_ReportServer WHERE ReportId = @ReportId and ProjectId = @ProjectId";
                SqlParameter[] parameter = new SqlParameter[]       
                    {
                        new SqlParameter("@ProjectId",Request.QueryString["projectId"].ToString()),
                        new SqlParameter("@ReportId",str)
                    };
                dt = BLL.SQLHelper.GetDataTableRunText(strSql, parameter);
            }
            catch (Exception e)
            {
                Response.Write(e.Message);
                Response.Write(e.Source);
                Response.End();

            }
            finally
            {
            }
            return dt;
        }

        /// <summary>
        /// 获取模板内容
        /// </summary>
        private void ShowReportContent()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["reportId"].ToString()))
            {
                string reportId = Request.QueryString["reportId"].ToString().Trim();

                DataTable dt;
                dt = GetData(reportId);
                if (dt != null)
                {
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        string tabContent = dt.Rows[0]["TabContent"].ToString().Trim();
                        Response.Write(tabContent);
                    }
                }
            }
        }
    }

}