Exemplo n.º 1
0
            protected override void OnValueChanged(StoredProcedureFieldBase element, string oldValue, string newValue)
            {
                //If not laoding then parse the name for the data type
                var hasChanged = false;

                if (element.StoredProcedure != null && !element.StoredProcedure.nHydrateModel.IsLoading)
                {
                    if (!string.IsNullOrEmpty(newValue))
                    {
                        var arr = newValue.Split(':');
                        if (arr.Length == 2)
                        {
                            var typearr = arr[1].Split(' ');
                            var d       = Extensions.GetDataTypeFromName(typearr[0]);
                            if (d != null)
                            {
                                if (typearr.Length == 2)
                                {
                                    int len;
                                    if (int.TryParse(typearr[1], out len))
                                    {
                                        element.DataType = d.Value;
                                        element.Length   = len;
                                        newValue         = arr[0];
                                        hasChanged       = true;
                                    }
                                    else
                                    {
                                        throw new Exception("Unrecognized data type! Valid format is 'Name:Datatype length'");
                                    }
                                }
                                else
                                {
                                    element.DataType = d.Value;
                                    newValue         = arr[0];
                                    hasChanged       = true;
                                }
                            }
                            else
                            {
                                throw new Exception("Unrecognized data type! Valid format is 'Name:Datatype length'");
                            }
                        }
                    }
                }

                base.OnValueChanged(element, oldValue, newValue);

                //Reset after we set datatype
                if (hasChanged)
                {
                    element.Name = newValue;
                }
                else
                {
                    base.OnValueChanged(element, oldValue, newValue);
                }
            }
Exemplo n.º 2
0
            protected override void OnValueChanged(StoredProcedureFieldBase element, int oldValue, int newValue)
            {
                base.OnValueChanged(element, oldValue, newValue);

                //this will trigger another event
                if (newValue < 0)
                {
                    element.Scale = 0;
                }
            }
Exemplo n.º 3
0
            protected override void OnValueChanged(StoredProcedureFieldBase element, int oldValue, int newValue)
            {
                base.OnValueChanged(element, oldValue, newValue);

                //this will trigger another event
                var v = newValue;

                if (v < 0)
                {
                    v = 0;
                }
                v = element.DataType.ValidateDataTypeMax(v);
                if (newValue != v)
                {
                    element.Length = element.DataType.ValidateDataTypeMax(v);
                }
            }
Exemplo n.º 4
0
			protected override void OnValueChanged(StoredProcedureFieldBase element, int oldValue, int newValue)
			{
				base.OnValueChanged(element, oldValue, newValue);

				//this will trigger another event
				if (newValue < 0) element.Scale = 0;
			}
Exemplo n.º 5
0
			protected override void OnValueChanged(StoredProcedureFieldBase element, int oldValue, int newValue)
			{
				base.OnValueChanged(element, oldValue, newValue);

				//this will trigger another event
				var v = newValue;
				if (v < 0) v = 0;
				v = element.DataType.ValidateDataTypeMax(v);
				if (newValue != v)
					element.Length = element.DataType.ValidateDataTypeMax(v);
			}
Exemplo n.º 6
0
			protected override void OnValueChanged(StoredProcedureFieldBase element, string oldValue, string newValue)
			{
				//If not laoding then parse the name for the data type
				var hasChanged = false;
				if (element.StoredProcedure != null && !element.StoredProcedure.nHydrateModel.IsLoading)
				{
					if (!string.IsNullOrEmpty(newValue))
					{
						var arr = newValue.Split(':');
						if (arr.Length == 2)
						{
							var typearr = arr[1].Split(' ');
							var d = Extensions.GetDataTypeFromName(typearr[0]);
							if (d != null)
							{
								if (typearr.Length == 2)
								{
									int len;
									if (int.TryParse(typearr[1], out len))
									{
										element.DataType = d.Value;
										element.Length = len;
										newValue = arr[0];
										hasChanged = true;
									}
									else
									{
										throw new Exception("Unrecognized data type! Valid format is 'Name:Datatype length'");
									}
								}
								else
								{
									element.DataType = d.Value;
									newValue = arr[0];
									hasChanged = true;
								}

							}
							else
							{
								throw new Exception("Unrecognized data type! Valid format is 'Name:Datatype length'");
							}
						}
					}
				}

				base.OnValueChanged(element, oldValue, newValue);

				//Reset after we set datatype
				if (hasChanged)
					element.Name = newValue;
				else
					base.OnValueChanged(element, oldValue, newValue);
			}