private void DataGridViewSplitTreatmentCriteria_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; //Must be valid row index } if (e.ColumnIndex == 0) { return; } var strCriteria = ""; if (dataGridViewSplitTreatmentCriteria.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null) { strCriteria = dataGridViewSplitTreatmentCriteria.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); } else { dataGridViewSplitTreatmentCriteria.Rows.Add(); } var formAdvancedSearch = new FormAdvancedSearch(m_strNetwork, m_hashAttributeYear, strCriteria, true); if (formAdvancedSearch.ShowDialog() == DialogResult.OK) { dataGridViewSplitTreatmentCriteria[e.ColumnIndex, e.RowIndex].Value = formAdvancedSearch.GetWhereClause(); } dataGridViewSplitTreatmentCriteria.Update(); }
private void editCriteriaToolStripMenuItem_Click(object sender, EventArgs e) { int nRow = 0; if (dgvPerfomance.SelectedRows.Count > 0 || dgvPerfomance.SelectedCells.Count > 0) { if (dgvPerfomance.SelectedRows.Count > 0) { nRow = dgvPerfomance.SelectedRows[0].Index; } else if (dgvPerfomance.SelectedCells.Count > 0) { nRow = dgvPerfomance.SelectedCells[0].RowIndex; } } else { return; } DataGridViewRow row = dgvPerfomance.Rows[nRow]; String strValue = ""; if (row.Cells[3].Value != null) { strValue = row.Cells[3].Value.ToString(); } FormAdvancedSearch advancedSearch = new FormAdvancedSearch(m_strNetwork, m_hashAttributeYear, strValue, true); if (advancedSearch.ShowDialog() == DialogResult.OK) { row.Cells[3].Value = advancedSearch.GetWhereClause(); } }
private void buttonCriteria_Click(object sender, EventArgs e) { FormAdvancedSearch form = new FormAdvancedSearch(m_strNetwork, m_hashAttributeYear, "", false); if (form.ShowDialog() == DialogResult.OK) { textBoxFilter.Text = form.Query; } }
private void buttonAdvancedSearch_Click(object sender, EventArgs e) { FormAdvancedSearch formSearch = new FormAdvancedSearch(m_strNetwork, m_hashAttributeYear, textBoxAdvanceSearch.Text, false); if (formSearch.ShowDialog() == DialogResult.OK) { textBoxAdvanceSearch.Text = formSearch.GetWhereClause(); UpdateSectionGrid(); } }
private void dgvPerfomance_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex >= 2) { if (Global.SecurityOperations.CanModifySimulationPerformance(m_strNetworkID, m_strSimulationID)) { if (dgvPerfomance.Rows[e.RowIndex].Cells[0].Value == null) { Global.WriteOutput("Error: Select a performance attribute before editing the performance equation or criteria."); return; } String strAttribute = dgvPerfomance.Rows[e.RowIndex].Cells[0].Value.ToString(); if (strAttribute.Trim().Length == 0) { Global.WriteOutput("Error: Select a performance attribute before editing the performance equation or criteria."); return; } String strCriteria = ""; if (e.ColumnIndex == 2) { Performance performance = (Performance)dgvPerfomance.Rows[e.RowIndex].Tag; if (performance == null) { performance = new Performance(); } FormEditEquation formEditEquation = new FormEditEquation(performance); if (formEditEquation.ShowDialog() == DialogResult.OK) { dgvPerfomance.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = performance.Equation; dgvPerfomance.Update(); } } else if (e.ColumnIndex == 3) { if (dgvPerfomance.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null) { strCriteria = dgvPerfomance.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); } FormAdvancedSearch formAdvancedSearch = new FormAdvancedSearch(m_strNetwork, m_hashAttributeYear, strCriteria, true); if (formAdvancedSearch.ShowDialog() == DialogResult.OK) { dgvPerfomance[e.ColumnIndex, e.RowIndex].Value = formAdvancedSearch.GetWhereClause(); } dgvPerfomance.Update(); } } } }
private void dataGridViewCalculatedAssets_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 3) { return; } if (e.ColumnIndex == 3) { if (dataGridViewCalculatedAssets[0, e.RowIndex].Value == null || dataGridViewCalculatedAssets[2, 0].Value == null) { return; } String strAsset = dataGridViewCalculatedAssets[0, e.RowIndex].Value.ToString(); String strType = dataGridViewCalculatedAssets[2, e.RowIndex].Value.ToString(); String strEquation = ""; if (dataGridViewCalculatedAssets[e.ColumnIndex, e.RowIndex].Value != null) { strEquation = dataGridViewCalculatedAssets[e.ColumnIndex, e.RowIndex].Value.ToString(); } FormEditAssetEquation formEquation = new FormEditAssetEquation(strEquation, strAsset, strType); if (formEquation.ShowDialog() == DialogResult.OK) { dataGridViewCalculatedAssets[e.ColumnIndex, e.RowIndex].Value = formEquation.Equation; } } if (e.ColumnIndex == 4) { if (dataGridViewCalculatedAssets[0, e.RowIndex].Value == null || dataGridViewCalculatedAssets[2, 0].Value == null) { return; } String strAsset = dataGridViewCalculatedAssets[0, e.RowIndex].Value.ToString(); String strType = dataGridViewCalculatedAssets[2, e.RowIndex].Value.ToString(); String strCriteria = ""; if (dataGridViewCalculatedAssets[e.ColumnIndex, e.RowIndex].Value != null) { strCriteria = dataGridViewCalculatedAssets[e.ColumnIndex, e.RowIndex].Value.ToString(); } FormAdvancedSearch formSearch = new FormAdvancedSearch(strCriteria, strAsset); if (formSearch.ShowDialog() == DialogResult.OK) { dataGridViewCalculatedAssets[e.ColumnIndex, e.RowIndex].Value = formSearch.Query; } } }
private void NetworkAdvancedSearch() { if (MainMapImage.Map.Layers.Count > 0) { ApplyOldColorsToGeoms(true); String strQuery = tbAdvancedSearch.Text; FormAdvancedSearch form = new FormAdvancedSearch(m_strNetworkID, m_strSimulationID, tbAdvancedSearch.Text); form.Text = "Attribute/Network Map"; if (form.ShowDialog() == DialogResult.OK) { tbAdvancedSearch.Text = form.GetWhereClause(); m_htAdvancedSearchOldColors.Clear(); String strSelect; strSelect = "SELECT SECTION_" + m_strNetworkID + ".SECTIONID"; String strFrom = DBOp.BuildFromStatement(m_strNetworkID, m_strSimulationID, true); strSelect += strFrom; String strWhere = tbAdvancedSearch.Text; strSelect += " WHERE " + strWhere; String strSectionID; Geometry geo; try { DataReader dr = new DataReader(strSelect); while (dr.Read()) { strSectionID = dr["SECTIONID"].ToString(); geo = (Geometry)MainMapImage.Map.Layers[0].GeoIDs[strSectionID]; if (geo != null) { m_htAdvancedSearchOldColors.Add(geo, geo.Color); geo.Color = Color.Gold; geo.Width_ = 3; } } dr.Close(); } catch (Exception exc) { Global.WriteOutput("Error: Advanced attribute search failed. " + exc.Message); return; } MainMapImage.Refresh(); } } }
private void AttributeAdvancedSearch() { String strQuery = tbAdvancedSearch.Text; FormAdvancedSearch form = new FormAdvancedSearch(m_strNetworkID, m_strSimulationID, tbAdvancedSearch.Text); form.Text = "Attribute/Network Map"; if (form.ShowDialog() == DialogResult.OK) { tbAdvancedSearch.Text = form.GetWhereClause(); if (!String.IsNullOrEmpty(m_strYear) && !String.IsNullOrEmpty(m_strAttribute)) { FormGISLayerManager formGISLayerManager; if (FormManager.IsFormGISLayerManagerOpen(out formGISLayerManager)) { DisplayAttribute(m_strAttribute, m_strYear, formGISLayerManager.GetLayerColors(m_strAttribute, m_strYear, m_strNetworkID), 1); } } } }
private void DataGridViewBudgetCriteria_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.ColumnIndex == 1 && e.RowIndex != -1) { if (Global.SecurityOperations.CanModifySimulationTreatment(m_strNetworkID, m_strSimID)) { var strCriteria = ""; if (dataGridViewBudgetCriteria.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null) { strCriteria = dataGridViewBudgetCriteria.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); } var formAdvancedSearch = new FormAdvancedSearch(m_strNetwork, m_hashAttributeYear, strCriteria, true); if (formAdvancedSearch.ShowDialog() == DialogResult.OK) { dataGridViewBudgetCriteria[e.ColumnIndex, e.RowIndex].Value = formAdvancedSearch.GetWhereClause(); } dataGridViewBudgetCriteria.Update(); } } }
private void buttonAdvancedSearch_Click(object sender, EventArgs e) { String strSimulationID = ""; String strSimulation = toolStripComboBoxSimulation.Text; if (strSimulation == "") { strSimulationID = ""; } else { strSimulationID = m_hashSimulationID[strSimulation].ToString(); } FormAdvancedSearch formSearch = new FormAdvancedSearch(m_strNetworkID, strSimulationID, textBoxAdvanceSearch.Text); if (formSearch.ShowDialog() == DialogResult.OK) { textBoxAdvanceSearch.Text = formSearch.GetWhereClause(); UpdateAttributeView(new List <String>(), true); } }
private void dataGridViewCompoundTreatmentElements_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { // Extent column or Quantity column if (e.ColumnIndex != -1) { // Select only one element at a time for editing if (dataGridViewCompoundTreatmentElements.SelectedCells.Count == 1) { // If the selected cell contains data if (e.RowIndex != -1) { CompoundTreatmentElement selectedCompoundElement = (CompoundTreatmentElement)dataGridViewCompoundTreatmentElements["colCompoundTreatmentElement", e.RowIndex].Value; if (selectedCompoundElement != null) { if (dataGridViewCompoundTreatmentElements.Columns["colExtent"].Index == e.ColumnIndex) { // Extent column selected FormEditEquation formEditCompoundElementEquation = new FormEditEquation(selectedCompoundElement.ExtentEquation.m_expression, _effectedTreatmentAttribute); if (formEditCompoundElementEquation.ShowDialog() == DialogResult.OK) { selectedCompoundElement.ExtentEquation.m_expression = formEditCompoundElementEquation.Equation; dataGridViewCompoundTreatmentElements[e.ColumnIndex, e.RowIndex].Value = formEditCompoundElementEquation.Equation; } } if (dataGridViewCompoundTreatmentElements.Columns["colQuantity"].Index == e.ColumnIndex) { // Quantity column selected FormEditEquation formEditCompoundElementEquation = new FormEditEquation(selectedCompoundElement.Quantity.m_expression, _effectedTreatmentAttribute); if (formEditCompoundElementEquation.ShowDialog() == DialogResult.OK) { selectedCompoundElement.Quantity.m_expression = formEditCompoundElementEquation.Equation; dataGridViewCompoundTreatmentElements[e.ColumnIndex, e.RowIndex].Value = formEditCompoundElementEquation.Equation; } } if (dataGridViewCompoundTreatmentElements.Columns["colCriteria"].Index == e.ColumnIndex) { // Criteria column selected FormAdvancedSearch formEditCriteria = new FormAdvancedSearch(selectedCompoundElement.CriteriaEquation.Criteria); if (formEditCriteria.ShowDialog() == DialogResult.OK) { selectedCompoundElement.CriteriaEquation.Criteria = formEditCriteria.GetWhereClause(); dataGridViewCompoundTreatmentElements[e.ColumnIndex, e.RowIndex].Value = formEditCriteria.GetWhereClause(); } } if (dataGridViewCompoundTreatmentElements.Columns["colCost"].Index == e.ColumnIndex) { // Cost column selected FormEditEquation formEditCompoundElementExtent = new FormEditEquation(selectedCompoundElement.CostEquation.m_expression, _effectedTreatmentAttribute); if (formEditCompoundElementExtent.ShowDialog() == DialogResult.OK) { selectedCompoundElement.CostEquation.m_expression = formEditCompoundElementExtent.Equation; dataGridViewCompoundTreatmentElements[e.ColumnIndex, e.RowIndex].Value = formEditCompoundElementExtent.Equation; } } } } else { if (dataGridViewCompoundTreatmentElements.Columns["colExtent"].Index == e.ColumnIndex) { // Extent column selected FormEditEquation formEditCompoundElementEquation = new FormEditEquation("", _effectedTreatmentAttribute); if (formEditCompoundElementEquation.ShowDialog() == DialogResult.OK) { dataGridViewCompoundTreatmentElements[e.ColumnIndex, e.RowIndex].Value = formEditCompoundElementEquation.Equation; } } if (dataGridViewCompoundTreatmentElements.Columns["colQuantity"].Index == e.ColumnIndex) { // Quantity column selected FormEditEquation formEditCompoundElementEquation = new FormEditEquation("", _effectedTreatmentAttribute); if (formEditCompoundElementEquation.ShowDialog() == DialogResult.OK) { dataGridViewCompoundTreatmentElements[e.ColumnIndex, e.RowIndex].Value = formEditCompoundElementEquation.Equation; } } if (dataGridViewCompoundTreatmentElements.Columns["colCriteria"].Index == e.ColumnIndex) { // Criteria column selected FormAdvancedSearch formEditCriteria = new FormAdvancedSearch(""); if (formEditCriteria.ShowDialog() == DialogResult.OK) { dataGridViewCompoundTreatmentElements[e.ColumnIndex, e.RowIndex].Value = formEditCriteria.GetWhereClause(); } } if (dataGridViewCompoundTreatmentElements.Columns["colCost"].Index == e.ColumnIndex) { // Cost column selected FormEditEquation formEditCompoundElementExtent = new FormEditEquation("", _effectedTreatmentAttribute); if (formEditCompoundElementExtent.ShowDialog() == DialogResult.OK) { dataGridViewCompoundTreatmentElements[e.ColumnIndex, e.RowIndex].Value = formEditCompoundElementExtent.Equation; } } } } } }
private void ORACLEdgvCalculatedCellDoubleClick(DataGridViewCellEventArgs e) { int nRow = e.RowIndex; int nColumn = e.ColumnIndex; String strID = ""; if (nColumn == 0) //Edit equations { String strEquation = ""; String isFunctionTag = "0"; bool isFunction = false; if (dgvCalculated[nColumn, nRow].Value != null) { strEquation = dgvCalculated[nColumn, nRow].Value.ToString(); isFunctionTag = dgvCalculated[0, nRow].Tag.ToString(); if (isFunctionTag == "1") { isFunction = true; } } FormEditEquation formEditEquation = new FormEditEquation(strEquation, false, isFunction); formEditEquation.CalculatedField = true; if (formEditEquation.ShowDialog() == DialogResult.OK) { if (formEditEquation.IsFunction) { dgvCalculated[0, nRow].Tag = "1"; } else { dgvCalculated[0, nRow].Tag = "0"; } dgvCalculated[e.ColumnIndex, e.RowIndex].Value = formEditEquation.Equation; if (dgvCalculated.Rows[nRow].Tag == null) //Insert new { dgvCalculated.Rows.Add(); try { strEquation = formEditEquation.Equation; String strInsert = "INSERT INTO ATTRIBUTES_CALCULATED (ATTRIBUTE_,EQUATION,ISFUNCTION)VALUES('" + this.Attribute + "','" + strEquation + "','" + dgvCalculated[0, nRow].Tag.ToString() + "')"; DBMgr.ExecuteNonQuery(strInsert); dgvCalculated.Rows[nRow].Tag = DBMgr.GetCurrentAutoIncrement("ATTRIBUTES_CALCULATED").ToString(); dgvCalculated[nColumn, nRow].Value = strEquation; dgvCalculated.Update(); } catch (Exception exception) { Global.WriteOutput("Error: Inserting EQUATION for Calculated Fields." + exception.Message); } } else //Update existing { try { strEquation = formEditEquation.Equation; strID = dgvCalculated.Rows[nRow].Tag.ToString(); string strUpdate = "UPDATE ATTRIBUTES_CALCULATED SET EQUATION='" + strEquation + "', ISFUNCTION='" + dgvCalculated[0, nRow].Tag.ToString() + "' WHERE ID_='" + strID + "'"; DBMgr.ExecuteNonQuery(strUpdate); } catch (Exception exception) { Global.WriteOutput("Error: Updating EQUATION for Calculated Fields." + exception.Message); } } } } else // Edit criteria { String strCriteria = ""; if (dgvCalculated[nColumn, nRow].Value != null) { strCriteria = dgvCalculated[nColumn, nRow].Value.ToString(); } FormAdvancedSearch formAdvancedSearch = new FormAdvancedSearch(strCriteria); if (formAdvancedSearch.ShowDialog() == DialogResult.OK) { //SqlParameter param0 = new SqlParameter("@criteria", SqlDbType.VarBinary, -1); dgvCalculated[e.ColumnIndex, e.RowIndex].Value = formAdvancedSearch.Query; if (dgvCalculated.Rows[nRow].Tag == null) //Insert new { try { strCriteria = formAdvancedSearch.Query; dgvCalculated[nColumn, nRow].Value = strCriteria; strCriteria = strCriteria.Replace("'", "|"); string strInsert = "INSERT INTO ATTRIBUTES_CALCULATED (ATTRIBUTE_,EQUATION,CRITERIA)VALUES('" + this.Attribute + "','','" + strCriteria + "')"; DBMgr.ExecuteNonQuery(strInsert); dgvCalculated.Rows[nRow].Tag = DBMgr.GetCurrentAutoIncrement("ATTRIBUTES_CALCULATED"); dgvCalculated.Rows.Add(); dgvCalculated.Update(); dgvCalculated.Refresh(); } catch (Exception exception) { Global.WriteOutput("Error: Inserting Criteria for Calculated Fields." + exception.Message); } } else //Update existing { try { strCriteria = formAdvancedSearch.Query; dgvCalculated[nColumn, nRow].Value = strCriteria; strCriteria = strCriteria.Replace("'", "|"); strID = dgvCalculated.Rows[nRow].Tag.ToString(); string strUpdate = "UPDATE ATTRIBUTES_CALCULATED SET CRITERIA='" + strCriteria + "' WHERE ID_='" + strID + "'"; DBMgr.ExecuteNonQuery(strUpdate); dgvCalculated.Update(); } catch (Exception exception) { Global.WriteOutput("Error: Updating CRITERIA for Calculated Fields." + exception.Message); } } } } dgvCalculated.Update(); }
private void MSSQLdgvCalculatedCellDoubleClick(DataGridViewCellEventArgs e) { int nRow = e.RowIndex; int nColumn = e.ColumnIndex; String strID = ""; if (nColumn == 0) //Edit equations { String strEquation = ""; String isFunctionTag = "0"; bool isFunction = false; if (dgvCalculated[nColumn, nRow].Value != null) { strEquation = dgvCalculated[nColumn, nRow].Value.ToString(); } FormEditEquation formEditEquation = new FormEditEquation(strEquation, false, isFunction); formEditEquation.CalculatedField = true; if (formEditEquation.ShowDialog() == DialogResult.OK) { if (dgvCalculated.Rows[nRow].Tag == null) //Insert new { try { strEquation = formEditEquation.Equation; dgvCalculated.Rows.Add(); String strInsert = "INSERT INTO ATTRIBUTES_CALCULATED (ATTRIBUTE_,EQUATION,ISFUNCTION)VALUES('" + this.Attribute + "','" + strEquation + "','0')"; SqlCommand command = new SqlCommand(strInsert, DBMgr.NativeConnectionParameters.SqlConnection); command.ExecuteNonQuery(); String strIdentity = "SELECT IDENT_CURRENT ('ATTRIBUTES_CALCULATED') FROM ATTRIBUTES_CALCULATED"; DataSet ds = DBMgr.ExecuteQuery(strIdentity); strIdentity = ds.Tables[0].Rows[0].ItemArray[0].ToString(); dgvCalculated.Rows[nRow].Tag = strIdentity; dgvCalculated[nColumn, nRow].Value = strEquation; dgvCalculated.Update(); dgvCalculated[e.ColumnIndex, e.RowIndex].Value = formEditEquation.Equation; } catch (Exception exception) { Global.WriteOutput("Error: Inserting EQUATION for Calculated Fields." + exception.Message); } } else //Update existing { try { strEquation = formEditEquation.Equation; strID = dgvCalculated.Rows[nRow].Tag.ToString(); String strUpdate = "UPDATE ATTRIBUTES_CALCULATED SET EQUATION='" + strEquation + "', ISFUNCTION='0' WHERE ID_='" + strID + "'"; SqlCommand command = new SqlCommand(strUpdate, DBMgr.NativeConnectionParameters.SqlConnection); command.ExecuteNonQuery(); dgvCalculated[e.ColumnIndex, e.RowIndex].Value = formEditEquation.Equation; } catch (Exception exception) { Global.WriteOutput("Error: Updating EQUATION for Calculated Fields." + exception.Message); } } } } else // Edit criteria { String strCriteria = ""; if (dgvCalculated[nColumn, nRow].Value != null) { strCriteria = dgvCalculated[nColumn, nRow].Value.ToString(); } FormAdvancedSearch formAdvancedSearch = new FormAdvancedSearch(strCriteria); if (formAdvancedSearch.ShowDialog() == DialogResult.OK) { dgvCalculated[nColumn, nRow].Value = formAdvancedSearch.Query; SqlParameter param0 = new SqlParameter("@criteria", SqlDbType.VarBinary, -1); if (dgvCalculated.Rows[nRow].Tag == null) //Insert new { try { strCriteria = formAdvancedSearch.Query; dgvCalculated[nColumn, nRow].Value = strCriteria; strCriteria = strCriteria.Replace("'", "|"); String strInsert = "INSERT INTO ATTRIBUTES_CALCULATED (ATTRIBUTE_,EQUATION,CRITERIA)VALUES('" + this.Attribute + "','','" + strCriteria + "')"; SqlCommand command = new SqlCommand(strInsert, DBMgr.NativeConnectionParameters.SqlConnection); command.ExecuteNonQuery(); String strIdentity = "SELECT IDENT_CURRENT ('ATTRIBUTES_CALCULATED') FROM ATTRIBUTES_CALCULATED"; DataSet ds = DBMgr.ExecuteQuery(strIdentity); strIdentity = ds.Tables[0].Rows[0].ItemArray[0].ToString(); dgvCalculated.Rows[nRow].Tag = strIdentity; dgvCalculated.Rows.Add(); dgvCalculated.Update(); dgvCalculated.Refresh(); } catch (Exception exception) { Global.WriteOutput("Error: Inserting Criteria for Calculated Fields." + exception.Message); } } else //Update existing { try { strCriteria = formAdvancedSearch.Query; dgvCalculated[nColumn, nRow].Value = strCriteria; strCriteria = strCriteria.Replace("'", "|"); strID = dgvCalculated.Rows[nRow].Tag.ToString(); String strUpdate = "UPDATE ATTRIBUTES_CALCULATED SET CRITERIA='" + strCriteria + "' WHERE ID_='" + strID + "'"; SqlCommand command = new SqlCommand(strUpdate, DBMgr.NativeConnectionParameters.SqlConnection); command.ExecuteNonQuery(); dgvCalculated.Update(); } catch (Exception exception) { Global.WriteOutput("Error: Updating CRITERIA for Calculated Fields." + exception.Message); } } } } dgvCalculated.Update(); }