Exemplo n.º 1
0
    private void EditForm_OnAfterValidate(object sender, EventArgs e)
    {
        // Validate ToDate > FromDate
        FormEngineUserControl fromField = EditForm.FieldControls["CampaignOpenFrom"] as FormEngineUserControl;
        FormEngineUserControl toField   = EditForm.FieldControls["CampaignOpenTo"] as FormEngineUserControl;

        DateTime from = DateTimeHelper.ZERO_TIME;
        DateTime to   = DateTimeHelper.ZERO_TIME;

        if (fromField != null)
        {
            from = ValidationHelper.GetDateTime(fromField.Value, DateTimeHelper.ZERO_TIME);
        }

        if (toField != null)
        {
            to = ValidationHelper.GetDateTime(toField.Value, DateTimeHelper.ZERO_TIME);
        }

        if ((from != DateTimeHelper.ZERO_TIME) && (to != DateTimeHelper.ZERO_TIME) && (from > to))
        {
            EditForm.StopProcessing = true;
            EditForm.DisplayErrorLabel("CampaignOpenFrom", GetString("campaign.wronginterval"));
        }
    }
Exemplo n.º 2
0
    protected void EditForm_OnAfterValidate(object sender, EventArgs e)
    {
        DateTime from = ValidationHelper.GetDateTime(EditForm.GetFieldValue("CampaignOpenFrom"), DateTimeHelper.ZERO_TIME);
        DateTime to   = ValidationHelper.GetDateTime(EditForm.GetFieldValue("CampaignOpenTo"), DateTimeHelper.ZERO_TIME);

        // Validate FromDate <= ToDate
        if (!DateTimeHelper.IsValidFromTo(from, to))
        {
            EditForm.StopProcessing = true;
            EditForm.DisplayErrorLabel("CampaignOpenFrom", GetString("campaign.wronginterval"));
        }
    }