<%@ Page Language="C#" Inherits="SiteServer.BackgroundPages.ConsoleTableMetadata" %>
<%@ Register TagPrefix="bairong" Namespace="BaiRong.Controls" Assembly="BaiRong.Controls" %>
<%@ Register TagPrefix="user" Namespace="UserCenter.Controls" Assembly="UserCenter.Pages" %>
<%@ Register TagPrefix="site" Namespace="SiteServer.Controls" Assembly="SiteServer.Controls" %>

<html>
<head>
<!--#include file="../inc/html_head.inc"-->
<user:custom type="style" runat="server"></user:custom>

<bairong:Code type="Prototype" runat="server" />
<bairong:Code type="Scriptaculous" runat="server" />

<meta http-equiv="content-type" content="text/html;charset=gb2312">
</head>
<body>
<user:custom type="showpopwin" runat="server" />

<form id="myForm" Style="margin:0px" runat="server">
<bairong:Message runat="server"></bairong:Message>
<DIV class="column">
<div class="columntitle">辅助表字段管理(<%=Request.QueryString["ENName"]%>)</div>

	<ASP:DataGrid id="MyDataGrid" runat="server"
			Width="100%"
			Align="center"
			ShowHeader="true"
			ShowFooter="false"
			CellPadding="2"
			BorderWidth="0"
AutoGenerateColumns="false"
			DataKeyField="TableMetadataID"
			OnItemCommand="MyDataGrid_ItemCommand"
			OnItemDataBound="MyDataGrid_ItemBound"
			HeaderStyle-CssClass="summary-title"
			ItemStyle-CssClass="tdbg"
			CellSpacing="2" >
		<HeaderStyle HorizontalAlign="center" Height="25" />
		<EditItemStyle CssClass="tdbg-dark" />
		<ItemStyle Height="23"/>
		
		<Columns>
			<asp:TemplateColumn
				HeaderText="字段名">
				<ItemTemplate>
					<%#GetViewHtml((int)DataBinder.Eval(Container.DataItem,"TableMetadataID"), (string)DataBinder.Eval(Container.DataItem,"AttributeName"))%>
				</ItemTemplate>
				<ItemStyle HorizontalAlign="center" />
			</asp:TemplateColumn>
			<asp:TemplateColumn HeaderText="显示名称">
				<ItemTemplate>
					<%#GetDisplayName((string)DataBinder.Eval(Container.DataItem,"AttributeName"))%>
				</ItemTemplate>
				<ItemStyle Width="140" HorizontalAlign="center" />
			</asp:TemplateColumn>
			<asp:TemplateColumn HeaderText="数据类型">
				<ItemTemplate>
					<%#GetDataType((string)DataBinder.Eval(Container.DataItem,"IsSystem"), (string)DataBinder.Eval(Container.DataItem,"DataType"), (int)DataBinder.Eval(Container.DataItem,"DataLength"))%>
				</ItemTemplate>
				<ItemStyle Width="100" HorizontalAlign="center" />
			</asp:TemplateColumn>
			<asp:TemplateColumn HeaderText="是否显示">
				<ItemTemplate>
					<%#GetIsVisible((string)DataBinder.Eval(Container.DataItem,"AttributeName"))%>
				</ItemTemplate>
				<ItemStyle Width="50" HorizontalAlign="center" />
			</asp:TemplateColumn>
			<asp:TemplateColumn HeaderText="上升">
				<ItemTemplate>
					<asp:LinkButton ID="UpLinkButton" CommandName="UP" runat="server"><img src="../Pic/icon/up.gif" border="0" alt="上升" /></asp:LinkButton>
				</ItemTemplate>
				<ItemStyle Width="40" HorizontalAlign="center" />
			</asp:TemplateColumn>
			<asp:TemplateColumn HeaderText="下降">
				<ItemTemplate>
					<asp:LinkButton ID="DownLinkButton" CommandName="DOWN" runat="server"><img src="../Pic/icon/down.gif" border="0" alt="下降" /></asp:LinkButton>
				</ItemTemplate>
				<ItemStyle Width="40" HorizontalAlign="center" />
			</asp:TemplateColumn>
			<asp:TemplateColumn HeaderText="显示样式">
				<ItemTemplate>
					<%#GetEditStyleHtml((int)DataBinder.Eval(Container.DataItem,"TableMetadataID"), (string)DataBinder.Eval(Container.DataItem,"AttributeName"))%>
				</ItemTemplate>
				<ItemStyle Width="120" HorizontalAlign="center" />
			</asp:TemplateColumn>
			<asp:TemplateColumn>
				<ItemTemplate>
					<%#GetEditHtml((string)DataBinder.Eval(Container.DataItem,"IsSystem"), (int)DataBinder.Eval(Container.DataItem,"TableMetadataID"))%>
				</ItemTemplate>
				<ItemStyle Width="50" HorizontalAlign="center" />
			</asp:TemplateColumn>
			<asp:TemplateColumn>
				<ItemTemplate>
					<a <%#(IsSystem((string)DataBinder.Eval(Container.DataItem,"IsSystem"))) ? "style='display:none'" : ""%> href="console_tableMetadata.aspx?Delete=True&ENName=<%# DataBinder.Eval(Container.DataItem,"AuxiliaryTableENName")%>&TableMetadataID=<%# DataBinder.Eval(Container.DataItem,"TableMetadataID")%>&TableType=<%=Request.QueryString["TableType"]%>" onClick="javascript:return confirm('此操作将删除辅助字段“<%#DataBinder.Eval(Container.DataItem,"AttributeName")%>”，确认吗？');">删除字段</a>
				</ItemTemplate>
				<ItemStyle Width="60" HorizontalAlign="center" />
			</asp:TemplateColumn>
				
		</Columns>
	</ASP:DataGrid>	
</DIV>
<table width="95%" align="center">
  <tr>
    <td align="right"><table cellpadding="0" cellspacing="0" width="100%">
      <tr>
        <td>
			<asp:Button class="button" ID="AddColumnButton" Text="添加字段" runat="server"></asp:Button>
			<span style="<%=GetCreateDBCommandElementStyle()%>">
			&nbsp;&nbsp;
			<input type=button class="button" onClick="location.href='console_tableMetadata.aspx?CreateDB=True&ENName=<%=Request.QueryString["ENName"]%>&TableType=<%=Request.QueryString["TableType"]%>';" value="创建辅助表" />
			</span>
			<span style="<%=GetDeleteDBCommandElementStyle()%>">
				&nbsp;&nbsp;
				<input type=button class="button" onClick="if (confirm('此操作将删除辅助表“<%=Request.QueryString["ENName"]%>”，确认吗？'))location.href='console_tableMetadata.aspx?DeleteDB=True&ENName=<%=Request.QueryString["ENName"]%>&TableType=<%=Request.QueryString["TableType"]%>';" value="删除辅助表" />
			</span>
			<span style="<%=GetReCreateDBCommandElementStyle()%>">
				&nbsp;&nbsp;
				<input type=button class="button" onClick="if (confirm('此操作将覆盖已建立的辅助表，表中已存数据将丢失，确认吗？'))location.href='console_tableMetadata.aspx?ReCreateDB=True&ENName=<%=Request.QueryString["ENName"]%>&TableType=<%=Request.QueryString["TableType"]%>';" value="重新创建辅助表" />
			</span>
			<span style="<%=GetShowCommandElementStyle()%>">
			&nbsp;&nbsp;
			<input type=button class="button" onClick="location.href='console_tableMetadata.aspx?ShowCrateDBCommand=True&ENName=<%=Request.QueryString["ENName"]%>&TableType=<%=Request.QueryString["TableType"]%>';" value="显示创建表SQL命令" />
			</span>
			&nbsp;&nbsp;
			<input type=button class="button" onClick="location.href='console_auxiliaryTable.aspx';" value="返 回" />
		</td>
      </tr>
    </table></td>
  </tr>
</table>

<div id="SyncTable" runat="server">
<br>
<DIV class="column">
<div class="columntitle">同步辅助表</div>
<div class="columncontent" style="padding:5px">
	<span style="color:#FF0000">此辅助表在创建后被修改，与数据库中的实际表结构有差别，请同步辅助表。</span><br><br>
	<asp:Button class="button" ID="SyncTableButton" Text="同步辅助表" OnClick="SyncTableButton_OnClick" runat="server"></asp:Button></div>
</DIV>
</div>



<div style="<%=GetSQLTableStyle()%>">
<br>
<DIV class="column">
<div class="columntitle">创建辅助表SQL命令</div>
<div class="columncontent" style="padding:5px">
	<asp:Label id="MessageLabel" width="100%" Style="text-align:left" runat="server"/>
</div>
</DIV>
</div>

</form>

</body>
</html>