| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data;
- using System.Text;
- public partial class Report_TZSJFX_Report : System.Web.UI.Page
- {
- XYFDRQ.BLL.T_Report bll_T_Report = new XYFDRQ.BLL.T_Report();
- XYFDRQ.BLL.T_Sys_DictionaryValue bll_T_Sys_DictionaryValue = new XYFDRQ.BLL.T_Sys_DictionaryValue();
- XYFDRQ.BLL.T_Sys_UserAccount bll_T_Sys_UserAccount = new XYFDRQ.BLL.T_Sys_UserAccount();
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!this.IsPostBack)
- {
- DataBing();
- txtBeginDate.Value = DateTime.Now.ToString("yyyy-MM-01");
- txtEndDate.Value = DateTime.Now.ToString("yyyy-MM-dd");
- }
- AjaxPro.Utility.RegisterTypeForAjax(typeof(Report_TZSJFX_Report));
- }
- private void DataBing()
- {
- //绑定坐席
- this.ddlAccount.DataSource = bll_T_Sys_UserAccount.GetAllList();
- this.ddlAccount.DataTextField = "F_UserName";
- this.ddlAccount.DataValueField = "F_UserId";
- this.ddlAccount.DataBind();
- this.ddlAccount.Items.Insert(0, new ListItem("--请选择--", ""));
- }
- protected void btnExtWord_Click(object sender, EventArgs e)
- {
- byte[] content = System.Text.Encoding.Default.GetBytes(txtHideItems.Value);
- HttpResponse clsreponse = System.Web.HttpContext.Current.Response;
- clsreponse.ClearHeaders();
- clsreponse.ClearContent();
- clsreponse.AddHeader("Content-Disposition", "attachment;filename=TZSJFX" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");
- clsreponse.ContentType = "application/ms-excel";
- clsreponse.OutputStream.Write(content, 0, content.Length);
- clsreponse.End();
- #region MyRegion
- //HttpResponse resp = Page.Response;
- //resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
- ////下面这行很重要, attachment 参数表示作为附件下载,您可以改成 online在线打开
- ////filename=FileFlow.xls 指定输出文件的名称,注意其扩展名和指定文件类型相符,可以为:.doc .xls .txt .htm
- //resp.AppendHeader("Content-Disposition", "attachment;filename=FileFlow.xls");
- ////Response.ContentType指定文件类型 可以为application/ms-excel、application/ms-word、application/ms-txt、application/ms-html 或其他浏览器可直接支持文档
- //resp.ContentType = "application/ms-excel";
- ////向http输出流中写入取得的数据信息
- //resp.Write(txtHideItems.Value);
- ////处理行数据
- //resp.End();
- #endregion
- }
- [AjaxPro.AjaxMethod()]
- public string GetReportTable(AjaxPro.JavaScriptArray searchItems)
- {
- StringBuilder html = new StringBuilder();
- string reportsql = "";
- DataTable dt = new DataTable();
- DataTable dtdgd = new DataTable();
- DataTable dtyhf = new DataTable();
- string[] _operations = GetSearchItems(searchItems);
- html.Append("<h1 style='font-size: 18px;font-weight: bold;color: #333333;text-align:center;width:100%;'><b>坐席业务量统计表</b></h1>");
- html.Append("<div style='width:100%; text-align:right; height:25px;'>统计截止日期: " + _operations[0] + "—" + _operations[1] + " </div>");
- html.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" >");
- try
- {
- //开始时间
- if (!string.IsNullOrEmpty(_operations[0]))
- {
- reportsql += " and DATEDIFF(d,AddTime,'" + _operations[0] + "')<=0";
- }
- //结束时间
- if (!string.IsNullOrEmpty(_operations[1]))
- {
- reportsql += " and DATEDIFF(d,AddTime,'" + _operations[1] + "')>=0";
- }
- if (!string.IsNullOrEmpty(_operations[2]))
- {
- reportsql += " and UserId=" + _operations[2];
- }
- dt = bll_T_Report.GetAgentBusinessReport(reportsql);
- //标题第一行
- 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>");
- 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>");
- 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>");
- 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>");
- html.Append("</tr>");
- int allCount = 0;
- int dgdCount = 0;
- int yhfCount = 0;
- if (dt != null && dt.Rows.Count > 0)
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- html.Append("<tr align=\"center\" valign=\"middle\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\" bgcolor=\"#ffffff\">");
- //坐席员名称
- 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() + " </td>");
- //数量
- 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() + " </td>");
- //待归档数量
- string dgdsql = reportsql + " and State=2 and UserName='" + dt.Rows[i]["UserName"].ToString() + "'";
- dtdgd = bll_T_Report.GetAgentBusinessReport(dgdsql);
- if (dtdgd == null || dtdgd.Rows.Count == 0)
- {
- 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>");
- }
- else
- {
- 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() + " </td>");
- //待归档总数
- dgdCount += Convert.ToInt32(dtdgd.Rows[0]["TotalCount"].ToString());
- }
- //已回访数量
- string yhfsql = reportsql + " and ReturnVisitState=2 and UserName='" + dt.Rows[i]["UserName"].ToString() + "'";
- dtyhf = bll_T_Report.GetAgentBusinessReport(yhfsql);
- if (dtyhf == null || dtyhf.Rows.Count == 0)
- {
- 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>");
- }
- else
- {
- 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() + " </td>");
- //待归档总数
- yhfCount += Convert.ToInt32(dtyhf.Rows[0]["TotalCount"].ToString());
- }
- //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() + " +" + i + "@@@@</td>");
- //总数
- allCount += Convert.ToInt32(dt.Rows[i]["TotalCount"].ToString());
-
- //yhfCount += Convert.ToInt32(dtyhf.Rows[i]["TotalCount"].ToString());
- html.Append("</tr>");
- }
- }
- //合计
- 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>");
- 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 + " </td>");
- 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 + " </td>");
- 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 + " </td>");
- html.Append("</tr>");
- }
- catch
- { }
- finally
- {
- dt.Clear();
- dt.Dispose();
- }
- html.Append("</table>");
- return html.ToString();
- }
- private string[] GetSearchItems(AjaxPro.JavaScriptArray searchItems)
- {
- string[] operations = new string[searchItems.Count];
- int i = 0;
- foreach (Object obj in searchItems)
- {
- operations[i] = obj.ToString();
- i++;
- }
- return operations;
- }
- // /// <summary>
- // /// 合并列
- // /// </summary>
- // /// <param name="dt">要合并的数据</param>
- // /// <param name="key">后面列合并的标准</param>
- // /// <param name="row">开始合并的行</param>
- // /// <returns>合并的行数</returns>
- // private int GroupRows(DataTable dt,string key,int row)
- // {
- // int _rowSpanNum = 1;
-
- // for (int j = row + 1; j < dt.Rows.Count; j++)
- // {
- // if (dt.Rows[row][key].ToString() == dt.Rows[j][key].ToString())
- // {
- // _rowSpanNum++;
- // }
- // else
- // {
- // break;
- // }
-
- // }
-
- // return _rowSpanNum;
- // }
- // /// <summary>
- // /// 从数据字典读取值
- // /// </summary>
- // /// <param name="ddl"></param>
- // /// <param name="p_Condition"></param>
- // private string GetNameFromDictionary(string p_Flag, string p_Code)
- // {
- // string p_Name = string.Empty;
-
- // DataTable dt = bll_T_Sys_DictionaryValue.GetList("F_DictionaryFlag='" + p_Flag + "' and F_ValueCode='" + p_Code + "' order by F_Sort").Tables[0];
- // if (dt != null && dt.Rows.Count>0)
- // {
- // p_Name = dt.Rows[0]["F_Name"].ToString();
- // }
- // return p_Name;
- // }
- }
|