/// <summary> /// '表和视图列表框'的选择改变事件. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void clbTablesAndView_SelectedIndexChanged(object sender, EventArgs e) { string name = this.clbTablesAndView .Items[this.clbTablesAndView.SelectedIndex].ToString(); string tabName = this.GetTableOrViewName(name); if (name.StartsWith("@")) { this.lblTabStructure.Text = "视图" + tabName + "相关实体类结构:"; } else { this.lblTabStructure.Text = "表" + tabName + "相关实体类结构:"; } if (!this._clasInfo.Contains(tabName)) { DataTable tabStructure = null; ConnectOracle.OpenConnection(); tabStructure = ConnectOracle.ConvertTableOrViewStructure (ConnectOracle.GetTableOrViewStructure(tabName)); ConnectOracle.CloseConnection(); this._clasInfo.Add(tabName, tabStructure); DataTable tabNameDt = ConnectOracle.GetDataTable(String.Format(@"select COMMENTS from user_tab_comments WHERE TABLE_NAME = '{0}'", tabName)); if (tabNameDt.Rows.Count > 0) { this._clasRemarkInfo.Add(tabName, tabNameDt.Rows[0]["COMMENTS"].ToString()); } else { this._clasRemarkInfo.Add(tabName, ""); } } DataTable data = (DataTable)this._clasInfo[tabName]; this.dgvTableOrViewStructure.DataSource = data; //决定是否保存类注释. if (this._saveClassRemark) { this._clasRemarkInfo[this._tabName] = this.txtTabControlOneClassRemark.Text; this._saveClassRemark = false; } //决定是否保存字段注释. if (this._saveFieldRemark) { DataTable data2 = (DataTable)this._clasInfo[this._tabName2]; data2.Rows[this._index][2] = this.txtTabControlOneFieldInfo.Text; this._saveFieldRemark = false; } this.txtTabControlOneClassRemark.Text = this._clasRemarkInfo[tabName].ToString(); int index = this.dgvTableOrViewStructure.CurrentRow.Index; if (data.Rows.Count > 0) { this.txtTabControlOneFieldInfo.Text = data.Rows[index][2].ToString(); } //更改类注释标签文本. string className = GeneratorTool.CapFirstLetter(tabName) + ToolSetting.Postfix; this.lblClassRemark.Text = className + "类注释:"; }