protected void ActivityParametersGrid_OnItemCommand(Object sender, Telerik.Web.UI.GridCommandEventArgs eventArgs)
        {
            String parameterName;

            Telerik.Web.UI.RadComboBox parameterValueSelection;

            Telerik.Web.UI.RadTextBox parameterFixedValue;

            Client.Core.Individual.CareInterventionActivity careInterventionActivity = EditCareInterventionActivity;


            if (MercuryApplication == null)
            {
                return;
            }


            switch (eventArgs.CommandName)
            {
            case Telerik.Web.UI.RadGrid.EditCommandName:

                #region Edit Command

                Telerik.Web.UI.GridEditCommandColumn editColumn = (Telerik.Web.UI.GridEditCommandColumn)ActivityParametersGrid.MasterTableView.GetColumn("EditCommandColumn");

                if (!editColumn.Visible)
                {
                    editColumn.Visible = true;
                }

                Telerik.Web.UI.GridEditableItem editItem = (Telerik.Web.UI.GridEditableItem)eventArgs.Item;

                #endregion

                break;

            case Telerik.Web.UI.RadGrid.UpdateCommandName:

                #region Update Command

                parameterValueSelection = (Telerik.Web.UI.RadComboBox)eventArgs.Item.FindControl("ActivityParameterValueSelection");

                parameterFixedValue = (Telerik.Web.UI.RadTextBox)eventArgs.Item.FindControl("ActivityParameterFixedValue");

                if ((parameterValueSelection.SelectedItem != null) || (!String.IsNullOrEmpty(parameterFixedValue.Text)))
                {
                    parameterName = (String)((Telerik.Web.UI.GridEditableItem)eventArgs.Item).OwnerTableView.DataKeyValues[eventArgs.Item.ItemIndex]["ParameterName"];

                    if ((careInterventionActivity.Action.ActionParameters[parameterName].AllowFixedValue) && (!String.IsNullOrEmpty(parameterFixedValue.Text)))
                    {
                        careInterventionActivity.Action.ActionParameters[parameterName].ValueType = Mercury.Server.Application.ActionParameterValueType.FixedValue;

                        careInterventionActivity.Action.ActionParameters[parameterName].Value = parameterFixedValue.Text;

                        careInterventionActivity.Action.ActionParameters[parameterName].ValueDescription = parameterFixedValue.Text;
                    }

                    else
                    {
                        careInterventionActivity.Action.ActionParameters[parameterName].ValueType = Mercury.Server.Application.ActionParameterValueType.DataMapping;

                        careInterventionActivity.Action.ActionParameters[parameterName].Value = parameterValueSelection.SelectedItem.Value;

                        careInterventionActivity.Action.ActionParameters[parameterName].ValueDescription = parameterValueSelection.SelectedItem.Text;
                    }

                    if ((careInterventionActivity.Action.Name == "Workflow") && (parameterName == "Workflow"))
                    {
                        careInterventionActivity.Action.RebindActionParameters(MercuryApplication);
                    }
                }

                #endregion

                break;
            }

            EditCareInterventionActivity = careInterventionActivity;

            InitializeActivityParametersGrid();

            return;
        }
        protected void ActivityThresholdsGrid_OnItemCommand(Object sender, Telerik.Web.UI.GridCommandEventArgs eventArgs)
        {
            Client.Core.Individual.CareInterventionActivity careInterventionActivity = EditCareInterventionActivity;

            Mercury.Client.Core.Activity.ActivityThreshold threshold;

            String parameterName;

            Telerik.Web.UI.RadNumericTextBox thresholdRelativeDateValue;

            Telerik.Web.UI.RadComboBox thresholdRelativeDateQualifier;

            Telerik.Web.UI.RadComboBox thresholdStatusSelection;

            Telerik.Web.UI.RadComboBox thresholdActionSelection;

            Telerik.Web.UI.RadComboBox parameterValueSelection;

            Telerik.Web.UI.RadTextBox parameterFixedValue;

            Int64 actionId = 0;


            if (MercuryApplication == null)
            {
                return;
            }


            // SaveResponseLabel.Text = String.Empty;

            switch (eventArgs.CommandName)
            {
            case Telerik.Web.UI.RadGrid.EditCommandName:

                #region Edit Command

                switch (eventArgs.Item.OwnerTableView.Name)
                {
                case "Thresholds":

                    Telerik.Web.UI.GridEditCommandColumn editColumn = (Telerik.Web.UI.GridEditCommandColumn)ActivityThresholdsGrid.MasterTableView.GetColumn("EditCommandColumn");

                    if (!editColumn.Visible)
                    {
                        editColumn.Visible = true;
                    }

                    Telerik.Web.UI.GridEditableItem editItem = (Telerik.Web.UI.GridEditableItem)eventArgs.Item;

                    break;


                case "ThresholdParameters":

                    editColumn = (Telerik.Web.UI.GridEditCommandColumn)eventArgs.Item.OwnerTableView.GetColumn("EditCommandColumn");

                    if (!editColumn.Visible)
                    {
                        editColumn.Visible = true;
                    }

                    break;
                }

                #endregion

                break;

            case Telerik.Web.UI.RadGrid.InitInsertCommandName:

                break;

            case Telerik.Web.UI.RadGrid.PerformInsertCommandName:

                #region Perform Insert Command

                Telerik.Web.UI.GridEditableItem insertedItem = (Telerik.Web.UI.GridEditableItem)eventArgs.Item;

                thresholdRelativeDateValue = (Telerik.Web.UI.RadNumericTextBox)insertedItem.FindControl("ActivityThresholdRelativeDateValue");

                thresholdRelativeDateQualifier = (Telerik.Web.UI.RadComboBox)insertedItem.FindControl("ActivityThresholdRelativeDateQualifier");

                thresholdStatusSelection = (Telerik.Web.UI.RadComboBox)insertedItem.FindControl("ActivityThresholdStatusSelection");

                thresholdActionSelection = (Telerik.Web.UI.RadComboBox)insertedItem.FindControl("ActivityThresholdActionSelection");


                try {
                    if (thresholdRelativeDateValue.Value == null)
                    {
                        throw new ApplicationException("No Threshold Date Specified.");
                    }


                    threshold = careInterventionActivity.GetNewThreshold();

                    threshold.RelativeDateValue = Int32.Parse(thresholdRelativeDateValue.Value.ToString());

                    threshold.RelativeDateQualifier = (Mercury.Server.Application.DateQualifier)Int32.Parse(thresholdRelativeDateQualifier.SelectedItem.Value);

                    threshold.Status = (Mercury.Server.Application.ActivityStatus)Int32.Parse(thresholdStatusSelection.SelectedValue);


                    // RESERVED IF ACTIONS ARE ADDED TO CARE LEVEL ACTIVITY THRESHOLDS

                    //actionId = Int64.Parse (thresholdActionSelection.SelectedValue);

                    //threshold.Action = MercuryApplication.ActionById (actionId);

                    //if (threshold.Action == null) { threshold.Action = new Mercury.Client.Core.Action.Action (MercuryApplication); }


                    if (!EditCareInterventionActivity.HasThreshold(threshold))
                    {
                        careInterventionActivity.Thresholds.Add(threshold);

                        EditCareInterventionActivity = careInterventionActivity;
                    }

                    else
                    {
                        throw new ApplicationException("Duplicate Threshold");
                    }
                }

                catch (Exception MercuryApplicationException) {
                    // SaveResponseLabel.Text = "Error: " + MercuryApplicationException.Message;
                }

                #endregion

                break;

            case Telerik.Web.UI.RadGrid.UpdateCommandName:

                #region Update Command

                Telerik.Web.UI.GridEditableItem updatedItem = (Telerik.Web.UI.GridEditableItem)eventArgs.Item;

                switch (eventArgs.Item.OwnerTableView.Name)
                {
                case "Thresholds":

                    thresholdRelativeDateValue = (Telerik.Web.UI.RadNumericTextBox)updatedItem.FindControl("ActivityThresholdRelativeDateValue");

                    thresholdRelativeDateQualifier = (Telerik.Web.UI.RadComboBox)updatedItem.FindControl("ActivityThresholdRelativeDateQualifier");

                    thresholdStatusSelection = (Telerik.Web.UI.RadComboBox)updatedItem.FindControl("ActivityThresholdStatusSelection");

                    thresholdActionSelection = (Telerik.Web.UI.RadComboBox)updatedItem.FindControl("ActivityThresholdActionSelection");

                    threshold = careInterventionActivity.SortedThresholds.Values[updatedItem.ItemIndex];

                    threshold.RelativeDateValue = Int32.Parse(thresholdRelativeDateValue.Value.ToString());

                    threshold.RelativeDateQualifier = (Mercury.Server.Application.DateQualifier)Int32.Parse(thresholdRelativeDateQualifier.SelectedItem.Value);

                    threshold.Status = (Mercury.Server.Application.ActivityStatus)Int32.Parse(thresholdStatusSelection.SelectedValue);


                    // RESERVED IF ACTIONS ARE ADDED TO CARE LEVEL ACTIVITY THRESHOLDS

                    //actionId = Int64.Parse (thresholdActionSelection.SelectedValue);

                    //if (threshold.Action.Id != actionId) {

                    //    threshold.Action = MercuryApplication.ActionById (actionId);

                    //    if (threshold.Action == null) { threshold.Action = new Mercury.Client.Core.Action.Action (MercuryApplication); }

                    //}

                    break;

                case "ThresholdParameters":         // RESERVED IF ACTIONS ARE ADDED TO CARE LEVEL ACTIVITY THRESHOLDS

                    Int64 thresholdKey = Int64.Parse((String)((Telerik.Web.UI.GridEditableItem)eventArgs.Item).OwnerTableView.DataKeyValues[eventArgs.Item.ItemIndex]["ThresholdKey"]);

                    threshold = careInterventionActivity.SortedThresholds[thresholdKey];

                    parameterName = (String)((Telerik.Web.UI.GridEditableItem)eventArgs.Item).OwnerTableView.DataKeyValues[eventArgs.Item.ItemIndex]["ParameterName"];

                    if (threshold.Action.ActionParameters.ContainsKey(parameterName))
                    {
                        parameterValueSelection = (Telerik.Web.UI.RadComboBox)eventArgs.Item.FindControl("ActivityThresholdParameterValue");

                        parameterFixedValue = (Telerik.Web.UI.RadTextBox)eventArgs.Item.FindControl("ActivityThresholdParameterFixedValue");

                        if ((parameterValueSelection.SelectedItem != null) || (!String.IsNullOrEmpty(parameterFixedValue.Text)))
                        {
                            if ((threshold.Action.ActionParameters[parameterName].AllowFixedValue) && (!String.IsNullOrEmpty(parameterFixedValue.Text)))
                            {
                                threshold.Action.ActionParameters[parameterName].ValueType = Mercury.Server.Application.ActionParameterValueType.FixedValue;

                                threshold.Action.ActionParameters[parameterName].Value = parameterFixedValue.Text;

                                threshold.Action.ActionParameters[parameterName].ValueDescription = parameterFixedValue.Text;
                            }

                            else
                            {
                                threshold.Action.ActionParameters[parameterName].ValueType = Mercury.Server.Application.ActionParameterValueType.DataMapping;

                                threshold.Action.ActionParameters[parameterName].Value = parameterValueSelection.SelectedItem.Value;

                                threshold.Action.ActionParameters[parameterName].ValueDescription = parameterValueSelection.SelectedItem.Text;
                            }


                            if ((threshold.Action.Name == "Workflow") && (parameterName == "Workflow"))
                            {
                                threshold.Action.RebindActionParameters(MercuryApplication);
                            }
                        }
                    }

                    break;
                }

                #endregion

                break;

            case Telerik.Web.UI.RadGrid.ExpandCollapseCommandName:

                #region Expand/Collapse Command

                System.Data.DataTable parameterTable = (System.Data.DataTable)Session[SessionCachePrefix + "ActivityThresholdsGrid.ParameterTable"];

                parameterTable.Rows.Clear();

                Int32 currentThresholdIndex = 0;

                foreach (Mercury.Client.Core.Activity.ActivityThreshold currentThreshold in careInterventionActivity.SortedThresholds.Values)
                {
                    if (currentThreshold.Action != null)
                    {
                        foreach (String currentParameterName in currentThreshold.Action.ActionParameters.Keys)
                        {
                            parameterTable.Rows.Add(currentThresholdIndex, currentParameterName, currentThreshold.Action.ActionParameters[currentParameterName].ValueDescription);
                        }
                    }

                    currentThresholdIndex = currentThresholdIndex + 1;
                }

                ActivityThresholdsGrid.MasterTableView.DetailTables[0].DataSource = parameterTable;

                ActivityThresholdsGrid.MasterTableView.DetailTables[0].DataBind();

                #endregion

                break;

            case Telerik.Web.UI.RadGrid.DeleteCommandName:

                Int32 deleteIndex = eventArgs.Item.DataSetIndex;

                if ((deleteIndex > -1) && (deleteIndex < careInterventionActivity.Thresholds.Count))
                {
                    threshold = careInterventionActivity.SortedThresholds.Values[deleteIndex];

                    careInterventionActivity.Thresholds.Remove(threshold);
                }

                break;

            default:

                System.Diagnostics.Debug.WriteLine(eventArgs.CommandName);

                break;
            }


            EditCareInterventionActivity = careInterventionActivity;

            return;
        }
コード例 #3
0
        protected void ConditionEventsGrid_OnItemCommand(Object sender, Telerik.Web.UI.GridCommandEventArgs eventArgs)
        {
            String eventName;

            Telerik.Web.UI.RadComboBox conditionEventActionSelection;

            Int64 actionId;

            String parameterName;

            Telerik.Web.UI.RadComboBox parameterValueSelection;

            Telerik.Web.UI.RadTextBox parameterFixedValue;


            if (MercuryApplication == null)
            {
                return;
            }

            switch (eventArgs.CommandName)
            {
            case Telerik.Web.UI.RadGrid.EditCommandName:

                #region Edit Command

                switch (eventArgs.Item.OwnerTableView.Name)
                {
                case "ConditionEvent":

                    Telerik.Web.UI.GridEditCommandColumn editColumn = (Telerik.Web.UI.GridEditCommandColumn)ConditionEventsGrid.MasterTableView.GetColumn("EditCommandColumn");

                    if (!editColumn.Visible)
                    {
                        editColumn.Visible = true;
                    }

                    Telerik.Web.UI.GridEditableItem editItem = (Telerik.Web.UI.GridEditableItem)eventArgs.Item;

                    break;

                case "ConditionEventParameters":

                    editColumn = (Telerik.Web.UI.GridEditCommandColumn)eventArgs.Item.OwnerTableView.GetColumn("EditCommandColumn");

                    if (!editColumn.Visible)
                    {
                        editColumn.Visible = true;
                    }

                    break;
                }

                #endregion

                break;

            case Telerik.Web.UI.RadGrid.UpdateCommandName:

                #region Update Command

                Telerik.Web.UI.GridEditableItem updatedItem = (Telerik.Web.UI.GridEditableItem)eventArgs.Item;

                switch (eventArgs.Item.OwnerTableView.Name)
                {
                case "ConditionEvent":

                    eventName = (String)updatedItem.OwnerTableView.DataKeyValues[eventArgs.Item.ItemIndex]["EventName"];

                    conditionEventActionSelection = (Telerik.Web.UI.RadComboBox)updatedItem.FindControl("ConditionEventActionSelection");

                    actionId = Int64.Parse(conditionEventActionSelection.SelectedValue);

                    condition.Events[eventName] = MercuryApplication.ActionById(actionId);

                    if (condition.Events[eventName] == null)
                    {
                        condition.Events[eventName] = new Mercury.Client.Core.Action.Action(MercuryApplication);
                    }

                    break;

                case "ConditionEventParameters":

                    parameterValueSelection = (Telerik.Web.UI.RadComboBox)eventArgs.Item.FindControl("ConditionEventParameterValueSelection");

                    parameterFixedValue = (Telerik.Web.UI.RadTextBox)eventArgs.Item.FindControl("ConditionEventParameterFixedValue");

                    if ((parameterValueSelection.SelectedItem != null) || (!String.IsNullOrEmpty(parameterFixedValue.Text)))
                    {
                        eventName = (String)updatedItem.OwnerTableView.DataKeyValues[eventArgs.Item.ItemIndex]["EventName"];

                        parameterName = (String)((Telerik.Web.UI.GridEditableItem)eventArgs.Item).OwnerTableView.DataKeyValues[eventArgs.Item.ItemIndex]["ParameterName"];


                        if ((condition.Events[eventName].ActionParameters[parameterName].AllowFixedValue) && (!String.IsNullOrEmpty(parameterFixedValue.Text)))
                        {
                            condition.Events[eventName].ActionParameters[parameterName].ValueType = Mercury.Server.Application.ActionParameterValueType.FixedValue;

                            condition.Events[eventName].ActionParameters[parameterName].Value = parameterFixedValue.Text;

                            condition.Events[eventName].ActionParameters[parameterName].ValueDescription = parameterFixedValue.Text;
                        }

                        else
                        {
                            condition.Events[eventName].ActionParameters[parameterName].ValueType = Mercury.Server.Application.ActionParameterValueType.DataMapping;

                            condition.Events[eventName].ActionParameters[parameterName].Value = parameterValueSelection.SelectedItem.Value;

                            condition.Events[eventName].ActionParameters[parameterName].ValueDescription = parameterValueSelection.SelectedItem.Text;
                        }

                        if ((condition.Events[eventName].Name == "Workflow") && (parameterName == "Workflow"))
                        {
                            condition.Events[eventName].RebindActionParameters(MercuryApplication);
                        }
                    }

                    break;
                }

                #endregion

                break;
            }


            return;
        }