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 SaveTabFile : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SaveFile(); } } /// /// 执行SQL语句 /// /// public void ExecSaveFile(string str, IDataParameter[] parameters) { try { BLL.SQLHelper.ExecutSql(str, parameters); } catch (Exception e) { Response.Write(e.Message); Response.Write(e.Source); Response.End(); } finally { } } /// /// 保存模板文件 /// public void SaveFile() { string projectId = Request.Form["projectId"].ToString(); string reportId = Request.Form["reportId"].ToString(); string tabContent = Request.Form["tabContent"].ToString(); string reportName = Request.Form["reportName"].ToString(); string strSql = "SELECT COUNT(ReportId) FROM dbo.Common_ReportServer WHERE ReportId = @ReportId and ProjectId = @ProjectId"; SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@ProjectId",projectId), new SqlParameter("@ReportId",reportId) }; string reportCount = BLL.SQLHelper.GetStr(strSql, parameter); string str = string.Empty; if (reportCount == "0") { str = "INSERT INTO dbo.Common_ReportServer(ReportId,TabContent,ReportName,ProjectId) VALUES('" + reportId + "','" + tabContent + "','" + reportName + "','" + projectId + "')"; this.ExecSaveFile(str, null); } else { str = "UPDATE dbo.Common_ReportServer SET TabContent = '" + tabContent + "',ReportName='" + reportName + "' WHERE ReportId = @ReportId and ProjectId = @ProjectId"; SqlParameter[] parameter1 = new SqlParameter[] { new SqlParameter("@ProjectId",projectId), new SqlParameter("@ReportId",reportId) }; this.ExecSaveFile(str, parameter1); } Response.Write("保存成功"); } } }