protected void Page_Load(object sender, EventArgs e) { try { if (!this.IsPostBack) { //获取父id string parentId = Request.QueryString["parentId"]; if (!string.IsNullOrEmpty(parentId)) { this.hidParentId.Value = parentId; } else { YMessageBox.show(this, "未设置父菜单id失败!"); } //获取id string strId = Request.QueryString["id"]; if (!string.IsNullOrEmpty(strId)) { this.hidOrgId.Value = strId; //获取配置文件路径。 string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName; //创建操作对象 OrgOperater orgOper = OrgOperater.createOrgOperater(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey); if (orgOper != null) { //获取机构信息 OrganizationInfo org = orgOper.getOrganization(Convert.ToInt32(strId)); if (org != null) { this.txtOrgName.Value = org.name; this.txtOrgOrder.Value = org.order.ToString(); } else { YMessageBox.show(this, "获取机构信息失败!错误信息[" + orgOper.errorMessage + "]"); return; } } else { YMessageBox.show(this, "创建数据库操作对象失败!"); return; } } } } catch (Exception ex) { YMessageBox.show(this, "程序运行出错!错误信息[" + ex.Message + "]"); } }
/// <summary> /// 绑定组织机构。 /// 作者:董帅 创建时间:2012-8-22 13:45:41 /// </summary> public void bindOrgInfos() { try { //获取配置文件路径。 string configFile = AppDomain.CurrentDomain.BaseDirectory.ToString() + SystemConfig.databaseConfigFileName; //获取数据库操作对象 OrgOperater orgOper = OrgOperater.createOrgOperater(configFile, SystemConfig.databaseConfigNodeName, SystemConfig.configFileKey); if (orgOper != null) { //获取父机构信息 if (this.hidParentId.Value == "-1") { this.spanParentName.InnerText = "顶级机构"; this.returnButton.Disabled = true; this.hidReturnId.Value = ""; } else { OrganizationInfo org = orgOper.getOrganization(Convert.ToInt32(this.hidParentId.Value)); this.spanParentName.InnerText = org.name; this.hidReturnId.Value = org.parentId.ToString(); } //获取组织机构列表 List <OrganizationInfo> orgs = orgOper.getOrganizationByParentId(Convert.ToInt32(this.hidParentId.Value)); if (orgs != null) { this.orgList.DataSource = orgs; this.orgList.DataBind(); } else { YMessageBox.show(this, "获取组织机构数据失败!错误信息[" + orgOper.errorMessage + "]"); } } else { YMessageBox.show(this, "获取数据库操作对象失败!"); } } catch (Exception ex) { YMessageBox.show(this, "运行错误!错误信息[" + ex.Message + "]"); } }