Nav apraksta

TZSJFX_Report.aspx.cs 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. using System.Data;
  8. using System.Text;
  9. public partial class Report_TZSJFX_Report : System.Web.UI.Page
  10. {
  11. XYFDRQ.BLL.T_Report bll_T_Report = new XYFDRQ.BLL.T_Report();
  12. XYFDRQ.BLL.T_Sys_DictionaryValue bll_T_Sys_DictionaryValue = new XYFDRQ.BLL.T_Sys_DictionaryValue();
  13. XYFDRQ.BLL.T_Sys_UserAccount bll_T_Sys_UserAccount = new XYFDRQ.BLL.T_Sys_UserAccount();
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16. if (!this.IsPostBack)
  17. {
  18. DataBing();
  19. txtBeginDate.Value = DateTime.Now.ToString("yyyy-MM-01");
  20. txtEndDate.Value = DateTime.Now.ToString("yyyy-MM-dd");
  21. }
  22. AjaxPro.Utility.RegisterTypeForAjax(typeof(Report_TZSJFX_Report));
  23. }
  24. private void DataBing()
  25. {
  26. //绑定坐席
  27. this.ddlAccount.DataSource = bll_T_Sys_UserAccount.GetAllList();
  28. this.ddlAccount.DataTextField = "F_UserName";
  29. this.ddlAccount.DataValueField = "F_UserId";
  30. this.ddlAccount.DataBind();
  31. this.ddlAccount.Items.Insert(0, new ListItem("--请选择--", ""));
  32. }
  33. protected void btnExtWord_Click(object sender, EventArgs e)
  34. {
  35. byte[] content = System.Text.Encoding.Default.GetBytes(txtHideItems.Value);
  36. HttpResponse clsreponse = System.Web.HttpContext.Current.Response;
  37. clsreponse.ClearHeaders();
  38. clsreponse.ClearContent();
  39. clsreponse.AddHeader("Content-Disposition", "attachment;filename=TZSJFX" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");
  40. clsreponse.ContentType = "application/ms-excel";
  41. clsreponse.OutputStream.Write(content, 0, content.Length);
  42. clsreponse.End();
  43. #region MyRegion
  44. //HttpResponse resp = Page.Response;
  45. //resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
  46. ////下面这行很重要, attachment 参数表示作为附件下载,您可以改成 online在线打开
  47. ////filename=FileFlow.xls 指定输出文件的名称,注意其扩展名和指定文件类型相符,可以为:.doc    .xls    .txt   .htm
  48. //resp.AppendHeader("Content-Disposition", "attachment;filename=FileFlow.xls");
  49. ////Response.ContentType指定文件类型 可以为application/ms-excel、application/ms-word、application/ms-txt、application/ms-html 或其他浏览器可直接支持文档
  50. //resp.ContentType = "application/ms-excel";
  51. ////向http输出流中写入取得的数据信息
  52. //resp.Write(txtHideItems.Value);
  53. ////处理行数据
  54. //resp.End();
  55. #endregion
  56. }
  57. [AjaxPro.AjaxMethod()]
  58. public string GetReportTable(AjaxPro.JavaScriptArray searchItems)
  59. {
  60. StringBuilder html = new StringBuilder();
  61. string reportsql = "";
  62. DataTable dt = new DataTable();
  63. DataTable dtdgd = new DataTable();
  64. DataTable dtyhf = new DataTable();
  65. string[] _operations = GetSearchItems(searchItems);
  66. html.Append("<h1 style='font-size: 18px;font-weight: bold;color: #333333;text-align:center;width:100%;'><b>坐席业务量统计表</b></h1>");
  67. html.Append("<div style='width:100%; text-align:right; height:25px;'>统计截止日期: " + _operations[0] + "—" + _operations[1] + " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>");
  68. html.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" >");
  69. try
  70. {
  71. //开始时间
  72. if (!string.IsNullOrEmpty(_operations[0]))
  73. {
  74. reportsql += " and DATEDIFF(d,AddTime,'" + _operations[0] + "')<=0";
  75. }
  76. //结束时间
  77. if (!string.IsNullOrEmpty(_operations[1]))
  78. {
  79. reportsql += " and DATEDIFF(d,AddTime,'" + _operations[1] + "')>=0";
  80. }
  81. if (!string.IsNullOrEmpty(_operations[2]))
  82. {
  83. reportsql += " and UserId=" + _operations[2];
  84. }
  85. dt = bll_T_Report.GetAgentBusinessReport(reportsql);
  86. //标题第一行
  87. html.Append("<tr style=\"text-align: center;\"><td class=\"formtabletitle\" style=\"height: 35px;background-color: #D5EDFE;border:1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;width:150px\">坐席姓名</td>");
  88. html.Append("<td class=\"formtabletitle1\"style=\"height: 25px;background-color: #D5EDFE;border-left: 0px solid #FFFFFF;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">数量</td>");
  89. html.Append("<td class=\"formtabletitle1\"style=\"height: 25px;background-color: #D5EDFE;border-left: 0px solid #FFFFFF;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">待归档数</td>");
  90. html.Append("<td class=\"formtabletitle1\"style=\"height: 25px;background-color: #D5EDFE;border-left: 0px solid #FFFFFF;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">已回访数</td>");
  91. html.Append("</tr>");
  92. int allCount = 0;
  93. int dgdCount = 0;
  94. int yhfCount = 0;
  95. if (dt != null && dt.Rows.Count > 0)
  96. {
  97. for (int i = 0; i < dt.Rows.Count; i++)
  98. {
  99. html.Append("<tr align=\"center\" valign=\"middle\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\" bgcolor=\"#ffffff\">");
  100. //坐席员名称
  101. html.Append("<td class=\"formtable_td\" style=\"vertical-align: middle;border-top: 0px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;padding-left: 2px;height: 25px;padding-top: 3px;padding-bottom: 3px;\">" + dt.Rows[i]["UserName"].ToString() + "&nbsp;</td>");
  102. //数量
  103. html.Append("<td class=\"formtable_td\" style=\"vertical-align: middle;border-top: 0px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;padding-left: 2px;height: 25px;padding-top: 3px;padding-bottom: 3px;\">" + dt.Rows[i]["TotalCount"].ToString() + "&nbsp;</td>");
  104. //待归档数量
  105. string dgdsql = reportsql + " and State=2 and UserName='" + dt.Rows[i]["UserName"].ToString() + "'";
  106. dtdgd = bll_T_Report.GetAgentBusinessReport(dgdsql);
  107. if (dtdgd == null || dtdgd.Rows.Count == 0)
  108. {
  109. html.Append("<td class=\"formtable_td\" style=\"vertical-align: middle;border-top: 0px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;padding-left: 2px;height: 25px;padding-top: 3px;padding-bottom: 3px;\">0</td>");
  110. }
  111. else
  112. {
  113. html.Append("<td class=\"formtable_td\" style=\"vertical-align: middle;border-top: 0px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;padding-left: 2px;height: 25px;padding-top: 3px;padding-bottom: 3px;\">" + dtdgd.Rows[0]["TotalCount"].ToString() + "&nbsp;</td>");
  114. //待归档总数
  115. dgdCount += Convert.ToInt32(dtdgd.Rows[0]["TotalCount"].ToString());
  116. }
  117. //已回访数量
  118. string yhfsql = reportsql + " and ReturnVisitState=2 and UserName='" + dt.Rows[i]["UserName"].ToString() + "'";
  119. dtyhf = bll_T_Report.GetAgentBusinessReport(yhfsql);
  120. if (dtyhf == null || dtyhf.Rows.Count == 0)
  121. {
  122. html.Append("<td class=\"formtable_td\" style=\"vertical-align: middle;border-top: 0px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;padding-left: 2px;height: 25px;padding-top: 3px;padding-bottom: 3px;\">0</td>");
  123. }
  124. else
  125. {
  126. html.Append("<td class=\"formtable_td\" style=\"vertical-align: middle;border-top: 0px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;padding-left: 2px;height: 25px;padding-top: 3px;padding-bottom: 3px;\">" + dtyhf.Rows[0]["TotalCount"].ToString() + "&nbsp;</td>");
  127. //待归档总数
  128. yhfCount += Convert.ToInt32(dtyhf.Rows[0]["TotalCount"].ToString());
  129. }
  130. //html.Append("<td class=\"formtable_td\" style=\"vertical-align: middle;border-top: 0px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;padding-left: 2px;height: 25px;padding-top: 3px;padding-bottom: 3px;\">" + dtyhf.Rows[i]["TotalCount"].ToString() + "&nbsp;+" + i + "@@@@</td>");
  131. //总数
  132. allCount += Convert.ToInt32(dt.Rows[i]["TotalCount"].ToString());
  133. //yhfCount += Convert.ToInt32(dtyhf.Rows[i]["TotalCount"].ToString());
  134. html.Append("</tr>");
  135. }
  136. }
  137. //合计
  138. html.Append("<tr style=\"text-align: center;\"><td class=\"formtabletitle3\" style=\"height: 35px;background-color: #D5EDFE;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;border-top: 0px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 10px 3px 2px;text-align:center;\">总计:</td>");
  139. html.Append("<td class=\"formtabletitle2\" style=\"height: 25px;background-color: #D5EDFE;border-left: 0px solid #FFFFFF;border-right: 1px solid #CCCCCC;border-top: 0px solid #FFFFFF;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">" + allCount + "&nbsp;</td>");
  140. html.Append("<td class=\"formtabletitle2\" style=\"height: 25px;background-color: #D5EDFE;border-left: 0px solid #FFFFFF;border-right: 1px solid #CCCCCC;border-top: 0px solid #FFFFFF;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">" + dgdCount + "&nbsp;</td>");
  141. html.Append("<td class=\"formtabletitle2\" style=\"height: 25px;background-color: #D5EDFE;border-left: 0px solid #FFFFFF;border-right: 1px solid #CCCCCC;border-top: 0px solid #FFFFFF;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">" + yhfCount + "&nbsp;</td>");
  142. html.Append("</tr>");
  143. }
  144. catch
  145. { }
  146. finally
  147. {
  148. dt.Clear();
  149. dt.Dispose();
  150. }
  151. html.Append("</table>");
  152. return html.ToString();
  153. }
  154. private string[] GetSearchItems(AjaxPro.JavaScriptArray searchItems)
  155. {
  156. string[] operations = new string[searchItems.Count];
  157. int i = 0;
  158. foreach (Object obj in searchItems)
  159. {
  160. operations[i] = obj.ToString();
  161. i++;
  162. }
  163. return operations;
  164. }
  165. // /// <summary>
  166. // /// 合并列
  167. // /// </summary>
  168. // /// <param name="dt">要合并的数据</param>
  169. // /// <param name="key">后面列合并的标准</param>
  170. // /// <param name="row">开始合并的行</param>
  171. // /// <returns>合并的行数</returns>
  172. // private int GroupRows(DataTable dt,string key,int row)
  173. // {
  174. // int _rowSpanNum = 1;
  175. // for (int j = row + 1; j < dt.Rows.Count; j++)
  176. // {
  177. // if (dt.Rows[row][key].ToString() == dt.Rows[j][key].ToString())
  178. // {
  179. // _rowSpanNum++;
  180. // }
  181. // else
  182. // {
  183. // break;
  184. // }
  185. // }
  186. // return _rowSpanNum;
  187. // }
  188. // /// <summary>
  189. // /// 从数据字典读取值
  190. // /// </summary>
  191. // /// <param name="ddl"></param>
  192. // /// <param name="p_Condition"></param>
  193. // private string GetNameFromDictionary(string p_Flag, string p_Code)
  194. // {
  195. // string p_Name = string.Empty;
  196. // DataTable dt = bll_T_Sys_DictionaryValue.GetList("F_DictionaryFlag='" + p_Flag + "' and F_ValueCode='" + p_Code + "' order by F_Sort").Tables[0];
  197. // if (dt != null && dt.Rows.Count>0)
  198. // {
  199. // p_Name = dt.Rows[0]["F_Name"].ToString();
  200. // }
  201. // return p_Name;
  202. // }
  203. }