protected string Province(int a, string name) { Tz888.BLL.Visit.VisitInfoBLL visit = new Tz888.BLL.Visit.VisitInfoBLL(); string com = ""; int num = visit.SelValidNew(a, name); if (a == 1) { switch (num) { case 0: com = "无效"; break; case 1: com = "有效"; break; } } else if (a == 2) { switch (num) { case 0: com = "未回访"; break; case 1: com = "已回访"; break; } } return(com); }
/// <summary> /// 翻译类型 /// </summary> private void ManageType() { Tz888.BLL.Visit.VisitInfoBLL visit = new Tz888.BLL.Visit.VisitInfoBLL(); this.ddlTypeID.DataSource = visit.SelManageTypeName(); this.ddlTypeID.DataTextField = "ManageTypeName"; this.ddlTypeID.DataValueField = "ManageTypeID"; this.ddlTypeID.DataBind(); ddlTypeID.Items.Insert(0, new ListItem("请选择 ", "")); }
protected void btnDC_Click(object sender, EventArgs e) { //单位名称 联系人 手机 电话 邮箱 会员类型 //contacname membername mobile tel Email managetypeid RetureWhere(); Tz888.BLL.Visit.VisitInfoBLL visit = new Tz888.BLL.Visit.VisitInfoBLL(); DataTable dt = visit.SelDataTable(ViewState["Criteria"].ToString()); Tz888.BLL.Login.LoginInfoBLL obj1 = new Tz888.BLL.Login.LoginInfoBLL(); HSSFWorkbook hssfworkbook = new HSSFWorkbook(); DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation(); dsi.Company = "深圳拓富投资有限公司"; SummaryInformation si = PropertySetFactory.CreateSummaryInformation(); si.Subject = "会员管理"; si.Author = "颜品庄"; si.CreateDateTime = DateTime.Now; hssfworkbook.DocumentSummaryInformation = dsi; hssfworkbook.SummaryInformation = si; HSSFSheet sheet1 = hssfworkbook.CreateSheet("Sheet1"); //sheet1.DefaultColumnWidth=10;设置列宽 HSSFRow row = sheet1.CreateRow(0); row.CreateCell(0).SetCellValue("单位名称"); row.CreateCell(1).SetCellValue("联系人"); row.CreateCell(2).SetCellValue("手机"); row.CreateCell(3).SetCellValue("电话"); row.CreateCell(4).SetCellValue("邮件"); row.CreateCell(5).SetCellValue("会员类型"); for (int i = 0; i < dt.Rows.Count; i++) { HSSFRow row0 = sheet1.CreateRow(i + 1); DataTable dt1 = obj1.GetLoginInfoList("*", " LoginID=" + dt.Rows[i]["LoginID"].ToString() + " ", "LoginName"); row0.CreateCell(0).SetCellValue(dt1.Rows[0]["contactname"].ToString()); row0.CreateCell(1).SetCellValue(dt.Rows[i]["membername"].ToString()); row0.CreateCell(2).SetCellValue(dt.Rows[i]["mobile"].ToString()); row0.CreateCell(3).SetCellValue(dt.Rows[i]["tel"].ToString()); row0.CreateCell(4).SetCellValue(dt.Rows[i]["Email"].ToString()); row0.CreateCell(5).SetCellValue(visit.SelManageType(dt.Rows[i]["managetypeid"].ToString())); } string t1 = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString(); string filename = "attachment;filename=" + System.Web.HttpUtility.UrlEncode("会员表" + t1, System.Text.Encoding.UTF8) + ".xls"; Response.ContentType = "application/vnd.ms-excel"; Response.AppendHeader("Content-Disposition", filename); Response.Clear(); MemoryStream filestream = new MemoryStream(); hssfworkbook.Write(filestream); Response.BinaryWrite(filestream.GetBuffer()); Response.End(); #region //RetureWhere(); //DataTable d = new DataTable(); //DataTable dt = new DataTable(); //dt.Columns.Add("编号", typeof(String)); //dt.Columns.Add("用户名", typeof(String)); //dt.Columns.Add("邮箱", typeof(String)); //dt.Columns.Add("座机", typeof(String)); //dt.Columns.Add("手机", typeof(String)); //dt.Columns.Add("会员类型", typeof(String)); //string sql = "select * from MemberLoginInfoView" + (string.IsNullOrEmpty(ViewState["Criteria"].ToString()) ? "" : " where " + ViewState["Criteria"].ToString()); //this.Page.RegisterStartupScript("K", "<script>alert('" + sql + "')</script>"); //string connStr = ConfigurationManager.ConnectionStrings["SQLConnString1"].ToString(); //using (SqlConnection con = new SqlConnection(connStr)) //{ // SqlCommand com = new SqlCommand(); // com.CommandText = sql; // com.Connection = con; // con.Open(); // SqlDataAdapter dp = new SqlDataAdapter(); // dp.SelectCommand = com; // dp.Fill(d); //}; //foreach (DataRow r in d.Rows) //{ // DataRow dr = dt.NewRow(); // dr["编号"] = r["MemberID"].ToString(); // dr["用户名"] = r["LoginName"].ToString(); // dr["邮箱"] = r["Email"].ToString(); // dr["座机"] = r["Tel"].ToString(); // dr["手机"] = r["Mobile"].ToString(); // dr["会员类型"] = GetType(r["ManageTypeID"].ToString()); // dt.Rows.Add(dr); //} //HSSFWorkbook hssfworkbook = new HSSFWorkbook(); //DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation(); //dsi.Company = "深圳拓富投资有限公司"; //SummaryInformation si = PropertySetFactory.CreateSummaryInformation(); //si.Subject = "会员管理"; //si.Author = "颜品庄"; //si.CreateDateTime = DateTime.Now; //hssfworkbook.DocumentSummaryInformation = dsi; //hssfworkbook.SummaryInformation = si; //HSSFSheet sheet1 = hssfworkbook.CreateSheet("Sheet1"); //HSSFRow row = sheet1.CreateRow(0); //row.CreateCell(0).SetCellValue("编号"); //row.CreateCell(1).SetCellValue("用户名"); //row.CreateCell(2).SetCellValue("邮箱"); //row.CreateCell(3).SetCellValue("座机"); //row.CreateCell(4).SetCellValue("手机"); //row.CreateCell(5).SetCellValue("会员类型"); ////单位名称 联系人 手机 电话 邮箱 会员类型 ////contacname membername mobile tel Email managetypeid //for (int i = 0; i < dt.Rows.Count; i++) //{ // HSSFRow row0 = sheet1.CreateRow(i + 1); // row0.CreateCell(0).SetCellValue(dt.Rows[i]["编号"].ToString()); // row0.CreateCell(1).SetCellValue(dt.Rows[i]["用户名"].ToString()); // row0.CreateCell(2).SetCellValue(dt.Rows[i]["邮箱"].ToString()); // row0.CreateCell(3).SetCellValue(dt.Rows[i]["座机"].ToString()); // row0.CreateCell(4).SetCellValue(dt.Rows[i]["手机"].ToString()); // row0.CreateCell(5).SetCellValue(dt.Rows[i]["会员类型"].ToString()); //} //string t1 = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString(); //string filename = "attachment;filename=" + System.Web.HttpUtility.UrlEncode("会员表" + t1, System.Text.Encoding.UTF8) + ".xls"; //Response.ContentType = "application/vnd.ms-excel"; //Response.AppendHeader("Content-Disposition", filename); //Response.Clear(); //MemoryStream filestream = new MemoryStream(); //hssfworkbook.Write(filestream); //Response.BinaryWrite(filestream.GetBuffer()); //Response.End(); #endregion }