private void GetTableNames(ListView LV) { int I; ListViewItem lvi; TStringList aTableCaptionList = new TStringList(); TStringList aTableList = new TStringList(); String[] Params = null; String ViewFieldName = "TABLE_NAME"; if (FServerData.DatabaseType == ClientType.ctOracle) { String UserID = WzdUtils.GetFieldParam(FServerData.ConnectionString.ToLower(), "user id"); Params = new String[] { UserID }; ViewFieldName = "VIEW_NAME"; } if (FServerData != null) { aTableCaptionList = FServerData.TableNameCaptionList; aTableList = FServerData.TableNameList; } else { if (FConnection.GetType().FullName != "IBM.Data.Informix.IfxConnection") { GetTableCaptionFromCOLDEF(aTableCaptionList); DataTable D = FConnection.GetSchema("Tables", Params); D.Select("", "TABLE_NAME DESC"); for (I = 0; I < D.Rows.Count; I++) aTableList.Add(D.Rows[I]["TABLE_NAME"].ToString()); DataTable T = FConnection.GetSchema("Views", Params); DataRow[] dr = T.Select("", "VIEW_NAME ASC"); foreach (DataRow DR in dr) { aTableList.Add(DR["VIEW_NAME"].ToString()); } } else { List<String> allTables = WzdUtils.GetAllTablesList(FConnection, ClientType.ctInformix); allTables.Sort(); foreach (String str in allTables) aTableList.Add(str); } } //if (FConnection.GetType().FullName != "IBM.Data.Informix.IfxConnection") //{ // DataTable D1 = FConnection.GetSchema("Views", Params); // D1.Select("", ViewFieldName + " DESC"); // foreach (DataRow DR in D1.Rows) // { // if (aTableList.IndexOf(DR[ViewFieldName].ToString()) < 0) // aTableList.Add(DR[ViewFieldName].ToString()); // } //} LV.Items.Clear(); if (aTableList.Count > 0) { LV.BeginUpdate(); for (I = 0; I < aTableList.Count; I++) { lvi = new ListViewItem(); lvi.Text = aTableList[I].ToString(); //lvi.SubItems[""] = ""; LV.Items.Add(lvi); String tableName = lvi.Text; if (tableName.Contains(".")) tableName = tableName.Split('.')[1]; lvi.SubItems.Add(aTableCaptionList.Values(tableName)); lvi.Selected = lvi.Text.CompareTo(FTableName) == 0; } LV.EndUpdate(); } LV.Sort(); }
private void GetFieldNamesEx(TDatasetItem aDatasetItem, string DatabaseName, string TableName, String DataSetName, ListView SrcListView, ListView DestListView) { int I, J = 0; bool Found = false; ListViewItem lvi = null; //TFieldAttrItem tai; TStringList aPhysFieldNameList = new TStringList(); TStringList aFieldCaptionList = new TStringList(); if (aDatasetItem != null) { aPhysFieldNameList = aDatasetItem.FieldList; aFieldCaptionList = aDatasetItem.FieldCaptionList; } else { GetFieldList(DatabaseName, TableName, aPhysFieldNameList); } /* for (I = 0; I < DestListView.Items.Count - 1; I++) { lvi = DestListView.Items[I]; if (aPhysFieldNameList.IndexOf(lvi.Text) < 0) { tai = (TFieldAttrItem)lvi.Tag; } } */ SrcListView.Items.Clear(); for (I = 0; I < aPhysFieldNameList.Count; I++) { Found = false; for (J = 0; J < DestListView.Items.Count; J++) { lvi = DestListView.Items[J]; if (string.Compare(aPhysFieldNameList[I].ToString(), lvi.Text, false) == 0) { Found = true; break; } } if (Found == false) { lvi = SrcListView.Items.Add(aPhysFieldNameList[I].ToString()); lvi.SubItems.Add(aFieldCaptionList.Values(lvi.Text)); } } if (SrcListView.Items.Count > 0) SrcListView.Items[0].Selected = true; }