private void btnSave_Click(object sender, EventArgs e) { if (!dcRole.Validate()) { return; } dcRole.GetValue(role); //获取选中的菜单权限 this.lstCheckedMenuID.Clear(); if (treeList1.Nodes.Count > 0) { foreach (TreeListNode root in treeList1.Nodes) { if (root.CheckState == CheckState.Checked || root.CheckState == CheckState.Indeterminate) { MenuEntity menu = treeList1.GetDataRecordByNode(root) as MenuEntity; if (menu != null) { lstCheckedMenuID.Add(menu.id); } } GetCheckedID(treeList1, root, lstCheckedMenuID); } } string idStr = string.Empty; foreach (String id in lstCheckedMenuID) { idStr += id + ","; } if (idStr.Length != 0) { idStr = idStr.Substring(0, idStr.Length - 1); } role.menuIds = idStr; //获取选中的功能权限 this.lstCheckedFunctionID.Clear(); if (treeList2.Nodes.Count > 0) { foreach (TreeListNode root in treeList2.Nodes) { if (root.CheckState == CheckState.Checked || root.CheckState == CheckState.Indeterminate) { FunctionEntity function = treeList2.GetDataRecordByNode(root) as FunctionEntity; if (function != null) { lstCheckedFunctionID.Add(function.id); } } GetCheckedID(treeList2, root, lstCheckedFunctionID); } } string functionIdStr = string.Empty; foreach (String id in lstCheckedFunctionID) { functionIdStr += id + ","; } if (functionIdStr.Length != 0) { functionIdStr = functionIdStr.Substring(0, functionIdStr.Length - 1); } role.functionIds = functionIdStr; //string strJson = JsonConvert.SerializeObject(test); String param = "?" + PackReflectionEntity <RoleEntity> .GetEntityToRequestParameters(role, true) + "&&oldName=" + oldName; String url = AppContext.AppConfig.serverUrl + "sys/sysRole/save" + param; cmd.ShowOpaqueLayer(); this.DoWorkAsync(500, (o) => //耗时逻辑处理(此处不能操作UI控件,因为是在异步中) { String data = HttpClass.httpPost(url); return(data); }, null, (data) => //显示结果(此处用于对上面结果的处理,比如显示到界面上) { JObject objT = JObject.Parse(data.ToString()); cmd.HideOpaqueLayer(); if (string.Compare(objT["state"].ToString(), "true", true) == 0) { DialogResult = DialogResult.OK; } else { MessageBoxUtils.Show(objT["message"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, this); } }); }