Esempio n. 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ZentCloud.BLLJIMP.Model.MemberGroupInfo model = new BLLJIMP.Model.MemberGroupInfo()
            {
                GroupID   = bll.GetGUID(BLLJIMP.TransacType.MemberGroupAdd),
                UserID    = Comm.DataLoadTool.GetCurrUserID(),
                GroupName = this.txtGroupName.Text.Trim(),
                AddDate   = DateTime.Now,
                GroupType = this.groupType
            };

            //判断是否为空
            if (this.bll.Exists(model, new List <string>()
            {
                "UserID", "GroupName", "GroupType"
            }))
            {
                this.lbMsg.Text = "该组已存在!";
                return;
            }

            bll.Add(model);
            this.LoadData();
            this.HideAddPanel();
            this.Response.Redirect(this.Request.RawUrl);
        }
Esempio n. 2
0
        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;
            }
        }