<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.util.*" %>
<%@ page import="com.gx.webpage.framework.util.inoutformat.DataBean" %>
<%@ page import="com.gx.webpage.engine.pagedesigndbengine.factory.PageDesignDbEngineFactory"%>
<%@ page import="com.gx.webpage.engine.pagedesigndbengine.valueobject.*"%>
<%
    boolean isSave = false;
    boolean isError = false;
    String infStr = "";
    String uuid = DataBean.getStr(request, "uuid");
    FormsModel fm = null;
    String mainTblId = "";
    String mainTblUuid = "";
    try{
        fm = PageDesignDbEngineFactory.getInstance().getPageDbEngineApi().findForms(uuid,request);
        if(request.getMethod().equalsIgnoreCase("POST")){
            isSave = true;
            mainTblUuid = DataBean.getStr(request, "mainTblUuid");
            String tblName = DataBean.getStr(request, "tblName");
            String tblId = DataBean.getStr(request, "txtTblId");
            String desc = DataBean.getStr(request, "desc");
            //int tableAcl = DataBean.getInt(request, "tableAcl");
            int rowAcl = DataBean.getInt(request, "rowAcl");
            fm.setTblId(tblId);
            fm.setTblName(tblName);
            fm.setDescription(desc);
            //fm.setTableAcl(tableAcl);
            fm.setRowAcl(rowAcl);
            mainTblUuid = (mainTblUuid == null) ? "" : mainTblUuid.trim();
            boolean b = (mainTblUuid.equals("")) ? false : true;
            PageDesignDbEngineFactory.getInstance().getPageDbEngineApi().updateForms(fm, b, mainTblUuid,request);
        }
        else
        {
            Collection col = PageDesignDbEngineFactory.getInstance().getPageDbEngineApi().findFormPcByChildFormUuid(uuid,request);
            Iterator iter = col.iterator();
            if(iter.hasNext())
            {
                FormParentChildModel item = (FormParentChildModel)iter.next();
                FormsModel fm1 = PageDesignDbEngineFactory.getInstance().getPageDbEngineApi().findForms(item.getParentFormUuid(),request);
                mainTblId = fm1.getTblId();
                mainTblUuid =fm1.getUuid();
            }
        }
    }catch(Exception err){
        isError = true;
        infStr = DataBean.getErrStr(err);
    }
%>
<head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="./../../webpage/common/css/common.css" rel="StyleSheet"  type="text/css" />
<script language="javascript" src="./../../webpage/common/engine/constant.js"></script>
<script language="JScript.Encode" src="./../../webpage/common/engine/common.js"></script>
<script language="JScript.Encode" src="./../../webpage/common/engine/DTFControl.js"></script>
<script language="JScript.Encode" src="./../../webpage/common/js/DataReferControl.js"></script>
<script language="javascript">
<!--
    function btn_toList(){
        window.navigate("formsList.jsp");
    }
    function btn_addNext(){
        window.navigate("formsAdd.jsp");
    }
    function btn_submit()
    {
        var b = UTIL.checkNull("tblName","请输入业务对象名称．");
        if(b == false)
        {
            return;
        }
        var b = UTIL.checkVarDefine("txtTblId", "请输入存储名称．");
        if(b == false)
        {
            return;
        }
        formsAdd.submit();
    }
    function btn_back()
    {
        window.history.back();
    }
    function SelectMainTableId()
    {
        var ref = RefDataHandler.create();
        var arg = ref.getArg();
        var downArg = arg.getDownArg();
        downArg.setId("MAINTLIST");
				downArg.push("MODEL_CLASS","com.gx.webpage.component.model.WebPageDesignActionModel");
        var data = ref.show();
        var uuid = data.get("UUID");
        var id = data.get("ID");
        if(uuid != null && uuid.length > 0){
            document.all("mainTblId").value = id;
            document.all("mainTblUuid").value = uuid;
        }
    }
    function ClearMainTableId()
    {
        document.all("mainTblId").value = "";
        document.all("mainTblUuid").value = "";
    }
//-->
</script>
    <title>修改业务对象</title>
</head>
<body class="main">
<div align="center">
<h3 align="center">修改业务对象</h3>
<%if(!isError){
    if(isSave){
%>
    <p align=center>修改成功．
    <p align=center>
    <input class="butAction" type="button" name="toList" value=" 返回列表 " onclick="btn_toList();">
<%}else{%>
<form id="formsAdd" name="formsAdd" method="POST">
<table class="content">
    <tr>
        <td width=30%>业务对象名称</td><td><input type="text" id="tblName" size=40 name="tblName" value="<%=DataBean.getStr(fm.getTblName())%>"></td>
    </tr>
    <tr>
        <td>存储名称</td><td><input type="text" id="txtTblId" name="txtTblId" size=40 value="<%=DataBean.getStr(fm.getTblId())%>"></td>
    </tr>
<!--   
 <tr>
        <td>检测表数据权限</td>
<if(fm.getTableAcl() == fm.TABLE_ACL_NONE){>
        <td><input type=radio name=tableAcl value=1 >检测
            <input type=radio name=tableAcl value=0 checked>不检测
        </td>
<}else{>
        <td><input type=radio name=tableAcl value=1 checked>检测
            <input type=radio name=tableAcl value=0 >不检测
        </td>
<}>
    </tr>
-->
    <tr>
        <td>所属主视图</td>
        <td><input type="text" id="mainTblId" name="mainTblId" size=27 value="<%=mainTblId%>" readonly>
            <input class="butAction" type="button" value="选择" onclick="SelectMainTableId()">
            <input class="butAction" type="button" value="清除" onclick="ClearMainTableId()">
            <input type="hidden" id="mainTblUuid" name="mainTblUuid" value="<%=mainTblUuid%>">
        </td>
    </tr>
    <tr>
        <td>业务对象描述</td><td><textarea id="desc" name="desc" rows=4 cols=40><%=DataBean.getStr(fm.getDescription())%></textarea></td>
    </tr>
</table>
<table class="buttable2">
<tr>
    <td width=50% align=center><input class="butAction" type="button" name="add" value="修　　改" onclick="btn_submit();">
    <td width=50% align=center><input class="butAction" type="button" name="toList" value="返回列表" onclick="btn_toList();">
</tr>
</table>
</form>
<%}}else{%>
<p align=center>修改失败．
<p align=center><%= infStr%>
<table class="buttable2">
<tr>
    <td width=50% align=center><input class="butAction" type="button" name="add" value="后　　退" onclick="btn_back();">
    <td width=50% align=center><input class="butAction" type="button" name="toList" value="返回列表" onclick="btn_toList();">
</tr>
</table>
<%}%>
</div>
</body>
</html>
