Advertisement
fusor

Untitled

Feb 2nd, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.95 KB | None | 0 0
  1. @using Wemsy.UI.BusinessLogic.Models
  2. @using Wemsy.UI.BusinessLogic.DAL
  3. @using System.Data
  4. @model ConsolidationGroupAccountLineMappings
  5.            
  6. <header class="page-header">
  7.     <h1>
  8.         @Html.Translate("Account Mappings") (@Html.Translate(Model.Consolidation.Translation.TranslationID) - @Html.Translate(Model.Perimeter.CompanyDatabaseID))
  9.     </h1>
  10.     <ul class="breadcrumb" style="background: none;">
  11.         <li><a href="/">@Html.Translate("Home")</a><i id="sep" class="icon-double-angle-right"></i></li>
  12.         <li><a href="/Consolidation">@Html.Translate("Consolidation")</a><i id="sep" class="icon-double-angle-right"></i></li>
  13.         <li class="active"><a href="#">@Html.Translate("Edit")</a></li>
  14.     </ul>
  15. </header>
  16.  
  17. @using (Html.BeginForm(MVC4.ConsolidationGroupAccount.SaveGroupAccountMapping(), FormMethod.Post, new { autocomplete = "off", @class = "form-horizontal" }))
  18. {
  19.     @Html.AntiForgeryToken()
  20.     @Html.ValidationSummary(false, "Unable to save :", new { @class = "alert alert-block alert-error" })
  21.     @Html.SecureFor(model => model.Consolidation.ID)
  22.     @Html.SecureFor(model => model.Perimeter.ID)
  23.  
  24.     @Html.DropDownList("GroupAccountLineEditor", Model.GroupAccountLines.DataTable, "id", new string[] { "Code", "Description" }, new { @id = "GroupAccountLineEditor", @class = "input-xlarge form-control", @style="display:none" }, true)
  25.     <div class="panel panel-default">
  26.         <div class="panel-body">
  27.             <div class="row-fluid">
  28.                 <div class="col-xs-12">
  29.                     <table id="MainTable" class="table table-bordered table-condensed" >
  30.                         <thead>
  31.                             <tr style="background-color:#f5f5f5;">
  32.                                 <th>@Html.Translate("Local Account")</th>
  33.                                 <th style="width:auto">@Html.Translate("Local Account Description")</th>
  34.                                 <th style="width:300px">@Html.Translate("Group Account (Click cell to edit)")</th>
  35.                             </tr>
  36.                         </thead>
  37.                         <tbody>
  38.                             @foreach(ConsolidationGroupAccountLineMapping Mapping in Model.Mappings)
  39.                             {
  40.                                 <tr style="height:45px" class="@( (Mapping.GroupAccountLineID <= 0) ? "error" : "success")" onclick="ChangeMapping($(this), '@Mapping.Account', @Mapping.GroupAccountLineID)">
  41.                                     <td>@Mapping.Account @Html.HiddenFor(m => Mapping.Account)</td>
  42.                                     <td>@Mapping.Description</td>
  43.                                     <td class="GroupAccountLineEditor" style="cursor:pointer;">
  44.                                         <span>@Mapping.ConsoGroupAccountLineCode @Html.Translate(Mapping.ConsoGroupAccountLineTranslationID)</span>
  45.                                     </td>
  46.                                 </tr>
  47.                             }
  48.                         </tbody>
  49.                     </table>
  50.                 </div>
  51.             </div>            
  52.             <div class="row-fluid">
  53.                 <a href="/Consolidation/Index" class="btn btn-default"><i class="fa fa-ban"></i>&nbsp;@Html.Translate("Cancel")</a><span>&nbsp;</span>
  54.                 <button class="btn btn-primary" type="submit"><i class="fa fa-floppy-o"></i>&nbsp;@Html.Translate("Save")</button>
  55.             </div>
  56.         </div>
  57.     </div>
  58. }
  59. <script type="text/javascript">
  60.     var $SpanToShowBack;
  61.  
  62.     function ChangeMapping($this, Account, GroupAccountLineID) {
  63.         if ($this.find("#GroupAccountLineEditor").length == 0) {
  64.             $("#GroupAccountLineEditor").detach().insertAfter($this.find("span"));
  65.             $("#GroupAccountLineEditor").show();
  66.             $this.find("span").hide();
  67.             if ($SpanToShowBack != null)
  68.                 $SpanToShowBack.show();
  69.             $SpanToShowBack = $this.find("span");
  70.  
  71.             $("select").change(function () {
  72.                 if ($(this).val() == "-1")
  73.                     $(this).parents('tr').removeClass().addClass('error');
  74.                 else
  75.                     $(this).parents('tr').removeClass().addClass('success');
  76.  
  77.                 $(this).parent().find("input").val($(this).val());
  78.  
  79.                 if ($(this).val() > 0)
  80.                     $(this).parent().find("span").html($(this).find('option:selected').text());
  81.                 else
  82.                     $(this).parent().find("span").html("");
  83.  
  84.                 // AJAX SAVE
  85.                 console.log($(this).closest("input").find("#Account"));
  86.                 console.log($(this).val()); // Value of Group Account
  87.             });
  88.         }
  89.     }
  90.  
  91.     $(function () {
  92.         $('#MainTable').DataTable({
  93.             "dom": "<'row'<'col-sm-4'l><'col-sm-4 text-center'B><'col-sm-4'f>>tp",
  94.             "paging": true,
  95.             "ordering": true,
  96.             "info": true,
  97.             "filter": true,
  98.             "lengthMenu": [[12, 25, 50, -1], [12, 25, 50, "All"]],
  99.             "pageLength": 12,
  100.         });
  101.  
  102.         $('#MainTable').show();
  103.  
  104.     });
  105. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement