/// <summary> /// 更新一条数据 /// </summary> public void Update(BCW.Model.Role model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BCW.Model.Role model) { return(dal.Add(model)); }
private void SavePage() { int id = int.Parse(Utils.GetRequest("id", "post", 2, @"^[0-9]\d*$", "ID错误")); int UsID = int.Parse(Utils.GetRequest("UsID", "post", 2, @"^[1-9]\d*$", "用户ID错误")); string Role = Utils.GetRequest("Role", "post", 2, @"^[\w((;|,)\w)?]+$", "选择权限错误"); Role = Role.Replace(",", ";"); int rDay = int.Parse(Utils.GetRequest("rDay", "post", 2, @"^[0-9]\d*$", "期限填写错误")); string rName = Utils.GetRequest("rName", "post", 2, @"^[A-Za-zA-Z\d0-9\u4E00-\u9FA5]{1,10}$", "职称限10字内,不能使用特别字符"); int Include = int.Parse(Utils.GetRequest("Include", "post", 1, @"^[0-1]$", "0")); if (!new BCW.BLL.User().Exists(UsID)) { Utils.Error("不存在的会员ID", ""); } string ForumName = string.Empty; if (id > 0) { ForumName = new BCW.BLL.Forum().GetTitle(id); if (ForumName == "") { Utils.Error("不存在的版块ID", ""); } if (new BCW.BLL.Role().Exists(UsID, id)) { Utils.Error("ID:" + UsID + "已经是" + ForumName + "的版主", ""); } } else { if (new BCW.BLL.Role().Exists(UsID, 0)) { Utils.Error("ID:" + UsID + "已经是总版主", ""); } if (new BCW.BLL.Role().Exists(UsID, -1)) { Utils.Error("ID:" + UsID + "已经是管理员,管理员与总版不能同时兼职", ""); } } string UsName = new BCW.BLL.User().GetUsName(UsID); BCW.Model.Role model = new BCW.Model.Role(); model.UsID = UsID; model.UsName = UsName; model.ForumID = id; model.ForumName = ForumName; model.Rolece = Role; model.RoleName = rName; model.StartTime = DateTime.Now; if (rDay == 0) { model.OverTime = DateTime.Parse("1990-1-1 00:00:00"); } else { model.OverTime = DateTime.Now.AddDays(rDay); } model.Include = Include; model.Status = 0; new BCW.BLL.Role().Add(model); //发送内线给版主 if (id > 0) { new BCW.BLL.Guest().Add(UsID, UsName, "系统管理员将您设为论坛“" + ForumName + "”的版主"); //任职记录 new BCW.BLL.Forumlog().Add(14, id, "[url=/bbs/uinfo.aspx?uid=" + UsID + "]" + UsName + "(" + UsID + ")[/url]上任时间:" + DT.FormatDate(DateTime.Now, 11) + ""); } Utils.Success("添加版主", "恭喜,添加版主成功,正在返回..", Utils.getPage("moderator.aspx"), "1"); }
private void EditSavePage() { string ac = Utils.ToSChinese(Utils.GetRequest("ac", "post", 1, @"", "")); int id = int.Parse(Utils.GetRequest("id", "post", 2, @"^[0-9]\d*$", "ID错误")); string GetRole = string.Empty; if (ac == "编辑管理员") { string Roleall = Utils.GetRequest("Roleall", "post", 3, @"^[\w((;|,)\w)?]+$", "选择全局权限错误"); Roleall = Roleall.Replace(",", ";"); string Role = Utils.GetRequest("Role", "post", 3, @"^[\w((;|,)\w)?]+$", "选择权限错误"); Role = Role.Replace(",", ";"); GetRole = Roleall + ";" + Role; if (Roleall == "") { GetRole = Utils.Mid(GetRole, 1, GetRole.Length); } } else { string Role = Utils.GetRequest("Role", "post", 2, @"^[\w((;|,)\w)?]+$", "选择权限错误"); Role = Role.Replace(",", ";"); GetRole = Role; } DateTime sDay = Utils.ParseTime(Utils.GetRequest("sDay", "post", 2, DT.RegexTime, "上任时间填写错误")); string rDay = Utils.GetRequest("rDay", "post", 2, "", ""); string rName = Utils.GetRequest("rName", "post", 2, @"^[A-Za-zA-Z\d0-9\u4E00-\u9FA5]{1,10}$", "职称限10字内,不能使用特别字符"); int Include = int.Parse(Utils.GetRequest("Include", "post", 1, @"^[0-1]$", "0")); int Status = int.Parse(Utils.GetRequest("Status", "post", 2, @"^[0-1]$", "权限状态选择错误")); if (rDay == "0") { rDay = "1990-1-1 00:00:00"; } else { if (!Utils.IsRegex(rDay, DT.RegexTime)) { Utils.Error("卸任时间填写错误", ""); } } BCW.Model.Role m = new BCW.BLL.Role().GetRole(id); if (m == null) { Utils.Error("不存在的记录", ""); } //取用户昵称 string UsName = new BCW.BLL.User().GetUsName(m.UsID); //取论坛名称 string ForumName = new BCW.BLL.Forum().GetTitle(m.ForumID); BCW.Model.Role model = new BCW.Model.Role(); model.ID = id; model.UsName = UsName; model.Rolece = GetRole; model.RoleName = rName; model.ForumName = ForumName; model.StartTime = sDay; model.OverTime = DateTime.Parse(rDay); model.Include = Include; model.Status = Status; new BCW.BLL.Role().Update(model); if (ac == "编辑管理员") { new BCW.BLL.Guest().Add(m.UsID, UsName, "系统管理员编辑您的管理员权限"); Utils.Success("编辑管理员", "恭喜,编辑管理员成功,正在返回..", Utils.getPage("moderator.aspx"), "1"); } else { new BCW.BLL.Guest().Add(m.UsID, UsName, "系统管理员编辑您在论坛“" + ForumName + "”的版主权限"); Utils.Success("编辑版主", "恭喜,编辑版主成功,正在返回..", Utils.getPage("moderator.aspx"), "1"); } }
private void Save2Page() { int UsID = int.Parse(Utils.GetRequest("UsID", "post", 2, @"^[1-9]\d*$", "用户ID错误")); string Roleall = Utils.GetRequest("Roleall", "post", 2, @"^[\w((;|,)\w)?]+$", "选择全局权限错误"); Roleall = Roleall.Replace(",", ";"); string Role = Utils.GetRequest("Role", "post", 3, @"^[\w((;|,)\w)?]+$", "选择权限错误"); Role = Role.Replace(",", ";"); string GetRole = Roleall; if (Role != "") { GetRole = Roleall + ";" + Role; } int rDay = int.Parse(Utils.GetRequest("rDay", "post", 2, @"^[0-9]\d*$", "期限填写错误")); string rName = Utils.GetRequest("rName", "post", 2, @"^[A-Za-zA-Z\d0-9\u4E00-\u9FA5]{1,10}$", "职称限10字内,不能使用特别字符"); int Include = int.Parse(Utils.GetRequest("Include", "post", 1, @"^[0-1]$", "0")); if (!new BCW.BLL.User().Exists(UsID)) { Utils.Error("不存在的会员ID", ""); } if (new BCW.BLL.Role().Exists(UsID, -1)) { Utils.Error("ID:" + UsID + "已经是管理员", ""); } if (new BCW.BLL.Role().Exists(UsID, 0)) { Utils.Error("ID:" + UsID + "已经是总版,管理员与总版不能同时兼职", ""); } string UsName = new BCW.BLL.User().GetUsName(UsID); BCW.Model.Role model = new BCW.Model.Role(); model.UsID = UsID; model.UsName = UsName; model.ForumID = -1; model.ForumName = ""; model.Rolece = GetRole; model.RoleName = rName; model.StartTime = DateTime.Now; if (rDay == 0) { model.OverTime = DateTime.Parse("1990-1-1 00:00:00"); } else { model.OverTime = DateTime.Now.AddDays(rDay); } model.Status = 0; new BCW.BLL.Role().Add(model); //发送内线给版主 new BCW.BLL.Guest().Add(UsID, UsName, "系统管理员将您设为管理员"); Utils.Success("添加管理员", "恭喜,添加管理员成功,正在返回..", Utils.getPage("moderator.aspx"), "1"); }