コード例 #1
0
    /// <summary>
    /// OnBeforeSave event handler.
    /// </summary>
    protected void EditForm_OnBeforeSave(object sender, EventArgs e)
    {
        ScoreInfo score = EditForm.EditedObject as ScoreInfo;

        if (score != null)
        {
            if (score.ScoreEnabled)
            {
                // If score got changed from disabled to enabled, notify user that the score is not up to date
                if (!ValidationHelper.GetBoolean(score.GetOriginalValue("ScoreEnabled"), false))
                {
                    // Set its status to recalculation required
                    score.ScoreStatus = ScoreStatusEnum.RecalculationRequired;

                    string recalcRequired        = GetString("om.score.recalcrequired");
                    string recalcRequiredDetails = GetString("om.score.recalcrequired.details");

                    ShowWarning(recalcRequired, recalcRequiredDetails, recalcRequired);
                }
            }
            else
            {
                // If score is disabled, score never gets automatically recalculated, so set its status to new - recalculation is always required
                score.ScoreStatus = ScoreStatusEnum.RecalculationRequired;
            }

            if (score.ScoreID == 0)
            {
                score.ScoreStatus = ScoreStatusEnum.Ready;
            }
        }
    }