protected void Page_Load(object sender, EventArgs e) { WebLink ent = null; id = RequestData.Get <string>("id"); if (!string.IsNullOrEmpty(id)) { ent = WebLink.Find(id); } switch (RequestActionString) { case "create": ent = new WebLink(); ent.DoCreate(); PageState.Add("Entity", ent); break; case "update": string field = RequestData.Get <string>("field"); string value = RequestData.Get <string>("value"); if (field == "Url") { ent.Url = value; } else { ent.WebName = value; } ent.DoUpdate(); break; case "delete": string ids = RequestData.Get <string>("ids"); string[] idarray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); foreach (string tid in idarray) { ent = WebLink.Find(tid); if (ent.IsAdmin == "1") { ent.ExceptUserId += (string.IsNullOrEmpty(ent.ExceptUserId) ? "" : ",") + UserInfo.UserID; ent.DoUpdate(); } else { ent.DoDelete(); } } break; default: DoSelect(); break; } }
//创建多个url private void DoCrate() { // 判断是否系统管理员 string sql = @"select UserID from SysRole,SysUserRole where SysRole.RoleID=SysUserRole.RoleID and SysRole.Name like '%系统管理员%' and UserID='{0}'"; sql = string.Format(sql, UserInfo.UserID); object obj = DataHelper.QueryValue(sql); WebLink ent = this.GetPostedData <WebLink>(); if (!String.IsNullOrEmpty(ent.Url)) { string[] ArrUrl = ent.Url.Split(new string[] { "\r" }, StringSplitOptions.RemoveEmptyEntries); string[] ArrName = ent.WebName.Split(new string[] { "\r" }, StringSplitOptions.RemoveEmptyEntries); int point = 0; //指向下一个Name if (ArrUrl.Length > 0) { for (int i = 0; i < ArrUrl.Length; i++) { WebLink WL_ent = new WebLink(); WL_ent.Url = ArrUrl[i]; WL_ent.WebName = ArrName[point]; if (obj != null) { WL_ent.IsAdmin = "1"; //表示管理员 } WL_ent.DoCreate(); if (i < ArrName.Length - 1) { point++; } } } else { ent.DoCreate(); } } }