public PropertyColumnData(MemberBase member, EntityMetadata entity, bool isInherit) : base(member, entity, isInherit) { switch (Member.GenerateMode) { case EColumnGenerateMode.Database: DatabaseGenerated("Computed"); GeneratedProperty(Member.DatabaseGenerate); break; case EColumnGenerateMode.DatabaseCreate: DatabaseGenerated("Computed"); GeneratedProperty(Member.DatabaseGenerate, ""); break; case EColumnGenerateMode.DatabaseUpdate: DatabaseGenerated("Computed"); GeneratedProperty("", Member.DatabaseGenerate); break; } DecimalType dec = member.Content as DecimalType; if (dec != null) { Precision(dec.Precision, dec.Scale); } }
public void DecimalTypeNames() { var expected = new[] { "System.Decimal", "System.Single", "System.Double" }; var actual = new DecimalType().TypeNames; TestHelper.AreEqual(expected, actual); }
internal FbDecFloat(DecimalType type, bool negative, BigInteger coefficient, int exponent) { Type = type; Negative = negative; Coefficient = coefficient; Exponent = exponent; }
public PropertyPrimaryData(MemberBase member, EntityMetadata entity, bool isInherit) : base(member, entity, isInherit) { Key(); switch (Member.GenerateMode) { case EPrimaryGenerateMode.Identity: DatabaseGenerated("Identity"); break; case EPrimaryGenerateMode.Database: DatabaseGenerated("Identity"); GeneratedProperty(Member.DatabaseGenerate, ""); break; case EPrimaryGenerateMode.Disabled: DatabaseGenerated("None"); break; } DecimalType dec = member.Content as DecimalType; if (dec != null) { Precision(dec.Precision, dec.Scale); } }
public void UnsavedValue() { DecimalType type = (DecimalType)NHibernateUtil.Decimal; object mappedValue = type.StringToObject("0"); Assert.AreEqual(0m, mappedValue); Assert.IsTrue(type.IsEqual(mappedValue, 0m), "'0' in the mapping file should have been converted to a 0m"); }
private void UpdateDistance() { if (this.directSalesAgentId.IsValid) { this.distance = CalculateDistance(DirectSalesAgent.MailingAddress.Latitude, DirectSalesAgent.MailingAddress.Longitude, this.Latitude, this.Longitude); } }
/// <summary> /// Returns the scalar type for the strings, decimals, uris, etc... /// </summary> /// <param name="type"></param> /// <param name="scalarType"></param> /// <returns></returns> public static bool TryGetBuiltInScalarType( Type type, [NotNullWhen(true)] out ScalarType?scalarType ) { if (type == typeof(string)) { scalarType = new StringType(); } else if (type == typeof(decimal)) { scalarType = new DecimalType(); } else if (type == typeof(int)) { scalarType = new IntType(); } else if (type == typeof(bool)) { scalarType = new BooleanType(); } else if (type == typeof(float)) { scalarType = new FloatType(); } else if (type == typeof(Guid)) { scalarType = new UuidType(); } else if (type == typeof(DateTime)) { scalarType = new DateTimeType(); } else if (type == typeof(byte)) { scalarType = new ByteType(); } else if (type == typeof(Uri)) { scalarType = new UrlType(); } else if (type == typeof(long)) { scalarType = new LongType(); } else if (type == typeof(short)) { scalarType = new ShortType(); } else { scalarType = null; } return(scalarType is object); }
public void ParseShouldReturnOptionDecimalSome() { // Arrange var s = "1"; Option <decimal> expected = Some(1M); // Act var result = DecimalType.Parse(s); // Assert result.Should().Be(expected); }
public void ParseShouldReturnOptionDecimalNone() { // Arrange var s = "not a decimal"; Option <decimal> expected = None; // Act var result = DecimalType.Parse(s); // Assert result.Should().Be(expected); }
public void ParseWithNumberStylesShouldReturnOptionDecimalNone() { // Arrange var s = "not a decimal"; Option <decimal> expected = None; // Act var result = DecimalType.Parse(s, NumberStyles.AllowDecimalPoint); // Assert result.Should().Be(expected); }
public void ParseWithNumberStylesShouldReturnOptionDecimalNoneWhenStringIsNotExpectedHexNumber() { // Arrange var s = "1.1"; Option <decimal> expected = None; // Act var result = DecimalType.Parse(s, NumberStyles.HexNumber); // Assert result.Should().Be(expected); }
public void FromObject() { Assert.Equal(0m, DecimalType.FromObject(null)); Assert.Equal(-1m, DecimalType.FromObject(true)); Assert.Equal(123m, DecimalType.FromObject((byte)123)); Assert.Equal(123m, DecimalType.FromObject((short)123)); Assert.Equal(123m, DecimalType.FromObject((int)123)); Assert.Equal(123m, DecimalType.FromObject((long)123)); Assert.Equal(123m, DecimalType.FromObject((float)123)); Assert.Equal(123m, DecimalType.FromObject((double)123)); Assert.Equal(123m, DecimalType.FromObject((decimal)123)); Assert.Equal(123m, DecimalType.FromObject("123")); }
public Decimal AbonoTotal() { Decimal d1 = Decimal.Zero; int num1 = 0; int num2 = checked (this._Registros - 1); int index = num1; while (index <= num2) { d1 = Decimal.Add(d1, DecimalType.FromObject(this.dgDatos[index, 2])); checked { ++index; } } return(d1); }
public void Equals() { decimal lhs = 5.64351M; decimal rhs = 5.64351M; DecimalType type = (DecimalType)NHibernateUtil.Decimal; Assert.IsTrue(type.IsEqual(lhs, rhs)); // Test that two decimal fields that are equal except one has a higher precision than // the other one are returned as Equal by the DecimalType. rhs = 5.643510M; Assert.IsTrue(type.IsEqual(lhs, rhs)); }
public static char GetDecimalSeparator(DecimalType decimalSeparator) { switch (decimalSeparator) { default: case DecimalType.Dot: return('.'); case DecimalType.Comma: return(','); case DecimalType.Colon: return(':'); } }
public object Read(DecimalType decimalType) { switch (decimalType.Size) { case 4: return((decimal)reader.ReadInt32() / decimalType.Exponent); case 8: return((decimal)reader.ReadInt64() / decimalType.Exponent); default: var bigInt = new BigInteger(reader.ReadBytes(decimalType.Size)); return((decimal)bigInt / decimalType.Exponent); } }
public void RegistrarAbonos(int Año, int AlmacenGas, int MovimientoAlmacen, DateTime FVenta, string Usuario) { int num1 = 0; int num2 = checked (this._Registros - 1); int index = num1; while (index <= num2) { Decimal num3 = DecimalType.FromObject(this.dgDatos[index, 2]); int num4 = IntegerType.FromObject(this.dgDatos[index, 0]); int num5 = IntegerType.FromObject(this.dgDatos[index, 1]); new Consulta.cCobroComisionista().Actualizar((short)1, 0, Año, this._Cliente, num3, AlmacenGas, MovimientoAlmacen, FVenta, Usuario, 0, "", num4, num5, (short)0, DateAndTime.Now); checked { ++index; } } }
public static DecimalType CalculateDistance(DecimalType latitude1, DecimalType longitude1, DecimalType latitude2, DecimalType longitude2) { if (latitude1.IsValid && longitude1.IsValid && latitude2.IsValid && longitude2.IsValid) { return (new DecimalType( CalculateDistance(DecimalType.ToDouble(latitude1), DecimalType.ToDouble(longitude1), DecimalType.ToDouble(latitude2), DecimalType.ToDouble(longitude2)))); } else { return(-1); } }
public static DirectSalesAgentList FindReferrals(Double latitude, Double longitude, Int32 minimum) { DirectSalesAgentList referrals = new DirectSalesAgentList(); // TODO: change to use radicals Double radius = Double.Parse(ConfigurationProvider.Instance.Settings["ReferralRadius"]); Double distance = 0; Int32 daysSinceReferral = Int32.Parse(ConfigurationProvider.Instance.Settings["DaysSinceReferral"]); Int32 minimumReferrals = minimum == 0 ? Int32.Parse(ConfigurationProvider.Instance.Settings["MinimumReferrals"]) : minimum; Int32 maxSearches = Int32.Parse(ConfigurationProvider.Instance.Settings["ReferralMaxSearches"]); IdType minimumTitleId = IdType.Parse(ConfigurationProvider.Instance.Settings["MinimumReferralTitleId"]); Int32 referralsFound = 0; Int32 searchCount = 0; try { while ((referralsFound < minimumReferrals) && (searchCount < maxSearches)) { searchCount++; if (searchCount >= maxSearches) { distance = int.MaxValue; } else { distance += radius; } DecimalType minLat = Convert.ToDecimal(CalculateSouthernRadicalPoint(latitude, longitude, distance).Latitude); DecimalType maxLat = Convert.ToDecimal(CalculateNorthernRadicalPoint(latitude, longitude, distance).Latitude); DecimalType minLong = Convert.ToDecimal(CalculateEasternRadicalPoint(latitude, longitude, distance).Longitude); DecimalType maxLong = Convert.ToDecimal(CalculateWesternRadicalPoint(latitude, longitude, distance).Longitude); referrals = DemonstratorDAO.DAO.FindWithinGeographicArea(Convert.ToDecimal(latitude), Convert.ToDecimal(longitude), minLat, maxLat, minLong, maxLong, minimumTitleId); referralsFound = referrals.Count; } } catch (Exception ex) { log.Error(ex.ToString()); return(new DirectSalesAgentList()); } return(referrals); }
public void ParseWithNumberStylesAndFormatProviderShouldReturnOptionDecimalNone() { // Arrange var s = "p1$234.4"; IFormatProvider formatProvider = new NumberFormatInfo() { PositiveSign = "p" }; Option <decimal> expected = None; // Act var result = DecimalType.Parse(s, NumberStyles.AllowDecimalPoint, formatProvider); // Assert result.Should().Be(expected); }
public void ParseWithNumberStylesAndFormatProviderShouldReturnOptionDecimalSome() { // Arrange var s = "p1.1"; IFormatProvider formatProvider = new NumberFormatInfo() { PositiveSign = "p", NumberDecimalSeparator = "." }; Option <decimal> expected = Some(1.1M); // Act var result = DecimalType.Parse(s, NumberStyles.Number, formatProvider); // Assert result.Should().Be(expected); }
public void ParseWithFormatProviderShouldReturnOptionDecimalSome() { // Arrange var s = "p1234"; IFormatProvider formatProvider = new NumberFormatInfo() { PositiveSign = "p" }; Option <decimal> expected = Some(1234M); // Act var result = DecimalType.Parse(s, formatProvider); // Assert result.Should().Be(expected); }
private void WriteLargeDecimal(DecimalType dti, decimal value) { var bigInt = new BigInteger(value); byte[] bigIntBytes = bigInt.ToByteArray(); byte[] decimalBytes = new byte[dti.Size]; bigIntBytes.CopyTo(decimalBytes, 0); // If a negative BigInteger is not long enough to fill the whole buffer, the remainder needs to be filled with 0xFF if (bigInt < 0) { for (int i = bigIntBytes.Length; i < dti.Size; i++) { decimalBytes[i] = 0xFF; } } writer.Write(decimalBytes); }
public void Write(DecimalType decimalType, object value) { decimal multipliedValue = Convert.ToDecimal(value) * decimalType.Exponent; switch (decimalType.Size) { case 4: writer.Write((int)multipliedValue); break; case 8: writer.Write((long)multipliedValue); break; default: WriteLargeDecimal(decimalType, multipliedValue); break; } }
private void CargarDatos(int Mes, int Año) { this.dgPedidos.DataSource = (object)null; Consulta.cPedidoComisionRes pedidoComisionRes = new Consulta.cPedidoComisionRes(0, this.Cliente, Mes, Año); this.Cursor = Cursors.WaitCursor; Decimal d1 = Decimal.Zero; int num1 = 0; int num2 = checked (((DataTable)pedidoComisionRes.dtTable).Rows.Count - 1); int index = num1; while (index <= num2) { d1 = Decimal.Add(d1, DecimalType.FromObject(((DataTable)pedidoComisionRes.dtTable).Rows[index][3])); checked { ++index; } } this.dgPedidos.DataSource = (object)pedidoComisionRes.dtTable; this.lblTotal.Text = Strings.Format((object)d1, "n2"); this.Cursor = Cursors.Default; }
public void Consulta(int Cliente, int Año, int Mes, string Usuario) { try { this.cnSigamet = new SqlConnection(Globals.GetInstance._CadenaConexion); SqlCommand sqlCommand = new SqlCommand("spPTLClienteComisionista", this.cnSigamet); sqlCommand.Parameters.Add("@Configuracion", SqlDbType.SmallInt).Value = (object)2; sqlCommand.Parameters.Add("@Cliente", SqlDbType.Int).Value = (object)Cliente; sqlCommand.Parameters.Add("@Año", SqlDbType.Int).Value = (object)Año; sqlCommand.Parameters.Add("@Mes", SqlDbType.Int).Value = (object)Mes; sqlCommand.Parameters.Add("@ComisionDiaria", SqlDbType.Money).Value = (object)0; sqlCommand.Parameters.Add("@ComisionPorTanque", SqlDbType.Money).Value = (object)0; sqlCommand.Parameters.Add("@Prestaciones", SqlDbType.Money).Value = (object)0; sqlCommand.Parameters.Add("@Deducciones", SqlDbType.Money).Value = (object)0; sqlCommand.Parameters.Add("@ComisionMensual", SqlDbType.Money).Value = (object)0; sqlCommand.Parameters.Add("@Total", SqlDbType.Money).Value = (object)0; sqlCommand.Parameters.Add("@Factor", SqlDbType.Decimal).Value = (object)0; sqlCommand.Parameters.Add("@Kilos", SqlDbType.Decimal).Value = (object)0; sqlCommand.Parameters.Add("@Usuario", SqlDbType.VarChar).Value = (object)Usuario; sqlCommand.Parameters.Add("@AjustePorTanque", SqlDbType.Money).Value = (object)0; sqlCommand.CommandType = CommandType.StoredProcedure; this.cnSigamet.Open(); this.drReader = sqlCommand.ExecuteReader(CommandBehavior.CloseConnection); while (this.drReader.Read()) { this.MontoComision = DecimalType.FromObject(this.drReader[0]); this.MontoDeduccion = DecimalType.FromObject(this.drReader[1]); } this.cnSigamet.Close(); } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception exception = ex; EventLog.WriteEntry("Consulta cliente factor" + exception.Source, exception.Message, EventLogEntryType.Error); int num = (int)MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); ProjectData.ClearProjectError(); } }
public void Update(ReferralData data) { firstName = data.FirstName.IsDefault ? firstName : data.FirstName; middleName = data.MiddleName.IsDefault ? middleName : data.MiddleName; lastName = data.LastName.IsDefault ? lastName : data.LastName; directSalesAgentId = data.DirectSalesAgentId.IsDefault ? directSalesAgentId : data.DirectSalesAgentId; streetAddress = data.StreetAddress.IsDefault ? streetAddress : data.StreetAddress; city = data.City.IsDefault ? city : data.City; state = data.State.IsDefault ? state : data.State; postalCode = data.PostalCode.IsDefault ? postalCode : data.PostalCode; latitude = data.Latitude.IsDefault ? latitude : data.Latitude; longitude = data.Longitude.IsDefault ? longitude : data.Longitude; email = data.Email.IsDefault ? email : data.Email; phoneNumber = data.PhoneNumber.IsDefault ? phoneNumber : data.PhoneNumber; messageBody = data.MessageBody.IsDefault ? messageBody : data.MessageBody; preferredContactMethod = data.PreferredContactMethod.IsDefault ? preferredContactMethod : data.PreferredContactMethod; distance = data.Distance.IsDefault ? distance : data.Distance; referralDate = data.ReferralDate.IsDefault ? referralDate : data.ReferralDate; demonstratorNotified = data.DemonstratorNotified.IsDefault ? demonstratorNotified : data.DemonstratorNotified; iPAddress = data.IPAddress.IsDefault ? iPAddress : data.IPAddress; referralSourceId = data.ReferralSourceId.IsDefault ? referralSourceId : data.ReferralSourceId; Store(); }
public static Object Int(Object Number) { if (Number == null) { throw new ArgumentNullException("Number"); } switch (ObjectType.GetTypeCode(Number)) { case TypeCode.Boolean: case TypeCode.Char: case TypeCode.SByte: case TypeCode.Byte: case TypeCode.Int16: case TypeCode.UInt16: case TypeCode.Int32: return(Int(IntegerType.FromObject(Number))); case TypeCode.UInt32: case TypeCode.Int64: case TypeCode.UInt64: return(Number); case TypeCode.Single: return(Int(SingleType.FromObject(Number))); case TypeCode.Double: return(Int(DoubleType.FromObject(Number))); case TypeCode.Decimal: return(Int(DecimalType.FromObject(Number))); case TypeCode.String: return(Int(DoubleType.FromString (StringType.FromObject(Number)))); } throw new ArgumentException(S._("VB_InvalidNumber"), "Number"); }
public Decimal FactorActual(int Cliente, DateTime FVenta) { Decimal num1 = 0; try { this.cnSigamet = new SqlConnection(Globals.GetInstance._CadenaConexion); SqlCommand sqlCommand = new SqlCommand("spPTLClienteIncentivo", this.cnSigamet); sqlCommand.Parameters.Add("@Configuracion", SqlDbType.SmallInt).Value = (object)4; sqlCommand.Parameters.Add("@Cliente", SqlDbType.Int).Value = (object)Cliente; sqlCommand.Parameters.Add("@TipoIncentivo", SqlDbType.Int).Value = (object)0; sqlCommand.Parameters.Add("@FIncentivo", SqlDbType.DateTime).Value = (object)FVenta; sqlCommand.Parameters.Add("@Incentivo", SqlDbType.Decimal).Value = (object)0; sqlCommand.Parameters.Add("@Usuario", SqlDbType.VarChar).Value = (object)""; sqlCommand.Parameters.Add("@Status", SqlDbType.VarChar).Value = (object)""; sqlCommand.CommandType = CommandType.StoredProcedure; this.cnSigamet.Open(); this.drReader = sqlCommand.ExecuteReader(CommandBehavior.CloseConnection); Decimal num2 = 0; while (this.drReader.Read()) { num2 = DecimalType.FromObject(this.drReader[0]); } this.cnSigamet.Close(); num1 = num2; } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception exception = ex; EventLog.WriteEntry("Consulta cliente factor" + exception.Source, exception.Message, EventLogEntryType.Error); int num2 = (int)MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); ProjectData.ClearProjectError(); } return(num1); }
private static void CheckDecimal(decimal dec, DecimalType res) { Assert.AreEqual((decimal) dec, res.DecimalField); Assert.AreEqual((double) dec, res.DoubleField); Assert.AreEqual((float) dec, res.FloatField); }
public void DecimalTypeNames() { var expected = new[] { "System.Decimal", "System.Single", "System.Double" }; var actual = new DecimalType().TypeNames; TestHelper.AreEqual(expected, actual); }
private static void CheckDecimal(decimal dec, DecimalType res) { Assert.AreEqual((decimal)dec, res.DecimalField); Assert.AreEqual((double)dec, res.DoubleField); Assert.AreEqual((float)dec, res.FloatField); }
public void JavaBytes_To_BigDecimal() { // arrange // act DecimalType actual = new DecimalType(); actual.SetValueFromBigEndian(javaByteOrder); // assert Assert.Equal(bigDecimal, (BigDecimal)actual); }