Example #1
0
    //to validate the comments field for admin users
    void CusValComments_ServerValidate(object source, ServerValidateEventArgs args)
    {
        try
        {
            string strRetVal, strUserId, strCamperUserId, strComments;
            strUserId       = Master.UserId;
            strCamperUserId = Master.CamperUserId;
            strComments     = txtComments.Text.Trim();
            UserInfo        = ConstructParentInfo("1"); //to get the parent 1 info values

            //to check whether the parent info 1 values has been modified
            CamperAppl.IsParentInfoUpdated(ConstructParentInfo("1"), out strRetVal);

            //to check whether the parent info 2 has modified values
            if (strRetVal.Equals("1")) //the data is not modified for parent info 1
            {
                CamperAppl.IsParentInfoUpdated(ConstructParentInfo("2"), out strRetVal);
            }

            if (strUserId != strCamperUserId) //then the user is admin user
            {
                switch (strRetVal)
                {
                case "0":     //data has been modified
                    if (strComments == "")
                    {
                        args.IsValid   = false;
                        bPerformUpdate = false;
                        return;
                    }
                    else
                    {
                        args.IsValid   = true;
                        bPerformUpdate = true;
                        return;
                    }

                case "1":     //data is not modified
                    args.IsValid   = true;
                    bPerformUpdate = false;
                    return;
                }
            }
            else //the user is camper
            {
                switch (strRetVal)
                {
                case "0":     //data has been modified
                    bPerformUpdate = true;
                    break;

                case "1":     //data is not modified
                    bPerformUpdate = false;
                    break;
                }
                args.IsValid = true;
                return;
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }