Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2014
    Posts
    8

    Help with C# code in MVC

    Hi All,
    I'm stuck regarding where to post this question so i posted it in here.

    I have a validation class (as shown below)

    private bool IsValidCustom(CIv2_AnnualLeave_AL civ2_annualLeave_al)
    {
    bool result = true;

    if (civ2_annualLeave_al.AL_EndDate < civ2_annualLeave_al.AL_StartDate)
    {
    ViewBag.ErrorMessage = "End Date should be greater than or equal to Start Date";
    result = false;
    }
    if (civ2_annualLeave_al.AL_EndDate.Year != civ2_annualLeave_al.AL_StartDate.Year)
    {
    ViewBag.ErrorMessage = "Start Date and End Date should be of same year, please book seperate booking for different year.";
    result = false;
    }
    if ((civ2_annualLeave_al.AL_StartDate.Year.Equals(Vie wBag.varCurrentYear)) && (civ2_annualLeave_al.AL_DaysRequested > ViewBag.varCurrentYearRemaining))
    {
    ViewBag.ErrorMessage = "Days Requested cannot be greater than " + ViewBag.varCurrentYearRemaining + " for " + ViewBag.varCurrentYear;
    result = false;
    }

    if ((civ2_annualLeave_al.AL_StartDate.Year.Equals(Vie wBag.varNextYear)) && (civ2_annualLeave_al.AL_DaysRequested > ViewBag.varNextYearRemaining))
    {
    ViewBag.ErrorMessage = "Days Requested cannot be greater than " + ViewBag.varNextYearRemaining + " for " + ViewBag.varNextYear;
    result = false;
    }
    return result;
    }

    I need to write some code to allow if a tickbox is ticked to override or to skip this validation but im stuck on how to approve this. The Tickbox coulmn is civ2_annualLeave_al.AL_IsUnpaid.

    Any help will be appreciated.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    There is a forum for C related posts:-
    http://www.dbforums.com/forumdisplay...5-Delphi-C-etc

    ...however Im not too certain how relevant it is given that there doesn't really seem to be anything db related in your code, so you may be better off posting on a C# coding site
    I'd rather be riding on the Tiger 800 or the Norton

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •