/// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        private bool ParseParameterValue(out IComparable value)
        {
            value = null;
            ParameterDefine pd         = GetSelectedParameterDefine();
            object          paramValue = GetParameterValue();

            IComparable v = null;

            try
            {
                v = (IComparable)Convert.ChangeType(paramValue, pd.TypeCode);
            }
            catch (Exception ex)
            {
                NUnit.UiKit.UserMessage.Display(ex.ToString());
                return(false);
            }

            if (pd.Constraint == null)
            {
                return(true);
            }

            value = v;

            return(pd.Constraint.Verify(v));
        }
        //}
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void okButton_Click(object sender, EventArgs e)
        {
            IComparable value;
            bool        r = ParseParameterValue(out value);

            if (!r)
            {
                return;
            }

            // TODO: 2010-07-29 convert param value to byte[]
            //
            // 1. get converter name
            // 2. get bytes converter
            // 3. bc.ConvertToBytes( paramvalue ) save to data byte array
            //
            ParameterDefine pd            = this.GetSelectedParameterDefine();
            string          converterName = pd.ConverterName;
            IBytesConverter ibc           = GetBytesConverter(converterName);

            if (ibc == null)
            {
                string exmsg = string.Format("cannot get bytesconverter '{0}'", converterName);
                throw new InvalidOperationException(exmsg);
            }

            byte[] bs = ibc.ConvertToBytes(value);
            this._datas       = bs;
            this.DialogResult = DialogResult.OK;
            Close();
        }
        public static List<ParameterDefine> LoadParameterDefine()
        {
            List<ParameterDefine> parameterDefines = new List<ParameterDefine>();
            string sql = "SELECT * FROM dbo.FT_ParameterDefine()";
            DataAccess.GetInstance().ExecuteReader(sql, CommandType.Text, delegate(SqlDataReader reader) {
                while (reader.Read())
                {
                    ParameterDefine parameter = new ParameterDefine();
                    parameter.ParameterKey = reader["ParameterKey"].ToString();
                    parameter.SettingParameterType = reader["SettingType"].ConvertToEnumValue<SettingParameterType>();
                    parameter.SqlDbType = reader["SqlDbType"].ConvertToEnumValue<SqlDbType>();

                    parameterDefines.Add(parameter);
                }
            });
            return parameterDefines;
        }