コード例 #1
0
 /// <summary>
 /// Constructor for simple assignment
 /// </summary>
 public Rule_SimpleAssign(DashboardHelper dashboardHelper, string friendlyRule, string destinationColumnName, SimpleAssignType assignmentType, List <string> assignmentParameters)
 {
     this.friendlyRule          = friendlyRule;
     this.destinationColumnName = destinationColumnName;
     this.DashboardHelper       = dashboardHelper;
     this.variableType          = DashboardVariableType.Numeric;
     this.assignmentType        = assignmentType;
     this.destinationColumnType = GetDestinationColumnType(this.assignmentType);
     this.assignmentParameters  = assignmentParameters;
 }
コード例 #2
0
 /// <summary>
 /// Constructor for simple assignment
 /// </summary>
 public Rule_SimpleAssign(DashboardHelper dashboardHelper, string friendlyRule, string destinationColumnName, SimpleAssignType assignmentType, List<string> assignmentParameters)
 {
     this.friendlyRule = friendlyRule;
     this.destinationColumnName = destinationColumnName;
     this.DashboardHelper = dashboardHelper;
     this.variableType = DashboardVariableType.Numeric;
     this.assignmentType = assignmentType;
     this.destinationColumnType = GetDestinationColumnType(this.assignmentType);
     this.assignmentParameters = assignmentParameters;
 }
コード例 #3
0
        /// <summary>
        /// Creates the rule from an Xml element
        /// </summary>
        /// <param name="element">The XmlElement from which to create the rule</param>
        public override void CreateFromXml(System.Xml.XmlElement element)
        {
            foreach (XmlElement child in element.ChildNodes)
            {
                if (child.Name.Equals("friendlyRule"))
                {
                    this.friendlyRule = child.InnerText;
                }
                else if (child.Name.Equals("assignmentType"))
                {
                    this.assignmentType = ((SimpleAssignType)Int32.Parse(child.InnerText));
                }
                else if (child.Name.Equals("destinationColumnName"))
                {
                    this.destinationColumnName = child.InnerText;
                }
                else if (child.Name.Equals("destinationColumnType"))
                {
                    this.destinationColumnType = child.InnerText;
                }
                else if (child.Name.Equals("parameterList"))
                {
                    foreach (XmlElement parameter in child.ChildNodes)
                    {
                        if (parameter.Name.ToLower().Equals("parameter"))
                        {
                            AssignmentParameters.Add(parameter.InnerText);
                        }
                    }
                }
            }

            if (destinationColumnType.Equals("System.String"))
            {
                this.variableType = DashboardVariableType.Text;
            }
            else if (destinationColumnType.Equals("System.Single") || destinationColumnType.Equals("System.Double") || destinationColumnType.Equals("System.Decimal") || destinationColumnType.Equals("System.Int16") || destinationColumnType.Equals("System.Int32"))
            {
                this.variableType = DashboardVariableType.Numeric;
            }
        }
コード例 #4
0
        /// <summary>
        /// Gets the appropriate column type to create given the type of assignment being carried out
        /// </summary>
        /// <param name="sAssignmentType">The simple assign type</param>
        /// <returns>A string representing the type of a .NET DataColumn</returns>
        protected string GetDestinationColumnType(SimpleAssignType sAssignmentType)
        {
            switch (sAssignmentType)
            {
            case SimpleAssignType.DaysElapsed:
            case SimpleAssignType.HoursElapsed:
            case SimpleAssignType.MinutesElapsed:
            case SimpleAssignType.MonthsElapsed:
            case SimpleAssignType.YearsElapsed:
            case SimpleAssignType.TextToNumber:
            case SimpleAssignType.StringLength:
            case SimpleAssignType.FindText:
            case SimpleAssignType.Round:
                return("System.Decimal");

            case SimpleAssignType.Substring:
                return("System.String");

            case SimpleAssignType.TextToDate:
                return("System.DateTime");
            }

            return("System.Decimal");
        }
コード例 #5
0
        /// <summary>
        /// Constructor used for editing an existing format rule
        /// </summary>
        /// <param name="dashboardHelper">The dashboard helper to attach</param>
        public SimpleAssignDialog(DashboardHelper dashboardHelper, Rule_SimpleAssign assignRule)
        {
            InEditMode           = true;
            this.dashboardHelper = dashboardHelper;
            this.AssignRule      = assignRule;
            InitializeComponent();

            SimpleAssignType assignType = assignRule.AssignmentType;

            switch (assignType)
            {
            case SimpleAssignType.YearsElapsed:
                cbxAssignmentType.SelectedIndex = 0;
                break;

            case SimpleAssignType.MonthsElapsed:
                cbxAssignmentType.SelectedIndex = 1;
                break;

            case SimpleAssignType.DaysElapsed:
                cbxAssignmentType.SelectedIndex = 2;
                break;

            case SimpleAssignType.HoursElapsed:
                cbxAssignmentType.SelectedIndex = 3;
                break;

            case SimpleAssignType.MinutesElapsed:
                cbxAssignmentType.SelectedIndex = 4;
                break;

            case SimpleAssignType.Round:
                cbxAssignmentType.SelectedIndex = 5;
                break;

            case SimpleAssignType.TextToNumber:
                cbxAssignmentType.SelectedIndex = 6;
                break;

            case SimpleAssignType.StringLength:
                cbxAssignmentType.SelectedIndex = 7;
                break;

            case SimpleAssignType.FindText:
                cbxAssignmentType.SelectedIndex = 8;
                break;

            case SimpleAssignType.Substring:
                cbxAssignmentType.SelectedIndex = 9;
                break;

            case SimpleAssignType.Uppercase:
                cbxAssignmentType.SelectedIndex = 10;
                break;

            case SimpleAssignType.Lowercase:
                cbxAssignmentType.SelectedIndex = 11;
                break;

            case SimpleAssignType.AddDays:
                cbxAssignmentType.SelectedIndex = 12;
                break;

            case SimpleAssignType.DetermineNonExistantListValues:
                cbxAssignmentType.SelectedIndex = 13;
                break;

            case SimpleAssignType.CountCheckedCheckboxesInGroup:
                cbxAssignmentType.SelectedIndex = 14;
                break;

            case SimpleAssignType.CountYesMarkedYesNoFieldsInGroup:
                cbxAssignmentType.SelectedIndex = 15;
                break;

            case SimpleAssignType.DetermineCheckboxesCheckedInGroup:
                cbxAssignmentType.SelectedIndex = 16;
                break;

            case SimpleAssignType.DetermineYesMarkedYesNoFieldsInGroup:
                cbxAssignmentType.SelectedIndex = 17;
                break;

            case SimpleAssignType.CountNumericFieldsBetweenValuesInGroup:
                cbxAssignmentType.SelectedIndex = 18;
                break;

            case SimpleAssignType.CountNumericFieldsOutsideValuesInGroup:
                cbxAssignmentType.SelectedIndex = 19;
                break;

            case SimpleAssignType.FindSumNumericFieldsInGroup:
                cbxAssignmentType.SelectedIndex = 20;
                break;

            case SimpleAssignType.FindMeanNumericFieldsInGroup:
                cbxAssignmentType.SelectedIndex = 21;
                break;

            case SimpleAssignType.FindMaxNumericFieldsInGroup:
                cbxAssignmentType.SelectedIndex = 22;
                break;

            case SimpleAssignType.FindMinNumericFieldsInGroup:
                cbxAssignmentType.SelectedIndex = 23;
                break;

            case SimpleAssignType.CountFieldsWithMissingInGroup:
                cbxAssignmentType.SelectedIndex = 24;
                break;

            case SimpleAssignType.CountFieldsWithoutMissingInGroup:
                cbxAssignmentType.SelectedIndex = 25;
                break;

            case SimpleAssignType.DetermineFieldsWithMissingInGroup:
                cbxAssignmentType.SelectedIndex = 26;
                break;

            case SimpleAssignType.NumberToText:
                cbxAssignmentType.SelectedIndex = 27;
                break;

            case SimpleAssignType.StripDate:
                cbxAssignmentType.SelectedIndex = 28;
                break;

            case SimpleAssignType.TextToDate:
                cbxAssignmentType.SelectedIndex = 29;
                break;

            case SimpleAssignType.NumberToDate:
                cbxAssignmentType.SelectedIndex = 30;
                break;
            }

            FillSelectionComboBoxes();

            this.txtDestinationField.Text    = AssignRule.DestinationColumnName;
            this.txtDestinationField.Enabled = false;
        }
コード例 #6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtDestinationField.Text))
            {
                MsgBox.ShowError(SimpleAssignmentStrings.ERROR_DESTINATION_FIELD_MISSING);
                this.DialogResult = DialogResult.None;
                return;
            }

            if (cbxAssignmentType.SelectedIndex < 0)
            {
                MsgBox.ShowError(SimpleAssignmentStrings.ERROR_TYPE_MISSING);
                this.DialogResult = DialogResult.None;
                return;
            }

            if (
                (cbxParam1.Visible == true && string.IsNullOrEmpty(cbxParam1.Text)) ||
                (cbxParam2.Visible == true && string.IsNullOrEmpty(cbxParam2.Text)) ||
                (cbxParam3.Visible == true && string.IsNullOrEmpty(cbxParam3.Text))
                )
            {
                MsgBox.ShowError(SimpleAssignmentStrings.ERROR_PARAMS_BLANK);
                this.DialogResult = DialogResult.None;
                return;
            }

            bool overwritesPermanentField = false;

            if (this.AssignRule != null)
            {
                overwritesPermanentField = this.AssignRule.OverwritesPermanentField;
            }

            if (!editMode)
            {
                ColumnDataType columnDataType = ColumnDataType.Boolean | ColumnDataType.Numeric | ColumnDataType.Text;

                foreach (IDashboardRule rule in dashboardHelper.Rules)
                {
                    if (rule is DataAssignmentRule)
                    {
                        DataAssignmentRule assignmentRule = rule as DataAssignmentRule;
                        if (txtDestinationField.Text.ToLowerInvariant().Equals(assignmentRule.DestinationColumnName.ToLowerInvariant()))
                        {
                            MsgBox.ShowError(SimpleAssignmentStrings.ERROR_FIELD_ALREADY_EXISTS_WITH_RECODED_DATA);
                            this.DialogResult = DialogResult.None;
                            return;
                        }
                    }
                }

                foreach (string s in dashboardHelper.GetFieldsAsList(columnDataType))
                {
                    if (txtDestinationField.Text.ToLowerInvariant().Equals(s.ToLowerInvariant()))
                    {
                        System.Windows.Forms.DialogResult result = MsgBox.ShowQuestion(SimpleAssignmentStrings.OVERWRITE_FIELD_DATA);
                        if (result != System.Windows.Forms.DialogResult.Yes && result != System.Windows.Forms.DialogResult.OK)
                        {
                            this.DialogResult = DialogResult.None;
                            return;
                        }
                        else
                        {
                            overwritesPermanentField = true;
                        }
                    }
                }
            }

            string friendlyLabel = "Assign " + txtDestinationField.Text;

            string param1 = cbxParam1.Text.ToString();
            string param2 = cbxParam2.Text.ToString();
            string param3 = cbxParam3.Text.ToString();

            List <string> parameters = new List <string>();

            parameters.Add(param1);
            if (!string.IsNullOrEmpty(param2))
            {
                parameters.Add(param2);
            }
            if (!string.IsNullOrEmpty(param3))
            {
                parameters.Add(param3);
            }
            SimpleAssignType assignmentType = SimpleAssignType.YearsElapsed;

            //switch (cbxAssignmentType.SelectedItem.ToString())
            switch (cbxAssignmentType.SelectedIndex)
            {
            case 0:     //"Difference in years":
                friendlyLabel  = friendlyLabel + " the difference in years between " + param1 + " and " + param2;
                assignmentType = SimpleAssignType.YearsElapsed;
                break;

            case 1:     //"Difference in months":
                friendlyLabel  = friendlyLabel + " the difference in months between " + param1 + " and " + param2;
                assignmentType = SimpleAssignType.MonthsElapsed;
                break;

            case 2:     //"Difference in days":
                friendlyLabel  = friendlyLabel + " the difference in days between " + param1 + " and " + param2;
                assignmentType = SimpleAssignType.DaysElapsed;
                break;

            case 3:     //"Difference in hours":
                friendlyLabel  = friendlyLabel + " the difference in hours between " + param1 + " and " + param2;
                assignmentType = SimpleAssignType.HoursElapsed;
                break;

            case 4:     //"Difference in minutes":
                friendlyLabel  = friendlyLabel + " the difference in minutes between " + param1 + " and " + param2;
                assignmentType = SimpleAssignType.MinutesElapsed;
                break;

            case 5:     //"Round a number":
                friendlyLabel = friendlyLabel + " the rounded value of " + param1;
                if (!string.IsNullOrEmpty(param2))
                {
                    friendlyLabel = friendlyLabel + " to " + param2 + " decimal place(s)";
                }
                assignmentType = SimpleAssignType.Round;
                break;

            case 6:     //"Convert text data to numeric data":
                friendlyLabel  = friendlyLabel + " the numeric representation of " + param1;
                assignmentType = SimpleAssignType.TextToNumber;
                break;

            case 7:     //"Find the length of text data":
                friendlyLabel  = friendlyLabel + " the length of the text contained in " + param1;
                assignmentType = SimpleAssignType.StringLength;
                break;

            case 8:     //"Find the location of text data":
                friendlyLabel  = friendlyLabel + " the starting location of the text " + param2 + " contained in " + param1;
                assignmentType = SimpleAssignType.FindText;
                break;

            case 9:     //"Substring":
                friendlyLabel  = friendlyLabel + " the portion of the text contained in " + param1 + " starting at position " + param2 + " and continuing for " + param3 + " characters";
                assignmentType = SimpleAssignType.Substring;
                break;

            // New ones added after 7.0.9.48
            case 10:     //"Convert text characters to uppercase":
                friendlyLabel  = friendlyLabel + " the upper case equivalent of " + param1;
                assignmentType = SimpleAssignType.Uppercase;
                break;

            case 11:     //"Convert text characters to lower":
                friendlyLabel  = friendlyLabel + " the lower case equivalent of " + param1;
                assignmentType = SimpleAssignType.Lowercase;
                break;

            // New ones added after 7.0.9.51
            case 12:     //"Add days to a date field":
                friendlyLabel  = friendlyLabel + " the date value in " + param1 + " and add " + param2 + " days";
                assignmentType = SimpleAssignType.AddDays;
                break;

            case 13:     //"Determine if a drop-down list field contains a value not present in its code table":
                friendlyLabel  = friendlyLabel + " a Yes if the value in " + param1 + " appears in its corresponding code table";
                assignmentType = SimpleAssignType.DetermineNonExistantListValues;
                break;

            case 14:     //"Count the number of checked checkboxes in a group":
                friendlyLabel  = friendlyLabel + " the number of checked checkboxes in " + param1 + " (group field)";
                assignmentType = SimpleAssignType.CountCheckedCheckboxesInGroup;
                break;

            case 15:     //"Count the number of Yes-marked Yes/No fields in a group":
                friendlyLabel  = friendlyLabel + " the number of Yes-marked Yes/No fields in " + param1 + " (group field)";
                assignmentType = SimpleAssignType.CountYesMarkedYesNoFieldsInGroup;
                break;

            case 16:     //"Determine if more than N checkboxes are checked in a group":
                friendlyLabel  = friendlyLabel + " a Yes if more than " + param2 + " checkboxes are checked in " + param1 + " (group field)";
                assignmentType = SimpleAssignType.DetermineCheckboxesCheckedInGroup;
                break;

            case 17:     //"Determine if more than N Yes/No fields are marked Yes in a group":
                friendlyLabel  = friendlyLabel + " a Yes if more than " + param2 + " Yes/No fields are marked Yes in " + param1 + " (group field)";
                assignmentType = SimpleAssignType.DetermineYesMarkedYesNoFieldsInGroup;
                break;

            case 18:     //"Count the number of numeric fields with values between X and Y in a group":
                friendlyLabel  = friendlyLabel + " the number of numeric fields with values between (inclusive) " + param2 + " and " + param3 + " in " + param1 + " (group field)";
                assignmentType = SimpleAssignType.CountNumericFieldsBetweenValuesInGroup;
                break;

            case 19:     //"Count the number of numeric fields with values outside X and Y in a group":
                friendlyLabel  = friendlyLabel + " the number of numeric fields with values outside " + param2 + " and " + param3 + " in " + param1 + " (group field)";
                assignmentType = SimpleAssignType.CountNumericFieldsOutsideValuesInGroup;
                break;

            case 20:     //"Find the sum of all numeric fields in a group":
                friendlyLabel = friendlyLabel + " the sum of all numeric fields in " + param1 + " (group field).";
                if (param2 == dashboardHelper.Config.Settings.RepresentationOfYes)
                {
                    friendlyLabel = friendlyLabel + " Include Yes/No fields.";
                }
                else
                {
                    friendlyLabel = friendlyLabel + " Do not include Yes/No fields.";
                }
                if (param3 == dashboardHelper.Config.Settings.RepresentationOfYes)
                {
                    friendlyLabel = friendlyLabel + " Include Comment Legal fields.";
                }
                else
                {
                    friendlyLabel = friendlyLabel + " Do not include Comment Legal fields.";
                }
                assignmentType = SimpleAssignType.FindSumNumericFieldsInGroup;
                break;

            case 21:     //"Find the mean of all numeric fields in a group":
                friendlyLabel = friendlyLabel + " the mean of all numeric fields in " + param1 + " (group field).";
                if (param2 == dashboardHelper.Config.Settings.RepresentationOfYes)
                {
                    friendlyLabel = friendlyLabel + " Include Yes/No fields.";
                }
                else
                {
                    friendlyLabel = friendlyLabel + " Do not include Yes/No fields.";
                }
                if (param3 == dashboardHelper.Config.Settings.RepresentationOfYes)
                {
                    friendlyLabel = friendlyLabel + " Include Comment Legal fields.";
                }
                else
                {
                    friendlyLabel = friendlyLabel + " Do not include Comment Legal fields.";
                }
                assignmentType = SimpleAssignType.FindMeanNumericFieldsInGroup;
                break;

            case 22:     //"Find the maximum value of all numeric fields in a group":
                friendlyLabel  = friendlyLabel + " the maximum numeric value in " + param1 + " (group field)";
                assignmentType = SimpleAssignType.FindMaxNumericFieldsInGroup;
                break;

            case 23:     //"Find the minimum value of all numeric fields in a group":
                friendlyLabel  = friendlyLabel + " the minimum numeric value in " + param1 + " (group field)";
                assignmentType = SimpleAssignType.FindMinNumericFieldsInGroup;
                break;

            case 24:     //"Count the number of fields with missing values in a group":
                friendlyLabel  = friendlyLabel + " the number of fields with missing values in " + param1 + " (group field)";
                assignmentType = SimpleAssignType.CountFieldsWithMissingInGroup;
                break;

            case 25:     //"Count the number of fields without missing values in a group":
                friendlyLabel  = friendlyLabel + " the number of fields without missing values in " + param1 + " (group field)";
                assignmentType = SimpleAssignType.CountFieldsWithoutMissingInGroup;
                break;

            case 26:     //"Determine if more than N fields have missing values in a group":
                friendlyLabel  = friendlyLabel + " a Yes if more than " + param2 + " fields are missing in " + param1 + " (group field)";
                assignmentType = SimpleAssignType.DetermineFieldsWithMissingInGroup;
                break;

            case 27:     //"Convert numeric data to text data":
                friendlyLabel  = friendlyLabel + " the text representation of " + param1;
                assignmentType = SimpleAssignType.NumberToText;
                break;

            case 28:     //"Strip date":
                friendlyLabel  = friendlyLabel + " the date component of " + param1;
                assignmentType = SimpleAssignType.StripDate;
                break;

            case 29:     //"Convert text data to date data":
                friendlyLabel  = friendlyLabel + " the date representation of " + param1;
                assignmentType = SimpleAssignType.TextToDate;
                break;

            case 30:     //"Convert numeric data to date data":
                friendlyLabel  = friendlyLabel + " the date representation of " + param1 + "(day) and " + param2 + "(month) and " + param3 + "(year)";
                assignmentType = SimpleAssignType.NumberToDate;
                break;
            }

            AssignRule = new Rule_SimpleAssign(this.dashboardHelper, friendlyLabel, txtDestinationField.Text, assignmentType, parameters);
            AssignRule.OverwritesPermanentField = overwritesPermanentField;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
コード例 #7
0
        /// <summary>
        /// Creates the rule from an Xml element
        /// </summary>
        /// <param name="element">The XmlElement from which to create the rule</param>
        public override void CreateFromXml(System.Xml.XmlElement element)
        {
            foreach (XmlElement child in element.ChildNodes)
            {
                if (child.Name.Equals("friendlyRule"))
                {
                    this.friendlyRule = child.InnerText;
                }
                else if (child.Name.Equals("assignmentType"))
                {
                    this.assignmentType = ((SimpleAssignType)Int32.Parse(child.InnerText));
                }
                else if (child.Name.Equals("destinationColumnName"))
                {
                    this.destinationColumnName = child.InnerText;
                }
                else if (child.Name.Equals("destinationColumnType"))
                {
                    this.destinationColumnType = child.InnerText;
                }
                else if (child.Name.Equals("parameterList"))
                {
                    foreach (XmlElement parameter in child.ChildNodes)
                    {
                        if (parameter.Name.ToLower().Equals("parameter"))
                        {
                            if (parameter.Attributes.Count > 0 && parameter.Attributes[0].Value.ToLower().Equals("literal") && parameter.Attributes[1].Value.ToLower().Equals("ticks"))
                            {
                                DateTime dt = new DateTime(long.Parse(parameter.InnerText));
                                AssignmentParameters.Add(dt.ToString());
                            }
                            else
                            {
                                AssignmentParameters.Add(parameter.InnerText);
                            }
                        }
                    }
                }
            }

            if (destinationColumnType.Equals("System.String"))
            {
                this.variableType = DashboardVariableType.Text;
            }
            else if(destinationColumnType.Equals("System.Single") || destinationColumnType.Equals("System.Double") || destinationColumnType.Equals("System.Decimal") || destinationColumnType.Equals("System.Int16") || destinationColumnType.Equals("System.Int32"))
            {
                this.variableType = DashboardVariableType.Numeric;
            }
            else if (destinationColumnType.Equals("System.DateTime"))
            {
                this.variableType = DashboardVariableType.Date;
            }
        }
コード例 #8
0
        /// <summary>
        /// Gets the appropriate column type to create given the type of assignment being carried out
        /// </summary>
        /// <param name="sAssignmentType">The simple assign type</param>
        /// <returns>A string representing the type of a .NET DataColumn</returns>
        protected string GetDestinationColumnType(SimpleAssignType sAssignmentType)
        {
            switch (sAssignmentType)
            {
                case SimpleAssignType.DaysElapsed:
                case SimpleAssignType.HoursElapsed:
                case SimpleAssignType.MinutesElapsed:
                case SimpleAssignType.MonthsElapsed:
                case SimpleAssignType.YearsElapsed:
                case SimpleAssignType.TextToNumber:
                case SimpleAssignType.StringLength:
                case SimpleAssignType.FindText:
                case SimpleAssignType.Round:
                case SimpleAssignType.CountCheckedCheckboxesInGroup:
                case SimpleAssignType.CountYesMarkedYesNoFieldsInGroup:
                case SimpleAssignType.CountNumericFieldsBetweenValuesInGroup:
                case SimpleAssignType.CountNumericFieldsOutsideValuesInGroup:
                case SimpleAssignType.FindSumNumericFieldsInGroup:
                case SimpleAssignType.FindMeanNumericFieldsInGroup:
                case SimpleAssignType.FindMaxNumericFieldsInGroup:
                case SimpleAssignType.FindMinNumericFieldsInGroup:
                case SimpleAssignType.CountFieldsWithMissingInGroup:
                case SimpleAssignType.CountFieldsWithoutMissingInGroup:
                    return "System.Decimal";
                case SimpleAssignType.Substring:
                case SimpleAssignType.Uppercase:
                case SimpleAssignType.Lowercase:
                case SimpleAssignType.NumberToText:
                    return "System.String";
                case SimpleAssignType.TextToDate:
                case SimpleAssignType.AddDays:
                case SimpleAssignType.StripDate:
                    return "System.DateTime";
                case SimpleAssignType.DetermineNonExistantListValues:
                case SimpleAssignType.DetermineCheckboxesCheckedInGroup:
                case SimpleAssignType.DetermineYesMarkedYesNoFieldsInGroup:
                case SimpleAssignType.DetermineFieldsWithMissingInGroup:
                    return "System.Boolean";
            }

            return "System.Decimal";
        }
コード例 #9
0
        /// <summary>
        /// Constructor used for editing an existing format rule
        /// </summary>
        /// <param name="dashboardHelper">The dashboard helper to attach</param>
        public SimpleAssignDialog(DashboardHelper dashboardHelper, Rule_SimpleAssign assignRule)
        {
            InEditMode           = true;
            this.dashboardHelper = dashboardHelper;
            this.AssignRule      = assignRule;
            InitializeComponent();

            SimpleAssignType assignType = assignRule.AssignmentType;

            switch (assignType)
            {
            case SimpleAssignType.YearsElapsed:
                cbxAssignmentType.SelectedIndex = 0;
                break;

            case SimpleAssignType.MonthsElapsed:
                cbxAssignmentType.SelectedIndex = 1;
                break;

            case SimpleAssignType.DaysElapsed:
                cbxAssignmentType.SelectedIndex = 2;
                break;

            case SimpleAssignType.HoursElapsed:
                cbxAssignmentType.SelectedIndex = 3;
                break;

            case SimpleAssignType.MinutesElapsed:
                cbxAssignmentType.SelectedIndex = 4;
                break;

            case SimpleAssignType.Round:
                cbxAssignmentType.SelectedIndex = 5;
                break;

            case SimpleAssignType.TextToNumber:
                cbxAssignmentType.SelectedIndex = 6;
                break;

            case SimpleAssignType.StringLength:
                cbxAssignmentType.SelectedIndex = 7;
                break;

            case SimpleAssignType.FindText:
                cbxAssignmentType.SelectedIndex = 8;
                break;

            case SimpleAssignType.Substring:
                cbxAssignmentType.SelectedIndex = 9;
                break;

            case SimpleAssignType.TextToDate:
                cbxAssignmentType.SelectedIndex = 10;
                break;
            }

            FillSelectionComboBoxes();

            this.txtDestinationField.Text    = AssignRule.DestinationColumnName;
            this.txtDestinationField.Enabled = false;
        }
コード例 #10
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtDestinationField.Text))
            {
                MsgBox.ShowError("Destination fields is blank.");
                this.DialogResult = DialogResult.None;
                return;
            }

            if (cbxAssignmentType.SelectedIndex < 0)
            {
                MsgBox.ShowError("Assignment type is blank.");
                this.DialogResult = DialogResult.None;
                return;
            }

            if (
                (cbxParam1.Visible == true && string.IsNullOrEmpty(cbxParam1.Text)) ||
                (cbxParam2.Visible == true && string.IsNullOrEmpty(cbxParam2.Text)) ||
                (cbxParam3.Visible == true && string.IsNullOrEmpty(cbxParam3.Text))
                )
            {
                MsgBox.ShowError("One or more required parameters are blank.");
                this.DialogResult = DialogResult.None;
                return;
            }

            if (!editMode)
            {
                ColumnDataType columnDataType = ColumnDataType.Boolean | ColumnDataType.Numeric | ColumnDataType.Text;
                foreach (string s in dashboardHelper.GetFieldsAsList(columnDataType))
                {
                    if (txtDestinationField.Text.ToLower().Equals(s.ToLower()))
                    {
                        MsgBox.ShowError("Destination fields name already exists as a column in this data set. Please use another name.");
                        this.DialogResult = DialogResult.None;
                        return;
                    }
                }

                foreach (IDashboardRule rule in dashboardHelper.Rules)
                {
                    if (rule is DataAssignmentRule)
                    {
                        DataAssignmentRule assignmentRule = rule as DataAssignmentRule;
                        if (txtDestinationField.Text.ToLower().Equals(assignmentRule.DestinationColumnName.ToLower()))
                        {
                            MsgBox.ShowError("Destination fields name already exists as a defined fields with recoded values. Please use another fields name.");
                            this.DialogResult = DialogResult.None;
                            return;
                        }
                    }
                }
            }

            string friendlyLabel = "Assign to " + txtDestinationField.Text;

            string param1 = cbxParam1.Text.ToString();
            string param2 = cbxParam2.Text.ToString();
            string param3 = cbxParam3.Text.ToString();

            List <string> parameters = new List <string>();

            parameters.Add(param1);
            if (!string.IsNullOrEmpty(param2))
            {
                parameters.Add(param2);
            }
            if (!string.IsNullOrEmpty(param3))
            {
                parameters.Add(param3);
            }
            SimpleAssignType assignmentType = SimpleAssignType.YearsElapsed;

            switch (cbxAssignmentType.SelectedItem.ToString())
            {
            case "Difference in years":
                friendlyLabel  = friendlyLabel + " the difference in years between " + param1 + " and " + param2;
                assignmentType = SimpleAssignType.YearsElapsed;
                break;

            case "Difference in months":
                friendlyLabel  = friendlyLabel + " the difference in months between " + param1 + " and " + param2;
                assignmentType = SimpleAssignType.MonthsElapsed;
                break;

            case "Difference in days":
                friendlyLabel  = friendlyLabel + " the difference in days between " + param1 + " and " + param2;
                assignmentType = SimpleAssignType.DaysElapsed;
                break;

            case "Difference in hours":
                friendlyLabel  = friendlyLabel + " the difference in hours between " + param1 + " and " + param2;
                assignmentType = SimpleAssignType.HoursElapsed;
                break;

            case "Difference in minutes":
                friendlyLabel  = friendlyLabel + " the difference in minutes between " + param1 + " and " + param2;
                assignmentType = SimpleAssignType.MinutesElapsed;
                break;

            case "Round a number":
                friendlyLabel = friendlyLabel + " the rounded value of " + param1;
                if (!string.IsNullOrEmpty(param2))
                {
                    friendlyLabel = friendlyLabel + " to " + param2 + " decimal place(s)";
                }
                assignmentType = SimpleAssignType.Round;
                break;

            case "Convert text data to numeric data":
                friendlyLabel  = friendlyLabel + " the numeric representation of " + param1;
                assignmentType = SimpleAssignType.TextToNumber;
                break;

            case "Convert text data to date data":
                friendlyLabel  = friendlyLabel + " the numeric representation of " + param1;
                assignmentType = SimpleAssignType.TextToDate;
                break;

            case "Find the length of text data":
                friendlyLabel  = friendlyLabel + " the length of the text contained in " + param1;
                assignmentType = SimpleAssignType.StringLength;
                break;

            case "Find the location of text data":
                friendlyLabel  = friendlyLabel + " the starting location of the text " + param2 + " contained in " + param1;
                assignmentType = SimpleAssignType.FindText;
                break;

            case "Substring":
                friendlyLabel  = friendlyLabel + " the portion of the text contained in " + param1 + " starting at position " + param2 + " and continuing for " + param3 + " characters";
                assignmentType = SimpleAssignType.Substring;
                break;
            }

            AssignRule        = new Rule_SimpleAssign(this.dashboardHelper, friendlyLabel, txtDestinationField.Text, assignmentType, parameters);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }