Exemple #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (listBoxItems.SelectedItems.Count <= 0)
            {
                Epi.Windows.MsgBox.ShowError(DashboardSharedStrings.CREATE_VAR_GROUP_NO_FIELDS_SELECTED);
                this.DialogResult = System.Windows.Forms.DialogResult.None;
                return;
            }

            if (!editMode && (dashboardHelper.GetFieldsAsList().Contains(txtGroupField.Text) || dashboardHelper.GetAllGroupsAsList().Contains(txtGroupField.Text)))
            {
                Epi.Windows.MsgBox.ShowError(DashboardSharedStrings.CREATE_VAR_GROUP_FIELD_ALREADY_EXISTS);
                this.DialogResult = System.Windows.Forms.DialogResult.None;
                return;
            }

            if (string.IsNullOrEmpty(txtGroupField.Text))
            {
                Epi.Windows.MsgBox.ShowError(DashboardSharedStrings.CREATE_VAR_GROUP_NO_NAME_SPECIFIED);
                this.DialogResult = System.Windows.Forms.DialogResult.None;
                return;
            }

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

            foreach (string item in listBoxItems.SelectedItems)
            {
                items.Add(item);
            }

            group = new Rule_VariableGroup(this.dashboardHelper, txtGroupField.Text, items);
        }
Exemple #2
0
 public CreateGroupDialog(DashboardHelper dashboardHelper, Rule_VariableGroup group)
 {
     InitializeComponent();
     this.dashboardHelper    = dashboardHelper;
     this.group              = group;
     this.txtGroupField.Text = group.GroupName;
     editMode = true;
 }
        private void btnEditRule_Click(object sender, RoutedEventArgs e)
        {
            if (lbxRules.SelectedItems != null && lbxRules.SelectedItems.Count == 1)
            {
                Rule_Recode            recodeRule            = null;
                Rule_Format            formatRule            = null;
                Rule_ExpressionAssign  expressionAssignRule  = null;
                Rule_SimpleAssign      simpleAssignRule      = null;
                Rule_ConditionalAssign conditionalAssignRule = null;
                Rule_VariableGroup     variableGroupRule     = null;

                foreach (IDashboardRule rule in dashboardHelper.Rules)
                {
                    if (rule.FriendlyRule.Equals(lbxRules.SelectedItem.ToString()))
                    {
                        if (rule is Rule_Recode)
                        {
                            recodeRule = rule as Rule_Recode;
                            break;
                        }
                        else if (rule is Rule_Format)
                        {
                            formatRule = rule as Rule_Format;
                            break;
                        }
                        else if (rule is Rule_ExpressionAssign)
                        {
                            expressionAssignRule = rule as Rule_ExpressionAssign;
                            break;
                        }
                        else if (rule is Rule_SimpleAssign)
                        {
                            simpleAssignRule = rule as Rule_SimpleAssign;
                            break;
                        }
                        else if (rule is Rule_ConditionalAssign)
                        {
                            conditionalAssignRule = rule as Rule_ConditionalAssign;
                            break;
                        }
                        else if (rule is Rule_VariableGroup)
                        {
                            variableGroupRule = rule as Rule_VariableGroup;
                            break;
                        }
                    }
                }

                System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.None;

                if (recodeRule != null)
                {
                    EpiDashboard.Dialogs.RecodeDialog recodeDialog = new EpiDashboard.Dialogs.RecodeDialog(this.dashboardHelper, recodeRule);
                    result = recodeDialog.ShowDialog();

                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        dashboardHelper.UpdateRule(recodeRule, recodeDialog.RecodeRule);
                        UpdateRules();
                        if (UserVariableChanged != null)
                        {
                            UserVariableChanged(this, new EventArgs());
                        }
                    }
                }
                else if (formatRule != null)
                {
                    EpiDashboard.Dialogs.FormatDialog formatDialog = new EpiDashboard.Dialogs.FormatDialog(this.dashboardHelper, formatRule);
                    result = formatDialog.ShowDialog();

                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        dashboardHelper.UpdateRule(formatRule, formatDialog.FormatRule);
                        UpdateRules();
                        if (UserVariableChanged != null)
                        {
                            UserVariableChanged(this, new EventArgs());
                        }
                    }
                }
                else if (expressionAssignRule != null)
                {
                    EpiDashboard.Dialogs.ExpressionAssignDialog assignDialog = new EpiDashboard.Dialogs.ExpressionAssignDialog(this.dashboardHelper, expressionAssignRule);
                    result = assignDialog.ShowDialog();

                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        dashboardHelper.UpdateRule(expressionAssignRule, assignDialog.AssignRule);
                        UpdateRules();
                        if (UserVariableChanged != null)
                        {
                            UserVariableChanged(this, new EventArgs());
                        }
                    }
                }
                else if (simpleAssignRule != null)
                {
                    EpiDashboard.Dialogs.SimpleAssignDialog assignDialog = new EpiDashboard.Dialogs.SimpleAssignDialog(this.dashboardHelper, simpleAssignRule);
                    result = assignDialog.ShowDialog();

                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        dashboardHelper.UpdateRule(simpleAssignRule, assignDialog.AssignRule);
                        UpdateRules();
                        if (UserVariableChanged != null)
                        {
                            UserVariableChanged(this, new EventArgs());
                        }
                    }
                }
                else if (conditionalAssignRule != null)
                {
                    EpiDashboard.Dialogs.ConditionalAssignDialog assignDialog = new EpiDashboard.Dialogs.ConditionalAssignDialog(this.dashboardHelper, conditionalAssignRule);
                    result = assignDialog.ShowDialog();

                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        dashboardHelper.UpdateRule(conditionalAssignRule, assignDialog.AssignRule);
                        UpdateRules();
                        if (UserVariableChanged != null)
                        {
                            UserVariableChanged(this, new EventArgs());
                        }
                    }
                }
                else if (variableGroupRule != null)
                {
                    EpiDashboard.Dialogs.CreateGroupDialog groupDialog = new EpiDashboard.Dialogs.CreateGroupDialog(this.dashboardHelper, variableGroupRule);
                    result = groupDialog.ShowDialog();

                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        dashboardHelper.UpdateRule(variableGroupRule, groupDialog.Group);
                        UpdateRules();
                        if (UserVariableChanged != null)
                        {
                            UserVariableChanged(this, new EventArgs());
                        }
                    }
                }
            }
        }