62,243
社区成员




string tmpOutFile = System.IO.Path.GetTempFileName() + ".xls";
//C:\Users\85550\AppData\Local\Temp\tmp6977.tmp.xls
OleDbConnection conn = new OleDbConnection(string.Format(OleDbHelper.connectionStringBase, tmpOutFile));
try
{
for (int type = 1; type < 3; type++)
{
//title
string title = string.Format("Update title{0} Set F1='厦门大学附属中山医院 {1}至{2}{3}'", type, txtBegin.Text, txtEnd.Text, GetSumName(type));
OleDbHelper.ExecuteSql(tmpOutFile, OleDbHelper.TEMPLATE_STATISTICSURVEYITEMBYPLAN, conn, title);
// leftTitle
StringBuilder leftTitle = new StringBuilder(200);
leftTitle.Append(string.Format("Update leftTitle{0} SET F1='序号',F2='科室',F3='回访总人数',F4='回访成功人数',F5='科室总满意度(%)'", type));
OleDbHelper.ExecuteSql(tmpOutFile, OleDbHelper.TEMPLATE_STATISTICSURVEYITEMBYPLAN, conn, leftTitle.ToString());
//rightTitle
StringBuilder rightTitle = new StringBuilder(200);
rightTitle.Append(string.Format("Update rightTitle{0} SET ", type));
DataRow[] titles = dsData.Tables[0].Select(null, null, DataViewRowState.CurrentRows);
int i = 1;
//Update rightTitle1 SET F1='医患沟通',F2='医师服务态度',F3='护士服务态度',F4='医疗技术',F5='护理技术操作',
//F6='拒收红包',F7='饮食、睡眠',F8='用药情况',F9='功能锻炼',F10='病区环境'
foreach (DataRow drOne in titles)
{
rightTitle.Append(string.Format("F{0}='{1}',", i++.ToString().Trim(), drOne["Name"]));
}
OleDbHelper.ExecuteSql(tmpOutFile, OleDbHelper.TEMPLATE_STATISTICSURVEYITEMBYPLAN, rightTitle.ToString().Substring(0, rightTitle.Length - 1));
public static void ExecuteSql(string tmpOutFile, string templateName, string SQLString)
{
try
{
if (!File.Exists(tmpOutFile))
{
File.Copy(HttpContext.Current.Server.MapPath(@"~\App_Data\") + templateName, tmpOutFile);
}
using (OleDbConnection conn = new OleDbConnection(string.Format(connectionStringBase, tmpOutFile)))
{
OleDbCommand cmd = new OleDbCommand(SQLString, conn);
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
cmd.ExecuteNonQuery();
}
}
catch (IOException ie)
{
throw ie;
}
catch (OleDbException oe)
{
throw oe;
}
}