public void CreateCalculatedFieldPropertyGrid(PropertyGridEx.PropertyGridEx pg) { // Initialize the property grid for attributes. bool bReadOnly = true; if (pg.Dock == DockStyle.None) { bReadOnly = false; } pg.Item.Clear(); pg.Item.Add("Field Name", "", bReadOnly, "Database Information", "Data Attribute.", true); pg.Item.Add("Grouping", "", false, "Database Information", "Used to group attributes of similar types.", true); pg.Item.Add("Ascending", true, false, "Database Information", "True if the number gets smaller with deterioration.", true); pg.Item[pg.Item.Count - 1].Choices = new CustomChoices(trueFalse, false); pg.Item.Add("Format", "", false, "Database Information", "Determines how numeric data appears in the attribute view. (e.g. f1 = 1.0 f2 = 1.00 etc.)", true); pg.Item.Add("Minimum", "", false, "Database Information", "Maximum allowed data value", true); pg.Item.Add("Maximum", "", false, "Database Information", "Minimum allowed data value", true); pg.Item.Add("Default_Value", "", false, "Database Information", "The default data value to use if no data is present.", true); pg.Item.Add("One", "", false, "Levels", "Defined level breaks and coloring schemes.", true); pg.Item.Add("Two", "", false, "Levels", "Defined level breaks and coloring schemes.", true); pg.Item.Add("Three", "", false, "Levels", "Defined level breaks and coloring schemes.", true); pg.Item.Add("Four", "", false, "Levels", "Defined level breaks and coloring schemes.", true); pg.Item.Add("Five", "", false, "Levels", "Defined level breaks and coloring schemes.", true); pg.Item.Add("Network Definition Name", _currNetDef.NetDefName, true, "Database Information", "Defines which network definition this calculated field belongs to.", true); }
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 String CreateCalculatedField(PropertyGridEx.PropertyGridEx pgCalcField) { m_calculatedFieldName = pgCalcField.Item[0].Value.ToString(); String strInsert = "INSERT INTO ATTRIBUTES_ (ATTRIBUTE_, "; String strValues = " VALUES ('" + m_calculatedFieldName + "', '"; for (int i = 1; i < pgCalcField.Item.Count; i++) { String strDatabaseAttribteName = (String)Global.m_htFieldMapping[pgCalcField.Item[i].Name]; if (pgCalcField.Item[i].Value.ToString() != "") { strInsert += strDatabaseAttribteName + ", "; switch (DBMgr.NativeConnectionParameters.Provider) { case "ORACLE": switch (strDatabaseAttribteName.ToUpper()) { case "ASCENDING": if (pgCalcField.Item[i].Value.ToString().ToUpper().Trim() == "TRUE") { strValues += "1', '"; } else { strValues += "0', '"; } break; default: strValues += pgCalcField.Item[i].Value + "', '"; break; } break; default: strValues += pgCalcField.Item[i].Value + "', '"; break; } } } strInsert += "CALCULATED, NATIVE_, TYPE_, "; strValues += "1', '1', 'NUMBER', '"; strInsert = strInsert.Substring(0, strInsert.Length - 2) + ")"; strValues = strValues.Substring(0, strValues.Length - 3); strInsert += strValues + ")"; try { DBMgr.ExecuteNonQuery(strInsert); } catch (Exception sqlE) { Global.WriteOutput("Error: Insert new attribute into database failed with, " + sqlE.Message); } return(m_calculatedFieldName); }
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); } }
private bool IsPropertyGridComplete(PropertyGridEx.PropertyGridEx pgCalcField) { // Check the property grid for valid entries... bool bIsComplete = true; if (pgCalcField.Item["Field Name"].Value.ToString() == "" || pgCalcField.Item["Default_Value"].Value.ToString() == "" //|| pgCalcField.Item["Maximum"].Value.ToString() == "" //|| pgCalcField.Item["Minimum"].Value.ToString() == "" || pgCalcField.Item["One"].Value.ToString() == "" || pgCalcField.Item["Two"].Value.ToString() == "" || pgCalcField.Item["Three"].Value.ToString() == "" || pgCalcField.Item["Four"].Value.ToString() == "" || pgCalcField.Item["Five"].Value.ToString() == "") { bIsComplete = false; } else { bIsComplete = true; } return(bIsComplete); }
public bool VerifyCalcFieldProperties(out string error, PropertyGridEx.PropertyGridEx pgCalcField) { error = ""; Hashtable htProperties = new Hashtable(); for (int i = 0; i < pgCalcField.Item.Count; i++) { htProperties.Add(pgCalcField.Item[i].Name, pgCalcField.Item[i].Value); } bool bHasError = false; if (pgCalcField.Item["Field Name"].Value == null || pgCalcField.Item["Field Name"].Value.ToString().Trim() == "") { bHasError = true; error += "Field Name, "; } if (htProperties["One"] == null || htProperties["One"].ToString().Trim() == "") { error += "One, "; } if (htProperties["Two"] == null || htProperties["Two"].ToString().Trim() == "") { error += "Two, "; } if (htProperties["Three"] == null || htProperties["Three"].ToString().Trim() == "") { error += "Three, "; } if (htProperties["Four"] == null || htProperties["Four"].ToString().Trim() == "") { error += "Four, "; } if (htProperties["Five"] == null || htProperties["Five"].ToString().Trim() == "") { error += "Five, "; } if (htProperties["Default_Value"] == null || htProperties["Default_Value"].ToString().Trim() == "") { error += "Default_Value, "; } try { // Error check for correct formatting. float f = 1f; String strFormatValue = htProperties["Format"].ToString(); String str = f.ToString(strFormatValue); float.Parse(str); } catch { error += "Format, "; } if (error.Length == 0) { bHasError = true; } else { error = error.Substring(0, error.Length - 2); bHasError = false; } return(bHasError); }
public void SetAttributeProperties(PropertyGridEx.PropertyGridEx pg) { // Initialize the property grid for attributes. bool bReadOnly = true; if (pg.Dock == DockStyle.None) { bReadOnly = false; } pg.Item.Clear(); bool dataReadOnly = true; if (string.IsNullOrEmpty(m_strPropertyName) || Global.SecurityOperations.CanModifyRawAttributeData(m_strPropertyName)) { dataReadOnly = false; } pg.Item.Add("Attribute", "AttributeName" + RoadCare3.Properties.Settings.Default.ATTRIBUTE_DEFAULT.ToString(), bReadOnly, "1. Attribute Information", "Data Attribute.", true); pg.Item.Add("Native", true, bReadOnly, "3. Database Information", "Native should be set to true if the database is a native RoadCare database.", true); pg.Item[pg.Item.Count - 1].Choices = new CustomChoices(trueFalse, false); pg.Item.Add("Provider", RoadCare3.Properties.Settings.Default.LAST_DB_TYPE, true, "3. Database Information", "Database Type (MSSQL, ORACLE, MYSQL).", true); pg.Item[pg.Item.Count - 1].Choices = new CustomChoices(providers, false); pg.Item.Add("Integrated Security", true, true, "3. Database Information", "", true); pg.Item.Add("Type", RoadCare3.Properties.Settings.Default.TYPE_DEFAULT, bReadOnly, "1. Attribute Information", "STRING or NUMBER", true); pg.Item[pg.Item.Count - 1].Choices = new CustomChoices(types, false); pg.Item.Add("Ascending", true, dataReadOnly, "1. Attribute Information", "True if the number gets smaller with deterioration.", true); pg.Item[pg.Item.Count - 1].Choices = new CustomChoices(trueFalse, false); pg.Item.Add("Connection Type", RoadCare3.Properties.Settings.Default.CONNECTION_TYPE, true, "5. Oracle Database Information", "Oracle Basic or TNS connection type.", true); pg.Item[pg.Item.Count - 1].Choices = new CustomChoices(connType, false); pg.Item.Add("Server", RoadCare3.Properties.Settings.Default.LAST_DB_SERVER, true, "3. Database Information", "Name of server on which the attribute data resides.", true); pg.Item.Add("Database", RoadCare3.Properties.Settings.Default.LAST_DB.ToString(), true, "4. MSSQL Database Information", "Name of the database in which the attribute data resides.", true); pg.Item.Add("Network Alias", RoadCare3.Properties.Settings.Default.DBNETWORKALIAS, true, "5. Oracle Database Information", "Name of the Oracle Service", true); pg.Item.Add("SID", RoadCare3.Properties.Settings.Default.DBSID, true, "5. Oracle Database Information", "", true); pg.Item.Add("Port", RoadCare3.Properties.Settings.Default.DBPORT, true, "5. Oracle Database Information", "", true); pg.Item.Add("Login", RoadCare3.Properties.Settings.Default.LAST_LOGIN.ToString(), true, "3. Database Information", "User name.", true); pg.Item.Add("Password", RoadCare3.Properties.Settings.Default.LAST_PASSWORD.ToString(), true, "3. Database Information", "User password", true); pg.Item["Password"].IsPassword = true; pg.Item.Add("View", "", true, "6. View Statement", "Sql string for generating RoadCare specific views on the data server.", true); pg.Item[pg.Item.Count - 1].OnClick += this.CustomEventItem_OnClick; pg.Item.Add("Grouping", RoadCare3.Properties.Settings.Default.LAST_GROUP.ToString(), dataReadOnly, "1. Attribute Information", "Used to group attributes of similar types.", true); pg.Item.Add("Format", RoadCare3.Properties.Settings.Default.LAST_FORMAT.ToString(), dataReadOnly, "1. Attribute Information", "Determines how numeric data appears in the attribute view. (e.g. f1 = 1.0 f2 = 1.00 etc.)", true); pg.Item.Add("Maximum", RoadCare3.Properties.Settings.Default.LAST_MAXIMUM.ToString(), dataReadOnly, "1. Attribute Information", "Maximum allowed data value", true); pg.Item.Add("Minimum", RoadCare3.Properties.Settings.Default.LAST_MINIMUM.ToString(), dataReadOnly, "1. Attribute Information", "Minimum allowed data value", true); pg.Item.Add("Default_Value", RoadCare3.Properties.Settings.Default.LAST_DEFAULT.ToString(), dataReadOnly, "1. Attribute Information", "The default data value to use if no data is present.", true); pg.Item.Add("One", RoadCare3.Properties.Settings.Default.LAST_ONE.ToString(), dataReadOnly, "2. Levels", "Defined level breaks and coloring schemes.", true); pg.Item.Add("Two", RoadCare3.Properties.Settings.Default.LAST_TWO.ToString(), dataReadOnly, "2. Levels", "Defined level breaks and coloring schemes.", true); pg.Item.Add("Three", RoadCare3.Properties.Settings.Default.LAST_THREE.ToString(), dataReadOnly, "2. Levels", "Defined level breaks and coloring schemes.", true); pg.Item.Add("Four", RoadCare3.Properties.Settings.Default.LAST_FOUR.ToString(), dataReadOnly, "2. Levels", "Defined level breaks and coloring schemes.", true); pg.Item.Add("Five", RoadCare3.Properties.Settings.Default.LAST_FIVE.ToString(), dataReadOnly, "2. Levels", "Defined level breaks and coloring schemes.", true); SolutionExplorerTreeNode selectedNode = (SolutionExplorerTreeNode)FormManager.GetSolutionExplorer().GetTreeView().SelectedNode; pg.Item.Add("Network Definition Name", selectedNode.NetworkDefinition.NetDefName, true, "1. Attribute Information", "Network definition to which the attribute belongs.", true); m_pgProperties = pg; }
public void UpdateAssetProperties(PropertyGridEx.PropertyGridEx pgProperties) { pgProperties.Item["Asset Name"].Value = m_AssetName; }