public void btnSave_Click(object sender, ImageClickEventArgs e)
{

if(topic.Text=="")
{
finishMsg.Text="请输入标题";
return;
} OleDbConnection cn=new OleDbConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
OleDbDataReader dr;
OleDbCommand cmd;
string strSQL; try
{
cn.Open(); try
{
string new_file = UploadFile(); if(new_file=="ERROR") return; if(new_file!="NULL")
{
strSQL = "select attach_url from pbc_finance_record where id_no='"+id_no.Text+"'";
cmd=new OleDbCommand(strSQL,cn);
dr=cmd.ExecuteReader();

if(dr.Read())
{
string old_file = dr["attach_url"].ToString(); if(old_file!=new_file) DeleteFile(MapPath("upload/"+old_file));
} dr.Close();
cmd.Dispose();
}                                strSQL = "update pbc_doc_record set ";

strSQL+= "class_code='"+class_code.SelectedItem.Value+"',";

strSQL+= "topic='"+topic.Text.Replace("'","''")+"',";
if(new_file!="NULL") strSQL+= "attach_url='"+new_file+"',";

strSQL+= "where id_no='"+id_no.Text+"'";

cmd=new OleDbCommand(strSQL,cn);
cmd.ExecuteNonQuery();
cmd.Dispose();  Response.Redirect("finish.htm");
}
catch(Exception error2)
{
finishMsg.Text = error2.Message;
}
finally
{
cn.Close();
}
}
catch(Exception error1)
{
finishMsg.Text = error1.Message;
}
}