Ejemplo n.º 1
0
        //-----------------------------------------------
        // 页面事件
        //-----------------------------------------------
        // 初始化
        public void InitForm()
        {
            if (string.IsNullOrEmpty(EntityTypeName))
            {
                return;
            }
            this.entityType = Assembly.GetExecutingAssembly().GetType(EntityTypeName);

            // 构建表单
            InitToolbar();
            InitItemID();
            this.map = FormHelper.BuildForm(this, new UISetting(this.entityType), false, this.Mode == PageMode.View);
            if (this.Mode == PageMode.View)
            {
                this.btnSaveClose.Visible = false;
                this.btnSaveNew.Visible   = false;
                FormHelper.SetFormEditable(this, false);
            }

            // 初始化
            if (!(HttpContext.Current.Handler as Page).IsPostBack)
            {
                this.lblId.Text         = this.EntityID.ToString();
                this.btnSaveNew.Visible = (this.EntityID == -1);
                if (this.EntityID != -1)
                {
                    ShowData(this.EntityID);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 显示表单,请在页面首次初始化代码中调用
        /// </summary>
        public void ShowForm()
        {
            // 新建
            var mode = this.Mode;

            if (mode == PageMode.New)
            {
                NewData();
                ShowButtons(true, true, true);
                return;
            }

            // 尝试获取实体
            var id = Asp.GetQueryIntValue("id");

            if (id == null)
            {
                return;
            }
            T item = GetData(id.Value);

            if (item == null)
            {
                Alert.Show("参数错误!", String.Empty, ActiveWindow.GetHideReference());
                return;
            }

            // 显示表单数据
            ShowData(item);

            // 查看或编辑
            if (mode == PageMode.View)
            {
                ShowButtons(true, false, false);
                FormHelper.SetFormEditable(this.frm, false);
            }
            if (mode == PageMode.Edit)
            {
                ShowButtons(true, true, false);
            }
        }