private void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtDestinationField.Text)) { MsgBox.ShowError("Destination field is blank."); this.DialogResult = DialogResult.None; return; } if (cbxFieldType.SelectedIndex == 1 && cbxFieldType.Text == "Numeric") { foreach (DataRow row in RecodeTable.Rows) { string textValue = row["Representation"].ToString(); double value; bool success = double.TryParse(textValue, out value); if (!success && !string.IsNullOrEmpty(textValue)) { MsgBox.ShowError("The destination field type has been defined as numeric, but the destination values are not valid numbers."); 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.ToLowerInvariant().Equals(s.ToLowerInvariant())) { MsgBox.ShowError("Destination field 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.ToLowerInvariant().Equals(assignmentRule.DestinationColumnName.ToLowerInvariant())) { MsgBox.ShowError("Destination field name already exists as a defined field with recoded values. Please use another field name."); this.DialogResult = DialogResult.None; return; } } } } string friendlyRule = "Recode the values in " + sourceColumnName + " to " + txtDestinationField.Text + ""; string sourceColumnType = dashboardHelper.GetColumnType(sourceColumnName); RecodeRule = new Rule_Recode(this.DashboardHelper, friendlyRule, sourceColumnName, sourceColumnType, txtDestinationField.Text, DestinationFieldType, RecodeTable, txtElseValue.Text, checkboxMaintainSortOrder.Checked, checkboxUseWildcards.Checked); }
private void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtDestinationField.Text)) { MsgBox.ShowError(DashboardSharedStrings.EXPRESSION_ASSIGN_DESTINATION_FIELD_BLANK); this.DialogResult = DialogResult.None; return; } if (!editMode) { foreach (string s in dashboardHelper.GetFieldsAsList()) { if (txtDestinationField.Text.ToLowerInvariant().Equals(s.ToLowerInvariant())) { MsgBox.ShowError(DashboardSharedStrings.EXPRESSION_ASSIGN_DESTINATION_FIELD_ALREADY_EXISTS); this.DialogResult = DialogResult.None; return; } } 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(DashboardSharedStrings.EXPRESSION_ASSIGN_DESTINATION_FIELD_ALREADY_EXISTS_AS_RECODED); this.DialogResult = DialogResult.None; return; } } } } if (cbxDataType.Text.Equals("Text")) { AssignRule = new Rule_ExpressionAssign(this.dashboardHelper, "Assign " + txtDestinationField.Text + " the expression: " + txtExpression.Text, txtDestinationField.Text, "System.String", txtExpression.Text); } else if (cbxDataType.Text.Equals("Date/Time")) { AssignRule = new Rule_ExpressionAssign(this.dashboardHelper, "Assign " + txtDestinationField.Text + " the expression: " + txtExpression.Text, txtDestinationField.Text, "System.DateTime", txtExpression.Text); } else { AssignRule = new Rule_ExpressionAssign(this.dashboardHelper, "Assign " + txtDestinationField.Text + " the expression: " + txtExpression.Text, txtDestinationField.Text, txtExpression.Text); } this.DialogResult = DialogResult.OK; this.Close(); }
private void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtDestinationField.Text)) { MsgBox.ShowError("Destination field is blank."); this.DialogResult = DialogResult.None; return; } else if (cbxFormatOptions.SelectedIndex < 0) { MsgBox.ShowError("No format options selected."); this.DialogResult = DialogResult.None; return; } if (!editMode) { foreach (string s in dashboardHelper.GetFieldsAsList()) { if (txtDestinationField.Text.ToLowerInvariant().Equals(s.ToLowerInvariant())) { MsgBox.ShowError("Destination field 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.ToLowerInvariant().Equals(assignmentRule.DestinationColumnName.ToLowerInvariant())) { MsgBox.ShowError("Destination field name already exists as a defined field with recoded values. Please use another field name."); this.DialogResult = DialogResult.None; return; } } } } FormatRule = new Rule_Format(this.dashboardHelper, "Format the display of " + cbxFieldName.SelectedItem.ToString() + " to show " + cbxFormatOptions.SelectedItem.ToString() + " and place the formatted values in " + txtDestinationField.Text, cbxFieldName.SelectedItem.ToString(), txtDestinationField.Text, cbxFormatOptions.SelectedItem.ToString(), GetFormatType()); this.DialogResult = DialogResult.OK; this.Close(); }
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 (!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 friendlyRule = "Recode the values in " + sourceColumnName + " to " + txtDestinationField.Text + ""; string sourceColumnType = dashboardHelper.GetColumnType(sourceColumnName); RecodeRule = new Rule_Recode(this.DashboardHelper, friendlyRule, sourceColumnName, sourceColumnType, txtDestinationField.Text, DestinationFieldType, RecodeTable, txtElseValue.Text, checkboxMaintainSortOrder.Checked, checkboxUseWildcards.Checked); }
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(); }
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(); }