<%@ page contentType="text/html; charset=GBK" %>
<%@ page import = "zr.zrpower.common.util.SysPreperty" %>
<%@ page import = "zr.zrpower.entity.sys.SessionUser" %>
<%@ page import = "zr.zrpower.dbmanage.*"%>
<%@ page import = "zr.zrpower.dbmanage.service.*"%>
<%@ page import = "zr.zrpower.ejb.sys.UIService" %>
<%@ page import = "zr.zrpower.dbmanage.service.TableService"%>
<%@ page import = "zr.zrpower.dbmanage.service.TableSpaceService"%>
<%@ page import = "java.util.Hashtable" %>
<%@ page import = "java.lang.Object"%>

<HTML>
<%
TableSpaceService Space = new TableSpaceService();
SessionUser user = (SessionUser)session.getAttribute("userinfo");
UIService userUI =new UIService();
BPIP_TABLE[] TC = null;
TableService Table = new TableService();
String strID = request.getParameter("ID");
String strName = Space.GetSpaceCHINESENAME(strID);
String sum = Table.SumTable(strID);
BPIP_TABLESPACE[] SP = null;
String strname = Space.GetSpaceCHINESENAME(strID);

//得到查询的记录集
   TC = Table.GetBpipTableList(strID);

   Hashtable Hashtable1 = new Hashtable();
   Hashtable1.put("0","系统表");
   Hashtable1.put("1","字典表");
   Hashtable1.put("2","基础数据表");
   Hashtable1.put("3","审批表");

   String strshow_data="";
     if (TC!=null && TC.length>0){
        strshow_data = strshow_data + "[";
        for(int i=0;i<TC.length;i++){
            strshow_data = strshow_data + "[";
            strshow_data = strshow_data + "'"+TC[i].getTABLEID()+"',";
            strshow_data = strshow_data + "'"+TC[i].getTABLENAME()+"',";
            strshow_data = strshow_data + "'"+TC[i].getCHINESENAME()+"',";
            strshow_data = strshow_data + "'"+Hashtable1.get(TC[i].getTABLETYPE())+"',";
            strshow_data = strshow_data + "'"+TC[i].getPRIMARYKEY()+"',";
            strshow_data = strshow_data + "'"+TC[i].getTITLE()+"',";

            if (i < TC.length-1 )
            {
               strshow_data = strshow_data + "'"+TC[i].getDESCRIPTION()+"'],\r\n";
            }else
            {
               strshow_data = strshow_data + "'"+TC[i].getDESCRIPTION()+"']";
            }
        }

        strshow_data = strshow_data + "]";
    }else
    {
        strshow_data = "null";
    }

%>
<HTML>
<HEAD>
<TITLE></TITLE>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META http-equiv="Content-Type" content="text/html; charset=GBK">
<LINK type="text/css" rel="stylesheet" href="../../zrsysmanage/css/<%=user.getUserCSS()%>">
<SCRIPT LANGUAGE="JavaScript" src="../../zrsysmanage/script/Public.js"></SCRIPT>

<link rel="stylesheet" type="text/css" media="all" href="../../ZrwebGui/sigma_grid/grid/calendar/calendar-blue.css">
<script type="text/javascript" src="../../ZrwebGui/sigma_grid/grid/calendar/calendar.js"></script>
<script type="text/javascript" src="../../ZrwebGui/sigma_grid/grid/calendar/calendar-setup.js"></script>
<link rel="stylesheet" type="text/css" href="../../ZrwebGui/sigma_grid/grid/gt_grid.css">
<link rel="stylesheet" type="text/css" href="../../ZrwebGui/sigma_grid/grid/skin/vista/skinstyle.css">
<link rel="stylesheet" type="text/css" href="../../ZrwebGui/sigma_grid/grid/skin/pink/skinstyle.css">
<link rel="stylesheet" type="text/css" href="../../ZrwebGui/sigma_grid/grid/skin/mac/skinstyle.css">
<script type="text/javascript" src="../../ZrwebGui/sigma_grid/grid/gt_msg_en.js"></script>
<script type="text/javascript" src="../../ZrwebGui/sigma_grid/grid/gt_const.js"></script>
<script type="text/javascript" src="../../ZrwebGui/sigma_grid/grid/gt_grid_all.js"></script>
<%if("6".equals(user.getUserWINDOWTYPE())){ %>
<LINK type="text/css" rel="stylesheet" href="../../zrsysmanage/html5/css/style_tables.css">
<SCRIPT LANGUAGE="JavaScript" src="../../zrsysmanage/html5/script/jquery-2.0.3.min.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="../../zrsysmanage/html5/layer/layer.js"></SCRIPT>
<%}%>
<script type="text/javascript" >
var css = "<%=user.getUserCSS()%>";
var skincss = "vista";

if (css=="Blue.css")
{skincss = "vista";}
if (css=="Public.css")
{skincss = "default";}
if (css=="Window.css" || css=="nBlue.css")
{skincss = "mac";}
if (css=="Yellow.css")
{skincss = "pink";}


var grid_demo_id = "myGrid1" ;
var show_data= <%=strshow_data%>;

var dsOption= {

	fields :[
                {name : 'TABLEID'  },
		{name : 'TABLENAME'  },
		{name : 'CHINESENAME'  },
                {name : 'TABLETYPE'  },
                {name : 'PRIMARYKEY'  },
		{name : 'TITLE'  },
		{name : 'DESCRIPTION'  }
	],

	recordType : 'array',
	data : show_data
}



var colsOption = [

           {id: 'TABLEID' , header: "<center>编号</center>" , width :60 , align : 'center'  },
           {id: 'TABLENAME' , header: "<center>表名</center>" , width :160 , align : 'center'  },
           {id: 'CHINESENAME' , header: "<center>中文名称</center>" , width :160,  align : 'center'  },
           {id: 'TABLETYPE' , header: "<center>表类型</center>" , width :100,  align : 'center'  },
           {id: 'PRIMARYKEY' , header: "<center>主键</center>" , width :80,  align : 'center'  },
           {id: 'TITLE' , header: "<center>标题</center>" , width :100,  align : 'center'  },
           {id: 'DESCRIPTION' , header: "<center>描述</center>" , width :100,  align : 'center'  }
];



var gridOption={
	id : grid_demo_id,
	width: "800",
	height: "260",
	container : 'gridbox',
	replaceContainer : true,
	dataset : dsOption ,
	columns : colsOption,
	pageSize : 2000,
	toolbarContent : null,
        skin : skincss,

        onCellDblClick:function(value, record , cell, row,  colNO, rowNO,columnObj,grid){
           edit();
        },

       showIndexColumn : true
};


<%if(!"6".equals(user.getUserWINDOWTYPE())){ %>
var mygrid=new Sigma.Grid( gridOption );
Sigma.Util.onLoad( Sigma.Grid.render(mygrid));
<%}%>
</script>

</HEAD>
<BODY class="BodyMain">
<form name="recordfrm" action="TableList.jsp">

  <%if("6".equals(user.getUserWINDOWTYPE())){ %>
   <div id="mianRole" style="height: 300px;overflow: auto;">
   <%
//得到查询的记录集
     SP = Space.GetBpipTableSpaceList(strID);
     if (SP!=null && SP.length>0){
       %>
       <%=SP[0].getCHINESENAME()%>&nbsp;一共有表<%=sum%>张
      <%
     }%><br/><font color="red">说明：当表分类下建有表时不能删除。</font>
    <hr />
   <a style="margin-top: -15px" class="btn1 btn-medium btn-blue btn-radius" href="#" onclick="JavaScript:add();">增加表</a>
   <a style="margin-top: -15px" class="btn1 btn-medium btn-blue btn-radius" href="#" onclick="JavaScript:edit();">编辑表</a>
   <a style="margin-top: -15px" class="btn1 btn-medium btn-blue btn-radius" href="#" onclick="JavaScript:CreateEntity();">生成实体</a>

  <table class="bordered" id="html5_table">

<thead>
<tr>
<th style="width:60;">序号</th>
<th style="width:100;">表编号</th>
<th style="width:100;">表名</th>
<th style="width:200;">中文名称</th>
<th style="width:100;">表类型</th>
<th style="width:100;">主键</th>
<th style="width:100;">标题</th>
<th style="width:100;">描述</th>

</tr>
</thead>

<%
if (TC!=null && TC.length>0){
  for(int i=0;i<TC.length;i++){
     %>
     <tr onclick="click_color(this,'<%=TC[i].getTABLEID() %>');">
        <td style="text-align:center;"><%=i+1 %></td>
        <td style="text-align:left;"><%=TC[i].getTABLEID() %></td>
        <td style="text-align:left;"><%=TC[i].getTABLENAME() %></td>
        <td style="text-align:left;"><%=TC[i].getCHINESENAME() %></td>
        <td style="text-align:left;"><%=Hashtable1.get(TC[i].getTABLETYPE()) %></td>
        <td style="text-align:left;"><%=TC[i].getPRIMARYKEY() %></td>
        <td style="text-align:left;"><%=TC[i].getTITLE() %></td>
        <td style="text-align:left;"><%=TC[i].getDESCRIPTION() %></td>


     </tr>

     <%
  }
}

 %>
</table></div>

<%}else{ %>
  <table border='0' height="229" width="100%" background="../../zrsysmanage/images/<%=user.getUserImage()%>/databack2.jpg" cellspacing="0" cellpadding="0" align=center>
       <tr>
          <td  width="40%"></td>
          <td width="42%"></td>
          <td width="18%"></td>
        </tr>
       <tr>
          <td  width="40%"></td>
          <td width="42%"></td>
          <td width="18%"></td>
        </tr>
        <%
//得到查询的记录集
     SP = Space.GetBpipTableSpaceList(strID);
     if (SP!=null && SP.length>0){
       %>
       <tr>
         <td  width="40%"></td>
         <td width="42%" valign="bottom"><%=SP[0].getCHINESENAME()%>&nbsp;一共有表<%=sum%>张<br /></td>
         <td width="18%"></td>
       </tr>
      <%
     }%>
        <tr><td width="40%"></td>
           <td width="42%" valign="bottom" align="left">
          <br>
           <table cellspacing="0" cellpadding="0" border='0'>
            <tr><td height='22'><a href=JavaScript:add(); title='增加表'><img border='0' align='absmiddle' src='../../zrsysmanage/images/<%=user.getUserImage()%>/dataadd.gif'>&nbsp;增加表</a></td>
               <td height='22'><a href=JavaScript:edit(); title='编辑表'><img border='0' align='absmiddle' src='../../zrsysmanage/images/<%=user.getUserImage()%>/dataedit.gif'>&nbsp;编辑表</a></td>
               <td height='22'><a href=JavaScript:CreateEntity(); title='生成实体'><img border='0' align='absmiddle' src='../../zrsysmanage/images/<%=user.getUserImage()%>/dataedit.gif'>&nbsp;生成实体</a></td>
          </tr>
          </table>
      </td>
           <td width="18%"></td>
        </tr>
      </table>

<div id="gridbox" style="border:0px solid #cccccc;background-color:#f3f3f3;padding:5px;height:600px;width:800px;" ></div>
<%} %>


  </form>
</BODY>
<script language="JavaScript" type="text/JavaScript">
<%if("6".equals(user.getUserWINDOWTYPE())){ %>
 var h=$(document.body).height();//浏览器当前窗口文档body的高度
 h=h*1-10;
 $('div').css('height',h);
<%}%>

var allvalue="";
function clickValue(value){
    allvalue=value;
}
function add(){

  <%if("6".equals(user.getUserWINDOWTYPE())){%>
  layer.open({
  type: 2,
  area: ['520px', '380px'],
  fix: false, //不固定
  maxmin: false,//是否可以最大化
  content: 'TableAdd.jsp?ID=<%=strID%>'
});
  <%}else{%>
  var url="TableAdd.jsp?ID=<%=strID%>";
  var name="PopWindow";
  var ShowPopWindow = null;
  var status="toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width=520,height=320";
  ShowPopWindow = window.open(url,name,status);
  ShowPopWindow.moveTo(280,180);
  ShowPopWindow.focus();
  <%}%>
}
function edit(){

  <%if("6".equals(user.getUserWINDOWTYPE())){ %>
         var strID = allvalue;
         if(strID!=""){
           layer.open({
           type: 2,
           area: ['550px', '380px'],
           fix: false, //不固定
           maxmin: false,//是否可以最大化
           content: 'TableEdit.jsp?ID=<%=strID%>&SelectedItems='+strID
         });
         }else{
            layer.alert('请选择要操作的数据!', {icon: 7});
         }
    <%}else{%>
         var allvalue = mygrid.getSelectedRecords()+",0";
         var strID = allvalue.split(",")[0];
         var url="TableEdit.jsp?SelectedItems="+strID+"&ID=<%=strID%>";
         var name="PopWindow";
         var ShowPopWindow = null;
         var status="toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width=520,height=320";
         ShowPopWindow = window.open(url,name,status);
         ShowPopWindow.moveTo(280,180);
         ShowPopWindow.focus();
    <%}%>

}

function CreateEntity(){
  <%if("6".equals(user.getUserWINDOWTYPE())){ %>
         var strID = allvalue;
         if(strID!=""){
           parent.parent.parent.layer.open({
           type: 2,
           area: ['500px', '200px'],
           fix: false, //不固定
           maxmin: false,//是否可以最大化
           content: 'zrsysmanage/DbManage/CreateEntity.jsp?ID='+strID
         });
          }else{
             layer.alert('请选择要操作的数据!', {icon: 7});
          }
    <%}else{%>
         var allvalue = mygrid.getSelectedRecords()+",0";
         var strID = allvalue.split(",")[0];
         var url="CreateEntity.jsp?ID="+strID;
        var name="PopWindow";
        var ShowPopWindow = null;
        var status="toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width=520,height=200";
        ShowPopWindow = window.open(url,name,status);
        ShowPopWindow.moveTo(280,180);
        ShowPopWindow.focus();
    <%}%>

}

</script>
</HTML>
<%
//清空相关对象
user = null;
userUI = null;
Space = null;
TC = null;
Table = null;
SP = null;
%>
