예제 #1
0
        private bool CheckValue(TransField field, object fieldValue)
        {
            bool result = false;

            if (field.DeleteForDecrease && decimal.Parse(fieldValue.ToString()) == decimal.Zero)
            {
                result = true;
            }

            if (field.ExceptionForMinus && decimal.Parse(fieldValue.ToString()) < decimal.Zero)
            {
                throw new ArgumentException(MessageHelper.EFTransactionMessage.ValueIsNegativeNumber);
            }

            return result;
        }
예제 #2
0
        private object GetFieldValue(TransField field, bool isGetOldValue, bool isAlwaysAppend)
        {
            object fieldValue = null;

            switch (field.UpdateMode)
            {
                case UpdateMode.Increase:
                case UpdateMode.Decrease:
                    if (isGetOldValue)
                    {
                        if (field.OldValue != null)
                        {
                            fieldValue = field.OldValue;
                        }
                    }
                    else
                    {
                        if (field.NewValue != null)
                        {
                            fieldValue = field.NewValue;
                        }
                    }

                    if (fieldValue != null)
                    {
                        if (isAlwaysAppend)
                        {
                            fieldValue = (field.UpdateMode == UpdateMode.Increase ? MinusSign : string.Empty) + fieldValue;
                        }
                        else
                        {
                            fieldValue = (field.UpdateMode == UpdateMode.Increase ? string.Empty : MinusSign) + fieldValue;
                        }
                    }
                    break;
                case UpdateMode.Replace:
                    fieldValue = isGetOldValue == true ? field.OldValue : field.NewValue;
                    break;
            }

            return fieldValue;
        }
예제 #3
0
        public Transaction Copy()
        {
            Transaction transPrivateCopy = new Transaction();

            transPrivateCopy.AutoNumber = this.AutoNumber;

            foreach (TransField field in this.TransFields)
            {
                TransField tf = new TransField();
                tf.DesField = field.DesField;
                tf.OldValue = field.OldValue;
                tf.SrcField = field.SrcField;
                tf.SrcGetValue = field.SrcGetValue;
                tf.NewValue = field.NewValue;
                tf.UpdateMode = field.UpdateMode;

                transPrivateCopy.TransFields.Add(tf);
            }

            foreach (TransKeyField keyField in this.TransKeyFields)
            {
                TransKeyField tkf = new TransKeyField();
                tkf.DesField = keyField.DesField;
                tkf.SrcField = keyField.SrcField;
                tkf.SrcGetValue = keyField.SrcGetValue;
                tkf.NewValue = keyField.NewValue;
                tkf.WhereMode = keyField.WhereMode;

                transPrivateCopy.TransKeyFields.Add(tkf);
            }
            transPrivateCopy.TransMode = this.TransMode;
            transPrivateCopy.TransStep = this.TransStep;
            transPrivateCopy.TransTableName = this.TransTableName;
            transPrivateCopy.WhenInsert = this.WhenInsert;
            transPrivateCopy.WhenUpdate = this.WhenUpdate;
            transPrivateCopy.WhenDelete = this.WhenDelete;

            return transPrivateCopy;
        }