<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/AppMaster.Master" Inherits="System.Web.Mvc.ViewPage<QMAPP.Common.Web.Models.TemplateListModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	查询模板列表
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%=Html.QPList() %>
    <%=Html.QDateGrid<QMAPP.Common.Web.Models.TemplateListModel>(Model)%>
    <%=Html.QPEnd() %>
    <%=Html.HiddenFor(p=>p.ProgramName) %>
    <%=Html.Hidden("selectKey")%> 
    <script type="text/javascript">
        
        //应用
        function Apply() {
            var ids = getSelectKey();
            if (ids == "") {
                MSI("提示", "请选择查询模板。");
                return;
            }
            if (ids.indexOf(":") > 0) {
                MSI("提示", "每次只能应用一个查询模板。");
                return;
            }
            parent.parent.closeAppWindow1();
            parent.parent.ApplyTemplate(ids);
        }

        //添加
        function Add() {
            parent.parent.closeAppWindow1();
            parent.parent.AddQueryTL($('#ProgramName').val());
        }

        //编辑
        function Update() {
            var ids = getSelectKey();
            if (ids == "") {
                MSI("提示", "请选择查询模板。");
                return;
            }
            if (ids.indexOf(":") > 0) {
                MSI("提示", "每次只能修改一个查询模板。");
                return;
            }

            parent.parent.closeAppWindow1();
            parent.parent.UpdateQueryTL($('#ProgramName').val(), ids);
        }

        //删除
        function Delete() {
            var ids = getSelectKey();

            if (ids == "") {
                MSI("错误", "至少选择一个模板");
            }
            else {
                document.getElementById("selectKey").value = ids;
                MSQ("提示", "确定要删除选中的模板吗?", function () {
                    submitByButton("TemplateDelete");
                })
            }
        }

    </script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ToolContent" runat="server">
<table cellpadding=0 cellspacing=0>
    <tr>
        <td align="center">
            <%=Html.QTButton("apply", "TemplateApply", QMFrameWork.WebUI.IconCls.ok, "Apply()", (s, f) => { return true; })%> 
            <%=Html.QTButtonAdd("QueryTL", "TemplateAdd", "Add()")%>          
            <%=Html.QTButtonUpdate("QueryTL", "TemplateUpdate", "Update()")%> 
            <%=Html.QTButtonDelete("QueryTL", "TemplateDelete", "Delete()")%>
            <%=Html.QTButton("close", "close","close", "parent.parent.closeAppWindow1();return false;", (s, f) => { return true; })%>
        </td>
    </tr>
</table>
</asp:Content>