<%@ page language="C#" autoeventwireup="true" inherits="WebAdmin_NoticeTypeList, 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/ryjs.js" type="text/javascript"></script>
    <script src="js/tipswindown.js" type="text/javascript"></script>
    <script type="text/javascript">
         //修改一条信息
        function modifyById(id_,i){
            var tname=document.getElementById("txt_name_"+i).value;
            var ttypecode=document.getElementById("txt_sort_"+i).value;
            var showtype=document.getElementById("type_id"+i).value;
            var onfoot=document.getElementById("hidden_onfoot"+i).value;
            window.location.href="NoticeTypeResult.aspx?id="+id_+"&ttypecode="+escape(ttypecode)+"&t_name="+escape(tname)+"&showtype="+escape(showtype)+"&isonfoot="+escape(onfoot)+"&type=update";
        }
        //删除一条
        function deleteById(id_){
             if (confirm("确认要删除？")) {
                window.location.href="NoticeTypeResult.aspx?id="+id_+"&type=delete";//&page="+page;
            }
        }
        //保存
        function saveRow(){
            var form =document.forms[0];
            var flag=false;
            for(i=0;i<form.elements.length;i++)
            {
                if(form.elements[i].id!="Showtype"){
                    if(form.elements[i].type=="text")
                    {   
                        if(form.elements[i].id!="txt_name"&&form.elements[i].id!="txt_sort"){
                            if(form.elements[i].value==""){
                                document.getElementById("msg_a2").innerHTML="<span class='msg_submit'>以下填写不能有空值！</span>";
                                flag=false;
                                break;
                            }else{
                                flag=true;
                            }
                        }
                    }
                }
            }
            if(flag){
                document.getElementById("form1").submit();
            }
        }
        //批量删除
        function deleteAll(){
            var form =document.forms[0];
            var strid="";
            if (confirm("确认要删除？")) {
               
                var del_cb=document.getElementsByName("cb_delete");
                for(var i=0;i<del_cb.length;i++)
                {
                    if(del_cb[i].checked){
                        strid+=del_cb[i].value+",";
                    }
                }
                if(strid!="")
                window.location.href="NoticeTypeResult.aspx?ustrid="+strid+"&type=dels";
            }
        }
       
        function cleartxt()
        {
          document.getElementById("Showtype").value="";
        }
         function select(){
           var title=document.getElementById("Showtype").value;
           window.location.href="NoticeTypeList.aspx?title="+escape(title);
        }
        //保留查询条件
        function getSelect(){
            var title='<%=title %>';
            if(title !=""){
                document.getElementById("Showtype").value=title;
            }
        }
        function setValue(i_){
            if(document.getElementById("cb_onfoot"+i_).checked==true){
                document.getElementById("hidden_onfoot"+i_).value=1;
            }else{
                document.getElementById("hidden_onfoot"+i_).value=0;
            }
        }
        function AllChecked2(str){
             var listc=document.getElementsByName(str);
             for(i=0;i<listc.length;i++){
                if(listc[i].checked){
                    listc[i].checked=false;
                }else{
                    listc[i].checked=true;
                }
             }
        }
        function val_name(){
           var name= document.getElementById("txt_name").value;
           if(name==""){
                document.getElementById("sp_msg").innerHTML="<span class='msg_submit'>类型名称不能为空！</span>";
                return false;
           }else{
                document.getElementById("sp_msg").style.display="none";
                return true;
           }
        }
    </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=="false1"){
                tipsWindown('操作结果','text:此类型已存在，不能添加！！','250','100','true','2000','true','text');
            }
            if(f=="false"){
                tipsWindown('操作结果','text:操作失败！','250','100','true','2000','true','text');
            }
            function fun() {
                if (i == 1) {
                    window.location.href="NoticeTypeList.aspx";
                }
                i--;
            }
        </script>
        <div class="tabmenus mainwidth">
            <ul>
                <li><a href="NoticeList.aspx"><span>信息管理</span></a></li>
                <li><a href="helpCenter.aspx"><span>信息添加</span></a></li>
                <li class="current"><a href="NoticeTypeList.aspx"><span>类别管理</span></a></li>
            </ul>
        </div>
        <div class="tab-mainbody">
            <div class="tab-mainbody2">
                <div class="functionHandleArea clearfix">
                    <input id="Image1" type="image" title=" 保存 " onclick="return val_name();" src="images/bt_app.gif" runat="server"  onserverclick="Button1_Click" align="absmiddle" />&nbsp;<span id="sp_msg"></span>
                </div>
                <div id="datalist">
                <table cellspacing="0" width="100%" cellpadding="0" id="list">
                    <tr> 
                        <th style="width: 25%;">类型名称</th>
                        <th style="width: 20%;">显示类型</th>
                        <th style="width: 15%">底部显示</th>
                        <th style="width: 40%">排序</th>
                    </tr>
                    <tr>
                        <td>
                            <input type="text" id="txt_name" runat="server" class="input" />
                        </td>
                        <td>
                            <select id="type_id" runat="server" class="input">
                                <option value="1" selected>列表型</option>
                                <option value="2">信息型 </option>
                            </select>
                        </td>
                        <td>
                            <input type="checkbox" id="cb_onfoot"  checked  runat="server"/>
                        </td>
                        <td>
                            <input type="text" id="txt_sort" runat="server" value="0" class="input" style="width:50px" />
                        </td>
                    </tr>
                </table>
                <script type="text/javascript">tdshowm("list");</script>
                </div>
                <div class="functionHandleArea clearfix" style="padding:3px 0 3px 4px; margin-top:5px;">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <input type="text" id="Showtype" name="Showtype" runat="server" class="input" style="width: 150px"  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="saveRow();return false;" src="images/bt_app.gif" align="absmiddle" />
                                <input type="image" title=" 删除 " onclick="deleteAll();return false;" src="images/bt_delete.gif" align="absmiddle" />
                                <span id="msg_a2" runat="server" class="msg2"></span>
                            </td>
                        </tr>
                    </table>
                </div>
                <div id="datalist">
                <table cellspacing="0" width="100%" cellpadding="0" id="list2">
                    <tr>
                        <th style="width: 5%; cursor: pointer" title="全选" onclick="AllChecked2('cb_delete')">
                            选择</th>
                        <th style="width: 25%;">
                            类型名称</th>
                        <th style="width: 10%;">
                            显示类型</th>
                        <th style="width: 10%">
                            底部显示
                        </th>
                        <th style="width: 40%">
                            排序
                        </th>
                        <th style="width: 10%;">
                            操作
                        </th>
                    </tr>
                    <%for (int i = 0; i < ds.Tables[0].Rows.Count; i++){%>
                    <tr>
                        <td>
                            <input 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>
                            <input type="text" id="txt_name_<%=i %>" name="txt_name_<%=i %>" value="<%=ds.Tables[0].Rows[i]["Tname"] %>"
                                class="input" />
                        </td>
                        <td>
                            <select id="type_id<%=i %>" name="type_id<%=i %>">
                                <% 
                                    if (ds.Tables[0].Rows[i]["showtype"].ToString() == "1")
                                    {
                                %>
                                <option id='<%=ds.Tables[0].Rows[i]["id"] %>_id' value="1" selected>列表型 </option>
                                <option id='<%=ds.Tables[0].Rows[i]["id"] %>_di' value="2">信息型 </option>
                                <%}
                                  else
                                  { %>
                                <option id='<%=ds.Tables[0].Rows[i]["id"] %>d_i' value="1">列表型 </option>
                                <option id='<%=ds.Tables[0].Rows[i]["id"] %>i_d' value="2" selected>信息型 </option>
                                <%
                                    } %>
                            </select>
                        </td>
                        <td>
                            <input type="checkbox" id="cb_onfoot<%=i %>" name="cb_onfoot<%=i %>" <%if (ds.Tables[0].Rows[i]["isonfoot"].ToString() == "1")%>
                                checked onclick="setValue(<%=i %>)" />
                                
                                <input type=hidden id="hidden_onfoot<%=i %>" name="hidden_onfoot<%=i %>" value="<%=ds.Tables[0].Rows[i]["isonfoot"] %>" />
                        </td>
                        <td>
                            <input type="text" id="txt_sort_<%=i %>" name="txt_sort_<%=i %>" value="<%=ds.Tables[0].Rows[i]["typecode"] %>"
                                class="input" style="width:50px" />
                        </td>
                        <td>
                            <a href='javascript:deleteById(<%=ds.Tables[0].Rows[i]["id"] %>)'>删除</a> | <a href='javascript:modifyById(<%=ds.Tables[0].Rows[i]["id"] %>,<%=i %>)'>
                                修改</a>
                        </td>
                    </tr>
                    <%} %>
                    <tr>
                        <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("list2");</script>
                </div>
            </div>
        </div>
    </form>
</body>
</html>
