Advertisement
locnhse61312

Untitled

Nov 25th, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 16.91 KB | None | 0 0
  1. @{
  2.     ViewBag.Title = "Quản lý của hàng";
  3.     Layout = "~/Views/Shared/_Layout.cshtml";
  4. }
  5.  
  6. <div class="page-content">
  7.     <div class="page-header">
  8.         @*<h1>@Resources.Resources.Admin_Bill_Title Phòng</h1>
  9.         *@
  10.         <h1>
  11.             Quản lý cửa hàng
  12.  
  13.  
  14.         </h1>
  15.     </div>
  16.  
  17.     <div class="form-inline">
  18.         <div class="col-xs-3" style="width: 17%;">
  19.             <div class="input-group input-group-sm">
  20.                 <input type="text" id="dpFrom" class="form-control" data-date-format="dd/mm/yyyy" placeholder="Từ" />
  21.                 <span class="input-group-addon" onclick="focusOnDpFrom()">
  22.                     <i class="icon-calendar"></i>
  23.                 </span>
  24.             </div>
  25.         </div>
  26.         <div class="col-xs-3" style="width: 17%;">
  27.             <div class="input-group input-group-sm">
  28.                 <input type="text" id="dpTo" class="form-control" data-date-format="dd/mm/yyyy" placeholder="Đến" />
  29.                 <span class="input-group-addon" onclick="focusOnDpTo()">
  30.                     <i class="icon-calendar"></i>
  31.                 </span>
  32.             </div>
  33.         </div>
  34.         <div class="col-xs-1">
  35.             <input type="button" class="btn btn-sm active" value="Lọc" onclick="RefreshTable()" />
  36.         </div>
  37.         <div class="col-sm-5">
  38.             <a id="btnCreate" href="#" role="button" class="btn btn-success btn-sm pull-right">
  39.                 <strong>Tạo mới</strong>
  40.             </a>
  41.         </div>
  42.  
  43.         <div class="">
  44.             <table id="storeDatatable" class="table table-striped table-bordered table-hover" style="width: 100% !important">
  45.                 <thead>
  46.                     <tr>
  47.                         <th>
  48.                             <label class="">STT</label>
  49.                         </th>
  50.                         <th>
  51.                             <label class="">ID</label>
  52.                         </th>
  53.                         <th>
  54.                             <label class="">Tên cửa hàng</label>
  55.                         </th>
  56.                         <th>
  57.                             <label class="">Địa chỉ</label>
  58.                         </th>
  59.                         <th>
  60.                             <label class="">ID quản lí</label>
  61.                         </th>
  62.                         <th></th>
  63.                     </tr>
  64.                 </thead>
  65.                 <tbody></tbody>
  66.             </table>
  67.         </div>
  68.     </div>
  69. </div>
  70.  
  71.  
  72. <div id="create-store-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
  73.      aria-hidden="true">
  74.     <div class="modal-form col-lg-offset-1 col-lg-10 col-md-12 col-sm-12 col-xs-12">
  75.         <div class="widget-box">
  76.             <div class="widget-header">
  77.                 Khởi tạo cửa hàng
  78.             </div>
  79.             <div class="widget-body" id="create-store-modal-body">
  80.  
  81.             </div>
  82.         </div>
  83.     </div>
  84. </div>
  85.  
  86. <!--Modal-->
  87. <div id="createModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
  88.     <div class="modal-form">
  89.         <div class="widget-box col-lg-6 col-lg-offset-3" style="opacity: 1; z-index: 0;">
  90.             <div class="widget-header">
  91.                 <h5 class="bigger-120" id="modalHeader">Thêm Đối Tác</h5>
  92.                 <div class="widget-toolbar">
  93.                     <a id="btnModalClose" href="#">
  94.                         <i class="icon-remove"></i>
  95.                     </a>
  96.                 </div>
  97.             </div>
  98.  
  99.             <div class="widget-body margin-20">
  100.                 <div class="widget-main">
  101.                     @*<div class="col-sm-12">*@
  102.  
  103.                     <div class="widget-box transparent">
  104.                         <div id="content">
  105.                             <div class="row">
  106.                                 <div class="col-xs-12">
  107.                                     <form id="CreateEditForm">
  108.                                         <input type="hidden" name="FormMode" value="Create" />
  109.                                         <input type="hidden" name="Id" value="" />
  110.                                         <div class="form-horizontal">
  111.                                             <div id="FormError" class="alert alert-danger" style="display: none; padding: 10px; margin-left: 10px"></div>
  112.                                             <div id="FormSuccess" class="alert alert-success" style="display: none; padding: 10px; margin-left: 10px"></div>
  113.                                             <div class="form-group">
  114.                                                 @Html.Label("Tên cửa hàng", htmlAttributes: new { @class = "control-label col-md-4" })
  115.                                                 <div class="col-md-5">
  116.                                                     @Html.TextBox("Name", "", new { @class = "col-sm-12" })
  117.                                                     @Html.ValidationMessage("Name", htmlAttributes: new { @class = "error-message", style = "color: red;" })
  118.                                                 </div>
  119.                                             </div>
  120.  
  121.                                             <div class="form-group">
  122.                                                 @Html.Label("Địa chỉ", htmlAttributes: new { @class = "control-label col-md-4" })
  123.                                                 <div class="col-md-5">
  124.                                                     @Html.TextArea("Address", "", new { @class = "col-sm-12" })
  125.                                                     @Html.ValidationMessage("Address", htmlAttributes: new { @class = "error-message", style = "color: red;" })
  126.                                                 </div>
  127.                                             </div>
  128.  
  129.                                             <div class="form-group">
  130.                                                 @Html.Label("Mã quản lí", htmlAttributes: new { @class = "control-label col-md-4" })
  131.                                                 <div class="col-md-5">
  132.                                                     @Html.TextBox("ManagerID", "", new { @class = "col-sm-12" })
  133.                                                     @Html.ValidationMessage("ManagerID", htmlAttributes: new { @class = "error-message", style = "color: red;" })
  134.                                                 </div>
  135.                                             </div>
  136.                                             <div class="form-group">
  137.                                                 <div class="col-md-offset-4 col-md-8">
  138.                                                     <input type="button" id="btnSubmit" value="Create" class="btn btn-default" />
  139.                                                 </div>
  140.                                             </div>
  141.                                         </div>
  142.                                     </form>
  143.                                 </div>
  144.                             </div>
  145.                         </div>
  146.                     </div>
  147.                     @* </div>*@
  148.                 </div>
  149.                 <div class="clearfix"></div>
  150.             </div>
  151.  
  152.             @*<div class="modal-footer"></div>*@
  153.         </div>
  154.     </div>
  155. </div>
  156.  
  157.  
  158.  
  159. <script>
  160.    
  161.     $("#btnModalClose").click(function () {
  162.         $("#createModal").modal("hide");
  163.         if (modalModified) location.reload();
  164.     });
  165.  
  166.     // Button submit on modal form
  167.     $("#btnSubmit").click(function () {
  168.         // clear error
  169.         $(".error-message").html("");
  170.         $("#FormError").hide();
  171.         $("#FormError").html("");
  172.         $("#FormSuccess").hide();
  173.         $("#FormSuccess").html("");
  174.  
  175.         var hasError = false;
  176.  
  177.         // validating
  178.         if ($("input[name='Name']").val() == "") {
  179.             $("span[data-valmsg-for='Name']").html("Tên đối tác không được bỏ trống");
  180.             hasError = true;
  181.         }
  182.  
  183.         if ($("textarea[name='Address']").val() == "") {
  184.             $("span[data-valmsg-for='Address']").html("Địa chỉ đối tác không được bỏ trống");
  185.             hasError = true;
  186.         }
  187.  
  188.         // submit
  189.         if (!hasError) {
  190.             $("form#CreateEditForm").submit();
  191.         }
  192.     });
  193.     // Edit a partner
  194.     function EditStore(id) {
  195.         $.ajax({
  196.             url: '@Url.Action("GetStoreJSon")',
  197.             type: 'POST',
  198.             data: 'id=' + id,
  199.             success: function (data) {
  200.                 if (data.success) {
  201.                     // clear error
  202.                     $(".error-message").html("");
  203.                     $("#FormError").hide();
  204.                     $("#FormError").html("");
  205.                     $("#FormSuccess").hide();
  206.                     $("#FormSuccess").html("");
  207.                     $("form#CreateEditForm")[0].reset();
  208.  
  209.                     $("#modalHeader").html("Sửa thông tin đối tác");
  210.                     $("#createModal").modal("show");
  211.                     $("input[name='FormMode']").val("Edit");
  212.                     $("input[name='ID']").val(data.info.CustomerID);
  213.                     $("input[name='Name']").val(data.info.Name);
  214.                     $("textarea[name='Address']").html(data.info.Address);
  215.                     $("input[name='ManagerID']").val(data.info.ManagerID);
  216.                     $("#btnSubmit").val("Save");
  217.                     modalModified = false;
  218.                 } else {
  219.                     ShowMessage("Không thể lấy dữ liệu của đối tác này. Xin vui lòng thử lại sau!", 1);
  220.                 }
  221.             },
  222.             error: function (e) {
  223.                 ShowMessage("Không thể lấy dữ liệu của đối tác này. Xin vui lòng thử lại sau!", 1);
  224.             }
  225.         });
  226.  
  227.         modalModified = false;
  228.     }
  229.     // Delete a partner
  230.     function DeleteStore(id, name) {
  231.         bootbox.dialog({
  232.             title: 'Xác nhận',
  233.             message: "<h5>Bạn có muốn xóa cửa hàng '" + name + "'?</h5>",
  234.             buttons:
  235.             {
  236.                 "ok":
  237.                  {
  238.                      "label": "<i class='icon-ok'></i> Đồng ý",
  239.                      "className": "btn-sm btn-success",
  240.                      "callback": function () {
  241.                          $.ajax({
  242.                              url: '@Url.Action("DeleteStore")',
  243.                              type: 'POST',
  244.                              data: 'id=' + id,
  245.                              error: function () {
  246.                                  ShowMessage("Không thể xóa đối tác này. Xin vui lòng thử lại sau!", 1);
  247.                              },
  248.                              success: function (data) {
  249.                                  if (data.success) {
  250.                                      location.reload();
  251.                                  } else {
  252.                                      ShowMessage("Không thể xóa đối tác này. Xin vui lòng thử lại sau!", 1);
  253.                                  }
  254.                              }
  255.                          });
  256.                      }
  257.                  },
  258.                 "close":
  259.                  {
  260.                      "label": "<i class='icon-remove'></i> Đóng",
  261.                      "className": "btn-sm btn-danger",
  262.                      "callback": function () {
  263.                          bootbox.hideAll();
  264.                      }
  265.                  }
  266.             }
  267.         });
  268.     }
  269.  
  270.  
  271.     // Initial submit form
  272.     $("form#CreateEditForm").submit(function () {
  273.         var formData = new FormData($(this)[0]);
  274.         $.ajax({
  275.             url: '@Url.Action("CreateNew")',
  276.             type: 'POST',
  277.             data: formData,
  278.             async: false,
  279.             success: function (data) {
  280.                 if (data.success) {
  281.                     if (data.type == "create") {
  282.                         $("#FormSuccess").html(data.msg);
  283.                         $("#FormSuccess").show();
  284.                         $("form#CreateEditForm")[0].reset();
  285.                     } else if (data.type == "edit") {
  286.                         $("#FormSuccess").html(data.msg);
  287.                         $("#FormSuccess").show();
  288.                     }
  289.                     modalModified = true;
  290.                 } else {
  291.                     $("#FormError").html(data.msg);
  292.                     $("#FormError").show();
  293.                 }
  294.             },
  295.             cache: false,
  296.             contentType: false,
  297.             processData: false
  298.         });
  299.  
  300.         return false;
  301.     });
  302.  
  303.  
  304.     $("#btnCreate").click(function () {
  305.         // clear error
  306.         $(".error-message").html("");
  307.         $("#FormError").hide();
  308.         $("#FormError").html("");
  309.         $("#FormSuccess").hide();
  310.         $("#FormSuccess").html("");
  311.         $("form#CreateEditForm")[0].reset();
  312.  
  313.         $("#modalHeader").html("Tạo mới");
  314.         $("#createModal").modal("show");
  315.         $("input[name='FormMode']").val("Create");
  316.         $("#btnSubmit").val("Create");
  317.         modalModified = false;
  318.     });
  319.  
  320.     function GetCreateForm() {
  321.         $.ajax({
  322.             url: "/StoreManager/Store/Create",
  323.             context: document.body
  324.         }).done(function (result) {
  325.             $('#create-store-modal-body').html(result);
  326.         });
  327.     }
  328.     function focusOnDpFrom() {
  329.         $("#dpFrom").focus();
  330.     }
  331.     function focusOnDpTo() {
  332.         $("#dpTo").focus();
  333.     }
  334.     $(document).ready(function () {
  335.         $("#dpFrom").datetimepicker({
  336.             showOtherMonths: true,
  337.             selectOtherMonths: false,
  338.             changeMonth: true,
  339.             changeYear: true,
  340.             dateFormat: 'dd-mm-yy',
  341.             showButtonPanel: true,
  342.             beforeShow: function () {
  343.                 //change button colors
  344.                 var datepicker = $(this).datepicker("widget");
  345.                 setTimeout(function () {
  346.                     var buttons = datepicker.find('.ui-datepicker-buttonpane')
  347.                         .find('button');
  348.                     buttons.eq(0).addClass('btn btn-xs');
  349.                     buttons.eq(1).addClass('btn btn-xs btn-success');
  350.                     buttons.wrapInner('<span class="bigger-110" />');
  351.                 }, 0);
  352.             },
  353.             onClose: function (selectedDate) {
  354.                 if (selectedDate != "") {
  355.  
  356.                     var newDate = selectedDate.match(/\d\d\d\d/).toString()
  357.                         + "/"
  358.                         + selectedDate.match(/-\d\d/).toString().substr(1, 3)
  359.                         + "/"
  360.                         + selectedDate.match(/\d\d/).toString()
  361.                         + selectedDate.match(/ \d\d:\d\d/).toString();
  362.                     $("#dpTo").datetimepicker("option", "minDate", selectedDate);
  363.                     $("#dpTo").datetimepicker("option", "minDateTime", new Date(newDate));
  364.                 }
  365.             }
  366.         });
  367.         $("#dpTo").datetimepicker({
  368.             showOtherMonths: true,
  369.             selectOtherMonths: false,
  370.             changeMonth: true,
  371.             changeYear: true,
  372.             dateFormat: 'dd-mm-yy',
  373.             showButtonPanel: true,
  374.             beforeShow: function () {
  375.                 //change button colors
  376.                 var datepicker = $(this).datepicker("widget");
  377.                 setTimeout(function () {
  378.                     var buttons = datepicker.find('.ui-datepicker-buttonpane')
  379.                         .find('button');
  380.                     buttons.eq(0).addClass('btn btn-xs');
  381.                     buttons.eq(1).addClass('btn btn-xs btn-success');
  382.                     buttons.wrapInner('<span class="bigger-110" />');
  383.                 }, 0);
  384.             }
  385.         });
  386.  
  387.     });
  388.     InitDatatable();
  389.     function RefreshTable() {
  390.         var oTable = $("#storeDatatable").dataTable();
  391.         oTable._fnPageChange(0);
  392.         oTable._fnAjaxUpdate();
  393.     }
  394.     function InitDatatable() {
  395.  
  396.         $("#storeDatatable").dataTable({
  397.             "bFilter": false,
  398.             "bRetrieve": true,
  399.             "bServerSide": true,
  400.             "bScrollCollapse": true,
  401.             "sAjaxSource": "/StoreManager/Store/LoadStoreByStatusDatatables",
  402.             "bProcessing": true,
  403.             "oLanguage": {
  404.                 "sSearch": "Tên cửa hàng:",
  405.                 "sZeroRecords": "Không có dữ liệu phù hợp",
  406.                 "sInfo": "Hiển thị từ _START_ đến _END_ trên tổng số _TOTAL_ dòng",
  407.                 "sEmptyTable": "Không có dữ liệu",
  408.                 "sInfoFiltered": " - lọc ra từ _MAX_ dòng",
  409.                 "sLengthMenu": "Hiển thị _MENU_ dòng",
  410.                 "sProcessing": "Đang xử lý..."
  411.  
  412.             },
  413.             "aoColumnDefs": [
  414.                 { "aTargets": [0, 1, 3] },
  415.                 {
  416.                     "aTargets": [2, 4,5],
  417.                     "bSortable": false,
  418.                 }
  419.  
  420.             ],
  421.             "bAutoWidth": false,
  422.  
  423.         });
  424.     }
  425. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement