[fix]Config创建默认配置文件的开关Runtime.CreateConfigOnMissing,仅需对自动创建生效,而不应该阻止用户主动Save
智能大石头 authored at 2024-08-09 00:30:41 石头 committed at 2024-08-10 14:22:24
2.22 KiB
X
using System;
using NewLife.CommonEntity;
using NewLife.Web;
using XCode.Membership;

public partial class Admin_Ascx_SelectAdmin : System.Web.UI.UserControl
{
    #region 属性
    /// <summary>产品编号</summary>
    public Int32 Value
    {
        get
        {
            Int32 _Value = 0;
            if (String.IsNullOrEmpty(btn.Value) ||
                !Int32.TryParse(btn.Value, out _Value) ||
                _Value < 1) _Value = 0;
            if (_Value < 1)
            {
                _Value = WebHelper.RequestInt("AdminID");
                if (_Value < 1) _Value = WebHelper.RequestInt("UserID");
                btn.Value = _Value.ToString();
            }

            return _Value;
        }
        set
        {
            Int32 _Value = value;
            if (_Value < 1)
            {
                _Value = WebHelper.RequestInt("AdminID");
                if (_Value < 1) _Value = WebHelper.RequestInt("UserID");
            }
            btn.Value = _Value.ToString();
        }
    }

    private IUser _Admin;
    /// <summary>产品</summary>
    public IUser Admin
    {
        get
        {
            if (_Admin == null && Value > 0)
            {
                //_Admin = Admin.Meta.Cache.Entities.Find(Admin._.ID, Value);
                _Admin = ManageProvider.Provider.FindByID(Value) as IUser;
            }
            return _Admin;
        }
    }

    /// <summary>自动回发</summary>
    public Boolean AutoPostBack
    {
        get { return btn.AutoPostBack; }
        set { btn.AutoPostBack = value; }
    }

    public event EventHandler ValueChanged
    {
        add { btn.ValueChanged += value; }
        remove { btn.ValueChanged -= value; }
    }
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        ////if (IsPostBack) Value = Convert.ToInt32(frmAdminID.Value);
        //if (IsPostBack && !String.IsNullOrEmpty(frmAdminID.Value)) Value = Convert.ToInt32(frmAdminID.Value);

        btn.DataBind();
    }

    //protected override void OnPreRender(EventArgs e)
    //{
    //    base.OnPreRender(e);

    //    if (String.IsNullOrEmpty(frmAdminID.Value)) frmAdminID.DataBind();
    //}
}