Advertisement
FoxTuGa

RazorView

Feb 3rd, 2014
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.89 KB | None | 0 0
  1. @using EPEdition.Data.Extensions
  2. @using EPEdition.Data.ViewModels
  3. @using EPEdition.Model.Models
  4. @model int
  5.  
  6. @{
  7.     List<SurveyLineViewModel> line = SurveyBuilderExtensions.GetGroupQuestions(Model, iSurveyEntryID: Convert.ToInt32(ViewData["SurveyEntryID"]));
  8.  
  9.     string disabled = "";
  10.     bool isDisabled = false;
  11.     if (ViewData["EntryStatusCode"].ToString().ToUpper() == "SUBMITTED")
  12.     {
  13.         disabled = "disabled";
  14.         isDisabled = true;
  15.     }
  16. }
  17.  
  18. @foreach (SurveyQuestionSubType subtype in SurveyBuilderExtensions._GetSurveyQuestionSubTypes())
  19. {
  20.     SurveyQuestionTypes? sub = SurveyBuilderExtensions.GetSurveyQuestionSubType(subtype.ID);
  21.     bool hasAnotherQuestion = (line.Where(x => x.HasAnotherQuestion == true && x.QuestionSubTypeID == subtype.ID).Count() > 0 ? true : false);    
  22.    
  23.     <table class="questionlist SurveyTable" data-id="@subtype.ID">
  24.         <tr>
  25.             <td class="QuestionColumn">&nbsp;
  26.             </td>
  27.             @foreach (SurveyQuestionTypeValue value in SurveyBuilderExtensions.QuestionValues(subtype.ID))
  28.             {
  29.                 <td class="QuestionColumn2 FontSize15 QuestionColumn2Header">
  30.                     <div>@value.Label</div>
  31.                 </td>
  32.             }
  33.  
  34.             @if (hasAnotherQuestion)
  35.             {
  36.                 <td class="QuestionColumn2 FontSize15 QuestionColumn2Header"></td>
  37.             }
  38.         </tr>
  39.  
  40.         @foreach (SurveyLineViewModel question in line)
  41.         {
  42.  
  43.             if (question.QuestionSubTypeID == subtype.ID)
  44.             {
  45.                 if (sub == SurveyQuestionTypes.FreeText)
  46.                 {
  47.             <tr class="SingleQuestion FontSize14 GroupQuestionAlt">
  48.  
  49.                 <td class="QuestionColumn2Alt">
  50.                     <i class="icon-comments red"></i>&nbsp;
  51.                     @question.Nr @question.Name
  52.                     @{
  53.                     if (question.IsRequired == true)
  54.                     {
  55.                         <span style="color: red;">*</span>  
  56.                     }
  57.                     }
  58.                 </td>
  59.  
  60.                 <td class="QuestionColumn3" style="text-align: left;">
  61.                     @if (question.AnswerValues.Count > 0)
  62.                     {
  63.                         <span>@Html.TextArea("TXT|" + question.ID.ToString(), question.AnswerValues[0], new { @class = "FreeText limited", @maxlenght = "250" })</span>
  64.                     }
  65.                     else
  66.                     {
  67.                         <span>@Html.TextArea("TXT|" + question.ID.ToString(), new { @class = "FreeText limited", @maxlenght = "250" })</span>
  68.                     }
  69.                 </td>
  70.             </tr>
  71.                 }
  72.                 else
  73.                 {
  74.             <tr class="BorderTopBot SingleQuestion FontSize14">
  75.  
  76.                 <td class="QuestionColumn">
  77.                     <i class="icon-comments red"></i>&nbsp;
  78.                     @question.Nr @question.Name
  79.                     @{
  80.                     if (question.IsRequired == true)
  81.                     {
  82.                         <span style="color: red;">*</span>  
  83.                     }
  84.                     }
  85.                 </td>
  86.  
  87.                 @foreach (SurveyQuestionTypeValue value in SurveyBuilderExtensions.QuestionValues(subtype.ID))
  88.                 {
  89.                     <td class="QuestionColumn2 QuestionColumn2Row">
  90.                         @if (sub == SurveyQuestionTypes.Checkbox)
  91.                         {
  92.                             if (question.AnswerValues.Count > 0)
  93.                             {
  94.                                 if (question.AnswerValues.FirstOrDefault(x => x == value.ID.ToString()) != null)
  95.                                 {
  96.                             <span>@Html.CheckBox("CHK|" + question.ID + "|" + value.ID, true)</span>
  97.                            
  98.                                     //isDisabled = true;
  99.                                 }
  100.                                 else
  101.                                 {
  102.                             <span>@Html.CheckBox("CHK|" + question.ID + "|" + value.ID)</span>
  103.                                 }
  104.                             }
  105.                             else
  106.                             {
  107.                             <span>@Html.CheckBox("CHK|" + question.ID + "|" + value.ID)</span>
  108.                             }
  109.  
  110.                         }
  111.                         @if (sub == SurveyQuestionTypes.Radiobutton)
  112.                         {
  113.                             if (question.AnswerValues.Count > 0)
  114.                             {
  115.                                 if (question.AnswerValues.FirstOrDefault(x => x == value.ID.ToString()) != null)
  116.                                 {
  117.                             <span>@Html.RadioButton("RDB|" + question.ID.ToString(), value.ID, true, new { @class = "RadiobuttonOption" })</span>
  118.                                 }
  119.                                 else
  120.                                 {
  121.                             <span>@Html.RadioButton("RDB|" + question.ID.ToString(), value.ID, false, new { @class = "RadiobuttonOption" })</span>
  122.                                 }
  123.                             }
  124.                             else
  125.                             {
  126.                             <span>@Html.RadioButton("RDB|" + question.ID.ToString(), value.ID, false, new { @class = "RadiobuttonOption" })</span>
  127.                             }
  128.  
  129.  
  130.                         }
  131.                     </td>
  132.                 }
  133.  
  134.                 @if (question.HasAnotherQuestion == true)
  135.                 {
  136.                    
  137.                     <td class="QuestionColumn2 QuestionColumn2Row OtherColumn" data-id="@question.ID" style="margin-bottom: auto; margin-top: auto; height: 20px; width: 250px; border-right: none;">
  138.                         @if (sub == SurveyQuestionTypes.Checkbox)
  139.                         {
  140.                             if (question.AnswerValues.Count > 0 != null)
  141.                             {
  142.                             <span>@Html.CheckBox("CHK|" + question.ID + "_AnotherQuestion", true, new { @id = "" + question.ID + "_AnotherQuestion", @class = "CheckboxOther" })</span>
  143.                             }
  144.                             else
  145.                             {
  146.                             <span>@Html.CheckBox("CHK|" + question.ID + "_AnotherQuestion", false, new { @id = "" + question.ID + "_AnotherQuestion", @class = "CheckboxOther" })</span>
  147.                             }
  148.  
  149.  
  150.                         }
  151.                         @if (sub == SurveyQuestionTypes.Radiobutton)
  152.                         {
  153.                             if (question.AnswerValues.Count > 0 != null)
  154.                             {
  155.                             <span>@Html.RadioButton("RDB|" + question.ID.ToString(), "AnotherQuestion", true, new { @id = question.ID.ToString(), @class = "RadiobuttonOther RadiobuttonOption" })</span>
  156.                             }
  157.                             else
  158.                             {
  159.                             <span>@Html.RadioButton("RDB|" + question.ID.ToString(), "AnotherQuestion", false, new { @id = question.ID.ToString(), @class = "RadiobuttonOther RadiobuttonOption" })</span>
  160.                             }
  161.                         }
  162.  
  163.                         @if (question.AnswerValues.Count > 0 != null)
  164.                         {
  165.                             <span>@Html.TextBox((sub == SurveyQuestionTypes.Checkbox ? "CHK|" : "RDB|") + question.ID.ToString() + "_AnotherQuestionDescription", question.AnswerValues[0], new { @id = "" + question.ID.ToString() + "_AnotherQuestionDescription", @class = "AnotherAnswerDescriptionCLASS", @style = "margin-top: auto;margin-bottom: auto;height: 20px;margin-left: auto;margin-right: auto;width: 210px;" })</span>
  166.                         }
  167.                         else
  168.                         {
  169.                             <span>@Html.TextBox((sub == SurveyQuestionTypes.Checkbox ? "CHK|" : "RDB|") + question.ID.ToString() + "_AnotherQuestionDescription", "", new { @id = "" + question.ID.ToString() + "_AnotherQuestionDescription", @class = "AnotherAnswerDescriptionCLASS", @style = "margin-top: auto;margin-bottom: auto;height: 20px;margin-left: auto;margin-right: auto;width: 210px;" })</span>
  170.                         }
  171.                     </td>  
  172.                 }
  173.                 else
  174.                 {
  175.                     if (hasAnotherQuestion)
  176.                     {
  177.                     <td>&nbsp;</td>
  178.                     }
  179.                 }
  180.             </tr>
  181.                 }
  182.             }
  183.         }
  184.     </table>
  185. }
  186.  
  187. <script>
  188.     $(function () {
  189.         @if (isDisabled == true)
  190.         {
  191.             <text>
  192.         $('#ToRender input[type=radio]').attr("disabled", "disabled");
  193.         $('#ToRender input[type=checkbox]').attr("disabled", "disabled");
  194.         $('#ToRender input[type=text]').attr("disabled", "disabled");
  195.         </text>
  196.         }
  197.     });
  198. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement