コード例 #1
0
        private void FrmCheckValue_Load(object sender, EventArgs e)
        {
            Item.SYSMethod sysMethod = new Item.SYSMethod();
            CBBApp.DataSource    = sysMethod.MethodList;
            CBBApp.DisplayMember = "txt";
            CBBApp.ValueMember   = "val";
            //可用系统参数提示
            string temp = string.Empty;

            Item.SysValue sysVal = new Item.SysValue();
            foreach (PropertyGrid.TxtValObject obj in sysVal.ValueList)
            {
                temp += obj.Txt + "  :" + obj.Val + "\n";
            }
            lblInf.Text = temp;

            RadioApp.CheckedChanged     += new EventHandler(Radio_CheckedChanged);
            RadioRegular.CheckedChanged += new EventHandler(Radio_CheckedChanged);
            RadioSQL.CheckedChanged     += new EventHandler(Radio_CheckedChanged);

            if (this.checkValueObject != null)
            {
                switch (this.checkValueObject.ValueType)
                {
                case "0": RadioApp.Checked = true; break;

                case "1": RadioRegular.Checked = true; break;

                case "2": RadioSQL.Checked = true; break;
                }
                CBBApp.SelectedValue = this.checkValueObject.ValueApp;
                txtRegular.Text      = this.checkValueObject.ValueRegular;
                txtSql.Text          = this.checkValueObject.ValueSql;
            }
        }
コード例 #2
0
        /// <summary>
        /// 验证输入的是否正确
        /// </summary>
        /// <param name="property"></param>
        /// <param name="ValueStr"></param>
        /// <returns></returns>
        private bool checkValudate(StimControlProperty property, string ValueStr, Hashtable htItem)
        {
            bool ch = true;

            if (property.CheckRegular != null)
            {
                PropertyGrid.Item.SYSMethod Method = new PropertyGrid.Item.SYSMethod();
                //0,系统方法;1,正则表达式;2,sql语句
                switch (property.CheckRegular.ValueType)
                {
                case "0": ch = Method.CheckValue(property.CheckRegular.ValueApp, ValueStr); break;

                case "1": ch = Method.RegexCheck(ValueStr, property.CheckRegular.ValueRegular); break;

                case "2":
                    string    sql = property.CheckRegular.ValueSql;
                    Hashtable ht  = new Hashtable();
                    //ht.Add(property.Name, ValueStr);
                    //获取系统默认值
                    PropertyGrid.Item.SysValue _sysValue = new PropertyGrid.Item.SysValue();
                    foreach (PropertyGrid.TxtValObject obj in _sysValue.ValueList)
                    {
                        if (sql.IndexOf(":" + obj.Val) > 0)
                        {
                            ht.Add(obj.Val, _sysValue.GetValue(obj.Val));
                        }
                    }
                    //获取界面其他控件的值
                    foreach (DictionaryEntry objDE in htItem)
                    {
                        StimControlProperty tempProperty = objDE.Key as StimControlProperty;
                        if (sql.IndexOf(":" + tempProperty.Name) > 0)
                        {
                            ht.Add(tempProperty.Name, objDE.Value);
                        }
                    }
                    ch = (new BLL.STIM_CONFIG()).SqlCheckValue(sql, ht);
                    break;
                }
            }
            return(ch);
        }