<%@ page language="C#" autoeventwireup="true" inherits="WebAdmin_NoticeListType, LebiMall" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>列表型消息列表</title>
    <link href="css/css.css" rel="stylesheet" type="text/css" />
    <link href="css/tipswindown.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" language="javascript" src="js/topHead.js"></script>
    <script type="text/javascript" src="js/checked.js"></script>
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/tipswindown.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="js/ryjs.js"></script>


    <script type="text/javascript">
   
     var page="<%=page %>";
        //整体修改
        function updataAll(){
            document.getElementById("hid_type").value="updataAll";
            document.getElementById("hid_page").value=page;
            var cbs= document.getElementsByName('checkbox');
            var strcb="";
            for(i=0;i<cbs.length;i++)
            {
                if(cbs[i].checked==true)
                {
                    strcb+=1+",";
                }else{
                    strcb+=0+",";
                }
            }
            document.getElementById('hid_checkbox').value=strcb;
            document.getElementById("form1").submit();
        }
        //批量删除
        function deleteAll(){
            var list= document.getElementsByName('cb_delete');
            var strid="";
            if (confirm("确认要删除？")) {
                 for(i=0;i<list.length;i++)
                {
                    if(list[i].checked==true){
                        strid+=list[i].value+",";
                    }
                } 
                window.location.href="NoticeListType.aspx?strid="+strid+"&type=dels&page="+page+"&typeid=<%=typeid %>";
            }
        }
        //单个编辑
        function edit(id){
             window.location.href="NoticeListEdit.aspx?id="+id+"&page="+page;
        }
        function selectchange(obj,i){
              document.getElementById("hid_checkbox_"+i).value=obj.value;
        }
        //单个修改
        function modifyById(id_,i){
            var isshow="";
            if(document.getElementById('checkbox_'+i).checked)
            {
               isshow= 1 ;
            }else{
                isshow=0;
            }
            document.getElementById('hid_checkbox').value=isshow;
            var txttitle=document.getElementById('txt_ntitle_'+i).value;
            var txtsubmittime=document.getElementById('txt_submittime_'+i).value;
           
            window.location.href="NoticeListType.aspx?txttitle="+escape(txttitle)+"&txtsubmittime="+escape(txtsubmittime)
                                +"&isshow="+escape(isshow)+"&id="+id_+"&type=update&page="+page;
        }
        function select(){
           var id=document.getElementById("type_id").value;
           var title=document.getElementById("txtTitle").value;
           var dateFrom=document.getElementById("dateFrom").value;
           var dateTo=document.getElementById("dateTo").value;
           window.location.href="NoticeListType.aspx?id="+id+"&title="+escape(title)+"&dateFrom="+dateFrom+"&dateTo="+dateTo;
        }
        function getSelect(){
            var typeid='<%=typeid %>';
            var lists=document.getElementById("type_id");
            for(var i=0;i<lists.length;i++){
                if(typeid==lists[i].value){
                    lists[i].selected=true;
                    break;
                }
            }
            var title='<%=title %>';
            document.getElementById("txtTitle").value=title;
            var fromtime='<%=fromtime %>';
            var totime='<%=totime %>';
            document.getElementById("dateFrom").value=fromtime;
            document.getElementById("dateTo").value=totime;
        }
    </script>

</head>
<body onload="getSelect()">
    <form id="form1" runat="server">
        
        <script>header(5,4,"images/");</script>
        <div class="blank clearfix">
        </div>
        <script type="text/javascript">
            var $=jQuery;
            var f="<%=returnValue %>";
            var i=2;
            if(f=="true"){
                tipsWindown('操作结果','text:操作成功！','250','100','true','2000','true','text');
                setInterval("fun()", 1000);
            }
            if(f=="false"){
                tipsWindown('操作结果','text:操作失败！','250','100','true','2000','true','text');
            }
            function fun() {
                if (i == 1) {
                    window.location.href='NoticeListType.aspx?id=<%=typeid %>';
                }
                i--;
            }
        </script>
        <div class="tabmenus mainwidth">
            <ul>
                <li class="current"><a href="NoticeList.aspx"><span>信息管理</span></a></li>
                <li><a href="HelpCenter.aspx"><span>信息添加</span></a></li>
                <li><a href="NoticeTypeList.aspx"><span>类别管理</span></a></li>
            </ul>
        </div>
        <div class="tab-mainbody">
            <div class="tab-mainbody2">
            <div class="functionHandleArea clearfix"  style="padding:3px 0 3px 4px">
                <input type="hidden" id="hid_checkbox" name="hid_checkbox" />
                <input type="hidden" id="hid_page" name="hid_page" />
                <input type="hidden" id="hid_type" name="hid_type" />
                <table cellpadding="0" cellspacing="0" >
                    <tr>
                        <td>
                            <input type="text" name="dateFrom" id="dateFrom" onkeydown="quickQueryCust(event);" runat="server" size="12" class="texttime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',skin:'whyGreen',autoPickDate:'null'})" />
                            -
                            <input type="text" name="dateTo" id="dateTo" onkeydown="quickQueryCust(event);" runat="server" size="12" class="texttime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',skin:'whyGreen',autoPickDate:'null'})" />
                            <input type="hidden" id="hid_id" runat="server" />
                            <select id="type_id" name="type" onchange="javascript:chang(this);" class="input">
                                <option id="selectall" value="0">全部</option>
                                <%
                                    for (int j = 0; j < dstype.Tables[0].Rows.Count; j++)
                                    {
                                %>
                                <option id='<%=dstype.Tables[0].Rows[j]["id"] %>_id' value="<%=dstype.Tables[0].Rows[j]["id"]%>">
                                    <%=dstype.Tables[0].Rows[j]["Tname"]%>
                                </option>
                                <%
                                    }
                                %>
                            </select>

                            <script>
                                function chang(obj){
                                    document.getElementById("hid_id").value=obj.value;
                                }
                            </script>
                            <input type="text" name="txtTitle" id="txtTitle" style="width:150px;" class="input" onkeydown="quickQueryCust(event);"/><input type="button" id="btnSou" title=" 搜索 " onclick="location.href='javascript:select()';" class="btn-search" align="absmiddle" />
                        </td>
                    </tr>
                    <tr>
                        <td style="height:30px;">
                            <input type="image" title=" 保存 " onclick="updataAll();return false;" src="images/bt_app.gif" />
                            <input type="image" name="Submit" title=" 删除 " onclick="deleteAll();return false;" src="images/bt_delete.gif" />
                            <input type="image" title=" 添加 " onclick="location.href='AddNotice.aspx';return false;" src="images/bt_add.gif" />
                            <input type="image" title=" 返回 " onclick="history.back();return false;" src="images/bt_bak.gif" />
                        </td>
                    </tr>
                </table>
            </div>
            <div>
                <div id="datalist">
                <table cellspacing="0" width="100%" cellpadding="0" id="list">
                    <tr class="row">
                        <th style="width: 5%; cursor: pointer" title="全选" onclick="CheckedAllInfo()">
                            选择</th>
                        <th style="width: 35%;">
                            标题</th>
                        <th style="width: 15%;">
                            类型
                        </th>
                        <th style="width: 25%;">
                            上传时间
                        </th>
                        <th style="width: 10%;">
                            是否显示
                        </th>
                        <th style="width: 10%;">
                            基本操作
                        </th>
                    </tr>
                    <%
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                    %>
                    <tr class="row">
                        <td class="row">
                            <input id="ck_select" type="checkbox" value="<%=ds.Tables[0].Rows[i]["id"] %>" name="cb_delete" />
                            <input type="hidden" id="hidden<%=i %>" name="hidden<%=i %>" value="<%=ds.Tables[0].Rows[i]["id"] %>" />
                        </td>
                        <td class="row">
                            <input type="text" id="txt_ntitle_<%=i %>" name="txt_ntitle_<%=i %>" value="<%=ds.Tables[0].Rows[i]["ntitle"] %>"
                                class="input" style="width:300px;" />
                        </td>
                        <td class="row">
                            <%
                                for (int j = 0; j < dstype.Tables[0].Rows.Count; j++)
                                {
                            %>
                            <%
                                if (ds.Tables[0].Rows[i]["typeid"].ToString() == dstype.Tables[0].Rows[j]["id"].ToString())
                                {
                            %>
                            <input type="hidden" id='type_<%=i %>' name='type_<%=i %>' value='<%=ds.Tables[0].Rows[i]["typeid"].ToString() %>' /> 
                            <a href='NoticeListType.aspx?id=<%=dstype.Tables[0].Rows[j]["id"].ToString() %>'>
                                <%=dstype.Tables[0].Rows[j]["Tname"]%>
                            </a>
                            <%
                                }

                            } %>
                        </td>
                        <td class="row">
                            <input type="text" id="txt_submittime_<%=i %>" name="txt_submittime_<%=i %>" value="<%=ds.Tables[0].Rows[i]["Submittime"] %>"
                                class="texttime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',skin:'whyGreen',autoPickDate:'null'})" style="width:160px;" />
                        </td>
                        <td class="row">
                            <input type="checkbox" id="checkbox_<%=i %>" name="checkbox" <%if (ds.Tables[0].Rows[i]["isshow"].ToString()=="1"){%>
                                checked value="1" <%} %> />
                        </td>
                        <td class="row">
                            <a href='javascript:edit(<%=ds.Tables[0].Rows[i]["id"] %>)'>编辑</a> | <a href='javascript:modifyById(<%=ds.Tables[0].Rows[i]["id"] %>,<%=i %>)'>修改</a>
                        </td>
                    </tr>
                    <%} %>
                    <tr class="row">
                        <td colspan="6" class="list-foot">
                            <div style="float: left; padding-top: 3px;">
                                </div>
                                <div id="divAsp" runat="server" style="float: right; padding-top: 3px;">
                                    <webdiyer:AspNetPager CssClass="pages" CurrentPageButtonClass="cpb" ID="AspNetPager1"
                                        runat="server" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页"
                                        PrevPageText="上一页" PageSize="20" UrlPaging="True" CustomInfoClass="pages1" CurrentPageButtonPosition="Center" ShowBoxThreshold="50"
                                        ShowFirstLast="true" NumericButtonCount="4" BackColor="Transparent" ShowDisabledButtons="False" EnableViewState="False">
                                    </webdiyer:AspNetPager>
                                </div>
                        </td>
                    </tr>
                </table>

                <script type="text/javascript">tdshowm("list");</script>

            </div>
            </div>
        </div>
        </div>
    </form>
</body>
</html>
