TeacherCount.aspx.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. public partial class TeacherCount : System.Web.UI.Page
  8. {
  9. LYS.UserData1 myud = new LYS.UserData1();
  10. //string QueryConditions = "";
  11. string SQL = "select ID,教师姓名,系部,课程名,督导姓名,听课日期 from TKJL";
  12. string TableName = "TKJL";
  13. string sql = "";
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16. //tbEndTime.Value = DateTime.Now.ToShortDateString();
  17. //tbStartTime.Value = DateTime.Now.ToShortDateString();
  18. Session["SQL"] = "";
  19. HttpContext.Current.Session["TableName"] = "";
  20. HttpContext.Current.Session["SQL"] = SQL;
  21. HttpContext.Current.Session["TableName"] = TableName;
  22. Literal1.Text = myud.HTML5SQLBindRecValueToDDL("用户名", "select distinct(用户名) from UserS").ToString();
  23. if (!Page.IsPostBack)
  24. {
  25. // myud.BindFiledToDropDownList(QueryField, SQL, TableName);
  26. }
  27. //DateTime startTime = Convert.ToDateTime("2017-9-1");
  28. //DateTime endTime = Convert.ToDateTime("2017-9-11");
  29. // string sql = "select count(*) as 总计 from TKJL where 听课日期 >= #2017-9-1# and 听课日期 <=#2017-9-10#"; //OK
  30. //DateTime time3 = DateTime.D dateTimePicker1.Value.Date.ToString("yyyy-MM-dd");
  31. //DateTime time4 = dateTimePicker2.Value.Date.ToString("yyyy-MM-dd");
  32. // checkCmd = "SELECT sum([单笔账单总计]) As 总计 FROM Account where 时间 between #" + time3 + "# and #" + time4 + "#";
  33. //Literal1.Text = myud.DispLineCount(sql).ToString();
  34. }
  35. protected void Button1_Click(object sender, EventArgs e)
  36. {
  37. Panel1.Visible = true;
  38. Literal2.Text = "《" + sDemp.Value + "》" + ReportName.Value + "督导统计报表";
  39. DateTime startTime = Convert.ToDateTime(tbStartTime.Value.ToString());
  40. DateTime endTime = Convert.ToDateTime(tbEndTime.Value.ToString());
  41. //2.督导听课
  42. if (sDemp.Value.Trim().ToString() == "全院")
  43. {
  44. // sql = "select count(*) as " + ReportName.Value + " from TKJL where 听课日期 >= '" + tbStartTime.Value + "' and 听课日期 <='" + tbEndTime.Value + "'"; //OK
  45. sql = "select count(*) from TKJL where 听课日期 >= '" + tbStartTime.Value + "' and 听课日期 <='" + tbEndTime.Value + "'"; //OK
  46. }
  47. else
  48. {
  49. // sql = "select count(*) as " + ReportName.Value + " from TKJL where 听课日期 >= '" + tbStartTime.Value + "' and 听课日期 <='" + tbEndTime.Value + "' and 系部='" + sDemp.Value.Trim().ToString() + "'"; //OK
  50. sql = "select count(*) from TKJL where 听课日期 >= '" + tbStartTime.Value + "' and 听课日期 <='" + tbEndTime.Value + "' and 督导姓名='" + sDemp.Value.Trim().ToString() + "'"; //OK
  51. }
  52. //string sql = "select count(*) as " + ReportName.Value + " from TKJL where 听课日期 >= #" + tbStartTime.Value + "# and 听课日期 <=#" + tbEndTime.Value + "#"; //OK ACCESS
  53. XB.Text = sDemp.Value.ToString();
  54. DDTK.Text = myud.DispLineCountNum(sql).ToString();
  55. //1.督导会议
  56. if (sDemp.Value.Trim().ToString() == "全院")
  57. {
  58. sql = "select count(*) from OthProg where 督导时间 >= '" + tbStartTime.Value + "' and 督导时间 <='" + tbEndTime.Value + "' and 督导项目名 Like '%督导会议%'"; //OK
  59. }
  60. else
  61. {
  62. sql = "select count(*) from OthProg where 督导时间 >= '" + tbStartTime.Value + "' and 督导时间 <='" + tbEndTime.Value + "' and 督导项目名 Like '%督导会议%' and 系部='" + sDempent.Value.Trim().ToString() + "'"; //OK
  63. }
  64. DDHY.Text = myud.DispLineCountNum(sql).ToString();
  65. //3.评课次数
  66. //if (sDemp.Value.Trim().ToString() == "全院")
  67. //{
  68. // sql = "select count(*) from OthProg where 督导时间 >= '" + tbStartTime.Value + "' and 督导时间 <='" + tbEndTime.Value + "' and 督导项目名 Like '%教学评课%'"; //OK
  69. //}
  70. //else
  71. //{
  72. // sql = "select count(*) from OthProg where 督导时间 >= '" + tbStartTime.Value + "' and 督导时间 <='" + tbEndTime.Value + "' and 督导项目名 Like '%教学评课%' and 系部='" + sDemp.Value.Trim().ToString() + "'"; //OK
  73. //}
  74. if (sDemp.Value.Trim().ToString() == "全院")
  75. {
  76. sql = "select count(*) from TKJL where 听课日期 >= '" + tbStartTime.Value + "' and 听课日期 <='" + tbEndTime.Value + "' and 综合评价 IS NOT NULL"; //OK
  77. }
  78. else
  79. {
  80. sql = "select count(*) from TKJL where 听课日期 >= '" + tbStartTime.Value + "' and 听课日期 <='" + tbEndTime.Value + "' and 综合评价 IS NOT NULL and 系部='" + sDempent.Value.Trim().ToString() + "'"; //OK
  81. }
  82. DDPK.Text = myud.DispLineCountNum(sql).ToString();
  83. //4.督学情况
  84. if (sDemp.Value.Trim().ToString() == "全院")
  85. {
  86. sql = "select count(*) from OthProg where 督导时间 >= '" + tbStartTime.Value + "' and 督导时间 <='" + tbEndTime.Value + "' and 督导项目名 Like '%督学情况%'"; //OK
  87. }
  88. else
  89. {
  90. sql = "select count(*) from OthProg where 督导时间 >= '" + tbStartTime.Value + "' and 督导时间 <='" + tbEndTime.Value + "' and 督导项目名 Like '%督学情况%' and 督导姓名='" + sDemp.Value.Trim().ToString() + "'"; //OK
  91. }
  92. DXCS.Text = myud.DispLineCountNum(sql).ToString();
  93. //5.教学检查
  94. if (sDemp.Value.Trim().ToString() == "全院")
  95. {
  96. sql = "select count(*) from OthProg where 督导时间 >= '" + tbStartTime.Value + "' and 督导时间 <='" + tbEndTime.Value + "' and 督导项目名 Like '%教学检查%'"; //OK
  97. }
  98. else
  99. {
  100. sql = "select count(*) from OthProg where 督导时间 >= '" + tbStartTime.Value + "' and 督导时间 <='" + tbEndTime.Value + "' and 督导项目名 Like '%教学检查%' and 督导姓名='" + sDemp.Value.Trim().ToString() + "'"; //OK
  101. }
  102. JXJC.Text = myud.DispLineCountNum(sql).ToString();
  103. //7.项目评审
  104. if (sDemp.Value.Trim().ToString() == "全院")
  105. {
  106. sql = "select count(*) from OthProg where 督导时间 >= '" + tbStartTime.Value + "' and 督导时间 <='" + tbEndTime.Value + "' and 督导项目名 Like '%项目评审%'"; //OK
  107. }
  108. else
  109. {
  110. sql = "select count(*) from OthProg where 督导时间 >= '" + tbStartTime.Value + "' and 督导时间 <='" + tbEndTime.Value + "' and 督导项目名 Like '%项目评审%' and 督导姓名='" + sDemp.Value.Trim().ToString() + "'"; //OK
  111. }
  112. XMPH.Text = myud.DispLineCountNum(sql).ToString();
  113. //8.培训交流
  114. if (sDemp.Value.Trim().ToString() == "全院")
  115. {
  116. sql = "select count(*) from OthProg where 督导时间 >= '" + tbStartTime.Value + "' and 督导时间 <='" + tbEndTime.Value + "' and 督导项目名 Like '%培训交流%'"; //OK
  117. }
  118. else
  119. {
  120. sql = "select count(*) from OthProg where 督导时间 >= '" + tbStartTime.Value + "' and 督导时间 <='" + tbEndTime.Value + "' and 督导项目名 Like '%培训交流%' and 督导姓名='" + sDemp.Value.Trim().ToString() + "'"; //OK
  121. }
  122. PXJL.Text = myud.DispLineCountNum(sql).ToString();
  123. //9.其它
  124. if (sDemp.Value.Trim().ToString() == "全院")
  125. {
  126. sql = "select count(*) from OthProg where 督导时间 >= '" + tbStartTime.Value + "' and 督导时间 <='" + tbEndTime.Value + "' and 督导项目名 Like '%其它%'"; //OK
  127. }
  128. else
  129. {
  130. sql = "select count(*) from OthProg where 督导时间 >= '" + tbStartTime.Value + "' and 督导时间 <='" + tbEndTime.Value + "' and 督导项目名 Like '%其它%' and 督导姓名='" + sDemp.Value.Trim().ToString() + "'"; //OK
  131. }
  132. Othe.Text = myud.DispLineCountNum(sql).ToString();
  133. }
  134. /// <summary>
  135. /// 以行显示,每一行下划线显示 显示统计结果(总数)
  136. /// </summary>
  137. /// <param name="SQL"></param>
  138. /// <returns></returns>
  139. //public StringBuilder DispLineCount(string SQL)
  140. //{ //调用
  141. // //DateTime startTime = Convert.ToDateTime("2017-9-1");
  142. // //DateTime endTime = Convert.ToDateTime("2017-9-11");
  143. // //string sql = "select count(*) as 总计 from TKJL where 听课日期 >= #2017-9-1# and 听课日期 <=#2017-9-10#"; //OK
  144. // StringBuilder sb = new StringBuilder();
  145. // // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
  146. // string sql = SQL;
  147. // OleDbConnection dtConn = new OleDbConnection(connectionString);
  148. // OleDbDataAdapter dtCmd = new OleDbDataAdapter(sql, dtConn);
  149. // DataSet dtSet = new DataSet();
  150. // dtCmd.Fill(dtSet);
  151. // DataTableReader objreader = dtSet.CreateDataReader();
  152. // int i = 0, j = 0;
  153. // sb.Append("\n <table width=\"900\" align=\"center\" class=\"lh28 font_st\">");
  154. // sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
  155. // for (i = 0; i <= objreader.FieldCount - 1; i++)
  156. // {
  157. // sb.Append(" <td align=\"center\" nowrap=\"nowrap\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>" + objreader.GetName(i) + "&nbsp;</b>");
  158. // }
  159. // sb.Append("\n </tr>");
  160. // while (objreader.Read())
  161. // {
  162. // j = j + 1;
  163. // sb.Append("\n <tr class=\"list_bline1\">");
  164. // for (i = 0; i <= objreader.FieldCount - 1; i++)
  165. // {
  166. // sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \">" + objreader.GetValue(i).ToString() + "&nbsp;</td>");
  167. // }
  168. // sb.Append("\n </tr>");
  169. // }
  170. // sb.Append("</table>");
  171. // return sb;
  172. //}
  173. protected void Button3_Click(object sender, EventArgs e)
  174. {
  175. HttpContext.Current.Response.Buffer = true;
  176. HttpContext.Current.Response.Clear();
  177. HttpContext.Current.Response.Charset = "gb2312";
  178. HttpContext.Current.Response.ClearContent();
  179. HttpContext.Current.Response.ClearHeaders();
  180. Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
  181. HttpContext.Current.Response.ContentType = "application/ms-word";
  182. HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=fileDown.doc");
  183. //关闭控件的视图状态 ,如果仍然为true,RenderControl将启用页的跟踪功能,存储与控件有关的跟踪信息
  184. this.EnableViewState = false;
  185. //将要下载的页面输出到HtmlWriter
  186. System.IO.StringWriter writer = new System.IO.StringWriter();
  187. System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(writer);
  188. this.RenderControl(htmlWriter);
  189. //提取要输出的内容
  190. string pageHtml = writer.ToString();
  191. int startIndex = pageHtml.IndexOf("<div style=\"margin: 0 auto;\" id=\"mainContent\">");
  192. int endIndex = pageHtml.LastIndexOf("</div>");
  193. int lenth = endIndex - startIndex;
  194. pageHtml = pageHtml.Substring(startIndex, lenth);
  195. //输出
  196. HttpContext.Current.Response.Write(pageHtml.ToString());
  197. HttpContext.Current.Response.End();
  198. }
  199. }