Пример #1
0
        protected override void Save(DataStore store)
        {
            base.Save(store);

            ChartingUtilities.UpdateTSTClassIfRequired(store, this.Project);
            ChartingUtilities.ClearTSTClassUpdateTag(this.Project);
        }
Пример #2
0
 public override string GetCacheTag(ChartDescriptor descriptor)
 {
     if (ChartingUtilities.DescriptorHasAgeReference(descriptor))
     {
         return(Constants.AGE_QUERY_CACHE_TAG);
     }
     else if (ChartingUtilities.DescriptorHasTSTReference(descriptor))
     {
         return(Constants.TST_QUERY_CACHE_TAG);
     }
     else
     {
         return(null);
     }
 }
Пример #3
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_TST_GROUP_MAXIMUM_COLUMN_NAME)
            {
                return;
            }

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

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

                    e.Cancel = true;
                }
            }
        }
Пример #4
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);
        }
Пример #5
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);
        }
Пример #6
0
        private static ValidationTable CreateClassBinValidationTable(
            Project project,
            string classTypeDatasheetName,
            string classTypeFrequencyColumnName,
            string classTypeMaximumColumnName,
            string classGroupDatasheetName,
            string classGroupMaximumColumnName,
            string validationTableName)
        {
            DataTable dt = new DataTable(validationTableName);

            dt.Locale = CultureInfo.InvariantCulture;

            dt.Columns.Add(new DataColumn(Strings.VALUE_MEMBER_COLUMN_NAME, typeof(long)));
            dt.Columns.Add(new DataColumn(Strings.DISPLAY_MEMBER_COLUMN_NAME, typeof(string)));

            List <ClassBinDescriptor> e = ChartingUtilities.GetClassBinGroupDescriptors(
                project,
                classGroupDatasheetName,
                classGroupMaximumColumnName);

            if (e == null)
            {
                e = ChartingUtilities.GetClassBinTypeDescriptors(
                    project,
                    classTypeDatasheetName,
                    classTypeFrequencyColumnName,
                    classTypeMaximumColumnName);
            }

            if (e != null)
            {
                foreach (ClassBinDescriptor d in e)
                {
                    long   Value   = Convert.ToInt64(d.Minimum);
                    string Display = null;

                    if (d.Maximum.HasValue)
                    {
                        if (d.Maximum.Value == d.Minimum)
                        {
                            Display = string.Format(CultureInfo.InvariantCulture, "{0}", d.Minimum);
                        }
                        else
                        {
                            Display = string.Format(CultureInfo.InvariantCulture, "{0}-{1}", d.Minimum, d.Maximum.Value);
                        }
                    }
                    else
                    {
                        Display = string.Format(CultureInfo.InvariantCulture, "{0}+", d.Minimum);
                    }

                    dt.Rows.Add(new object[] { Value, Display });
                }

                dt.Rows.Add(new object[] { Constants.INCLUDE_DATA_NULL_ID, "(unclassified)" });
            }

            return(new ValidationTable(
                       dt,
                       Strings.VALUE_MEMBER_COLUMN_NAME,
                       Strings.DISPLAY_MEMBER_COLUMN_NAME,
                       SortOrder.None));
        }
Пример #7
0
 protected override void OnRowsModified(object sender, DataSheetRowEventArgs e)
 {
     base.OnRowsModified(sender, e);
     ChartingUtilities.SetTSTClassUpdateTag(this.Project);
 }