<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/SimonMasterPage.Master"
    Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
     <%: Html.Language("RepairRecord")%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="easyui-layout" data-options="fit:true">
        <div data-options="region:'north',border:false" style="overflow: hidden; height: 30px;">
            <div class="toolbar">
                <a href="javascript:void(0)" class="toolbar-button tb-icon-refresh" onclick="$('#dg').datagrid('load',{});">
                    <%: Html.Language("Refresh")%></a> <a href="javascript:void(0)" class="toolbar-button tb-icon-register"
                        onclick="add()">
                        <%: Html.Language("RepairRecord")%></a>
            </div>
        </div>
        <div data-options="region:'center',border:false">
            <table id="dg" class="easyui-datagrid" style="width: 100%; height: auto;" data-options="
						border: false,
						pagination: true,
						pageSize: 20,
						rownumbers: true,
						striped: true,
						sortName: 'Number',
						sortOrder: 'asc',
						fit: true,
						fitColumns: true,
						idField: 'ID',
						frozenColumns: [[ { field: 'ID', checkbox: true } ]],
						method: 'post',
						url: '/FaultRecords/LoadAllByPage/',
						onDblClickRow: function(index, row) { edit(row); }
					">
                <thead>
                    <tr>
                        <th data-options="field:'Status',sortable:true,resizable:false,formatter: function(value){ return value == 0 ? lang.NoMaintenance : lang.HaveMaintenance; }">
                            <%: Html.Language("MaintenanceState")%>
                        </th>
                        <th data-options="field:'IsCancel',sortable:true,resizable:false,formatter: function(value){ return value ? lang.HasBeenCancelled : ''; }">
                            <%: Html.Language("Logout")%>
                        </th>
                        <th data-options="field:'Number',sortable:true,resizable:false">
                            <%: Html.Language("ID")%>
                        </th>
                        <th data-options="field:'RoomNumber',sortable:true,resizable:false">
                            <%: Html.Language("RoomNumber")%>
                        </th>
                        <th data-options="field:'FaultTypeCode',sortable:true,resizable:false">
                            <%: Html.Language("FaultCode")%>
                        </th>
                        <th data-options="field:'FaultType',sortable:true,resizable:false">
                            <%: Html.Language("FaultName")%>
                        </th>
                        <th data-options="field:'FaultTime',sortable:true,resizable:false">
                            <%: Html.Language("FaultDate")%>
                        </th>
                        <th data-options="field:'Description',sortable:true,resizable:false">
                            <%: Html.Language("Remark")%>
                        </th>
                        <th data-options="field:'RepairPerson',sortable:true,resizable:false">
                            <%: Html.Language("MaintenanceMan")%>
                        </th>
                        <th data-options="field:'RepairTime',sortable:true,resizable:false">
                            <%: Html.Language("MaintenanceTime")%>
                        </th>
                        <th data-options="field:'RepairContent',sortable:true,resizable:false">
                            <%: Html.Language("MaintenanceContent")%>
                        </th>
                        <th data-options="field:'CancelPerson',sortable:true,resizable:false">
                            <%: Html.Language("CancellationPersonnel")%>
                        </th>
                        <th data-options="field:'CancelTime',sortable:true,resizable:false">
                            <%: Html.Language("CancellationTime")%>
                        </th>
                        <th data-options="field:'CancelReason',sortable:true,resizable:false">
                            <%: Html.Language("CancellationReason")%>
                        </th>
                        <th data-options="field:'RegisteredPerson',sortable:true,resizable:false">
                            <%: Html.Language("Registrant")%>
                        </th>
                        <th data-options="field:'RegisteredTime',sortable:true,resizable:false,formatter:$.tools.formatDateTime">
                            <%: Html.Language("FaultBookDate")%>
                        </th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
    <div id="addRepairDlg" class="easyui-window"   title='<%: Html.Language("RepairRecord")%>' style="width: 400px; height: 420px;
        padding: 5px;" closed="true" modal="true" collapsible="false" minimizable="false"
        maximizable="false">
        <div class="easyui-layout" fit="true">
            <div data-options="region:'center'">
                <form id="ff" class="easyui-form" method="post" data-options="novalidate:true">
                <input name="ID" type="hidden" value="0" />
                <table style="margin: 20px auto;" cellpadding="3">
                    <tr>
                        <td class="align-right">
                             <%: Html.Language("FaultID")%>：
                        </td>
                        <td>
                            <input id="txtNumber" name="Number" class="easyui-validatebox textbox text" readonly="readonly" />
                        </td>
                    </tr>
                    <tr>
                        <td class="align-right">
                            <%: Html.Language("FaultType")%>：
                        </td>
                        <td>
                            <input id="txtFaultTime" name="FaultTime" class="easyui-validatebox textbox text"
                                readonly="readonly" />
                        </td>
                    </tr>
                    <tr>
                        <td class="align-right">
                            <%: Html.Language("RoomNumber")%>：
                        </td>
                        <td>
                            <input name="RoomNumber" class="easyui-validatebox textbox text" readonly="readonly" />
                        </td>
                    </tr>
                    <tr>
                        <td class="align-right">
                             <%: Html.Language("FaultTime")%>：
                        </td>
                        <td>
                            <input name="FaultType" class="easyui-validatebox textbox text" readonly="readonly" />
                        </td>
                    </tr>
                    <tr>
                        <td class="align-right">
                            <%: Html.Language("MaintenanceTime")%>：
                        </td>
                        <td>
                            <input id="txtRepairTime" name="RepairTime" class="easyui-datetimebox textbox text"
                                data-options="required:true,editable:false" />
                        </td>
                    </tr>
                    <tr>
                        <td class="align-right">
                            <%: Html.Language("MaintenanceMan")%>：
                        </td>
                        <td>
                            <input id="txtRepairPerson" name="RepairPerson" class="easyui-validatebox textbox text"
                                data-options="required:true,validType:'length[1,20]'" />
                        </td>
                    </tr>
                    <tr>
                        <td class="align-right">
                             <%: Html.Language("MaintenanceContent")%>：
                        </td>
                        <td>
                            <textarea id="txtRepairContent" name="RepairContent" class="easyui-validatebox textbox text"
                                data-options="validType:length[0,200]" cols="30" rows="5"></textarea>
                        </td>
                    </tr>
                </table>
                </form>
            </div>
            <div data-options="region:'south',border:false" style="text-align: right; padding: 5px 0 0;">
                <a class="easyui-linkbutton" data-options="iconCls:'icon-save'" href="javascript:void(0)"
                    onclick="save();">
                    <%: Html.Language("Save")%></a> <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'"
                        href="javascript:void(0)" onclick="$('#addRepairDlg').window('close');">
                        <%: Html.Language("Cancel")%></a>
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        function add() {

            var row = $('#dg').datagrid('getSelected');
            if (row) {

                if (row.Status != 0 || row.IsCancel) {
                    $.tools.alert(lang.ORNMANCB);
                    return;
                }

                $("#ff").form("reset").form("load", row);
                $("#addRepairDlg").window("open");
            } else {
                $.tools.alert(lang.PleaseSelectTheData);
            }
        }
        function save() {
            if ($("#ff").form("enableValidation").form("validate")) {
                var entity = $("#ff").serializeJson();
                $.tools.post(entity, "/FaultRecords/Repair/", function (r) {
                    $("#dg").datagrid("reload");
                    $("#addRepairDlg").window("close");
                });
            }
        }
    </script>
</asp:Content>
