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; using NPOI.HSSF.UserModel; using System.IO; using NPOI.HSSF.Util; namespace Com.Jpsoft.Hospital.Web.Module.FllowUp.FollowUpRecord { public partial class List : Com.Jpsoft.Hospital.Web.Common.BasePage { public double zhjs = 0;//总呼叫 public double yxhj = 0;//有效呼叫 public double gjwj = 0;//关机未接 public double tjkh = 0;//停机空号 public double hmbf = 0;//号码不符 public string yxl = string.Empty;//有效率 #region 事件处理 //protected override void OnInit(EventArgs e) //{ // if (!IsPostBack) // { // base.AutoCheckRight = false; // base.CheckRightParam = Com.Jpsoft.Hospital.Web.Common.PageFuntionType.List; // } // base.OnInit(e); //} protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { switch (ddlCustomerType.SelectedValue.ToString()) { case "0": BindKYData(); break; case "2": BindSFData(); break; case "1": BindZYData(); break; case "3": BindQZData(); break; } if (!base.CheckRightByFun(Common.PageFuntionType.Print)) { ddlVisitType.SelectedIndex = 1; ddlVisitType.Visible = false; } BindKS(); } // SumSF(); } private void BindKS() { Com.Jpsoft.Hospital.BLL.Ex.ZY_BRSYKEx bll = new BLL.Ex.ZY_BRSYKEx(); DataTable dt = bll.GetYY_KSBMKList(" (name NOT LIKE '%门诊%') AND (name NOT LIKE '%停用%') AND (kslb = 0) "); ddlks.Items.Add(new ListItem("请选择", "")); foreach (DataRow dr in dt.Rows) { ddlks.Items.Add(new ListItem(dr["name"].ToString(), dr["id"].ToString())); } } private void BindQZData() { string strWhere = " where 1=1 "; int recordCount = 0; if (!string.IsNullOrEmpty((string)ViewState["SearchTerms"])) { strWhere = ViewState["SearchTerms"].ToString(); } string orderby = " order by date DESC"; using (IDataReader idr = BLL.BaseClass.SelectPage("jp_qz_followuprecord", "*", "id", AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, strWhere, orderby)) { if (idr.Read()) { recordCount = int.Parse(idr["RecordCount"].ToString()); } AspNetPager1.RecordCount = recordCount; idr.NextResult(); this.GvList.DataSource = idr; this.GvList.DataBind(); } } private void BindKYData() { string strWhere = " where 1=1 "; int recordCount = 0; if (!string.IsNullOrEmpty((string)ViewState["SearchTerms"])) { strWhere = ViewState["SearchTerms"].ToString(); } string orderby = " order by date DESC"; using (IDataReader idr = BLL.BaseClass.SelectPage("jp_ky_followuprecord", "*", "id", AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, strWhere, orderby)) { if (idr.Read()) { recordCount = int.Parse(idr["RecordCount"].ToString()); } AspNetPager1.RecordCount = recordCount; idr.NextResult(); this.GvList.DataSource = idr; this.GvList.DataBind(); } } protected void btnQuery_Click(object sender, EventArgs e) { Query(); } //protected void btnExport_Click(object sender, EventArgs e) //{ // Export(); //} protected void AspNetPager1_PageChanged(object sender, EventArgs e) { switch (ddlCustomerType.SelectedValue.ToString()) { case "0": BindKYData(); break; case "2": BindSFData(); break; case "1": BindZYData(); break; case "3": BindQZData(); break; } } //住院病人随访统计 protected void btnsftj_Click(object sender, EventArgs e) { SFSumMZ(); } #endregion #region 事件方法 /// /// 绑定门诊病人随访记录信息 /// private void BindSFData() { string strWhere = " where 1=1 "; int recordCount = 0; if (!string.IsNullOrEmpty((string)ViewState["SearchTerms"])) { strWhere = ViewState["SearchTerms"].ToString(); } string orderby = " order by mzfr_date DESC"; using (IDataReader idr = BLL.BaseClass.SelectPage("jp_sf_followuprecord", "*", "mzfr_id", AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, strWhere, orderby)) { if (idr.Read()) { recordCount = int.Parse(idr["RecordCount"].ToString()); } AspNetPager1.RecordCount = recordCount; idr.NextResult(); this.GvList.DataSource = idr; this.GvList.DataBind(); } } /// /// 随访统计 /// private void SumSF() { string where = " 1=1 "; if (!string.IsNullOrEmpty((string)ViewState["SearchTerms"])) { where = ViewState["SearchTerms"].ToString(); } //if (txtDate1.Text != "") //{ // where = where + " and date>='" + txtDate1.Text + "' "; //} //if (txtDate2.Text != "") //{ // where = where + " and date<='" + txtDate2.Text + "' "; //} //if (Request.QueryString["typeid"] != null) //{ // where = where + " and type='" + Request.QueryString["typeid"] + "'"; //} //else //{ // where = where + " and (type=1 or type=2) "; //} //where = where + " and customertype='" + ddlCustomerType.SelectedValue + "' "; where = where + " and visitway=1 and customertype='" + ddlCustomerType.SelectedValue + "'"; where = where.Replace("where", ""); Com.Jpsoft.Hospital.BLL.Ex.jp_followup_recordEx bll = new Com.Jpsoft.Hospital.BLL.Ex.jp_followup_recordEx(); zhjs = bll.GetListZY(where).Tables[0].Rows.Count; yxhj = bll.GetListZY(where + " and issuccess=0 ").Tables[0].Rows.Count; gjwj = bll.GetListZY(where + " and issuccess=1 ").Tables[0].Rows.Count; tjkh = bll.GetListZY(where + " and issuccess=2 ").Tables[0].Rows.Count; hmbf = bll.GetListZY(where + " and issuccess=3 ").Tables[0].Rows.Count; double xl = 0;//(yxhj / zhjs)*100; if (zhjs != 0) { xl = (yxhj / zhjs) * 100; } yxl = xl.ToString("F2") + "%"; } /// /// 绑定住院病人门诊信息 /// private void BindZYData() { string strWhere = " where type='2'"; if (base.CheckRightByFun(Common.PageFuntionType.Confirm)) { if (!base.IsAdmin()) { ddlVisitType.SelectedIndex = 5; ddlVisitType.Visible = false; strWhere = " where type='5'"; } } int recordCount = 0; if (!string.IsNullOrEmpty((string)ViewState["SearchTerms"])) { strWhere = ViewState["SearchTerms"].ToString(); } string orderby = " order by date DESC"; using (IDataReader idr = BLL.BaseClass.SelectPage("jp_zy_followuprecord", "*", "id", AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, strWhere, orderby)) { if (idr.Read()) { recordCount = int.Parse(idr["RecordCount"].ToString()); } AspNetPager1.RecordCount = recordCount; idr.NextResult(); this.GvList.DataSource = idr; this.GvList.DataBind(); } } /// /// 查询数据 /// private void Query() { StringBuilder strWhere = new StringBuilder(" where 1=1 "); if (!string.IsNullOrEmpty(this.txtcqrq1.Text)) { strWhere.Append(" and cqrq >='" + Convert.ToDateTime(this.txtcqrq1.Text).ToString("yyyyMMdd00:00:00") + "'"); } if (!string.IsNullOrEmpty(this.txtcqrq2.Text)) { strWhere.Append(" and cqrq <'" + Convert.ToDateTime(this.txtcqrq2.Text).AddDays(1).ToString("yyyyMMdd00:00:00") + "'"); } if (!string.IsNullOrEmpty(this.txtrqrq1.Text)) { strWhere.Append(" and rqrq >='" + Convert.ToDateTime(this.txtrqrq1.Text).ToString("yyyyMMdd00:00:00") + "'"); } if (!string.IsNullOrEmpty(this.txtrqrq2.Text)) { strWhere.Append(" and rqrq <'" + Convert.ToDateTime(this.txtrqrq2.Text).AddDays(1).ToString("yyyyMMdd00:00:00") + "'"); } if (!string.IsNullOrEmpty(this.txtDate1.Text)) { strWhere.Append(" and date >='" + Convert.ToDateTime(this.txtDate1.Text).ToString("yyyy/MM/dd 00:00:00") + "'"); } if (!string.IsNullOrEmpty(this.txtDate2.Text)) { strWhere.Append(" and date <'" + Convert.ToDateTime(this.txtDate2.Text).AddDays(1).ToString("yyyy/MM/dd 00:00:00") + "'"); } if (ddlVisitWay.SelectedValue == "0") { strWhere.Append(" and visitway=0 "); } if (ddlVisitWay.SelectedValue == "1") { strWhere.Append(" and visitway=1 "); } if (txtUserName.Text.Trim() != "") { strWhere.Append(" and creater='" + txtUserName.Text.Trim() + "'"); } if (ddlVisitType.SelectedValue != "") { strWhere.Append(" and type='" + ddlVisitType.SelectedValue + "' "); } if (ddlks.SelectedValue != "") { strWhere.Append(" and ksdm='" + ddlks.SelectedValue + "'"); } ViewState["SearchTerms"] = strWhere.ToString(); switch (ddlCustomerType.SelectedValue.ToString()) { case "0": BindKYData(); break; case "2": BindSFData(); break; case "1": BindZYData(); break; case "3": BindQZData(); break; } SumSF(); //if (GvList.Rows.Count != 0) //{ // this.btnExport.Enabled = true; //} //else //{ // this.btnExport.Enabled = false; //} } ///// ///// 导出为EXCEL表格 ///// //private void Export() //{ // string strWhere = " where 1=1 "; // if (!string.IsNullOrEmpty((string)ViewState["SearchTerms"])) // { // strWhere = ViewState["SearchTerms"].ToString(); // } // if (ddlCustomerType.SelectedIndex == 0 || ddlCustomerType.SelectedValue == "0") // { // strWhere += " and customertype=0"; // } // if (ddlCustomerType.SelectedValue == "1") // { // strWhere += " and customertype=1"; // } // strWhere = strWhere.Replace("where", ""); // Jpsoft.Hospital.ReportClass.ExcelReports.ReportFollowUpRecord report = new Com.Jpsoft.Hospital.ReportClass.ExcelReports.ReportFollowUpRecord(); // hylReport.NavigateUrl = Page.ResolveClientUrl(report.GetReportPath(strWhere)); // hylReport.Text = "随访记录统计"; //} public string GetVistType(int type) { string result = string.Empty; switch (type) { case 0: result = "科研随访"; break; case 1: result = "客服"; break; case 2: result = "医生"; break; case 3: result = "质管"; break; case 4: result = "探访"; break; case 5: result = "护理"; break; default: result = "未知"; break; } return result; } public string GetVistWay(int vistWay) { string result = string.Empty; switch (vistWay) { case 0: result = "短信"; break; case 1: result = "电话"; break; default: result = "未知方式"; break; } return result; } public string GetIsSuccess(int isSuccess) { string result = string.Empty; switch (isSuccess) { case 0: result = "有效呼叫"; break; case 1: result = "关机未接"; break; case 2: result = "停机空号"; break; case 3: result = "号码不符"; break; default: result = "未知方式"; break; } return result; } public string GetCustomerType(int customerType) { string result = string.Empty; switch (customerType) { case 0: result = "科研随访"; break; case 1: result = "住院病人"; break; case 2: result = "门诊病人"; break; case 3: result = "潜在客户"; break; default: result = "未知"; break; } return result; } /// /// 门诊随访统计 /// private void SFSumMZ() { base.AutoCheckRight = false; base.CheckRightParam = Com.Jpsoft.Hospital.Web.Common.PageFuntionType.Export; base.CheckRight(); string where = " 1=1 "; if (!string.IsNullOrEmpty((string)ViewState["SearchTerms"])) { where = ViewState["SearchTerms"].ToString(); } else { where += " and customertype=1 "; } //if (txtDate1.Text != "") //{ // where = where + " and date>='" + txtDate1.Text + "' "; //} //if (txtDate2.Text != "") //{ // where = where + " and date<='" + txtDate2.Text + "' "; //} where = where + " and visitway=1 and customertype=1 "; where = where.Replace("where", ""); //where += " order by date desc "; Com.Jpsoft.Hospital.BLL.Ex.jp_followup_recordEx bll = new Com.Jpsoft.Hospital.BLL.Ex.jp_followup_recordEx(); double zhjs1 = bll.GetListZY(where).Tables[0].Rows.Count; double yxhj1 = bll.GetListZY(where + " and issuccess=0 order by date desc ").Tables[0].Rows.Count; double gjwj1 = bll.GetListZY(where + " and issuccess=1 order by date desc ").Tables[0].Rows.Count; double tjkh1 = bll.GetListZY(where + " and issuccess=2 order by date desc ").Tables[0].Rows.Count; double hmbf1 = bll.GetListZY(where + " and issuccess=3 order by date desc ").Tables[0].Rows.Count; double xl = 0;//(yxhj / zhjs)*100; if (zhjs1 != 0) { xl = (yxhj1 / zhjs1) * 100; } string yxl1 = xl.ToString("F2") + "%"; string str0 = "随访结果说明:0表示有效呼叫,1表示关机未接,2表示停机空号,3表示号码不符。"; string str1 = "一、电话随访总呼" + zhjs1 + "位,其中有效呼" + yxhj1 + "位,关机未接" + gjwj1 + "位,停机空号" + tjkh1 + "位 号码不符" + hmbf1 + "位 ,呼叫有效率为" + yxl1 + "."; string str2 = "二、涉及科室有:"; DataTable dt = bll.GetListR(where).Tables[0]; DataTable dt1 = bll.GetListRR(where + " and customeridea!='' ").Tables[0]; for (int i = 0; i < dt1.Rows.Count; i++) { if (i < dt1.Rows.Count - 1) { str2 = str2 + dt1.Rows[i]["ksmc"].ToString() + ","; } else { str2 = str2 + dt1.Rows[i]["ksmc"].ToString() + "。"; } } str2 = str2.Replace(" ", ""); if (dt.Rows.Count > 0) { string FileName = "随访统计"; FileStream fs = File.OpenRead(Request.PhysicalApplicationPath + "stencil/sftj.xls"); HSSFWorkbook workbook = new HSSFWorkbook(fs); HSSFSheet sheet = workbook.GetSheetAt(0); HSSFCellStyle style1 = workbook.CreateCellStyle(); style1.BorderBottom = CellBorderType.THIN; style1.BorderLeft = CellBorderType.THIN; style1.BorderRight = CellBorderType.THIN; style1.BorderTop = CellBorderType.THIN; style1.VerticalAlignment = CellVerticalAlignment.CENTER; for (int i = 0; i < dt.Rows.Count; i++) { int j = i + 2; HSSFRow row = sheet.CreateRow(j); row.Height = 439; HSSFCell cell0 = row.CreateCell(0); cell0.SetCellValue(dt.Rows[i][0].ToString()); cell0.CellStyle = style1; HSSFCell cell1 = row.CreateCell(1); cell1.SetCellValue(dt.Rows[i][1].ToString()); cell1.CellStyle = style1; HSSFCell cell2 = row.CreateCell(2); cell2.SetCellValue(dt.Rows[i][2].ToString()); cell2.CellStyle = style1; HSSFCell cell3 = row.CreateCell(3); cell3.SetCellValue(dt.Rows[i][3].ToString()); cell3.CellStyle = style1; HSSFCell cell4 = row.CreateCell(4); cell4.SetCellValue(dt.Rows[i][4].ToString()); cell4.CellStyle = style1; HSSFCell cell5 = row.CreateCell(5); cell5.SetCellValue(dt.Rows[i][5].ToString()); cell5.CellStyle = style1; HSSFCell cell6 = row.CreateCell(6); cell6.SetCellValue(dt.Rows[i][6].ToString()); cell6.CellStyle = style1; HSSFCell cell7 = row.CreateCell(7); cell7.SetCellValue(dt.Rows[i][7].ToString()); cell7.CellStyle = style1; HSSFCell cell8 = row.CreateCell(8); cell8.SetCellValue(dt.Rows[i][8].ToString()); cell8.CellStyle = style1; HSSFCell cell9 = row.CreateCell(9); cell9.SetCellValue(dt.Rows[i][9].ToString()); cell9.CellStyle = style1; HSSFCell cell10 = row.CreateCell(10); cell10.SetCellValue(""); cell10.CellStyle = style1; } HSSFRow rowEx1 = sheet.CreateRow(dt.Rows.Count + 2); rowEx1.Height = 439; HSSFCell cellEx1 = rowEx1.CreateCell(0); cellEx1.SetCellValue(str0); sheet.AddMergedRegion(new CellRangeAddress(dt.Rows.Count + 2, dt.Rows.Count + 2, 0, 10)); HSSFRow rowEx2 = sheet.CreateRow(dt.Rows.Count + 3); rowEx2.Height = 439; HSSFCell cellEx2 = rowEx2.CreateCell(0); cellEx2.SetCellValue(str1); sheet.AddMergedRegion(new CellRangeAddress(dt.Rows.Count + 3, dt.Rows.Count + 3, 0, 10)); HSSFRow rowEx3 = sheet.CreateRow(dt.Rows.Count + 4); rowEx3.Height = 439; HSSFCell cellEx3 = rowEx3.CreateCell(0); cellEx3.SetCellValue(str2); sheet.AddMergedRegion(new CellRangeAddress(dt.Rows.Count + 4, dt.Rows.Count + 4, 0, 10)); Stream stream = Response.OutputStream; workbook.Write(stream); string filename = string.Format("{0}.xls", HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8)); Response.ContentType = "application/vnd.ms-excel;charset=GBK"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", filename)); Response.Write(stream); Response.Flush(); } else { Response.Write(""); } } #endregion } }