protected void btn_CreatePDF_Click(object sender, EventArgs e) { string str_PdfFilename, str_mulu; string str_DocFilename; str_mulu = "./2015课题成果/研究报告/"; string str_MapPath = Server.MapPath(str_mulu); DirectoryInfo di = new DirectoryInfo(str_MapPath); FileInfo[] dis = di.GetFiles();//取目录中所有内容 for (int i = 0; i < dis.Length; i++) { str_DocFilename = dis[i].Name; str_PdfFilename = str_DocFilename.Substring(0, str_DocFilename.LastIndexOf(".")) + ".pdf"; try { Microsoft.Office.Interop.Word.WdSaveFormat wdf = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatRTF; WordToal.Word2Format(str_MapPath + str_DocFilename, str_MapPath + str_PdfFilename, wdf); } catch (Exception ee) { CommFun.error_record(Session["jsh"].ToString(), Session["jsm"].ToString(), ee.Message); } } }
/// <summary> /// 执行Sql更新语句 /// </summary> /// <param name="sqlstr">传入的Sql语句</param> /// <returns>布尔值</returns> public static bool ExecuteUpdate(string sqlstr) { int isUpdateOk = 0; try { openConnection(); comm.CommandType = CommandType.Text; comm.CommandText = sqlstr; isUpdateOk = Convert.ToInt32(comm.ExecuteNonQuery()); } catch (Exception e) { throw new Exception(e.Message); CommFun.error_record("", "", e.Message); } finally { closeConnection(); } if (isUpdateOk >= 0) { return(true); } else { return(false); } }
protected void bindData() { str_sql = "SELECT a.jsh, appNO,appyear, a.ktmc, a.sqbm, a.sqr,c.name AS tj," + " cGroup, a.id, pm, a.xmbh, zzlb " + " FROM t_teacher_list AS a, t_teacher AS b ,t_dict c " + " WHERE mid(a.appNo,5) = b.jsh and flm=11 and status = bm " + //" and Status =(select url from t_dict where flm= 11 and bm = 5)" + " and xmbh is not null " + " and a.jsh = '" + Session["jsh"].ToString() + "'"; //排序 str_sql += " order by appyear desc"; dv = DBFun.GetDataView(str_sql); ViewState["sql"] = str_sql; PagedDataSource pds = new PagedDataSource(); pds.AllowPaging = true; pds.PageSize = AspNetPager1.PageSize; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.DataSource = dv; GridView1.DataSource = pds; //GridView1.DataKeyNames = new string[] { "ID" }; GridView1.DataBind(); try { AspNetPager1.RecordCount = dv.Table.Rows.Count; } catch (Exception ee) { Response.Write("<script>alert('" + ee.Message + ",请与管理员联系。" + "');</script>"); CommFun.error_record(Session["jsh"].ToString(), Session["jsm"].ToString(), ee.Message); } }
protected void btn_ok_Click(object sender, EventArgs e) { string str_status; if (cbx_1.Checked) { str_sql = "select url from t_dict where flm= 11 and bm = 6"; } else { str_sql = "select url from t_dict where flm= 11 and bm = 5"; } str_status = DBFun.ExecuteScalar(str_sql).ToString(); str_sql = string.Format("update t_teacher_list set Status = {0} where xmbh = '{1}'", str_status, Session["xmbh"].ToString()); try { if (DBFun.ExecuteUpdate(str_sql)) { Response.Write("<script>alert('保存成功!');</script>"); bindData(); } else { Response.Write("<script>alert('保存失败!');</script>"); } } catch (Exception ee) { Response.Write("<script>alert('" + ee.Message + ",请与管理员联系。" + "');</script>"); CommFun.error_record(Session["jsh"].ToString(), Session["jsm"].ToString(), ee.Message); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["jsh"] == null) { Response.Redirect("./SessionTimeOut.aspx?type=top"); } if (!IsPostBack) { str_sql = "select status from t_teacher_list where appNo = '" + Session["appNo"].ToString() + "'"; string str_status; try { str_status = DBFun.ExecuteScalar(str_sql).ToString(); } catch (Exception ee) { Response.Write("<script>alert('" + ee.Message + ",请与管理员联系。" + "');</script>"); CommFun.error_record(Session["jsh"].ToString(), Session["jsm"].ToString(), ee.Message); return; } str_sql = " select iif(count(*)=0,false,true) From t_dict where flm=10 and bm=1 " + " and date() between cdate(url) and cdate(content) "; hl_1.Enabled = Convert.ToBoolean(DBFun.ExecuteScalar(str_sql)); if (str_status == "") { } } }
protected void bindData() { str_sql = "SELECT sqr,xmbh,rws_dName,rws from t_teacher_list where xmbh = '" + Session["xmbh"].ToString() + "';"; DataRow dr = DBFun.GetDataRow(str_sql); if (dr == null) { return; } string str_sqr = dr["sqr"].ToString(); string str_xmbh = dr["xmbh"].ToString(); string str_DocFilename = dr["rws"].ToString(); string str_HtmlFilename, str_mulu; str_mulu = "./任务书/"; if (str_DocFilename == "") { Response.Write("<script>alert('尚未上传期任务书!');</script>"); hl_1.ForeColor = System.Drawing.Color.Tomato; hl_1.Text = "尚未上传期任务书"; hl_1.NavigateUrl = ""; return; } str_HtmlFilename = str_DocFilename.Substring(0, str_DocFilename.LastIndexOf(".")) + ".pdf"; string str_MapPath = Server.MapPath(str_mulu); hl_1.ForeColor = System.Drawing.Color.FromArgb(000066); hl_1.Text = "查看任务书"; try { word.WdSaveFormat wdf = word.WdSaveFormat.wdFormatPDF; WordToal.Word2Format(str_MapPath + str_DocFilename, str_MapPath + str_HtmlFilename, wdf); } catch (Exception e) { CommFun.error_record(Session["jsh"].ToString(), Session["jsm"].ToString(), e.Message); return; } hl_1.NavigateUrl = str_mulu + str_HtmlFilename; }