Пример #1
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());
        }
Пример #2
0
        public override void RenderView(ViewContext viewContext, System.IO.TextWriter writer)
        {
            writer.Write("<!DOCTYPE html>");
            writer.Write("<head>");
            writer.Write("<title>用户登录</title>");
            var x = Html.X();

            writer.Write(Html.X().ResourceManager().ToHtmlString());
            var loginWindow = new Window()
            {
                Title       = "用户登录",
                Width       = 300,
                Height      = 200,
                Closable    = false,
                Modal       = true,
                Icon        = Icon.Key,
                Draggable   = false,
                BodyPadding = 10,
                Resizable   = false
            };
            var formPanel = new ValidatedForm()
            {
                Border      = true,
                BodyPadding = 10,
                ID          = "loginForm",
                Url         = Url.Action("login")
            };

            formPanel.Layout = "table";
            formPanel.LayoutConfig.Add(new TableLayoutConfig()
            {
                Columns = 2
            });
            loginWindow.Add(formPanel);
            var textField = new TextField()
            {
                FieldLabel = "用户名",
                Name       = "Username",
                ColSpan    = 2,
                AllowBlank = false,
                BlankText  = "用户名不能为空"
            };
            var passwordField = new TextField()
            {
                FieldLabel = "密码",
                Name       = "Password",
                ColSpan    = 2,
                AllowBlank = false,
                InputType  = Ext.Net.InputType.Password,
                BlankText  = "密码不能为空"
            };
            var verifyImg = new Image()
            {
                Width    = 100,
                ImageUrl = Url.Action("VerifyImage"),
                Height   = 22,
                ColSpan  = 1,
                ID       = "imgVerify"
            };
            var verifyCodeField = new TextField()
            {
                FieldLabel = "验证码",
                ColSpan    = 1,
                AllowBlank = false,
                BlankText  = "验证码不能为空'",
                Name       = "VerifyCode"
            };

            formPanel.Add(textField);
            formPanel.Add(passwordField);
            formPanel.Add(verifyCodeField);
            formPanel.Add(verifyImg);
            var btnLogin = new Button()
            {
                Text = "登录",
                Icon = Icon.KeyStart,
            };
            var btnChangeImage = new Button()
            {
                Text = "更换验证码",
                Icon = Icon.ImageEdit,
                ID   = "btnChangeImage"
            };

            btnChangeImage.Handler = "var src='" + verifyImg.ImageUrl + "';src=src+'?'+new Date().valueOf();App.imgVerify.setImageUrl(src);";
            btnLogin.Handler       = @"App.loginForm.submitData(function(r){if(r.success){location.href='" + @Url.Action("index", "home") + "';}else{App.btnChangeImage.handler();}});";
            loginWindow.Buttons.Add(btnChangeImage);
            loginWindow.Buttons.Add(btnLogin);
            writer.Write(loginWindow.ToBuilder().ToHtmlString());
            writer.Write("</head>");
        }
Пример #3
0
        public override void RenderView(ViewContext viewContext, System.IO.TextWriter writer)
        {
            writer.Write("<!DOCTYPE html>");
            writer.Write("<head>");
            writer.Write("<title>用户登录</title>");
            var x = Html.X();
            writer.Write(Html.X().ResourceManager().ToHtmlString());
            var loginWindow = new Window()
            {
                Title = "用户登录",
                Width = 300,
                Height = 200,
                Closable = false,
                Modal = true,
                Icon = Icon.Key,
                Draggable = false,
                BodyPadding = 10,
                Resizable = false
            };
            var formPanel = new ValidatedForm()
            {
                Border = true,
                BodyPadding = 10,
                ID = "loginForm",
                Url = Url.Action("login")
            };
            formPanel.Layout = "table";
            formPanel.LayoutConfig.Add(new TableLayoutConfig()
            {
                Columns = 2
            });
            loginWindow.Add(formPanel);
            var textField = new TextField()
            {
                FieldLabel = "用户名",
                Name = "Username",
                ColSpan = 2,
                AllowBlank = false,
                BlankText = "用户名不能为空"
            };
            var passwordField = new TextField()
            {
                FieldLabel = "密码",
                Name = "Password",
                ColSpan = 2,
                AllowBlank = false,
                InputType = Ext.Net.InputType.Password,
                BlankText = "密码不能为空"
            };
            var verifyImg = new Image()
            {
                Width = 100,
                ImageUrl = Url.Action("VerifyImage"),
                Height = 22,
                ColSpan = 1,
                ID = "imgVerify"
            };
            var verifyCodeField = new TextField()
            {
                FieldLabel = "验证码",
                ColSpan = 1,
                AllowBlank = false,
                BlankText = "验证码不能为空'",
                Name="VerifyCode"
            };
            formPanel.Add(textField);
            formPanel.Add(passwordField);
            formPanel.Add(verifyCodeField);
            formPanel.Add(verifyImg);
            var btnLogin = new Button()
            {
                Text = "登录",
                Icon = Icon.KeyStart,

            };
            var btnChangeImage = new Button()
            {
                Text = "更换验证码",
                Icon = Icon.ImageEdit,
                ID = "btnChangeImage"
            };
            btnChangeImage.Handler = "var src='" + verifyImg.ImageUrl + "';src=src+'?'+new Date().valueOf();App.imgVerify.setImageUrl(src);";
            btnLogin.Handler = @"App.loginForm.submitData(function(r){if(r.success){location.href='" + @Url.Action("index", "home") + "';}else{App.btnChangeImage.handler();}});";
            loginWindow.Buttons.Add(btnChangeImage);
            loginWindow.Buttons.Add(btnLogin);
            writer.Write(loginWindow.ToBuilder().ToHtmlString());
            writer.Write("</head>");

        }
Пример #4
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());
        }