protected override void OnPreInit(EventArgs e)
 {
     base.OnPreInit(e);
     _formPanel             = new FormPanel();
     _formPanel.BodyPadding = 10;
     _formPanel.Layout      = "table";
     _formPanel.LayoutConfig.Add(new TableLayoutConfig()
     {
         Columns = 2
     });
     _formPanel.ID            = "addForm";
     _formPanel.DefaultAnchor = "100%";
     _txtRolename             = new TextField();
     _txtRolename.ID          = "txtname";
     _txtRolename.Name        = "Name";
     _txtRolename.ColSpan     = 1;
     _txtRolename.Width       = 300;
     _txtRolename.AllowBlank  = false;
     _txtRolename.FieldLabel  = "角色名";
     _txtRolename.EmptyText   = "输入角色名";
     _formPanel.Add(_txtRolename);
     _comboStatus                 = new ComboBox();
     _comboStatus.EmptyText       = "选择状态";
     _comboStatus.ValueHiddenName = "Status";
     _comboStatus.SimpleSubmit    = true;
     _comboStatusStore            = new Store();
     _comboStatusStore.ID         = "comboStoreStatus";
     _comboStatusStore.Model.Add(ComponentHelper.GetModel(
                                     new Dictionary <string, ModelFieldType>()
     {
         { "Id", ModelFieldType.Int }, { "Name", ModelFieldType.String }
     }));
     _comboStatus.DisplayField = "Name";
     _comboStatus.ValueField   = "Id";
     _comboStatus.Store.Add(_comboStatusStore);
     _comboStatus.FieldLabel = "状态";
     _comboStatus.Editable   = false;
     _formPanel.Add(_comboStatus);
     _txtMemo            = new TextArea();
     _txtMemo.Width      = 750;
     _txtMemo.Name       = "Description";
     _txtMemo.ColSpan    = 2;
     _txtMemo.EmptyText  = "简单描述一下角色的功能";
     _txtMemo.FieldLabel = "描述";
     _txtMemo.Height     = 70;
     _formPanel.Add(_txtMemo);
     _treePrivilegeSelector = new TreePanelNodeMover();
     _treePrivilegeSelector.LeftReadData  += _treePrivilegeSelector_LeftReadData;
     _treePrivilegeSelector.RightReadData += _treePrivilegeSelector_RightReadData;
     _treePrivilegeSelector.Height         = 180;
     _treePrivilegeSelector.Width          = 750;
     _treePrivilegeSelector.ColSpan        = 2;
     _treePrivilegeSelector.ID             = "treeRoles";
     _formPanel.Add(_treePrivilegeSelector);
     _btnSave      = new Button();
     _btnSave.Icon = Icon.DatabaseSave;
     _btnSave.Text = "保存";
     _btnSave.DirectEvents.Click.Event += SaveRole;
     _btnSave.DirectEvents.Click.EventMask.Set("正在添加");
     _formPanel.Buttons.Add(_btnSave);
     _hidId      = new Hidden();
     _hidId.Name = "Id";
     _formPanel.Controls.Add(_hidId);
     MainForm.Controls.Add(_formPanel);
 }
Exemple #2
0
        public override void RenderView(System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer)
        {
            RenderMain(writer);
            var _formPanel = new ValidatedForm();

            _formPanel.BodyPadding = 10;
            _formPanel.Layout      = "table";
            _formPanel.Url         = Url.Action("AddAccount");
            _formPanel.LayoutConfig.Add(new TableLayoutConfig()
            {
                Columns = 2
            });
            _formPanel.ID            = "addForm";
            _formPanel.DefaultAnchor = "100%";
            var _txtUsername = new TextField();

            _txtUsername.ID         = "txtUsername";
            _txtUsername.Name       = "Username";
            _txtUsername.ColSpan    = 1;
            _txtUsername.Width      = 300;
            _txtUsername.AllowBlank = false;
            _txtUsername.FieldLabel = "用户名";
            _txtUsername.EmptyText  = "输入用户名";
            _formPanel.Add(_txtUsername);
            var _comboStatus = new ComboBox();

            _comboStatus.EmptyText = "选择状态";
            _comboStatus.Name      = "Status";
            var _comboStatusStore = new Store();

            _comboStatusStore.ID    = "comboStoreStatus";
            _comboStatus.AllowBlank = false;
            _comboStatus.BlankText  = "必须选择一个状态";
            _comboStatusStore.Model.Add(ComponentHelper.GetModel(
                                            new Dictionary <string, ModelFieldType>()
            {
                { "Id", ModelFieldType.Int }, { "Name", ModelFieldType.String }
            }));
            _comboStatus.ValueHiddenName = "Status";
            _comboStatus.SimpleSubmit    = true;
            _comboStatus.DisplayField    = "Name";
            _comboStatus.ValueField      = "Id";
            _comboStatus.Store.Add(_comboStatusStore);
            _comboStatus.FieldLabel      = "状态";
            _comboStatus.Editable        = false;
            _comboStatusStore.DataSource = EnumHelper.GetList(typeof(BaseStatuses), (k, v) =>
            {
                return(new
                {
                    Id = k,
                    Name = v
                });
            });
            _comboStatusStore.DataBind();
            _formPanel.Add(_comboStatus);
            var _txtMemo = new TextArea();

            _txtMemo.Width      = 750;
            _txtMemo.Name       = "Description";
            _txtMemo.ColSpan    = 2;
            _txtMemo.FieldLabel = "描述";
            _txtMemo.Height     = 80;
            _formPanel.Add(_txtMemo);
            var _treeRoleSelector = new TreePanelNodeMover();

            _treeRoleSelector.LeftReadProxy.Url  = Url.Action("GetNotAddedRoles");
            _treeRoleSelector.RightReadProxy.Url = Url.Action("GetAddedRoles");
            _treeRoleSelector.Height             = 180;
            _treeRoleSelector.Width   = 750;
            _treeRoleSelector.ColSpan = 2;
            _treeRoleSelector.ID      = "treeRoles";
            _formPanel.Add(_treeRoleSelector);
            _formPanel.Add(new Hidden()
            {
                Name = "RoleIds",
                ID   = "hdnRoleIds"
            });
            var _btnAdd = new Button();

            _btnAdd.Text    = "添加";
            _btnAdd.Icon    = Icon.Add;
            _btnAdd.Handler = _treeRoleSelector.SyncAddedNodes("hdnRoleIds") + "App." + _formPanel.ID + ".submitData(function(r){if(r.success){" + HideWindowReloadGrid("gridUsers") + "}})";
            _formPanel.Buttons.Add(_btnAdd);
            writer.Write(_formPanel.ToBuilder().ToHtmlString());
        }
Exemple #3
0
        public override void RenderView(System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer)
        {
            RenderMain(writer);
            var _formPanel = new ValidatedForm();

            _formPanel.BodyPadding = 10;
            _formPanel.Layout      = "table";
            _formPanel.LayoutConfig.Add(new TableLayoutConfig()
            {
                Columns = 2
            });
            _formPanel.ID            = "addForm";
            _formPanel.DefaultAnchor = "100%";
            var _txtUsername = new TextField();

            _txtUsername.ID   = "txtUsername";
            _txtUsername.Name = "Username";
            _txtUsername.SetValue(Model.Username);
            _txtUsername.ColSpan    = 1;
            _txtUsername.Width      = 300;
            _txtUsername.AllowBlank = false;
            _txtUsername.FieldLabel = "用户名";
            _txtUsername.EmptyText  = "输入用户名";
            _formPanel.Add(_txtUsername);
            var _comboStatus = new ComboBox();

            _comboStatus.EmptyText       = "选择状态";
            _comboStatus.ValueHiddenName = "Status";
            _comboStatus.SimpleSubmit    = true;
            var _comboStatusStore = new Store();

            _comboStatusStore.ID = "comboStoreStatus";
            _comboStatusStore.Model.Add(ComponentHelper.GetModel(
                                            new Dictionary <string, ModelFieldType>()
            {
                { "Id", ModelFieldType.Int }, { "Name", ModelFieldType.String }
            }));
            _comboStatusStore.DataSource = EnumHelper.GetList(typeof(BaseStatuses), (k, v) =>
            {
                return(new
                {
                    Id = k,
                    Name = v
                });
            });
            _comboStatusStore.DataBind();
            _comboStatus.SetValue(Model.Status.GetHashCode());
            _comboStatus.DisplayField = "Name";
            _comboStatus.ValueField   = "Id";
            _comboStatus.Store.Add(_comboStatusStore);
            _comboStatus.FieldLabel = "状态";
            _comboStatus.Editable   = false;
            _formPanel.Add(_comboStatus);
            var _txtMemo = new TextArea();

            _txtMemo.SetValue(Model.Description);
            _txtMemo.Width      = 750;
            _txtMemo.Name       = "Description";
            _txtMemo.ColSpan    = 2;
            _txtMemo.EmptyText  = "简单描述一下用户的职责";
            _txtMemo.FieldLabel = "描述";
            _txtMemo.Height     = 70;
            _formPanel.Add(_txtMemo);
            var _treeRoleSelector = new TreePanelNodeMover();

            _treeRoleSelector.LeftReadProxy.Url = Url.Action("GetNotAddedRoles");
            _treeRoleSelector.LeftReadProxy.ExtraParams.Add(new Parameter("accountId", Model.Id.ToString(), ParameterMode.Raw));
            _treeRoleSelector.RightReadProxy.Url = Url.Action("GetAddedRoles");
            _treeRoleSelector.RightReadProxy.ExtraParams.Add(new Parameter("accountId", Model.Id.ToString(), ParameterMode.Raw));
            _treeRoleSelector.Height  = 180;
            _treeRoleSelector.Width   = 750;
            _treeRoleSelector.ColSpan = 2;
            _treeRoleSelector.ID      = "treeRoles";
            _formPanel.Add(_treeRoleSelector);
            var _btnSave = new Button();

            _btnSave.Icon = Icon.DatabaseSave;
            _btnSave.Text = "保存";
            _formPanel.Buttons.Add(_btnSave);
            var _hidId = new Hidden();

            _hidId.Name = "Id";
            _formPanel.Controls.Add(_hidId);
            writer.Write(_formPanel.ToBuilder().ToHtmlString());
        }