示例#1
0
        /// <summary>
        /// 调用注册的事件
        /// </summary>
        /// <param name="e"></param>
        public void ReiseEditValueChanging(ChangingEventArgs e)
        {
            ChangingEventHandler handler = (ChangingEventHandler)this.Events[editValueChanging];

            if (handler != null)
            {
                handler(this, e);
            }
        }
示例#2
0
        /// <summary>
        /// 编辑值正在改变事件
        /// </summary>
        /// <param name="e"></param>
        protected virtual void OnEditValueChanging(ChangingEventArgs e)
        {
            //调用注册的事件
            ReiseEditValueChanging(e);

            if (e.Cancel)//注册的事件取消 还原值
            {
                fEditValue = e.OldValue;
                return;
            }

            switch (_editValueType)
            {
                case ValueType.Number://数值类型
                    {
                        if (e.NewValue != null && !string.IsNullOrEmpty(e.NewValue.ToString()))//非空值
                        {
                            int intNewNum = 0;
                            if (!Int32.TryParse(e.NewValue.ToString(), out intNewNum))//非数字
                            {
                                string strOp = e.NewValue.ToString();
                                //负号
                                if (ParseValueIsMinus(strOp))
                                {
                                    strOp = strOp.Replace("-", "");

                                    int tempMin = 0;
                                    if (Int32.TryParse(strOp, out tempMin))
                                    {
                                        if (tempMin > Math.Abs(MinNum + 1))
                                        {
                                            fEditValue = e.OldValue;
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        fEditValue = e.OldValue;
                                        return;
                                    }
                                    strOp = "-" + strOp;
                                    fEditValue = strOp;
                                }
                                else if (strOp.Contains("-"))//多负号情况
                                {
                                    strOp = strOp.Replace("-", "");
                                    int tempMax = 0;
                                    if (Int32.TryParse(strOp, out tempMax))
                                    {
                                        if (tempMax > MaxNum)
                                        {
                                            fEditValue = e.OldValue;
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        fEditValue = e.OldValue;
                                        return;
                                    }
                                    fEditValue = strOp;
                                }
                                else
                                    fEditValue = e.OldValue;//还原
                                return;
                            }
                            if (intNewNum > MaxNum
                                || intNewNum < MinNum)//不在范围里的数据
                            {
                                fEditValue = e.OldValue;
                                return;
                            }
                            //同步设置新值
                            fEditValue = e.NewValue;
                        }
                        else
                        {
                            //同步设置新值(特殊)
                            fEditValue = 0;
                        }
                    } break;
                case ValueType.String:
                    {
                        fEditValue = e.NewValue;
                    } break;
                default:
                    {
                        fEditValue = e.NewValue;
                    } break;

            }
        }
示例#3
0
        /// <summary>
        /// 编辑值正在改变事件
        /// </summary>
        /// <param name="e"></param>
        protected virtual void OnEditValueChanging(ChangingEventArgs e)
        {
            //调用注册的事件
            ReiseEditValueChanging(e);

            if (e.Cancel)//注册的事件取消 还原值
            {
                fEditValue = e.OldValue;
                return;
            }

            switch (_editValueType)
            {
            case ValueType.Number:                                                      //数值类型
            {
                if (e.NewValue != null && !string.IsNullOrEmpty(e.NewValue.ToString())) //非空值
                {
                    int intNewNum = 0;
                    if (!Int32.TryParse(e.NewValue.ToString(), out intNewNum))        //非数字
                    {
                        string strOp = e.NewValue.ToString();
                        //负号
                        if (ParseValueIsMinus(strOp))
                        {
                            strOp = strOp.Replace("-", "");

                            int tempMin = 0;
                            if (Int32.TryParse(strOp, out tempMin))
                            {
                                if (tempMin > Math.Abs(MinNum + 1))
                                {
                                    fEditValue = e.OldValue;
                                    return;
                                }
                            }
                            else
                            {
                                fEditValue = e.OldValue;
                                return;
                            }
                            strOp      = "-" + strOp;
                            fEditValue = strOp;
                        }
                        else if (strOp.Contains("-"))        //多负号情况
                        {
                            strOp = strOp.Replace("-", "");
                            int tempMax = 0;
                            if (Int32.TryParse(strOp, out tempMax))
                            {
                                if (tempMax > MaxNum)
                                {
                                    fEditValue = e.OldValue;
                                    return;
                                }
                            }
                            else
                            {
                                fEditValue = e.OldValue;
                                return;
                            }
                            fEditValue = strOp;
                        }
                        else
                        {
                            fEditValue = e.OldValue;        //还原
                        }
                        return;
                    }
                    if (intNewNum > MaxNum ||
                        intNewNum < MinNum)           //不在范围里的数据
                    {
                        fEditValue = e.OldValue;
                        return;
                    }
                    //同步设置新值
                    fEditValue = e.NewValue;
                }
                else
                {
                    //同步设置新值(特殊)
                    fEditValue = 0;
                }
            } break;

            case ValueType.String:
            {
                fEditValue = e.NewValue;
            } break;

            default:
            {
                fEditValue = e.NewValue;
            } break;
            }
        }
示例#4
0
 /// <summary>
 /// 调用注册的事件
 /// </summary>
 /// <param name="e"></param>
 public void ReiseEditValueChanging(ChangingEventArgs e)
 {
     ChangingEventHandler handler = (ChangingEventHandler)this.Events[editValueChanging];
     if (handler != null) handler(this, e);
 }