private void SaveUserInfo_Click(object sender, EventArgs e) { if (base.CheckCookie()) { int uid = DNTRequest.GetInt("uid", -1); string text = ""; //if (!this.AllowEditUserInfo(@int, true)) //{ // return; //} if (this.userName.Text != this.ViewState["username"].ToString() && Users.GetUserId(this.userName.Text) > 0) { base.RegisterStartupScript("", "<script>alert('您所输入的用户名已被使用过, 请输入其他的用户名!');</script>"); return; } if (this.userName.Text == "") { base.RegisterStartupScript("", "<script>alert('用户名不能为空!');</script>"); return; } if (this.groupid.SelectedValue == "0") { base.RegisterStartupScript("", "<script>alert('您未选中任何用户组!');</script>"); return; } this.userInfo = Users.GetUserInfo(uid); this.userInfo.Name = this.userName.Text; this.userInfo.NickName = this.nickname.Text; this.userInfo.AccessMasks = Utility.ToInt(this.accessmasks.SelectedValue, 0); if (this.userInfo.GroupID.ToString() != this.groupid.SelectedValue) { this.userInfo.AdminID = UserGroup.FindByID(int.Parse(this.groupid.SelectedValue)).RadminID; } if (this.bday.Text == "0000-00-00" || (this.bday.Text == "0000-0-0" | this.bday.Text.Trim() == "")) { this.userInfo.Bday = ""; } else { if (!Utils.IsDateString(this.bday.Text.Trim())) { base.RegisterStartupScript("", "<script>alert('用户生日不是有效的日期型数据!');</script>"); return; } this.userInfo.Bday = this.bday.Text; } if (!String.IsNullOrEmpty(email.Text) && !Users.ValidateEmail(this.email.Text, uid)) { base.RegisterStartupScript("", "<script>alert('当前用户的邮箱地址已被使用过, 请输入其他的邮箱!');</script>"); return; } this.userInfo.Email = this.email.Text; this.userInfo.Gender = Utility.ToInt(this.gender.SelectedValue, 0); this.userInfo.GroupExpiry = 0; this.userInfo.ExtGroupIds = this.extgroupids.GetSelectString(","); if (this.groupid.SelectedValue != "1" && this.userInfo.ID == BaseConfigs.GetFounderUid) { base.RegisterStartupScript("", "<script>alert('创始人的所属用户组不能被修改为其它组!');window.location.href='edituser.aspx?uid=" + Request["uid"] + "';</script>"); return; } this.userInfo.GroupID = Utility.ToInt(this.groupid.SelectedValue, 0); this.userInfo.Invisible = Utility.ToInt(this.invisible.SelectedValue, 0) != 0; this.userInfo.JoinDate = Utility.ToDateTime(this.joindate.Text); this.userInfo.LastActivity = Utility.ToDateTime(this.lastactivity.Text); this.userInfo.LastIP = this.lastip.Text; this.userInfo.LastPost = Utility.ToDateTime(this.lastpost.Text); this.userInfo.LastVisit = Utility.ToDateTime(this.lastvisit.Text); this.userInfo.Newpm = Utility.ToInt(this.newpm.SelectedValue, 0) != 0; //this.userInfo.NewsLetter = (ReceivePMSettingType)this.GetNewsLetter(); this.userInfo.NewsLetter = this.GetNewsLetter(); this.userInfo.OLTime = Utility.ToInt(this.oltime.Text, 0); this.userInfo.PageViews = Utility.ToInt(this.pageviews.Text, 0); this.userInfo.Pmsound = Utility.ToInt(this.pmsound.Text, 0); this.userInfo.Posts = Utility.ToInt(this.posts.Text, 0); this.userInfo.Ppp = Utility.ToInt(this.ppp.Text, 0); this.userInfo.RegIP = this.regip.Text; this.userInfo.DigestPosts = Utility.ToInt(this.digestposts.Text, 0); if (this.secques.SelectedValue == "1") { this.userInfo.Secques = ""; } this.userInfo.ShowEmail = Utility.ToInt(this.showemail.SelectedValue, 0) != 0; this.userInfo.Sigstatus = Utility.ToInt(this.sigstatus.SelectedValue, 0); this.userInfo.TemplateID = Utility.ToInt(this.templateid.SelectedValue, 0); this.userInfo.Tpp = Utility.ToInt(this.tpp.Text, 0); if (!Utils.IsNumeric(this.extcredits1.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits1 = float.Parse(this.extcredits1.Text); if (!Utils.IsNumeric(this.extcredits2.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits2 = float.Parse(this.extcredits2.Text); if (!Utils.IsNumeric(this.extcredits3.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits3 = float.Parse(this.extcredits3.Text); if (!Utils.IsNumeric(this.extcredits4.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits4 = float.Parse(this.extcredits4.Text); if (!Utils.IsNumeric(this.extcredits5.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits5 = float.Parse(this.extcredits5.Text); if (!Utils.IsNumeric(this.extcredits6.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits6 = float.Parse(this.extcredits6.Text); if (!Utils.IsNumeric(this.extcredits7.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits7 = float.Parse(this.extcredits7.Text); if (!Utils.IsNumeric(this.extcredits8.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits8 = float.Parse(this.extcredits8.Text); this.userInfo.Credits = CreditsFacade.GetUserCreditsByUserInfo(this.userInfo); //if (UserGroups.IsCreditUserGroup(this.userInfo.GroupID)) if (userInfo.Group.IsCreditUserGroup) { var g = CreditsFacade.GetCreditsUserGroupId((float)this.userInfo.Credits); this.userInfo.GroupID = g.ID; userInfo.Group = g; } IUserField uf = userInfo.Field; uf.Website = this.website.Text; uf.Icq = this.icq.Text; uf.qq = this.qq.Text; uf.Yahoo = this.yahoo.Text; uf.Msn = this.msn.Text; uf.Skype = this.skype.Text; uf.Location = this.location.Text; uf.Customstatus = this.customstatus.Text; uf.Bio = this.bio.Text; if (this.signature.Text.Length > userInfo.Group.MaxSigSize) { text = "更新的签名长度超过 " + userInfo.Group.MaxSigSize + " 字符的限制,未能更新。"; } else { uf.Signature = this.signature.Text; PostpramsInfo postpramsInfo = new PostpramsInfo(); postpramsInfo.Showimages = userInfo.Group.AllowSigimgCode ? 1 : 0; postpramsInfo.Sdetail = this.signature.Text; uf.Sightml = UBB.UBBToHTML(postpramsInfo); } uf.RealName = this.realname.Text; uf.Idcard = this.idcard.Text; uf.Mobile = this.mobile.Text; uf.Phone = this.phone.Text; uf.Medals = Request["medalid"]; if (this.IsEditUserName.Checked && this.userName.Text != this.ViewState["username"].ToString()) { throw new NotImplementedException("UserNameChange"); //AdminUsers.UserNameChange(this.userInfo, this.ViewState["username"].ToString()); //Sync.RenameUser(userInfo.ID, ViewState["username"].ToString(), this.userInfo.Name, ""); } if (userInfo.Save() > 0) { Online.DeleteUserByUid(this.userInfo.ID); if (this.delavart.Checked) { Avatars.DeleteAvatar(this.userInfo.ID.ToString()); } AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "后台编辑用户", "用户名:" + this.userName.Text); if (text == "") { base.RegisterStartupScript("PAGE", "window.location.href='usergrid.aspx?condition=" + Request["condition"] + "';"); return; } base.RegisterStartupScript("PAGE", "alert('" + text + "');window.location.href='usergrid.aspx?condition=" + Request["condition"] + "';"); return; } else { base.RegisterStartupScript("", "<script>alert('操作失败');window.location.href='usergrid.aspx?condition=" + Request["condition"] + "';</script>"); } } }
private User CreateUserInfo() { User user = new User(); user.Name = this.userName.Text; user.NickName = this.userName.Text; user.Password = this.password.Text; user.Secques = ""; user.Gender = 0; int num = Convert.ToInt32(this.groupid.SelectedValue); user.AdminID = UserGroup.FindByID(num).RadminID; user.GroupID = num; //user.JoinDate = DateTime.Now; //user.LastIP = ""; //user.LastVisit = DateTime.Now; //user.LastActivity = DateTime.Now; //user.LastPost = DateTime.Now; //user.LastPostID = 0; //user.LastPostTitle = ""; //user.Posts = 0; //user.DigestPosts = 0; //user.OLTime = 0; //user.PageViews = 0; user.Credits = Convert.ToInt32(this.credits.Text); //user.ExtCredits1 = 0f; //user.ExtCredits2 = 0f; //user.ExtCredits3 = 0f; //user.ExtCredits4 = 0f; //user.ExtCredits5 = 0f; //user.ExtCredits6 = 0f; //user.ExtCredits7 = 0f; //user.ExtCredits8 = 0f; user.Salt = "0"; user.Email = this.email.Text; user.Bday = ""; user.Sigstatus = 0; user.TemplateID = GeneralConfigInfo.Current.Templateid; user.Tpp = 16; user.Ppp = 16; user.Pmsound = 1; user.ShowEmail = true; //user.NewsLetter = (Int32)ReceivePMSettingType.ReceiveAllPMWithHint; user.NewsLetter = 7; user.Invisible = false; user.Newpm = false; user.AccessMasks = 0; IUserField uf = user.Field; //uf.Website = ""; //uf.Icq = ""; //uf.qq = ""; //uf.Yahoo = ""; //uf.Msn = ""; //uf.Skype = ""; //uf.Location = ""; //uf.Customstatus = ""; //uf.Medals = ""; //uf.Bio = ""; uf.Signature = this.userName.Text; //uf.Sightml = ""; //uf.Authstr = ""; uf.RealName = this.realname.Text; uf.Idcard = this.idcard.Text; uf.Mobile = this.mobile.Text; uf.Phone = this.phone.Text; return(user); }
public void LoadCurrentUserInfo(int uid) { this.ViewState["username"] = this.userInfo.Name; this.userName.Text = this.userInfo.Name; if (this.userInfo.GroupID == 8 && this.config.Regverify == 1) { this.ReSendEmail.Visible = true; } else { this.ReSendEmail.Visible = false; } this.nickname.Text = this.userInfo.NickName; this.accessmasks.SelectedValue = this.userInfo.AccessMasks + ""; this.bday.Text = this.userInfo.Bday; this.credits.Text = this.userInfo.Credits.ToString(); this.digestposts.Text = this.userInfo.DigestPosts.ToString(); this.email.Text = this.userInfo.Email; this.gender.SelectedValue = this.userInfo.Gender.ToString(); //if (this.userInfo.GroupID.ToString() == "") //{ // this.groupid.SelectedValue = "0"; //} //else //{ if (this.groupid.Items.FindByValue(this.userInfo.GroupID.ToString()) != null) { this.groupid.SelectedValue = this.userInfo.GroupID.ToString(); } else { UserGroup ug = CreditsFacade.GetCreditsUserGroupId((float)this.userInfo.Credits); if (ug != null) { this.groupid.SelectedValue = ug.ID.ToString(); } } //} if (uid == BaseConfigs.GetFounderUid) { this.groupid.Enabled = false; } if (this.userInfo.GroupID == 4) { this.StopTalk.Text = "取消禁言"; this.StopTalk.HintInfo = "取消禁言将会把当前用户所在的 \\'系统禁言\\' 组进行系统调整成为非禁言组"; } this.ViewState["GroupID"] = this.userInfo.GroupID.ToString(); this.invisible.SelectedValue = this.userInfo.Invisible.ToString(); this.joindate.Text = this.userInfo.JoinDate.ToString("yyyy-MM-dd HH:mm:ss"); this.lastactivity.Text = this.userInfo.LastActivity.ToString("yyyy-MM-dd HH:mm:ss"); this.lastip.Text = this.userInfo.LastIP; this.lastpost.Text = this.userInfo.LastPost.ToString("yyyy-MM-dd HH:mm:ss"); this.lastvisit.Text = this.userInfo.LastVisit.ToString("yyyy-MM-dd HH:mm:ss");; this.newpm.SelectedValue = this.userInfo.Newpm.ToString(); switch ((ReceivePMSettingType)this.userInfo.NewsLetter) { case ReceivePMSettingType.ReceiveNone: this.SetNewsLetter(false, false, false); break; case ReceivePMSettingType.ReceiveSystemPM: this.SetNewsLetter(true, false, false); break; case ReceivePMSettingType.ReceiveUserPM: this.SetNewsLetter(false, true, false); break; case ReceivePMSettingType.ReceiveAllPM: this.SetNewsLetter(true, true, false); break; case ReceivePMSettingType.ReceiveSystemPMWithHint: this.SetNewsLetter(true, false, true); break; case ReceivePMSettingType.ReceiveUserPMWithHint: this.SetNewsLetter(false, true, true); break; default: this.SetNewsLetter(true, true, true); break; } this.oltime.Text = this.userInfo.OLTime.ToString(); this.pageviews.Text = this.userInfo.PageViews.ToString(); this.pmsound.Text = this.userInfo.Pmsound.ToString(); this.posts.Text = this.userInfo.Posts.ToString(); this.ppp.Text = this.userInfo.Ppp.ToString(); this.regip.Text = this.userInfo.RegIP; this.showemail.SelectedValue = this.userInfo.ShowEmail.ToString(); this.sigstatus.SelectedValue = this.userInfo.Sigstatus.ToString(); if (this.userInfo.TemplateID != 0) { this.templateid.SelectedValue = this.userInfo.TemplateID.ToString(); } this.tpp.Text = this.userInfo.Tpp.ToString(); this.extcredits1.Text = this.userInfo.ExtCredits1.ToString(); this.extcredits2.Text = this.userInfo.ExtCredits2.ToString(); this.extcredits3.Text = this.userInfo.ExtCredits3.ToString(); this.extcredits4.Text = this.userInfo.ExtCredits4.ToString(); this.extcredits5.Text = this.userInfo.ExtCredits5.ToString(); this.extcredits6.Text = this.userInfo.ExtCredits6.ToString(); this.extcredits7.Text = this.userInfo.ExtCredits7.ToString(); this.extcredits8.Text = this.userInfo.ExtCredits8.ToString(); IUserField uf = userInfo.Field; this.website.Text = uf.Website; this.icq.Text = uf.Icq; this.qq.Text = uf.qq; this.yahoo.Text = uf.Yahoo; this.msn.Text = uf.Msn; this.skype.Text = uf.Skype; this.location.Text = uf.Location; this.customstatus.Text = uf.Customstatus; this.bio.Text = uf.Bio; this.signature.Text = uf.Signature; this.realname.Text = uf.RealName; this.idcard.Text = uf.Idcard; this.mobile.Text = uf.Mobile; this.phone.Text = uf.Phone; this.givenusername.Text = this.userInfo.Name; if (String.IsNullOrEmpty(uf.Medals)) { uf.Medals = "0"; } string text = "," + uf.Medals + ","; //DataTable availableMedal = Medals.GetAvailableMedal(); DataTable availableMedal = Medal.GetAvailable().ToDataTable(false); if (availableMedal != null) { DataColumn dataColumn = new DataColumn(); dataColumn.ColumnName = "isgiven"; dataColumn.DataType = typeof(Boolean); dataColumn.DefaultValue = false; dataColumn.AllowDBNull = false; availableMedal.Columns.Add(dataColumn); foreach (DataRow dataRow in availableMedal.Rows) { if (text.IndexOf("," + dataRow["id"].ToString() + ",") >= 0) { dataRow["isgiven"] = true; } } this.medalslist.DataSource = availableMedal; this.medalslist.DataBind(); } }