protected void Page_Load(object sender, EventArgs e) { bll = new BLLJIMP.BLLMember(Comm.DataLoadTool.GetCurrUserID()); if (!IsPostBack) { //this.ViewState["EditState"] = 0; this.lbtnDeleteGroup.Attributes.Add("onclick", "return confirm(\" 删除分组后,该分组下的会员数据归为无分组数据,确定删除? \")"); //this.lbtnDeleteGroup.Attributes.Add("onclick", "return confirm(\"提交前系统会对提交号码再进行一次处理,确认添加到发送队列?\")"); //获取当前用户的会员分组 this.LoadData(); if (this.selectValue.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (string item in this.selectValue) { sb.Append(item.ToString() + ","); } MySpider.ASPNET.CheckBoxListHelper.SetChecked(this.chkData, sb.ToString(), ","); } } }
protected void btnUpload_Click(object sender, EventArgs e) { if (this.Session[Comm.SessionKey.UserType].ToString() == "0") { this.ShowMessge("未审核用户不能进行该项操作!"); return; } //上传文件并读取内容 //string filePath = Server.MapPath("~/FileUpload/") + this.Session[Comm.SessionKey.UserID].ToString() + Guid.NewGuid(); //this.AjaxFileUpload1.SaveAs(filePath); string fileName = FileUpload1.FileName; string extraName = fileName.Substring(fileName.LastIndexOf(".") + 1); if (fileName == "" || fileName == null) { ZentCloud.Common.WebMessageBox.Show(this.Page, "未选择任何文件!"); //this.ShowMessge("未选择任何文件"); return; } if (extraName.ToLower() == "xls") { string tmpPath = Server.MapPath("~/FileUpload/MemberInfo/" + Guid.NewGuid().ToString()); //建立临时目录 if (!Directory.Exists(tmpPath)) { Directory.CreateDirectory(tmpPath); } fileName = tmpPath + "/" + fileName; this.FileUpload1.SaveAs(fileName); ZentCloud.BLLJIMP.BLLMember bllMember = new ZentCloud.BLLJIMP.BLLMember(Session[Comm.SessionKey.UserID].ToString()); List <ZentCloud.BLLJIMP.Model.MemberInfo> memberList = bllMember.GetMemberListFromExcel(fileName, bllMember.UserID); int importCount = 0; foreach (ZentCloud.BLLJIMP.Model.MemberInfo member in memberList) { member.UserID = bllMember.UserID; if (!bllMember.Exists(member, new List <string>() { "Mobile", "UserID" })) { if (!bllMember.Add(member)) { this.ShowMessge("导入数据失败,请检查EXCEL文件内容。"); return; } ++importCount; } } //if (!bllMember.AddList<ZentCloud.BLLJIMP.Model.MemberInfo>(memberList)) //{ // this.ShowMessge("导入数据失败,请检查EXCEL文件内容。"); //} grvData.DataSource = memberList; grvData.DataBind(); lbUploadResult.Text = string.Format("导入成功,共读取{0}条记录,导入{1}条记录,其他记录已经存在!", memberList.Count, importCount); lbUploadResult.Visible = true; //删除临时目录 Directory.Delete(tmpPath, true); } else { this.ShowMessge("只支持.xls文件"); return; } }