<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OnHand.aspx.cs" Inherits="Stock_Report_OnHand" %>
<%@ Register Src="~/Scripts/AWGridRuntime/UserControl/ListHeader.ascx" TagPrefix="uc1" TagName="ListHeader" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <uc1:ListHeader runat="server" ID="ListHeader" />
    <script type="text/javascript">
        //搜索
        function search_grid() {
            var fg = document.getElementById("frame_grid");
            var keyword = $("#keyword").val();
            var wh_id = $("#wh_id").val();
            var wh_name = $("#wh_name").val();
            if (wh_name == "") {
                wh_id = "";
            }
            var ic_code = $("#ic_code").val();
            var ic_name = $("#ic_name").val();
            if (ic_name == "") {
                ic_code = "";
            }
            var i_code = $("#i_code").val();
            var i_name = $("#i_name").val();
            var standard = $("#standard").val();
            var free1 = $("#free1").val();
            var free2 = $("#free2").val();
            var batch = $("#batch").val();
            var above = $("#above").val();
            var equal = $("#equal").val();
            var less = $("#less").val();
            var url = "OnHand_Grid.aspx?keyword=" + keyword + "&i_code=" + i_code
                    + "&i_name=" + i_name + "&standard=" + standard
                    + "&wh_id=" + wh_id + "&ic_code=" + ic_code
                    + "&free1=" + free1 + "&free2=" + free2 + "&batch=" + batch
                    + "&above=" + above + "&less=" + less + "&equal=" + equal;
            fg.src = url;
        }
        //选择打印模板
        function grf_print(){
            var fg = document.getElementById("frame_grid"); //得到grid控件所在iframe
            var cw = fg.contentWindow;
            choice_print_template('<%=xview["auth_code"]%>',"",cw.sql_print_detail_session_id);
        }
        //整理现存量
        function fix_stock() {
            asyncbox.confirm('确定要整理现存量吗?', '警告', function (buttonResult) {
                if (buttonResult == "ok") {
                    ShowLoadingMask(); //显示遮罩
                    $.ajax({
                        type: "POST",
                        contentType: "application/json",
                        url: 'OnHand_Service.asmx/FixStock',
                        data: "{}",
                        dataType: 'json',
                        success: function (result) {
                            HideLoadingMask(); //关闭遮罩
                            var r = result.d;
                            if (r == "success") {
                                AlertOK("整理完毕!");
                                search_grid();
                            } else {
                                AlertNO(r);
                            }
                        }
                    });
                }
            });
        }
        function modify() {}
    </script>
</head>
<body>
    <!--工具栏-->
    <div style="height:30px;" class="list_menu_bar">
        <input type="text" class="keyword_box" id="keyword"/>
        <a plain="true" class="easyui-linkbutton" onclick="search_grid()">搜索</a>
        <a plain="true" class="easyui-linkbutton" onclick="$('#search_win').window('open')" iconcls="icon-search">高级搜索</a>
        <a plain="true" class="easyui-linkbutton" id="btn_refresh" onclick="search_grid()">刷新</a>
        <a plain="true" class="easyui-linkbutton" id="btn_fix_stock" onclick='fix_stock()' style='<%=auth.AuthView("Stock_Report_OnHand_FixOnHand")%>'>整理现存量</a>
        <a plain="true" class="easyui-linkbutton" id="btn_print" onclick='grf_print()'>打印</a>
        <a plain="true" class="easyui-linkbutton" onclick="DesignModuleFormat('Stock_Report_OnHand')">格式</a>
    </div>
    <!--Grid控件所在的iframe-->
    <%=xview["grid_frame"]%>
    <!--搜索窗口-->  
	<div id="search_win" class="easyui-dialog" title="搜索"
        data-options="modal:true,closed:false,closable: false,iconCls:'icon-search'"
        style="width:400px;height:350px;padding:10px;">
		<table style="margin:auto;">
            <tr>
                <td style="text-align:right">仓库:</td>
                <td>
                    <input type="hidden" class="edit_text_box" id="wh_id"/>
                    <input type="text" class="edit_text_box" id="wh_name" style='width:98px'/></td>
            </tr>
            <tr>
                <td style="text-align:right">存货编码:</td>
                <td>
                    <input type="hidden" class="edit_text_box" id="i_id"/>
                    <input type="text" class="edit_text_box" id="i_code" style='width:98px'/></td>
            </tr>
            <tr>
                <td style="text-align:right">存货名称:</td>
                <td><input type="text" class="edit_text_box" id="i_name"/></td>
            </tr>
            <tr>
                <td style="text-align:right">规格型号:</td>
                <td><input type="text" class="edit_text_box" id="standard"/></td>
            </tr>
            <tr>
                <td style="text-align:right">存货分类:</td>
                <td>
                    <input type="hidden" class="edit_text_box" id="ic_id"/>
                    <input type="hidden" class="edit_text_box" id="ic_code"/>
                    <input type="text" class="edit_text_box" id="ic_name" style='width:103px'/>
                    <div class='combobox_trigger'><a href='#' id='trigger_ic_name'></a></div></</td>
            </tr>
            <tr style="<%=cfg.DisplayFree1()%>">
                <td style="text-align:right"><%=cfg.Free1Title()%>:</td>
                <td>
                    <input type="text" class="edit_text_box" id="free1"/></td>
            </tr>
            <tr style="<%=cfg.DisplayFree2()%>">
                <td style="text-align:right"><%=cfg.Free2Title()%>:</td>
                <td>
                    <input type="text" class="edit_text_box" id="free2"/></td>
            </tr>
            <tr>
                <td style="text-align:right">批次:</td>
                <td><input type="text" class="edit_text_box" id="batch"/></td>
            </tr>
            <tr>
                <td style="text-align:right">数值范围:</td>
                <td>
                    ><input type="text" class="edit_text_box" id="above" style="width:40px;float:none"/>
                    =<input type="text" class="edit_text_box" id="equal" style="width:40px;float:none"/>
                    <<input type="text" class="edit_text_box" id="less" style="width:40px;float:none"/>
                    </td>
            </tr>
		</table>
        <div style="margin-top:20px;text-align:center">
            <a href="javascript:search_grid()" class="easyui-linkbutton" onclick="javascript:$('#search_win').dialog('close')">搜索</a>
        </div>
	</div>
    <!--end of 搜索窗口--> 
    <script type="text/javascript">
        $(document).ready(function(){
            FastSearch_Warehouse(); //仓库
            FastSearch_Inventory(); //查询存货
            $F("trigger_ic_name").onclick = function () {
                AdvancedSearch_InventoryClass($("#ic_name").val());
            };
            //$F("keyword").focus();
            $F("keyword").onkeypress = function (evt) {
                evt = evt ? evt : (window.event ? window.event : null);
                if (evt.keyCode == "13") {
                    search_grid();
                }
            }
            var keyword = '<%=Request["keyword"]%>';
            if (keyword != null) {
                $("#keyword").val(keyword);
                $('#search_win').dialog('close'); //关闭查询框
                search_grid();
            }
        });
    </script>
</body>
</html>
