public void SetAssetProperties(PropertyGridEx.PropertyGridEx pgProperties, bool bIsModal) { pgProperties.Item.Clear(); try { DataSet columnNamesAndTypes = DBMgr.GetTableColumnsWithTypes("ASSETS"); foreach (DataRow columnNameAndType in columnNamesAndTypes.Tables[0].Rows) { m_columnNames.Add(columnNameAndType["column_name"].ToString()); pgProperties.Item.Add(columnNameAndType["column_name"].ToString(), "", true, "General", "", true); } } catch (Exception exc) { Global.WriteOutput("Error: Could not get ASSETS table column names or types. " + exc.Message); } string query = "SELECT ASSET, DATE_CREATED, CREATOR_NAME, CREATOR_ID, LAST_MODIFIED, SERVER, DATASOURCE, USERID, PASSWORD_, PROVIDER, NATIVE_ FROM ASSETS WHERE ASSET = '" + m_AssetName + "'"; try { DataSet assetTableInfo = DBMgr.ExecuteQuery(query); pgProperties.Item["ASSET"].Value = assetTableInfo.Tables[0].Rows[0]["ASSET"].ToString(); pgProperties.Item["DATE_CREATED"].Value = assetTableInfo.Tables[0].Rows[0]["DATE_CREATED"].ToString(); pgProperties.Item["CREATOR_NAME"].Value = assetTableInfo.Tables[0].Rows[0]["CREATOR_NAME"].ToString(); pgProperties.Item["CREATOR_ID"].Value = assetTableInfo.Tables[0].Rows[0]["CREATOR_ID"].ToString(); pgProperties.Item["LAST_MODIFIED"].Value = assetTableInfo.Tables[0].Rows[0]["LAST_MODIFIED"].ToString(); pgProperties.Item["SERVER"].Value = assetTableInfo.Tables[0].Rows[0]["SERVER"].ToString(); pgProperties.Item["DATASOURCE"].Value = assetTableInfo.Tables[0].Rows[0]["DATASOURCE"].ToString(); pgProperties.Item["USERID"].Value = assetTableInfo.Tables[0].Rows[0]["USERID"].ToString(); pgProperties.Item["PASSWORD_"].Value = assetTableInfo.Tables[0].Rows[0]["PASSWORD_"].ToString(); pgProperties.Item["PROVIDER"].Value = assetTableInfo.Tables[0].Rows[0]["PROVIDER"].ToString(); pgProperties.Item["NATIVE_"].Value = assetTableInfo.Tables[0].Rows[0]["NATIVE_"].ToString(); } catch (Exception exc) { Global.WriteOutput("Error: Can not get asset information from ASSETS. " + exc.Message); } try { ConnectionParameters cp = DBMgr.GetAssetConnectionObject(m_AssetName); DataSet columnNamesAndTypes = DBMgr.GetTableColumnsWithTypes(m_AssetName, cp); foreach (DataRow columnNameAndType in columnNamesAndTypes.Tables[0].Rows) { m_columnNames.Add(columnNameAndType["column_name"].ToString()); pgProperties.Item.Add(columnNameAndType["column_name"].ToString(), "", true, "General", "", true); pgProperties.Item[columnNameAndType["column_name"].ToString()].Value = columnNameAndType["data_type"].ToString(); } } catch (Exception exc) { Global.WriteOutput("Error: Could not get asset column names or types. " + exc.Message); } pgProperties.Refresh(); }
public void UpdatePropertyGrid(PropertyGridEx.PropertyGridEx pgProperties) { // Get Attribute information from the database regarding this attribute. String strQuery = ""; string netDefName = pgProperties.Item["Network Definition Name"].Value.ToString(); strQuery = "Select ATTRIBUTE_, NATIVE_, PROVIDER, SERVER, DATASOURCE, USERID, PASSWORD_, SQLVIEW, TYPE_, GROUPING, ASCENDING, FORMAT, MAXIMUM, MINIMUM_, DEFAULT_VALUE, LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5, SID_, SERVICE_NAME, INTEGRATED_SECURITY, PORT, NETWORK_DEFINITION_NAME From ATTRIBUTES_ Where ATTRIBUTE_ = '" + m_strPropertyName + "' AND NETWORK_DEFINITION_NAME = '" + netDefName + "'"; try { DataSet ds = DBMgr.ExecuteQuery(strQuery); // More random error checking if (ds.Tables[0].Rows.Count != 1) { throw (new Exception()); } else { DataRow dr = ds.Tables[0].Rows[0]; pgProperties.Item["Attribute"].Value = dr["ATTRIBUTE_"].ToString(); pgProperties.Item["Native"].Value = dr["NATIVE_"].ToString(); pgProperties.Item["Provider"].Value = dr["PROVIDER"].ToString(); pgProperties.Item["Server"].Value = dr["SERVER"].ToString(); pgProperties.Item["Database"].Value = dr["DATASOURCE"].ToString(); pgProperties.Item["Login"].Value = dr["USERID"].ToString(); pgProperties.Item["Password"].Value = dr["PASSWORD_"].ToString(); pgProperties.Item["View"].Value = dr["SQLVIEW"].ToString(); pgProperties.Item["Type"].Value = dr["TYPE_"].ToString(); pgProperties.Item["Grouping"].Value = dr["GROUPING"].ToString(); pgProperties.Item["Ascending"].Value = dr["ASCENDING"].ToString(); pgProperties.Item["Format"].Value = dr["FORMAT"].ToString(); pgProperties.Item["Maximum"].Value = dr["MAXIMUM"].ToString(); pgProperties.Item["Minimum"].Value = dr["MINIMUM_"].ToString(); pgProperties.Item["Default_Value"].Value = dr["DEFAULT_VALUE"].ToString(); pgProperties.Item["One"].Value = dr["LEVEL1"].ToString(); pgProperties.Item["Two"].Value = dr["LEVEL2"].ToString(); pgProperties.Item["Three"].Value = dr["LEVEL3"].ToString(); pgProperties.Item["Four"].Value = dr["LEVEL4"].ToString(); pgProperties.Item["Five"].Value = dr["LEVEL5"].ToString(); pgProperties.Item["SID"].Value = dr["SID_"].ToString(); pgProperties.Item["Network Alias"].Value = dr["SERVICE_NAME"].ToString(); pgProperties.Item["Integrated Security"].Value = dr["INTEGRATED_SECURITY"].ToString(); pgProperties.Item["Port"].Value = dr["PORT"].ToString(); pgProperties.Item["Network Definition Name"].Value = dr["NETWORK_DEFINITION_NAME"].ToString(); pgProperties.Refresh(); } } catch (Exception sqlE) { Global.WriteOutput("Error: Cannot update property tool window. " + sqlE.Message); } }