private void BindShow(int Id) { this.labTitle.Text = "邮件组审核"; Tz888.Model.Mail.Mialgroup model = bll.GetModel(Id); txtName.Text = model.groupname.Trim(); txtdesctption.Text = model.groupremark.Trim(); showshenhes.Attributes.Add("style", "display:block"); this.radiocaozuo.Items.FindByValue(model.Audit.ToString().Trim()).Selected = true; }
protected void btnSave_Click(object sender, EventArgs e) { if (Id == 0) { Tz888.Model.Mail.Mialgroup model = new Tz888.Model.Mail.Mialgroup(); if (txtName.Text.Trim() == "") { Response.Write("<script>alert('请输入组名称!')</script>"); return; } model.groupname = txtName.Text.Trim(); model.groupremark = txtdesctption.Text.Trim(); model.Audit = 1; int result = bll.Add(model); if (result > 0) { Response.Redirect("MialGroupManage.aspx"); } else { Response.Write("<script>alert('已经存在该组!')</script>"); } } else { Tz888.Model.Mail.Mialgroup model = new Tz888.Model.Mail.Mialgroup(); if (txtName.Text.Trim() == "") { Response.Write("<script>alert('请输入组名称!')</script>"); return; } model.groupname = txtName.Text.Trim(); model.groupremark = txtdesctption.Text.Trim(); model.Audit = Convert.ToInt32(this.radiocaozuo.SelectedValue); model.groupID = Id; int result = bll.Update(model); if (result > 0) { Response.Redirect("MialGroupManage.aspx"); } else { Response.Write("<script>alert('已经存在该组名称,请重命名组名称!')</script>"); } } }
protected void btnDaoChu_Click(object sender, EventArgs e) { List <Tz888.Model.Mail.MailInfo> list = mailinfobll.GetModelList(par); dt.Rows.Clear(); foreach (Tz888.Model.Mail.MailInfo model in list) { DataRow dr = dt.NewRow(); //单位名称 联系人 手机 电话 邮箱 类型 职位 // dr["编号"] = model .UserID; //dr["账号"] = model.LoginName; dr["名称"] = model.UserName; dr["公司名称"] = model.PanyName; Tz888.Model.Mail.Position modelpo = positionbll.GetModel(Convert.ToInt32(model.PositionId)); if (modelpo != null) { dr["职位"] = modelpo.Name; //dr["地址"] = model.Address; //dr["网址"] = model.LinkUrl; Tz888.Model.Mail.MailType modeltype = mailtypebll.GetModel(Convert.ToInt32(model.typeID)); string type = modeltype.TypeName.Trim(); dr["类型"] = type; string diyu = ""; Tz888.Model.Mail.Province modelp = provincebll.GetModel(Convert.ToInt32(model.ProvinceId)); Tz888.Model.Mail.City modelc = citybll.GetModel(Convert.ToInt32(model.CityId)); if (modelc != null) { diyu = modelp.Name + ": " + modelc.Name; } else { diyu = modelp.Name; } // dr["地域"] = diyu; if (Convert.ToInt32(model.industry) != -1) { Tz888.Model.Mail.Industry modelIndustry = industrybll.GetModel(Convert.ToInt32(model.industry)); string xingye = modelIndustry.Name.Trim(); // dr["行业"] = xingye; } else //dr["行业"] = "所有行业"; { } // string statue = ""; // if (model.audit == 0) //{ // statue = "未审核"; //} //else { statue = "已审核"; } //dr["状态"] = statue; dr["邮件"] = model.Mial; dr["手机"] = model.Mobile; Tz888.Model.Mail.Mialgroup modelpr = mialgroupbll.GetModel(Convert.ToInt32(model.groupID)); // dr["组"] = modelpr.groupname; // dr["备注"] = model.remark; //dr["时间"] = model.Mdatetime; //dr["操作"] = ""; 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"); //sheet1.DefaultColumnWidth=10;设置列宽 HSSFRow row = sheet1.CreateRow(0); // row.CreateCell(0).SetCellValue("编号"); // row.CreateCell(1).SetCellValue("账号"); row.CreateCell(0).SetCellValue("名称"); row.CreateCell(1).SetCellValue("公司名称"); row.CreateCell(2).SetCellValue("职位"); // row.CreateCell(5).SetCellValue("地址"); // row.CreateCell(6).SetCellValue("网址"); row.CreateCell(3).SetCellValue("类型"); // row.CreateCell(8).SetCellValue("地域"); // row.CreateCell(9).SetCellValue("行业"); // row.CreateCell(10).SetCellValue("状态"); row.CreateCell(4).SetCellValue("邮件"); row.CreateCell(5).SetCellValue("手机"); // row.CreateCell(13).SetCellValue("组"); // row.CreateCell(14).SetCellValue("备注"); //row.CreateCell(6).SetCellValue("时间"); // row.CreateCell(16).SetCellValue("操作"); 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(0).SetCellValue(dt.Rows[i]["名称"].ToString()); row0.CreateCell(1).SetCellValue(dt.Rows[i]["公司名称"].ToString()); row0.CreateCell(2).SetCellValue(dt.Rows[i]["职位"].ToString()); //row0.CreateCell(5).SetCellValue(dt.Rows[i]["地址"].ToString()); //row0.CreateCell(6).SetCellValue(dt.Rows[i]["网址"].ToString()); row0.CreateCell(3).SetCellValue(dt.Rows[i]["类型"].ToString()); //row0.CreateCell(8).SetCellValue(dt.Rows[i]["地域"].ToString()); //row0.CreateCell(9).SetCellValue(dt.Rows[i]["行业"].ToString()); //row0.CreateCell(10).SetCellValue(dt.Rows[i]["状态"].ToString()); row0.CreateCell(4).SetCellValue(dt.Rows[i]["邮件"].ToString()); row0.CreateCell(5).SetCellValue(dt.Rows[i]["手机"].ToString()); //row0.CreateCell(13).SetCellValue(dt.Rows[i]["组"].ToString()); //row0.CreateCell(14).SetCellValue(dt.Rows[i]["备注"].ToString()); //row0.CreateCell(15).SetCellValue(dt.Rows[i]["时间"].ToString()); // row0.CreateCell(6).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.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", filename)); Response.AppendHeader("Content-Disposition", filename); Response.Clear(); //Write the stream data of workbook to the root directory MemoryStream filestream = new MemoryStream(); hssfworkbook.Write(filestream); Response.BinaryWrite(filestream.GetBuffer()); Response.End(); }