public int addSysForm(SysForm form) { string maxId = "select max(formID) from sys_form"; int id = 1; try { id = 1 + ((int)DBHelp.ExeScalar(maxId)); } catch (Exception) { } string getFormIndex = string.Format("select max(formIndex) from sys_form where UpperID={0}", form.UpperID); int maxFormIndex = 0; try { maxFormIndex = ((int)DBHelp.ExeScalar(getFormIndex)) + 1; } catch (Exception) { } DBHelp.ExeCommand(string.Format("insert into sys_form values({4},'{0}','{1}',{2},{3},'') \r\n ", new object[] { form.DisplayName, form.AssemblyPath, form.UpperID, maxFormIndex, id })); return(id); }
/// <summary> /// 初始化 /// </summary> private void Initialize() { int?id = QueryString <int?>("id"); if (id == null) { throw new Exception("参数不正确"); } SysFormInstance fi = this.DataHelper.FindById <SysFormInstance>(id); if (fi == null) { throw new Exception("表单实例不存在"); } if (fi.State == (int)FormInstanceState.Approving) { throw new Exception("表单实例审核中,不能编辑"); } SysForm form = this.DataHelper.FindById <SysForm>(fi.FormId); if (form == null) { throw new Exception("表单不存在"); } this.FormInstanceId = fi.FormInstanceId; this.FormId = form.FormId; }
/// <summary> /// 对象实体绑定数据 /// </summary> public SysForm ReaderBind(IDataReader dataReader) { SysForm model = new SysForm(); object ojb; ojb = dataReader["formID"]; if (ojb != null && ojb != DBNull.Value) { model.FormID = (int)ojb; } model.DisplayName = dataReader["displayName"].ToString(); model.AssemblyPath = dataReader["assemblyPath"].ToString(); ojb = dataReader["upperID"]; if (ojb != null && ojb != DBNull.Value) { model.UpperID = (int)ojb; } ojb = dataReader["formIndex"]; if (ojb != null && ojb != DBNull.Value) { model.FormIndex = (int)ojb; } ojb = dataReader["formImgURL"]; if (ojb != null && ojb != DBNull.Value) { model.FormImgURL = dataReader["formImgURL"].ToString(); } return(model); }
protected void btnStop_Click(object sender, EventArgs e) { try { long?formId = (sender as LinkButton).CommandArgument.ToLongNullable(); if (formId != null) { SysForm form = this.DataHelper.FindById <SysForm>(formId); if (form != null) { form.State = (int)FormState.StopUsed; form.UpdateTime = DateTime.Now; form.UpdateUserId = this.LoginUserID; this.DataHelper.UpdatePartial(form, p => new { p.State, p.UpdateUserId, p.UpdateTime }); BindGrid(); } else { throw new Exception("表单不存在"); } } else { throw new Exception("表单不存在"); } } catch (Exception ex) { this.AjaxAlert(ex); } }
/// <summary> /// 初始化 /// </summary> private void Initialize() { int?id = QueryString <int?>("id"); if (id == null) { throw new Exception("参数不正确"); } SysFormInstance fi = this.DataHelper.FindById <SysFormInstance>(id); if (fi == null) { throw new Exception("表单实例不存在"); } //2013-10-8 zhumin 审核中的不能再提交 this.rApply.Visible = fi.State != (int)FormInstanceState.Approving; SysForm form = this.DataHelper.FindById <SysForm>(fi.FormId); if (form == null) { throw new Exception("表单不存在"); } this.FormInstanceId = fi.FormInstanceId; this.FormId = form.FormId; }
private string GetEntityName(SysForm p) { SysEntity entity = GetEntity(p.EntityId); if (entity != null) { return(entity.EntityName); } return(string.Empty); }
private string GetDisplayText(SysForm p) { SysEntity entity = GetEntity(p.EntityId); if (entity != null) { return(entity.DisplayText); } return(string.Empty); }
public bool modifySysForm(SysForm form) { if (this.getFormsByFormId(form.FormID).DisplayName != form.DisplayName) { int count = (int)DBHelp.ExeScalar(string.Format("select count(*) from sys_form where displayName='{0}'", form.DisplayName)); if (count > 0) { return(false); } } return(DBHelp.ExeCommand(string.Format("update sys_form set displayName='{0}',upperId={1} where formId={2}", form.DisplayName, form.UpperID, form.FormID))); }
/// <summary> /// 初始化 /// </summary> private void Initialize() { long?id = QueryString <long?>("id"); if (id == null) { throw new Exception("参数不正确"); } SysForm form = this.DataHelper.FindById <SysForm>(id); if (form == null) { throw new Exception("参数不正确"); } this.FormId = id.Value; }
/// <summary> /// 发布 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnPublish_Click(object sender, EventArgs e) { try { SysForm form = this.DataHelper.FindById <SysForm>(this.FormId); if (form != null) { using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { using (BizDataContext db = new BizDataContext()) { //更新表单状态 form.State = (int)FormState.StartUsed; form.UpdateTime = DateTime.Now; form.UpdateUserId = this.LoginUserID; db.UpdatePartial(form, p => new { p.State, p.UpdateUserId, p.UpdateTime }); //发布数据库 SysEntity entity = this.EntityCache.FindById <SysEntity>(this.EntityId); if (entity == null) //新增加的实体 { entity = db.FindById <SysEntity>(this.EntityId); if (entity == null) { throw new Exception("表单关联实体不存在"); } entity.Fields = db.Where <SysField>(p => p.EntityId == entity.EntityId); FormEntityPublishHelper publish = new FormEntityPublishHelper(entity, db); publish.Publish(); } } ts.Complete(); } } else { throw new Exception("表单不存在"); } this.AjaxAlertAndRedirect("发布成功", "FormQuery.aspx"); } catch (Exception ex) { this.AjaxAlertAndEnableButton(ex); } }
/// <summary> /// 加载表单(含表单实体对象数据),根据表单权限显示,审核页面上会额外根据活动判断权限 /// </summary> /// <param name="formInstanceId">表单实例ID</param> /// <param name="activityId">当前活动ID,审核页面用</param> public void LoadFormWithInstance(int formInstanceId, long?activityId = null) { SysFormInstance fi = this.DataHelper.FindById <SysFormInstance>(formInstanceId); if (fi == null) { throw new Exception("表单实例不存在"); } SysForm form = this.DataHelper.FindById <SysForm>(fi.FormId); if (form != null && form.EntityId != null) { this.Form = form; this.FormId = form.FormId; this.EntityId = form.EntityId.Value; this.FormInstanceId = fi.FormInstanceId; this.FormInstance = this.DataHelper.FindById <SysFormInstance>(this.FormInstanceId); if (this.FormInstance != null) { this.ObjectId = this.FormInstance.ObjectId; var fpDict = GetFormPrivilege(activityId); var controlDict = LoadFormContentControl(fpDict); if (!this.Page.IsPostBack) { LoadFormInstance(); LoadObjectData(controlDict); LoadProcessApproveHistory(); } } else { throw new Exception("流程实例不存在"); } } else { throw new Exception("表单不存在"); } }
public SysForm getFormsByFormId(int formId) { SysForm sysForms = null; DataTable dt = DBHelp.getDataTable(string.Format("select * from sys_form where formid={0}", formId)); foreach (DataRow dr in dt.Rows) { sysForms = new SysForm(); sysForms.FormID = Convert.ToInt32(dr[0]); sysForms.DisplayName = dr[1].ToString(); sysForms.AssemblyPath = dr[2].ToString(); sysForms.UpperID = Convert.ToInt32(dr[3]); sysForms.FormIndex = Convert.ToInt32(dr[4]); if (dr[5] != null) { sysForms.FormImgURL = dr[5].ToString(); } } return(sysForms); }
public List <SysForm> getAllForms_1() { string sql = string.Format("select * from sys_form", new object[0]); List <SysForm> SysForms = new List <SysForm>(); DataTable dt = DBHelp.getDataTable(sql); foreach (DataRow dr in dt.Rows) { SysForm sysForms = new SysForm(); sysForms.FormID = Convert.ToInt32(dr[0]); sysForms.DisplayName = dr[1].ToString(); sysForms.AssemblyPath = dr[2].ToString(); sysForms.UpperID = Convert.ToInt32(dr[3]); sysForms.FormIndex = Convert.ToInt32(dr[4]); if (dr[5] != null) { sysForms.FormImgURL = dr[5].ToString(); } SysForms.Add(sysForms); } return(SysForms); }
/// <summary> /// 初始化 /// </summary> private void Initialize() { long?id = QueryString <long?>("id"); if (id == null) { throw new Exception("参数不正确"); } SysForm form = this.DataHelper.FindById <SysForm>(id); if (form == null) { throw new Exception("参数不正确"); } this.FormId = id.Value; this.EntityId = form.EntityId.Value; BindSection(); BindSelectField(); BindDrowDown(); }
private void Initialize() { long?id = QueryString <long?>("id"); if (id == null) { throw new Exception("参数不正确"); } SysForm form = this.DataHelper.FindById <SysForm>(id); if (form == null) { throw new Exception("参数不正确"); } this.FormId = id.Value; this.EntityId = form.EntityId.Value; var roleList = this.DataHelper.Set <T_Role>().ToList(); this.ddlRoleList.DataSource = roleList; this.ddlRoleList.DataBind(); }
private List <SysForm> getFormsBySql(string sql) { List <SysForm> SysForms = new List <SysForm>(); DataTable dt = DBHelp.getDataTable(sql); foreach (DataRow dr in dt.Rows) { SysForm sysForms = new SysForm(); sysForms.FormID = Convert.ToInt32(dr[0]); sysForms.DisplayName = dr[1].ToString(); sysForms.AssemblyPath = dr[2].ToString(); sysForms.UpperID = Convert.ToInt32(dr[3]); sysForms.Menu = new sysMenuService().getSysMenuByMenuId(sysForms.UpperID); sysForms.FormIndex = Convert.ToInt32(dr[4]); if (dr[5] != null) { sysForms.FormImgURL = dr[5].ToString(); } SysForms.Add(sysForms); } return(SysForms); }
/// <summary> /// 加载预览(测试用数据),不判断权限 /// </summary> /// <param name="formId"></param> public void LoadPreview(long formId) { SysForm form = this.DataHelper.FindById <SysForm>(formId); if (form != null && form.EntityId != null) { this.Form = form; this.FormId = formId; this.EntityId = form.EntityId.Value; LoadFormContentControl(null); if (!this.Page.IsPostBack) { LoadPreivewTestData(); LoadFormInstance(); } } else { throw new Exception("表单不存在"); } }
/// <summary> /// 加载表单,根据表单权限显示 /// </summary> /// <param name="formId">表单ID</param> public void LoadForm(long formId) { SysForm form = this.DataHelper.FindById <SysForm>(formId); if (form != null && form.EntityId != null) { this.Form = form; this.FormId = formId; this.EntityId = form.EntityId.Value; var fpDict = GetFormPrivilege(); LoadFormContentControl(fpDict); if (!this.Page.IsPostBack) { LoadDefaultFormInstanceData(); //默认的表单实例信息 LoadFormInstance(); } } else { throw new Exception("表单不存在"); } }
/// <summary> /// 下一步 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnNextStep_Click(object sender, EventArgs e) { try { string processName = this.txtProcessName.Text.Trim(); long? formId = this.ddlForm.SelectedValue.ToLongNullable(); SysForm form = this.DataHelper.FindById <SysForm>(formId); if (form == null) { throw new Exception("流程关联的表单不能为空"); } if (string.IsNullOrEmpty(processName)) { throw new Exception("流程名称不能为空"); } int count = 0; SysProcess process = this.DataHelper.FindById <SysProcess>(this.ProcessId); if (process != null) { count = this.DataHelper.Set <SysProcess>().Where(p => p.ProcessName == processName && p.ProcessType != process.ProcessType).Count(); } else { count = this.DataHelper.Set <SysProcess>().Where(p => p.ProcessName == processName).Count(); } if (count > 0) { throw new Exception("流程名称重复,已有其它流程使用"); } if (process != null) { process.ProcessName = processName; process.FormId = formId; process.EntityId = form.EntityId; this.DataHelper.UpdatePartial(process, p => new { p.ProcessName, p.FormId, p.EntityId }); //清除缓存 Drision.Framework.WorkflowEngineCore.Cache.ProcessCacheFactory pc = new WorkflowEngineCore.Cache.ProcessCacheFactory(this.DataHelper); pc.ClearCache(process.ProcessId); } else { long approveEntityId = this.EntityCache.SysEntity.FirstOrDefault(p => p.EntityName == typeof(SysApproveActivityData).Name).EntityId; SysProcess temp = new SysProcess() { ProcessId = this.ProcessId, ProcessName = processName, FormId = formId, EntityId = form.EntityId, ActivityEntityId = approveEntityId, ProcessCategory = (int)ProcessCategory.FormApprove, ProcessStatus = (int)ProcessState.Created, ProcessType = this.ProcessId, ProcessVersion = "1", ProcessHeight = 692, ProcessWidth = 692, }; this.DataHelper.Insert(temp); } Response.Redirect(string.Format("FormProcessDesigner_SecondStep.aspx?id={0}", this.ProcessId)); } catch (Exception ex) { this.AjaxAlertAndEnableButton(ex); } }
/// <summary> /// 新增表单字段 /// </summary> /// <param name="sectionId"></param> /// <param name="parameter"></param> /// <param name="otherContent"></param> /// <returns></returns> private string NewField(long sectionId, string parameter, ref object otherContent) { string result = string.Empty; SysFormFieldSection section = this.DataHelper.FindById <SysFormFieldSection>(sectionId); if (section != null) { SysForm form = this.DataHelper.FindById <SysForm>(section.FormId); if (form == null) { throw new Exception("表单不存在"); } JavaScriptSerializer js = new JavaScriptSerializer(); var valueDict = js.DeserializeObject(parameter) as Dictionary <string, object>; if (valueDict == null) { throw new Exception("回调参数不正确"); } string displayText = valueDict["DisplayText"].ToStringNullable(); string fieldName = valueDict["FieldName"].ToStringNullable(); int? dataType = valueDict["DataType"].ToStringNullable().ToIntNullable(); int temp = this.DataHelper.Set <SysField>().Where(p => p.EntityId == form.EntityId && (p.DisplayText == displayText || p.FieldName == fieldName)).Count(); if (temp > 0) { throw new Exception("当前新增的字段名称已经存在"); } int maxOrder = this.DataHelper.Set <SysFormField>().Where(p => p.FormSectionId == sectionId).Max(p => p.DisplayOrder ?? 0); using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { using (BizDataContext db = new BizDataContext()) { //新增字段 SysField field = new SysField() { FieldId = db.GetNextIdentity(), DisplayText = displayText, FieldName = fieldName, EntityId = form.EntityId, Description = displayText, DataType = dataType, IsFormField = true,//2013-9-24 zhumin }; db.Insert(field); //新增表单字段 SysFormField ff = new SysFormField() { FormFieldId = db.GetNextIdentity(), FormSectionId = sectionId, EntityId = form.EntityId, DisplayOrder = maxOrder + 1, FormId = form.FormId, FieldId = field.FieldId, DataType = field.DataType, IsNullable = true, CreateTime = DateTime.Now, CreateUserId = this.LoginUserID, }; db.Insert(ff); result = string.Format("<div id=\"{0}\" class=\"field unselected\" onclick=\"Select(this);\">{1}</div>", ff.FormFieldId, field.DisplayText); otherContent = string.Format("<div class=\"divField\"><span><input type=\"checkbox\" fid=\"{0}\" /></span><span>{1}</span><span>{2}</span></div>", field.FieldId, field.DisplayText, field.FieldName); } ts.Complete(); } } return(result); }
/// <summary> /// 验证流程的完整性,绑定流程详情和验证错误信息 /// </summary> private void BindAndValidateData(SysProcess process) { this.lblProcessName.Text = process.ProcessName; this.lblProcessVersion.Text = process.ProcessVersion; //表单相关 SysForm form = this.DataHelper.FindById <SysForm>(process.FormId); if (form != null) { this.lblFormName.Text = form.FormName; SysEntity entity = GetEntity(form.EntityId); if (entity != null) { this.lblProcessEntity.Text = entity.DisplayText; } else { AddError(new Exception("流程实体为空,请至表单配置页面设置")); } } else { AddError(new Exception("流程关联表单为空,请返回至第一步配置")); } //流程参与人 var ppCount = this.DataHelper.Set <SysProcessParticipant>() .Where(p => p.ProcessId == this.ProcessId).Count(); if (ppCount == 0) { AddError(new Exception("流程参与人未配置,请返回至第一步配置")); } //活动相关 var activityList = this.DataHelper.Set <SysActivity>() .Where(p => p.ProcessId == this.ProcessId).OrderBy(p => p.DisplayOrder ?? 0).ToList(); this.gcActivity.DataSource = activityList.Select(p => new { p.ActivityName, ActivityType = EnumHelper.GetDescription((ActivityType)p.ActivityType), ExecuteType = EnumHelper.GetDescription((ActivityExecType)p.ExecType), ActivityParticipant = GetActivityParticipant(p), }).ToList(); this.gcActivity.DataBind(); if (activityList.Count(p => p.ActivityType == (int)ActivityType.Start) != 1) { AddError(new Exception("流程开始活动内部错误,请重建流程")); return; } if (activityList.Count(p => p.ActivityType == (int)ActivityType.End) != 2) { AddError(new Exception("流程结束活动内部错误,请重建流程")); return; } if (activityList.Count(p => p.ActivityType == (int)ActivityType.Approve) == 0) { AddError(new Exception("流程审核活动内部错误,请重建流程")); return; } foreach (var a in activityList) { if (string.IsNullOrEmpty(a.ActivityName)) { AddError(new Exception("活动名称为空,请返回至第二步配置")); } if (a.ActivityType == (int)ActivityType.Approve) { var apCount = this.DataHelper.Set <SysActivityParticipant>() .Where(p => p.ActivityId == a.ActivityId).Count(); if (apCount == 0) { AddError(new Exception(string.Format("活动【{0}】参与人未配置,请返回至第二步配置", a.ActivityName))); } } } //连接线完整性验证 List <SysTransition> tList = this.DataHelper.Set <SysTransition>() .Where(p => p.ProcessId == this.ProcessId).ToList(); Queue <SysActivity> queue = new Queue <SysActivity>(); SysActivity start = activityList.FirstOrDefault(p => p.ActivityType == (int)ActivityType.Start); SysActivity temp = start; queue.Enqueue(start); while (queue.Count > 0) { temp = queue.Dequeue(); SysTransition t = tList.FirstOrDefault(p => p.PreActivityId == temp.ActivityId && p.Direction == (int)FlowStepDirection.True); if (t != null) { temp = activityList.FirstOrDefault(p => p.ActivityId == t.PostActivityId); queue.Enqueue(temp); } else { break; } } if (!(temp.ActivityType == (int)ActivityType.End && temp.ActivityName == "通过")) { AddError(new Exception(string.Format("流程在活动【{0}】处断开,内部错误,请重建流程", temp.ActivityName))); } }
protected void btnNextStep_Click(object sender, EventArgs e) { try { string entityType = this.ddlEntityType.SelectedValue; string displayText = this.txtSysEntity.Text.Trim(); string entityName = "T_" + displayText.ToPingYin(); string formName = this.txtFormName.Text.Trim(); string formTitle = this.txtFormTitle.Text.Trim(); string formDecription = this.txtFormDescription.Text.Trim(); if (string.IsNullOrEmpty(formName)) { throw new Exception("表单名称不能为空"); } using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { using (BizDataContext db = new BizDataContext()) { switch (entityType) { case "0": case "1": if (this.EntityId == null) { throw new Exception("关联实体不能为空"); } break; case "2": if (string.IsNullOrEmpty(displayText)) { throw new Exception("关联实体不能为空"); } if (string.IsNullOrEmpty(entityName)) { throw new Exception("关联实体表名不能为空"); } SysEntity tempEntity = db.FirstOrDefault <SysEntity>(p => p.EntityName == entityName || p.DisplayText == displayText); if (tempEntity != null) { throw new Exception("当前新增的关联实体名称已存在"); } tempEntity = new SysEntity() { EntityId = db.GetNextIdentity(), EntityName = entityName, DisplayText = displayText, Description = displayText, IsFormEntity = true, CreateTime = DateTime.Now, }; db.Insert(tempEntity); this.EntityId = tempEntity.EntityId; //默认加一个主键字段 SysField tempField = new SysField() { FieldId = db.GetNextIdentity(), EntityId = tempEntity.EntityId, FieldName = displayText.ToPingYin() + "_Id", DisplayText = displayText + "ID", Description = displayText + "ID", DataType = (int)DataTypeEnum.pkey, IsFormField = true, //2013-9-24 zhumin }; db.Insert(tempField); break; default: break; } if (this.FormId != null) { SysForm form = db.FindById <SysForm>(this.FormId); if (form != null) { form.FormName = formName; form.EntityId = this.EntityId; form.UpdateTime = DateTime.Now; form.UpdateUserId = this.LoginUserID; form.FormTitle = formTitle; form.FormDescription = formDecription; db.UpdatePartial(form, p => new { p.FormName, p.FormTitle, p.FormDescription, p.EntityId, p.UpdateTime, p.UpdateUserId }); } else { throw new Exception("表单不存在"); } } else { SysForm form = new SysForm() { FormId = db.GetNextIdentity(), FormName = formName, FormTitle = formTitle, FormDescription = formDecription, EntityId = this.EntityId, CreateTime = DateTime.Now, CreateUserId = this.LoginUserID, OwnerId = this.LoginUserID, State = (int)FormState.New, }; db.Insert(form); this.FormId = form.FormId; } } ts.Complete(); } Response.Redirect(string.Format("FormDesigner_SecondStep.aspx?id={0}", this.FormId)); } catch (Exception ex) { this.AjaxAlertAndEnableButton(ex); } }
private void Initialize() { foreach (var p in this.EntityCache.SysEntity.OrderBy(p => p.DisplayText)) { this.ddlSysEntity.Items.Add(new ComboItem() { Text = p.DisplayText, Value = p.EntityId.ToString(), }); } foreach (var p in this.DataHelper.Set <SysEntity>() .Where(p => p.IsFormEntity == true)//2013-9-24 zhumin .OrderBy(p => p.DisplayText)) { this.ddlCustomEntity.Items.Add(new ComboItem() { Text = p.DisplayText, Value = p.EntityId.ToString(), }); } long?id = QueryString <long?>("id"); if (id == null) { this.ddlSysEntity.SetValue(null); this.txtFormName.SetValue(null); this.txtSysEntity.SetValue(null); this.lblCreateUser.Text = this.LoginUser.User_Name; this.ddlEntityType.SetValue(0); this.txtFormTitle.SetValue(null); this.txtFormDescription.SetValue(null); } else { SysForm form = this.DataHelper.FindById <SysForm>(id); if (form != null) { this.FormId = id; T_User user = this.DataHelper.FindById <T_User>(form.CreateUserId); if (user != null) { this.lblCreateUser.Text = user.User_Name; } SysEntity tempEntity = EntityCache.FindById <SysEntity>(form.EntityId); if (tempEntity == null) { this.ddlEntityType.SetValue(1); this.ddlCustomEntity.SetValue(form.EntityId); } else { this.ddlEntityType.SetValue(0); this.ddlSysEntity.SetValue(form.EntityId); } this.txtFormName.Text = form.FormName; this.txtFormTitle.Text = form.FormTitle; this.txtFormDescription.Text = form.FormDescription; this.EntityId = form.EntityId; } else { throw new Exception("参数不正确"); } } }
public void setTabPage(int selectedIndex) { this.formIndexs = new Dictionary <int, List <SysForm> >(); this.TreeView1.Nodes.Clear(); sysMenuService menuMan = new sysMenuService(); List <SysObject> sysobjects = new SysObjectService().getSomeObjects(selectedIndex); List <SysMenu> sysMenus = menuMan.getAllSysMenus(); sysFormService form1 = new sysFormService(); List <AllObjs> allobjs = new AllObjsService().getAllobjs(); List <SysForm> sysForms = form1.getAllForms_1(); foreach (SysMenu sysm in sysMenus) { int i; TreeNode fristNode = new TreeNode(sysm.DisplayName); SysForm form = new SysForm(); form.UpperID = sysm.MenuID; List <SysForm> currentForms = sysForms.FindAll(new Predicate <SysForm>(form.getForms)); this.formIndexs.Add(sysm.MenuIndex, currentForms); currentForms.Sort(delegate(SysForm from1, SysForm form2) { return(from1.FormIndex.CompareTo(form2.FormIndex)); }); foreach (SysForm currentForm in currentForms) { TreeNode secondNode = new TreeNode(currentForm.DisplayName); secondNode.Value = currentForm.FormID.ToString(); fristNode.ChildNodes.Add(secondNode); AllObjs all = new AllObjs(); all.FormId = currentForm.FormID; List <AllObjs> currentObjs = allobjs.FindAll(new Predicate <AllObjs>(all.getForms)); i = 0; while (i < currentObjs.Count) { TreeNode tiridNode = new TreeNode(currentObjs[i].Chinese); tiridNode.Value = currentObjs[i].English; SysObject oo = new SysObject(); oo.FromId = currentForm.FormID; List <SysObject> someObjs = sysobjects.FindAll(new Predicate <SysObject>(oo.getSomeObjct)); tiridNode.Checked = this.getEnable(someObjs, currentObjs[i].English); secondNode.ChildNodes.Add(tiridNode); i++; } } List <roleSysform> rsf = new roleSysFormService().getRightsByRoleId_1(selectedIndex); for (int j = 0; j < rsf.Count; j++) { for (i = 0; i < fristNode.ChildNodes.Count; i++) { int formId = Convert.ToInt32(fristNode.ChildNodes[i].Value); try { if (formId == rsf[j].Sysform.FormID) { fristNode.ChildNodes[i].Checked = true; fristNode.Checked = true; } } catch (Exception) { } } } this.TreeView1.Nodes.Add(fristNode); } }