⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileproperties.ascx.cs

📁 wrox c#高级编程
💻 CS
字号:
namespace SqlWebAdmin
{
    using System;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;

    using SqlAdmin;

    /// <summary>
    ///     Summary description for FileProperties.
    /// </summary>
    public abstract class FileProperties : System.Web.UI.UserControl
    {
        protected System.Web.UI.WebControls.CheckBox AutomaticallyGrowFileCheckBox;
        protected System.Web.UI.WebControls.DropDownList GrowthTypeDropDownList;
        protected System.Web.UI.WebControls.TextBox GrowthTextBox;
        protected System.Web.UI.WebControls.TextBox MaximumFileSizeTextBox;
        protected System.Web.UI.WebControls.RadioButton UnrestrictedGrowthRadioButton;
        protected System.Web.UI.WebControls.RadioButton RestrictGrowthRadioButton;


        public SqlAdmin.SqlFileProperties Properties
        {
            get
            {
                int growth = 0;
                int maximumFileSize = 0;

                try {
                    growth = Convert.ToInt32(GrowthTextBox.Text);
                }
                catch {
                    throw new Exception("Growth must be an integer");
                }

                try {
                    maximumFileSize = Convert.ToInt32(MaximumFileSizeTextBox.Text);
                }
                catch {
                    throw new Exception("Maximum file size must be an integer");
                }

                return new SqlFileProperties(
                    (GrowthTypeDropDownList.SelectedIndex == 0) ? SqlFileGrowthType.MB : SqlFileGrowthType.Percent,
                    AutomaticallyGrowFileCheckBox.Checked ? growth : 0,
                    UnrestrictedGrowthRadioButton.Checked ? -1 : maximumFileSize);
            }
            set 
            {
                SqlFileProperties props = value;
                if (props.FileGrowth == 0)
                    AutomaticallyGrowFileCheckBox.Checked = false;
                else
                    AutomaticallyGrowFileCheckBox.Checked = true;

                if (props.FileGrowthType == SqlFileGrowthType.MB)
                    GrowthTypeDropDownList.SelectedIndex = 0;
                else
                    GrowthTypeDropDownList.SelectedIndex = 1;

                GrowthTextBox.Text = props.FileGrowth.ToString();
                if (props.MaximumSize == -1) {
                    UnrestrictedGrowthRadioButton.Checked = true;
                    RestrictGrowthRadioButton.Checked = false;
                }
                else {
                    UnrestrictedGrowthRadioButton.Checked = false;
                    RestrictGrowthRadioButton.Checked = true;
                }

                MaximumFileSizeTextBox.Text = props.MaximumSize.ToString();
            }
        }


        public FileProperties()
        {
            this.Init += new System.EventHandler(Page_Init);
        }

        private void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
        }

        private void Page_Init(object sender, EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
        }

        #region Web Form Designer generated code
        ///     Required method for Designer support - do not modify
        ///     the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.Load += new System.EventHandler(this.Page_Load);

        }
        #endregion
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -