public void AddUser(IList <string> idList, IList <string> userList, string tableName) { BasicPrivilegeService service = new BasicPrivilegeService(); IList <string> subList = idList; if (tableName == "XPM_Basic_CodeList") { subList = new XPMBasicCodeListService().GetSubList(idList[0]); } foreach (string str in userList) { foreach (string str2 in subList) { BasicPrivilege bp = new BasicPrivilege { PrivilegeId = Guid.NewGuid().ToString(), RelationsTable = tableName, RelationsKey = str2, UserCode = str }; if (!service.Exists(bp)) { service.Add(bp); } } } }
protected void BtnAdd_Click(object sender, EventArgs e) { CodingInfo codeInfo = this.GatherInputInfo(); CodingInfo codingInfo = new CodingInfo(); int num = 0; if (base.DealType == OpType.Add) { codingInfo = this.CodingAct.QuerySingleCodeInfo(codeInfo.CodeName, codeInfo.TypeID); if (codingInfo.CodeName != "") { if (codingInfo.IsValid) { this.JS.Text = "alert('该编码已存在!')"; return; } codeInfo.CodeID = codingInfo.CodeID; num = this.CodingAct.RecycleCode(codeInfo); } else { num = this.CodingAct.AddBasicCode(codeInfo, "ccd"); XPMBasicCodeListService source = new XPMBasicCodeListService(); XPMBasicCodeList parent = ( from c in source where c.CodeID == this.ParentCodeID && c.TypeID == this.TypeID select c).FirstOrDefault <XPMBasicCodeList>(); if (parent != null) { BasicPrivilegeService basicPrivilegeService = new BasicPrivilegeService(); IList <string> user = basicPrivilegeService.GetUser("XPM_Basic_CodeList", parent.NoteID.ToString()); XPMBasicCodeList xPMBasicCodeList = ( from c in source where c.TypeID == this.TypeID && c.ParentCodeID == parent.CodeID && c.CodeName == codeInfo.CodeName select c).FirstOrDefault <XPMBasicCodeList>(); foreach (string current in user) { basicPrivilegeService.Add(new BasicPrivilege { PrivilegeId = Guid.NewGuid().ToString(), RelationsTable = "XPM_Basic_CodeList", RelationsKey = xPMBasicCodeList.NoteID.ToString(), UserCode = current }); } } } } if (base.DealType == OpType.Upd) { codingInfo = this.CodingAct.QuerySingleCodeInfo(codeInfo.CodeName, codeInfo.TypeID); if (codingInfo.CodeName != "") { if (codingInfo.CodeID != codeInfo.CodeID) { this.JS.Text = "alert('该编码已存在!如果没有出现在列表中,那么请重新添加!');"; } else { num = this.CodingAct.UpdBasicCode(codeInfo); } } else { num = this.CodingAct.UpdBasicCode(codeInfo); } } if (num == 1) { string script = "\r\n\t\t\t\t\t<script>\r\n\t\t\t\t\t\ttop.ui.tabSuccess({ parentName: '_codelist' });\r\n\t\t\t\t\t</script>\r\n\t\t\t\t"; base.ClientScript.RegisterStartupScript(base.GetType(), Guid.NewGuid().ToString(), script); return; } this.JS.Text = "alert('保存失败!');"; }
public IList <string> GetExistsUser(string id, string tableName) { BasicPrivilegeService service = new BasicPrivilegeService(); return(service.GetUser(tableName, id)); }