protected void Button1_Click(object sender, EventArgs e) { Stream srdPreview = FileUpload1.FileContent; string filecontent = StreamtoString(srdPreview); string[] linetxt = filecontent.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 1; i < linetxt.Length; i++) { string userinfo = linetxt[i]; string[] userarr = linetxt[i].Split(new string[] { "\t" }, StringSplitOptions.None); for (int ii = 0; ii < userarr.Length; ii++) { if (buser.GetUserIDByUserName(userarr[0].ToString()).UserID == 0) { M_UserInfo userinfos = new M_UserInfo(); userinfos.GroupID = gll.DefaultGroupID(); userinfos.UserName = userarr[0].ToString(); userinfos.Email = userarr[1].ToString(); //userinfos.UserExp = DataConverter.CLng(userarr[2].ToString()); if (userpwd.Text == "") { userinfos.UserPwd = StringHelper.MD5("admin888"); } else { userinfos.UserPwd = StringHelper.MD5(userpwd.Text); } userinfos.TrueName = userarr[3].ToString(); int userid = buser.AddModel(userinfos); M_Uinfo uinfos = new M_Uinfo(); uinfos.UserId = DataConverter.CLng(userid); uinfos.BirthDay = userarr[4].ToString(); uinfos.Address = userarr[5].ToString(); uinfos.OfficePhone = userarr[6].ToString(); uinfos.HomePhone = userarr[7].ToString(); uinfos.Fax = userarr[8].ToString(); uinfos.ZipCode = userarr[9].ToString(); uinfos.Mobile = userarr[10].ToString(); uinfos.UserSex = DataConverter.CBool(userarr[11].ToString()); uinfos.QQ = userarr[12].ToString(); uinfos.MSN = userarr[13].ToString(); uinfos.IDCard = userarr[14].ToString(); uinfos.HomePage = userarr[15].ToString(); uinfos.Province = userarr[16].ToString(); uinfos.County = userarr[17].ToString(); uinfos.WorkProvince = userarr[18].ToString(); uinfos.WorkCounty = userarr[19].ToString(); buser.AddBase(uinfos); } } } Label1.Text = "<font color=green>导入成功!</font>"; }
public void AddUser(string password) { M_UserInfo uinfo = buser.GetUserByName(UserName_T.Text.Trim()); if (uinfo == null || uinfo.UserID <= 0) { uinfo = new M_UserInfo(); } uinfo.UserName = UserName_T.Text.Trim(); uinfo.UserPwd = password; uinfo.Email = UserEmail_T.Text; if (buser.IsExistMail(uinfo.Email)) { uinfo.Email = function.GetRandomString(6) + "@random.com"; } uinfo.GroupID = groupBll.DefaultGroupID(); uinfo.LastLoginIP = IPScaner.GetUserIP(); M_Uinfo binfo = new M_Uinfo(); binfo.Province = Request.Form["tbProvince"]; binfo.City = Request.Form["tbCity"]; binfo.County = Request.Form["tbCounty"]; binfo.Mobile = UserPhone_T.Text; binfo.Position = Compay_T.Text; binfo.QQ = QQ_T.Text; if (uinfo == null || uinfo.UserID <= 0)//如果未注册会员则添加会员信息 { int uid = buser.AddModel(uinfo); binfo.UserId = uid; buser.AddBase(binfo); } else { buser.UpDateUser(uinfo); binfo.UserId = uinfo.UserID; buser.UpdateBase(binfo); } }
// 提交管理员信息 protected void btnSubmit_Click(object sender, EventArgs e) { if (AdminID > 0) { admin = B_Admin.GetAdminByAdminId(AdminID); string oldadminpassword = admin.AdminPassword; if (!string.IsNullOrEmpty(txtAdminTrueName.Text.Trim())) { admin.AdminTrueName = txtAdminTrueName.Text.Trim(); } if (!string.IsNullOrEmpty(hfNode.Value.Trim())) { admin.StructureID = hfNode.Value.Trim(); } } else { string pwd = tbPwd.Text.Trim().Replace(" ", ""); if (!Manager_Validator()) { function.WriteErrMsg("管理员名称重复!"); } if (pwd.Length < 3) { function.WriteErrMsg("密码长度不能少于3位"); } admin.AdminPassword = StringHelper.MD5(tbPwd.Text); admin.UserName = tbdName.Text; admin.StructureID = hfNode.Value.Trim(); } //获取管理员角色 string role = ""; foreach (ListItem item in cblRoleList.Items) { if (item.Selected) { role += item.Value + ","; } } if (admin.IsSuperAdmin(admin.RoleList)) { role = "0," + role; } admin.RoleList = role; admin.AdminName = tbdName.Text; admin.AdminTrueName = txtAdminTrueName.Text.Trim(); admin.EnableMultiLogin = cb1.Checked; admin.EnableModifyPassword = cb2.Checked; admin.IsLock = cb3.Checked; admin.IsTable = cb4.Checked; admin.LastLoginIP = ""; admin.LastLoginTime = DateTime.Now; admin.LastLogoutTime = DateTime.Now; admin.LastModifyPasswordTime = DateTime.Now; admin.LoginTimes = 0; admin.RandNumber = SPwd_T.Text; admin.ManageNode = ""; admin.DefaultStart = DataConverter.CLng(DefaultStart_DP.SelectedValue); admin.PubRole = CheckBox1.Checked ? 1 : 0; admin.StructureID = curmodel_hid.Value; if (AdminID > 0) { if (!string.IsNullOrEmpty(tbPwd.Text.Trim())) { admin.AdminPassword = StringHelper.MD5(tbPwd.Text.Trim()); B_Admin.Update(admin); if (admin.AdminId == B_Admin.GetLogin().AdminId) { function.WriteSuccessMsg("密码修改成功,系统现在自动注销,请使用新密码登录管理!", CustomerPageAction.customPath2 + "/SignOut.aspx"); } function.WriteSuccessMsg("密码修改成功!", "AdminManage.aspx"); } else { B_Admin.Update(admin); function.WriteSuccessMsg("修改成功", "AdminManage.aspx"); } } else { //新增 B_Admin.Add(admin); M_AdminInfo adminInfo = B_Admin.GetAdminByAdminName(admin.AdminName); #region 添加会员 if (AddUser_Chk.Checked) { string username = tbdName.Text.Trim(); M_UserInfo userinfo = buser.GetUserByName(username); Response.Write(userinfo.UserID.ToString()); if (userinfo.UserID > 0) { userinfo.UserPwd = StringHelper.MD5(tbPwd.Text); userinfo.Email = tbEmail.Text; buser.UpDateUser(userinfo); } else { B_Group gpBll = new B_Group(); M_UserInfo uinfo = new M_UserInfo(); uinfo.UserName = tbdName.Text; uinfo.UserPwd = tbPwd.Text; uinfo.Question = Question_DP.SelectedItem.Text; uinfo.Answer = tbAnswer.Text.Trim(); uinfo.Email = tbEmail.Text.Trim(); uinfo.GroupID = gpBll.DefaultGroupID(); uinfo.LastLoginIP = HttpContext.Current.Request.UserHostAddress; uinfo.LastLockTime = DateTime.Now; uinfo.LastLoginTimes = DateTime.Now; uinfo.LastPwdChangeTime = DateTime.Now; uinfo.LoginTimes = 0; uinfo.RegTime = DateTime.Now; uinfo.ConsumeExp = 0; uinfo.IsConfirm = 0; uinfo.VIP = 0; uinfo.UserPwd = StringHelper.MD5(uinfo.UserPwd); uinfo.UserID = buser.AddModel(uinfo); M_Uinfo binfo = new M_Uinfo(); binfo.UserId = uinfo.UserID; buser.AddBase(binfo); adminInfo.AddUserID = uinfo.UserID; B_Admin.Update(adminInfo); } } #endregion Response.Redirect("AdminDetail.aspx?id=" + adminInfo.AdminId + "&roleid=" + adminInfo.NodeRole); } }
public IActionResult Register_Submit() { B_UserBaseField bmf = new B_UserBaseField(); string siteurls = SiteConfig.SiteInfo.SiteUrl.TrimEnd('/'); if (!SiteConfig.UserConfig.EnableUserReg) { return(WriteErr("服务器已关闭用户注册")); } //----------------------------------- M_UserInfo info = new M_UserInfo(); info.UserBase = new M_Uinfo(); info.UserName = GetParam("TxtUserName").Replace(" ", ""); info.UserPwd = RequestEx["TxtPassword"]; info.Question = RequestEx["Question_DP"]; info.Answer = RequestEx["TxtAnswer"]; info.Email = DataConvert.CStr(RequestEx["TxtEmail"]).Replace(" ", ""); info.CheckNum = function.GetRandomString(10); info.GroupID = DataConverter.CLng(RequestEx["UserGroup"]); if (!SiteConfig.UserConfig.Reg_SelGroup)//不允许用户手动选择会员组 { info.GroupID = gpBll.DefaultGroupID(); } info.RegisterIP = IPScaner.GetUserIP(HttpContext); info.LastLoginIP = info.RegisterIP; //info.Purse = SiteConfig.UserConfig.PresentMoney;//注册赠送的余额,积分等 //info.UserPoint = SiteConfig.UserConfig.PresentPoint; //info.UserExp = DataConverter.CLng(SiteConfig.UserConfig.PresentExp); info.TrueName = RequestEx["TxtTrueName"]; info.UserPwd = StringHelper.MD5(info.UserPwd);; //----------------------------------------------------- //会员基本信息 info.UserBase.Address = RequestEx["TxtAddress"]; info.UserBase.BirthDay = RequestEx["TxtBirthday"]; info.UserFace = RequestEx["TxtUserFace"]; info.UserBase.Fax = RequestEx["TxtFax"]; info.UserBase.HomePage = RequestEx["TxtHomepage"]; info.UserBase.HomePhone = RequestEx["TxtHomePhone"]; info.UserBase.IDCard = RequestEx["TxtIDCard"]; info.UserBase.Mobile = RequestEx["TxtMobile"]; info.UserBase.OfficePhone = RequestEx["TxtOfficePhone"]; info.UserBase.Privating = DataConvert.CLng(RequestEx["DropPrivacy"]); info.UserBase.PHS = RequestEx["TxtPHS"]; info.UserBase.QQ = RequestEx["TxtQQ"]; info.UserBase.Sign = RequestEx["TxtSign"]; info.UserBase.UserSex = DataConverter.CBool(RequestEx["DropSex"]); info.UserBase.ZipCode = RequestEx["TxtZipCode"]; info.UserBase.HoneyName = ""; info.UserBase.CardType = ""; info.UserBase.Province = GetParam("selprovince"); info.UserBase.City = GetParam("selcity"); info.UserBase.County = GetParam("selcoutry"); if (!string.IsNullOrEmpty(RegisterMobile)) { info.UserBase.Mobile = RegisterMobile; RegisterMobile = null; } //----------------------------------------------------- #region 信息检测 string err = ""; if (SiteConfig.UserConfig.EnableCheckCodeOfReg) { if (!VerifyHelper.Check(RequestEx["VCode_hid"])) { return(WriteErr("您输入的验证码和系统产生的不一致,请重新输入", "javascript:history.go(-1);")); } } if (!CheckUserName(info.UserName, ref err)) { return(WriteErr(err)); } else if (!CheckUserInfo(info.UserBase)) { return(WriteErr(err)); } else if (SiteConfig.UserConfig.Reg_AnswerMust && string.IsNullOrEmpty(info.Answer)) { return(WriteErr("问题答案不能为空")); } else if (!CheckEmail(info.Email, ref err)) { return(WriteErr("问题答案不能为空")); } #endregion //推荐人处理 { //支持使用用户名和用户ID info.ParentUserID = CheckParentUser(RequestEx["TxtParentUser"]).UserID.ToString(); if (DataConvert.CLng(info.ParentUserID) < 1 && !string.IsNullOrEmpty(RequestEx["ParentUser_Hid"])) { info.ParentUserID = CheckParentUser(RequestEx["ParentUser_Hid"]).UserID.ToString(); } } //用于初始状态 if (SiteConfig.UserConfig.EmailCheckReg) { info.Status = 4; } //邮件认证 else if (SiteConfig.UserConfig.AdminCheckReg) { info.Status = 2; } //管理员认证 else if (SiteConfig.UserConfig.EmailCheckReg && SiteConfig.UserConfig.AdminCheckReg) { info.Status = 3; } //邮件认证及管理员认证 else if (!SiteConfig.UserConfig.UserValidateType) { info.Status = 5; } else { info.Status = 0; } //自定义字段信息 DataTable table; try { table = Call.GetDTFromMVC(bmf.Select_All(), Request); } catch (Exception e) { return(WriteErr(e.Message)); } string[] strArray2 = string.IsNullOrEmpty(SiteConfig.UserConfig.RegFieldsMustFill) ? new string[0] : SiteConfig.UserConfig.RegFieldsMustFill.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); foreach (string str2 in strArray2) { if (string.IsNullOrEmpty(GetParam("txt_" + str2))) { DataTable tbles = bmf.SelByFieldName(str2); } } //------------添加新用户 info.UserID = buser.Add(info); info.UserBase.UserId = info.UserID; if (info.UserID < 1) { return(WriteErr("注册失败")); } buser.AddBase(info.UserBase); if (table != null && table.Rows.Count > 0) { buser.UpdateUserFile(info.UserID, table); } buser.SetLoginState(info); //赠送虚拟币 //if (SiteConfig.UserConfig.PresentMoney > 0) //{ // buser.AddMoney(info.UserID, SiteConfig.UserConfig.PresentMoney, M_UserExpHis.SType.Purse, "注册赠送"); //} //if (SiteConfig.UserConfig.PresentExp > 0) //{ // buser.AddMoney(info.UserID, SiteConfig.UserConfig.PresentExp, M_UserExpHis.SType.Point, "注册赠送"); //} //---------------------------------------------------------------------------- string ReturnUrl = RequestEx["ReturnUrl_Hid"]; string RegMessage = ""; string RegRUrl = ""; bool isok = false; //关联绑定微信用户 //if (!string.IsNullOrEmpty(WXOpenID)) //{ // B_User_Token tokenBll = new B_User_Token(); // M_User_Token tokenMod = tokenBll.SelModelByUid(info.UserID); // if (tokenMod == null) { tokenMod = new M_User_Token(); } // tokenMod.uid = info.UserID; // tokenMod.WXOpenID = WXOpenID; // tokenBll.Insert(tokenMod); //} #region 自定义模型 int ModelID = DataConverter.CLng(gpBll.GetGroupModel(info.GroupID)); string usertablename = modBll.SelReturnModel(ModelID).TableName; if (ModelID > 0 && usertablename != "" && usertablename != null) { DataTable groupset = fieldBll.GetModelFieldListall(ModelID); DataTable tablereg = new DataTable(); tablereg.Columns.Add(new DataColumn("FieldName", typeof(string))); tablereg.Columns.Add(new DataColumn("FieldType", typeof(string))); tablereg.Columns.Add(new DataColumn("FieldValue", typeof(string))); if (groupset != null && groupset.Rows.Count > 0) { foreach (DataRow dr in groupset.Rows) { if (dr["FieldType"].ToString() == "FileType") { string[] Sett = dr["Content"].ToString().Split(new char[] { ',' }); bool chksize = DataConverter.CBool(Sett[0].Split(new char[] { '=' })[1]); string sizefield = Sett[1].Split(new char[] { '=' })[1]; if (chksize && sizefield != "") { DataRow row2 = tablereg.NewRow(); row2[0] = sizefield; row2[1] = "FileSize"; row2[2] = RequestEx["txt_" + sizefield]; tablereg.Rows.Add(row2); } } if (dr["FieldType"].ToString() == "MultiPicType") { string[] Sett = dr["Content"].ToString().Split(new char[] { ',' }); bool chksize = DataConverter.CBool(Sett[0].Split(new char[] { '=' })[1]); string sizefield = Sett[1].Split(new char[] { '=' })[1]; if (chksize && sizefield != "") { if (string.IsNullOrEmpty(RequestEx["txt_" + sizefield])) { return(WriteErr(dr["FieldAlias"].ToString() + "的缩略图不能为空!")); } DataRow row1 = tablereg.NewRow(); row1[0] = sizefield; row1[1] = "ThumbField"; row1[2] = RequestEx["txt_" + sizefield]; tablereg.Rows.Add(row1); } } DataRow row = tablereg.NewRow(); row[0] = dr["FieldName"].ToString(); string ftype = dr["FieldType"].ToString(); row[1] = ftype; string fvalue = RequestEx["txt_" + dr["FieldName"].ToString()]; if (ftype == "TextType" || ftype == "MultipleTextType" || ftype == "MultipleHtmlType") { if (dr["IsNotNull"].Equals("True") && string.IsNullOrEmpty(fvalue)) { return(WriteErr(dr["FieldAlias"] + ":不能为空!")); } } row[2] = fvalue; tablereg.Rows.Add(row); } try { if (tablereg.Select("FieldName='UserID'").Length == 0) { DataRow rowsd1 = tablereg.NewRow(); rowsd1[0] = "UserID"; rowsd1[1] = "int"; rowsd1[2] = info.UserID; tablereg.Rows.Add(rowsd1); } else { tablereg.Rows[0]["UserID"] = info.UserID; } } catch (Exception) { } try { if (tablereg.Select("FieldName='UserName'").Length == 0) { DataRow rowsd2 = tablereg.NewRow(); rowsd2[0] = "UserName"; rowsd2[1] = "TextType"; rowsd2[2] = info.UserName; tablereg.Rows.Add(rowsd2); } else { tablereg.Rows[0]["UserName"] = info.UserName; } } catch (Exception) { } try { if (tablereg.Select("FieldName='Styleid'").Length == 0) { DataRow rowsd3 = tablereg.NewRow(); rowsd3[0] = "Styleid"; rowsd3[1] = "int"; rowsd3[2] = 0; tablereg.Rows.Add(rowsd3); } else { tablereg.Rows[0]["UserName"] = 0; } } catch (Exception) { } try { if (tablereg.Select("FieldName='Recycler'").Length == 0) { DataRow rowsd4 = tablereg.NewRow(); rowsd4[0] = "Recycler"; rowsd4[1] = "int"; rowsd4[2] = 0; tablereg.Rows.Add(rowsd4); } else { tablereg.Rows[0]["Recycler"] = 0; } } catch (Exception) { } try { if (tablereg.Select("FieldName='IsCreate'").Length == 0) { DataRow rowsd5 = tablereg.NewRow(); rowsd5[0] = "IsCreate"; rowsd5[1] = "int"; rowsd5[2] = 0; tablereg.Rows.Add(rowsd5); } else { tablereg.Rows[0]["IsCreate"] = 0; } } catch (Exception) { } try { if (tablereg.Select("FieldName='NewTime'").Length == 0) { DataRow rs6 = tablereg.NewRow(); rs6[0] = "NewTime"; rs6[1] = "DateType"; rs6[2] = DateTime.Now; tablereg.Rows.Add(rs6); } else { tablereg.Rows[0]["NewTime"] = DateTime.Now; } } catch (Exception) { } } if (tablereg != null && tablereg.Rows.Count > 0) { buser.InsertModel(tablereg, usertablename); } } #endregion if (SiteConfig.UserConfig.EmailCheckReg && !string.IsNullOrEmpty(info.Email))//发送认证邮件,当需要邮件认证时 { //[c]需要新的邮件收发模块 //MailInfo mailInfo = new MailInfo(); //mailInfo.IsBodyHtml = true; //mailInfo.FromName = SiteConfig.SiteInfo.SiteName; //MailAddress address = new MailAddress(info.Email); //mailInfo.ToAddress = address; //string regurl = siteurls + "/User/Index/RegEmailCheck?UserName="******"&CheckNum=" + info.CheckNum; //string mailcontent = mailBll.SelByType(B_MailManage.MailType.NewUserReg); //mailInfo.MailBody = new OrderCommon().TlpDeal(mailcontent, GetRegEmailDt(info.UserName, info.CheckNum, regurl)); //mailInfo.Subject = SiteConfig.SiteInfo.SiteName + "网站会员注册验证码"; //if (SendMail.Send(mailInfo) == SendMail.MailState.Ok) //{ // RegMessage = "注册验证码已成功发送到你的注册邮箱,请到邮箱查收并验证!"; // RegMessage = RegMessage + "<a href=\"/\">返回首页</a>"; //} //else //{ // RegMessage = "注册成功,但发送验证邮件失败,请检查邮件地址是否正确,或与网站管理员联系!"; // RegMessage = RegMessage + "<a href=\"/\">返回首页</a>"; //} } switch (info.Status) { case 0: #region 直接注册成功 //[c] //if (!string.IsNullOrEmpty(info.Email) && SiteConfig.UserConfig.EmailTell) //{ // MailInfo mailInfo = new MailInfo(); // mailInfo.IsBodyHtml = true; // mailInfo.FromName = SiteConfig.SiteInfo.SiteName; // MailAddress address = new MailAddress(info.Email); // mailInfo.ToAddress = address; // //SiteConfig.UserConfig.EmailOfRegCheck // string regurl = siteurls + "/User/Index/RegEmailCheck?UserName="******"&CheckNum=" + info.CheckNum; // mailInfo.MailBody = new OrderCommon().TlpDeal(mailBll.SelByType(B_MailManage.MailType.NewUserReg), GetRegEmailDt(info.UserName, info.CheckNum, regurl)); // //mailInfo.MailBody = mailInfo.MailBody.Replace("{$UserName}", info.UserName).Replace("{$UserPwd}", TxtPassword.Text); // mailInfo.Subject = SiteConfig.SiteInfo.SiteName + "_注册成功提醒"; // if (SendMail.Send(mailInfo) == SendMail.MailState.Ok) // { // RegMessage = "注册基本信息已成功发送到你的注册邮箱!"; // RegMessage = RegMessage + "<a href=\"/\">返回首页</a>"; // } // else // { // RegMessage = "注册成功,但发送注册基本信息邮件失败,请检查邮件地址是否正确,或与网站管理员联系!"; // RegMessage = RegMessage + "<a href=\"/\">返回首页</a>"; // } //} //else //{ RegMessage = "注册成功!"; if (string.IsNullOrEmpty(ReturnUrl)) { RegMessage = RegMessage + "<a href=\"/\">返回首页</a> <a href=\"/User/Index\">进入会员中心</a>,5秒后系统自动跳转到会员中心!"; RegRUrl = "/User/Index"; } else { RegMessage = RegMessage + "<a href=\"/\">返回首页</a> <a href=\"" + ReturnUrl + "\">进入默认页面</a>,5秒后系统自动跳转到默认页面!"; RegRUrl = ReturnUrl; } isok = true; //} #endregion break; case 2: //等待管理员认证 { RegMessage = "注册成功!新注册会员需管理员认证才能有效,请耐心等待!"; RegMessage = RegMessage + "若长期没有通过管理员认证,请及时和管理员联系!"; RegMessage = RegMessage + "<a href=\"/\">返回首页</a>"; } break; default: //未开启邮箱验证,则可以登录 //if (!SiteConfig.UserConfig.EmailCheckReg) { RegMessage = "注册成功!"; } if (string.IsNullOrEmpty(ReturnUrl)) { RegMessage = "注册成功<a href=\"/\">返回首页</a> <a href=\"/User/Index\">进入会员中心</a>,5秒后系统自动跳转到会员中心!"; RegRUrl = "default"; } else { RegMessage = "<a href=\"/\">返回首页</a> <a href=\"" + ReturnUrl + "\">进入默认页面</a>,5秒后系统自动跳转到默认页面!"; RegRUrl = ReturnUrl; } isok = true; break; } if (SiteConfig.UserConfig.EmailCheckReg) { RegMessage = "<div class='emptyDiv'><br/>注册成功! <a href='http://mail." + info.Email.Substring(info.Email.LastIndexOf('@') + 1) + "' target='_blank'>立即登录邮箱进行验证>></a><br/></div>"; isok = false; } ViewBag.RegMessage = RegMessage; ViewBag.RegRUrl = RegRUrl; ViewBag.isok = isok;//为true则自动跳转 ViewBag.pwd = RequestEx["TxtPassword"]; return(View("Register_Finish", info)); }