<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Replace.aspx.cs" Inherits="ZYDN.Web.system.myWeb.Replace" %>

<!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 runat="server">
    <title>查找替换</title>
    <link rel="stylesheet" type="text/css" href="../skins/CSS/main.css" />
    <link rel="stylesheet" type="text/css" href="../skins/CSS/Sys.css" />
    <style type="text/css">
         table{border-collapse:collapse;border-color:#D9E9F8;color:#01439a; font-size:14px; width:270px; border-bottom:1px solid #CCCCCC;  border-top:1px solid #cccccc;}
         .biaotouTd{font-size:12px;font-weight:bold; text-align:left;height:20px; boder:1px #cccccc solid;  background-color:#A8C1DD; color:#01439a; line-height:20px; border-right:1px #cccccc solid; border-left:1px #cccccc solid;padding-left:5px;}
        .jishutd{border-top:1px #cccccc solid; font-size:12px; text-align:left;color:#01439a; line-height:20px;background-color:#F0F5FB;padding-left:5px;padding-right:5px;}
        .jishutdts{width:130px;border-right:1px #cccccc solid;border-top:1px #cccccc solid; font-size:12px; text-align:left;color:#01439a; line-height:20px;background-color:#F0F5FB;padding-left:5px;padding-right:5px;}
        .jishutds{width:30px;border-right:1px #cccccc solid;border-top:1px #cccccc solid; font-size:12px; text-align:left;color:#01439a; line-height:20px;background-color:#F0F5FB;padding-left:5px;padding-right:5px;}
        .oushutd{border-top:1px #cccccc solid;text-align:left; line-height:20px;font-size:12px;background-color:#FFFFFF;padding-left:5px;padding-right:5px;}
        .oushutds{width:30px;border-right:1px #cccccc solid;border-top:1px #cccccc solid;text-align:left; line-height:20px;font-size:12px;background-color:#FFFFFF;padding-left:5px;padding-right:5px;}
        .oushutdts{width:130px;border-right:1px #cccccc solid;border-top:1px #cccccc solid;text-align:left; line-height:20px;font-size:12px;background-color:#FFFFFF;padding-left:5px;padding-right:5px;}
    </style>

    <script type="text/javascript" language="javascript" src="../JS/JFramework.js"></script>
    <script type="text/javascript" language="javascript" src="../JS/Sys.js"></script>   
    <script language="javascript" type="text/javascript">
    function getList(index)
    {
       var objAjax=new JAjax();
       var objResponse=new JHttpResponse();
       objResponse.write("index",index);
       out=objAjax.getText("post","inputData.aspx?type=read",objResponse,null);      
       if(out==null||out=="")
       {
         return;
       }
       else
       {
          document.getElementById("getTabList").innerHTML=out;
       }
    }
 //替换数据
 function ReplaceTxt()
 {
     var txtOld=document.getElementById("txtOld").value;
     var txtNew=document.getElementById("txtNew").value;
     var list=document.getElementById("live").innerText;
     var lists=document.getElementById("live").innerHTML;
     if(list==""||list==null)
     {
      alert("请选择表");
      return;
     }
     if(txtOld==""||list==null)
     {
      alert("查找内容不能够为空");
      return;
     }
     if(confirm("你当前的操作:\n将表\n"+lists+"\n里面的内容\""+txtOld+"\"\n替换成内容\""+txtNew+"\"\n确实要替换吗?"))
     {    
        var ulist = document.getElementsByName("choice");
        for(var i=0;i<ulist.length;i++)
        {
            if(ulist[i].checked==true)
            {
               var objAjax=new JAjax();
               var objResponse=new JHttpResponse();
               objResponse.write("txtOld",txtOld);
               objResponse.write("txtNew",txtNew);
               objResponse.write("list",ulist[i].value);
               var out=objAjax.getText("post","inputData.aspx?type=Replace",objResponse,null); 
               if(out==""||out==null)
               {
                alert("替换"+ulist[i].value+"失败");
                return;
               } 
            }            
        } 
        alert("全部替换成功");
     }
 }
  //获取所有被选项的ID
    function getTeamIDList()
    {
        selectTeamID="";
        var ulist = document.getElementsByName("choice");
        for(var i=0;i<ulist.length;i++)
        {
            if(ulist[i].checked==true)
            {
                selectTeamID+=ulist[i].value+"、";
            }
        }
       document.getElementById("live").innerHTML=selectTeamID;
    }
    //全选或者单选
    function selectAllTeam(thisObj)
    {
        var isCheck = thisObj.checked;
        var ulist = document.getElementsByName("choice");
        for(var i=0;i<ulist.length;i++)
        {
            if(ulist[i]!=isCheck)
            {
                ulist[i].click();
            }
        }
        getTeamIDList();
    }
	function loadPage(){
	    
		 loadBodyclick();
		writeFettleLeft("提示:该功能用于对用户自定义数据表中的内容进行查找替换") //状态栏提示
	}
 </script>
</head>
<body onload="loadPage();">
<form id="form1" runat="server">
    <div style="width:100%;height:100%;top:0px;left:0px;position:absolute;z-index:2;background-color:#ffffff">
    <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="titleRow" style="width:40px; text-align:left;">
                        &nbsp;<input id='choiceAll' type='checkbox' onclick='selectAllTeam(this)' /></td>
                    <td class="titleRow" style="width:110px; padding-left:10px;">表名</td>
                    <td class="titleRow" style="width:130px;padding-left:20px;">表别名</td>
                </tr>
                <tr>
                    <td colspan="3" style="text-align:left; vertical-align:top; width:80%;">
                          <div style="width:100%; height:190px; overflow-y:scroll;">
                            <asp:repeater ID="DB" runat="server" EnableViewState="False">
                             <HeaderTemplate>
                               <table border="0" cellpadding="0" cellspacing="0">
                             </HeaderTemplate>
                             <ItemTemplate>
                                    <tr>
                                        <td class="jishutds"><input id='choice' name='choice' type='checkbox' value="<%# Eval("tabName") %>" onclick='getTeamIDList()'/></td>
                                        <td class="jishutdts"><%# Eval("tabName")%></td>
                                        <td class="jishutdts"><%# Eval("tabAsName")%></td>
                                    </tr>
                             </ItemTemplate>
                            <AlternatingItemTemplate>
                                    <tr>
                                        <td class="oushutds"><input id='choice' name='choice' type='checkbox' value="<%# Eval("tabName") %>" onclick='getTeamIDList()'/></td>
                                        <td class="oushutdts"><%# Eval("tabName")%></td>
                                        <td class="oushutdts"><%# Eval("tabAsName")%></td>
                                   </tr>
                           </AlternatingItemTemplate>
                             <FooterTemplate>
                                </table>
                             </FooterTemplate>     
                            </asp:repeater>        
                            </div>
                    </td>
                </tr>
                <tr>
                    <td colspan="3"><table border="0" cellpadding="0" cellspacing="0" style="width: 285px"><tr><td colspan='3' class='oushutd' style="width: 80px; height: 24px;border-right:1px #cccccc solid;">
                        查找内容：</td><td style="height: 24px"><input id='txtOld' type='text' style="width: 205px"/></td></tr></table></td></tr>
                <tr>
                    <td colspan="3"><table border="0" cellpadding="0" cellspacing="0" style="width: 285px"><tr><td colspan='3'  class='jishutd' style="width: 80px;border-right:1px #cccccc solid;">
                        替换内容：</td><td style="width: 130px"><input id='txtNew' type='text' style="width: 205px"/></td></tr></table></td></tr>
           
    </table>
    <div style="text-align:center; padding-top:2px;"><input id="Button1" type="button" value="替换" onclick="ReplaceTxt()" /></div>
    <div id="live" style="display:none;" ></div>
    </div>
    </form>
</body>
</html>
