Пример #1
0
        private void OnCellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.Cancel == true)
            {
                return;
            }

            if (!this.m_Grid.IsCurrentCellDirty)
            {
                return;
            }

            DataGridViewColumn c = this.m_Grid.Columns[e.ColumnIndex];

            if (c.Name != Strings.DATASHEET_AGE_GROUP_MAXIMUM_COLUMN_NAME)
            {
                return;
            }

            if (!ProjectUtilities.ProjectHasResults(this.Project))
            {
                return;
            }

            if (!ChartingUtilities.HasAgeClassUpdateTag(this.Project))
            {
                if (MessageBox.Show(
                        MessageStrings.PROMPT_AGE_GROUP_CHANGE,
                        "Age Group", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    this.m_Grid.CancelEdit();
                    this.ActiveControl = this.m_Grid;

                    e.Cancel = true;
                }
            }
        }
Пример #2
0
        protected override bool OnBoundTextBoxValidating(TextBox textBox, string columnName, string proposedValue)
        {
            if (!base.OnBoundTextBoxValidating(textBox, columnName, proposedValue))
            {
                return(false);
            }

            if (!ProjectUtilities.ProjectHasResults(this.Project))
            {
                return(true);
            }

            if (!ChartingUtilities.HasAgeClassUpdateTag(this.Project))
            {
                if (MessageBox.Show(
                        MessageStrings.PROMPT_AGE_TYPE_CHANGE,
                        "Age Type", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #3
0
        public override DataTable GetData(DataStore store, ChartDescriptor descriptor, DataSheet dataSheet)
        {
            if (ChartingUtilities.HasAgeClassUpdateTag(dataSheet.Project))
            {
                WinFormSession sess = (WinFormSession)dataSheet.Session;

                sess.SetStatusMessageWithEvents("Updating age related data...");
                dataSheet.Library.Save(store);
                sess.SetStatusMessageWithEvents(string.Empty);

                Debug.Assert(!ChartingUtilities.HasAgeClassUpdateTag(dataSheet.Project));
            }

            if (ChartingUtilities.HasTSTClassUpdateTag(dataSheet.Project))
            {
                WinFormSession sess = (WinFormSession)dataSheet.Session;

                sess.SetStatusMessageWithEvents("Updating TST related data...");
                dataSheet.Library.Save(store);
                sess.SetStatusMessageWithEvents(string.Empty);

                Debug.Assert(!ChartingUtilities.HasTSTClassUpdateTag(dataSheet.Project));
            }

            if (
                descriptor.DatasheetName == Strings.DATASHEET_OUTPUT_STRATUM_STATE_NAME ||
                descriptor.DatasheetName == Strings.DATASHEET_OUTPUT_STRATUM_TRANSITION_NAME)
            {
                if (descriptor.VariableName == Strings.STATE_CLASS_PROPORTION_VARIABLE_NAME)
                {
                    return(ChartingUtilities.CreateProportionChartData(
                               dataSheet.Scenario, descriptor, Strings.DATASHEET_OUTPUT_STRATUM_STATE_NAME, store));
                }
                else if (descriptor.VariableName == Strings.TRANSITION_PROPORTION_VARIABLE_NAME)
                {
                    return(ChartingUtilities.CreateProportionChartData(
                               dataSheet.Scenario, descriptor, Strings.DATASHEET_OUTPUT_STRATUM_TRANSITION_NAME, store));
                }
                else
                {
                    return(null);
                }
            }
            else if (
                descriptor.DatasheetName == Strings.DATASHEET_OUTPUT_STATE_ATTRIBUTE_NAME ||
                descriptor.DatasheetName == Strings.DATASHEET_OUTPUT_TRANSITION_ATTRIBUTE_NAME)
            {
                string[] s = descriptor.VariableName.Split('-');

                Debug.Assert(s.Count() == 2);
                Debug.Assert(s[0] == "stsim_AttrNormal" || s[0] == "stsim_AttrDensity");

                int    AttrId     = int.Parse(s[1], CultureInfo.InvariantCulture);
                bool   IsDensity  = (s[0] == "stsim_AttrDensity");
                string ColumnName = null;

                if (descriptor.DatasheetName == Strings.DATASHEET_OUTPUT_STATE_ATTRIBUTE_NAME)
                {
                    ColumnName = Strings.DATASHEET_STATE_ATTRIBUTE_TYPE_ID_COLUMN_NAME;
                }
                else
                {
                    ColumnName = Strings.DATASHEET_TRANSITION_ATTRIBUTE_TYPE_ID_COLUMN_NAME;
                }

                return(ChartingUtilities.CreateRawAttributeChartData(
                           dataSheet.Scenario, descriptor, dataSheet.Name, ColumnName, AttrId, IsDensity, store));
            }
            else if (descriptor.DatasheetName == Strings.OUTPUT_EXTERNAL_VARIABLE_VALUE_DATASHEET_NAME)
            {
                return(ChartingUtilities.CreateRawExternalVariableData(
                           dataSheet.Scenario, descriptor, store));
            }

            return(null);
        }