<%@ Page Language="C#" AutoEventWireup="true" debug="true" Inherits="WinLibClass.Form.Admin.SystemConfig.UI_Update"  CodePage="65001" PathLevel="1" PageFileFlag="SystemConfig_List7" PageFileTitle="数据库备份" DataBindingType="1" PageFlagId="1" CurrentFile="updateconfig7.aspx" %>


<%@ Register TagPrefix="Site" TagName="Menu" Src="../WUC/Site_Menu.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<Site:Menu id="menu_headtitle" runat="server" Flag="HeadTitle" CurrentPageTitle = " 数据库备份" />
<Site:Menu id="menu_headjs" runat="server" Flag="HeadJs" PathLevel="1" />
<Site:Menu id="menu_headcss" runat="server" Flag="HeadCss" PathLevel="1" />




<%//=CurrentFile%>
<script type="text/javascript"> 
$(document).ready(function(){
	$("#btnSaveConfig_1").click(function(){
		SaveConfig_1();
	});
	
	$("#btnSaveConfig_2").click(function(){
		SaveConfig_2();
	});
	$("#btnSaveConfig_3").click(function(){
		SaveConfig_3();
	});	
});
function SaveConfig_1()
{
	if(!confirm("是否备份当前数据库?")) return false;
	
	var queryString = {"DbUpdateType":1,"ConfigType":7,"DbFileList":""};
	var url = "UpdateConfig7.aspx?isadd=20";
	jQuery.ajax({
		type:"POST",
		"url":url,cache: false,
		data:queryString,
		success:function(msg){
			if(msg==-1){ 
				Alert("数据库备份成功.",1);
				Common.Refresh();
				
			}
			else AlertErr("数据库备份失败(异常代码:"+ msg +")",1);
		},
		error:function(msg)
		{
			AlertErr("系统异常:\r\n"+ msg.responseText +"",1);
		}
		});
	
	return false;
}


function SaveConfig_2()
{

	var DbFileList = GetSelectFileName(true);
	if(DbFileList.length<6)
	{
		AlertErr("您还没有选择用于数据库恢复的文件.\r\n请选择单一文件进行数据恢复.",2);
		return false;	
	}
	
	IsMulti = (DbFileList.indexOf(",")>-1);
	if(IsMulti)
	{
		AlertErr("请选择单一文件进行数据恢复.",2)
		return false;
	}

	if(!confirm("是否恢复当前数据库?")) return false;
	
	var queryString = {"DbUpdateType":2,"ConfigType":7,"DbFileList":DbFileList};
	var url = "UpdateConfig7.aspx?isadd=20";
	jQuery.ajax({
		type:"POST",
		"url":url,
		data:queryString,cache: false,
		success:function(msg){
			if(msg==-1){ 
				Alert("数据库恢复成功.",1);//Common.Refresh();
				
			}
			else AlertErr("数据库恢复失败(异常代码:"+ msg +")",2);
		},
		error:function(msg)
		{
			AlertErr("系统异常:\r\n"+ msg.responseText +"",2);
		}});
	
	return false;
}


function SaveConfig_3()
{
	if(!confirm("是否删除指定的数据库备份文件(删除须慎重,以免误删除!!!)?")) return false;
	
	var DbFileList = GetSelectFileName(true);
	
	var IsMulti = (DbFileList.indexOf(",")>-1);
	
	var queryString = {"DbUpdateType":(IsMulti?4:3),"ConfigType":7,"DbFileList":DbFileList};
	var url = "UpdateConfig7.aspx?isadd=20";
	jQuery.ajax({	
		type:"POST",
		"url":url,
		data:queryString,cache: false,
		success:function(msg){
			if(msg>0){ 
				Alert("数据库备份文件删除成功.",1);Common.Refresh();			
			}
			else AlertErr("数据库备份文件删除失败(异常代码:"+ msg +")",2);
		},
		error:function(msg)
		{
			AlertErr("系统异常:\r\n"+ msg.responseText +"",2);
		}});
	
	return false;
}


function GetSelectFileName(IsMulti)
{
	var str = "";
	if(!IsMulti){
		var o = jQuery("input[id^='chk_']:checked");
	
		if(o.length>0)
		str = o.attr("value");
	}
	else{
		var t = jQuery("input[id^='chk_']:checked");

		if(t)
		{
			var o=null;
			for(var i=0;i<t.length;i++ )
			{	
				o = t.eq(i);
				str += o.attr("value") +",";
			}
			if(str.length>0 && str.substr(str.length-1,1)==",")
				str = str.substr(0,str.length-1);
		}
	}
	return str;
}
</script> 

</head>
<body>

<Site:Menu id="menu_topmenu" runat="server" Flag="TopMenu"  />
<div class1="wrap" id="wrap">
	<Site:Menu id="Wuc_LeftMenu" runat="server" Flag="LeftMenu" PageFileFlag="Menu_A_800_801" PathLevel="1" />	
	<div class1="mainbox" class="MainBox W1100 ">
		<div class="PGTitle LH30 ">
			<div class="W200 FL MGL10 FWB FS12"><%=PageFileTitle%></div>
			<div class="ChileMenu1 FL FS12">
			</div>
			<div class="Clear"></div>
		</div>
		<div class="ContBox MGT10 " >


			<%
			{
			/*
System.Data.DataTable dt = WinLibClass.Data.DataDAL.DataProvider.Provider.Db_GetBackupFileList("");
Response.Write(dt.Rows.Count);
				rpList.DataSource = dt;
				rpList.DataBind();
			*/
}			
			%>

<form id="form_add" >	
	<input type="hidden" id="ConfigType" name="ConfigType" value="5" />


<table class="Table FS12 ">
	<tr>
	<td style="width:20%;">选择</td>
	<td style="width:50%;">文件名</td>
	<td style="width:30%;">创建日期</td>
	</tr>	
	
<asp:Repeater id="rpList" runat="server">
<ItemTemplate>
	<tr>
	<td style="width:20%;"><input type="checkbox" id="chk_<%#Eval("id")%>" value="<%#Eval("FileName")%>"></td>
	<td style="width:50%;" title="<%#Eval("FullName")%>"><a href='dbDown.aspx?dbfile=<%#Eval("FileName")%>'><%#Eval("FileName")%></a> </td>
	<td  style="width:30%;"><%#Eval("CreationTime")%></td>
	</tr>
</ItemTemplate>
</asp:Repeater>

	

</table>


</form>	


		</div>
		
		<div class="ContBox" >
			<div class="page" style="margin-left:-13px;"> 
			

			
			
		<BR />	
				操作：
	<a id='btnSaveConfig_1'>确认备份</a>			
	<a id='btnSaveConfig_2'>确认恢复</a>	
	<a id='btnSaveConfig_3'>确认删除</a>
				<br />	<br />
				<div class="Red">
				注:操作确认前请慎重,以免造成不必要的麻烦,并且,请在网站访问量尽可能低的情况下进行数据恢复.
				</DIV>
			
			</div>
		</div>		
	</div>
</div>


<div class="clear"></div>
<Site:Menu id="menu_foot" runat="server" Flag="Foot"   />
</body>
</html>



