using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EKETEAM.FrameWork;

public partial class Manage_layoutDesign : System.Web.UI.Page
{
    public string modelid = eParameters.QueryString("modelid");
    public string obj = eParameters.QueryString("obj");
    private DataRow _modelinfo;
    public DataRow ModelInfo
    {
        get
        {
            if (_modelinfo == null)
            {
                DataTable dt = eBase.DataBase.getDataTable("select * from a_eke_sysModels where ModelID='" + modelid + "'");
                if (dt.Rows.Count > 0) _modelinfo = dt.Rows[0];
            }
            return _modelinfo;
        }
    }
    public dynamic viewObj = new eViewObject();
    public string UserArea = "Manage";
    eUser user;
    protected void Page_Load(object sender, EventArgs e)
    {
        user = new eUser(eBase.getUserArea(UserArea));
        user.Check();

        string act = eParameters.Request("act");
        if (act == "save")
        {
            eBase.DataBase.Execute("update a_eke_sysModels set "+ obj +"Design='"+ eParameters.Form("html") +"' where ModelID='" + modelid + "'");
            eBase.End();
        }
        viewObj = eBase.DataBase.getValues("select * from a_eke_sysModels where ModelID='" + modelid + "'");
        if (viewObj.HtmlBodyDesign.ToString().Length == 0)
        {
            viewObj.HtmlBodyDesign = "<div class=\"grid-editor\"><div class=\"grid-toolbar\"><button class=\"add-row-btn\">添加行</button></div><div class=\"grid-rows\"><div class=\"grid-row\" style=\"display: grid;gap: 10px; margin-bottom: 10px;grid-template-columns: 1fr;\"><div class=\"grid-cell selected\"><div class=\"cell-buttons\"><button class=\"delete-cell\">删列</button><button class=\"add-col-cell\">加列</button><button class=\"nest-cell\">嵌套</button><button class=\"delete-row-cell\">删行</button></div><div class=\"cell-center\" data-text=\"\"><button class=\"bind-data-btn\">绑定数据</button></div><div class=\"cell-content\"></div></div></div></div></div>";
        }
        if (viewObj.mHtmlBodyDesign.ToString().Length == 0)
        {
            viewObj.mHtmlBodyDesign = "<div class=\"grid-editor\"><div class=\"grid-toolbar\"><button class=\"add-row-btn\">添加行</button></div><div class=\"grid-rows\"><div class=\"grid-row\" style=\"display: grid;gap: 10px; margin-bottom: 10px;grid-template-columns: 1fr;\"><div class=\"grid-cell selected\"><div class=\"cell-buttons\"><button class=\"delete-cell\">删列</button><button class=\"add-col-cell\">加列</button><button class=\"nest-cell\">嵌套</button><button class=\"delete-row-cell\">删行</button></div><div class=\"cell-center\" data-text=\"\"><button class=\"bind-data-btn\">绑定数据</button></div><div class=\"cell-content\"></div></div></div></div></div>";
        }
    }
}