protected void btnDelete_Click(object sender, System.EventArgs e) { System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>(); if (this.hfldParentId.Value.Contains("[")) { list = JsonHelper.GetListFromJson(this.hfldParentId.Value); } else { list.Add(this.hfldParentId.Value); } try { ResMappingService resMappingService = new ResMappingService(); foreach (string current in list) { resMappingService.DeleteFromParentId(current); } base.RegisterScript("alert('系统提示:\\n\\n删除成功!');"); this.DataBind(); } catch (System.Exception ex) { base.RegisterScript("alert('系统提示:\\n\\n" + ex.Message + "!');"); } }
protected void Page_Load(object sender, System.EventArgs e) { if (!base.IsPostBack && this.action == "update") { ResMappingService source = new ResMappingService(); System.Collections.Generic.List <string> list = ( from m in source where m.ParentId == this.parentId select m.ResourceId).ToList <string>(); this.hfldParentId.Value = this.parentId; Resource resource = new Resource(); this.txtParentName.Text = resource.GetResourceName(this.parentId); this.hfldChildResId.Value = JsonHelper.JsonSerializer <string[]>(list.ToArray()); this.DataBindChildRes(); } }
protected void btnSave_Click(object sender, System.EventArgs e) { if (string.IsNullOrEmpty(this.hfldParentId.Value) || string.IsNullOrEmpty(this.hfldChildResId.Value)) { return; } ResMappingService resMappingService = new ResMappingService(); resMappingService.DeleteFromParentId(this.parentId); string value = this.hfldParentId.Value; System.Collections.Generic.List <string> listFromJson = JsonHelper.GetListFromJson(this.hfldChildResId.Value); foreach (string current in listFromJson) { this.AddMapping(current, value); } base.RegisterScript("top.ui.tabSuccess({ parentName: '_ResMap' });"); }