コード例 #1
0
 public static SqlString ConvertMoneyToCN(SqlMoney money)
 {
     if (money.IsNull)
         return SqlString.Null;
     // 在此处放置代码
     return new SqlString(MoneyConverter.GetCnString(money.ToString()));
 }
コード例 #2
0
ファイル: SqlMoneyTest.cs プロジェクト: dotnet/corefx
        public void Create()
        {
            try
            {
                SqlMoney Test = new SqlMoney(1000000000000000m);
                Assert.False(true);
            }
            catch (Exception e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }

            SqlMoney CreationTest = new SqlMoney((decimal)913.3);
            Assert.Equal(913.3000m, CreationTest.Value);

            try
            {
                SqlMoney Test = new SqlMoney(1e200);
                Assert.False(true);
            }
            catch (Exception e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }

            SqlMoney CreationTest2 = new SqlMoney(913.3);
            Assert.Equal(913.3000m, CreationTest2.Value);

            SqlMoney CreationTest3 = new SqlMoney(913);
            Assert.Equal(913.0000m, CreationTest3.Value);

            SqlMoney CreationTest4 = new SqlMoney((long)913.3);
            Assert.Equal(913.0000m, CreationTest4.Value);
        }
コード例 #3
0
ファイル: SqlMoneyTest.cs プロジェクト: LevNNN/mono
                public void Create()
                {
			try {
				SqlMoney Test = new SqlMoney (1000000000000000m);
				Assert.Fail ("#B01");
			} catch (Exception e) {
				Assert.AreEqual ( typeof (OverflowException),
					      e.GetType (), "#A02");
			}

                        SqlMoney CreationTest = new SqlMoney ((decimal)913.3);
			Assert.AreEqual ( 913.3000m, CreationTest.Value, "A03");

			try {
				SqlMoney Test = new SqlMoney (1e200);
				Assert.Fail ("#B04");
			} catch (Exception e) {
				Assert.AreEqual ( typeof (OverflowException),
					      e.GetType (), "#A05");
			}
                        
                        SqlMoney CreationTest2 = new SqlMoney ((double)913.3);
			Assert.AreEqual ( 913.3000m, CreationTest2.Value, "A06");

                        SqlMoney CreationTest3 = new SqlMoney ((int)913);
			Assert.AreEqual ( 913.0000m, CreationTest3.Value, "A07");

                        SqlMoney CreationTest4 = new SqlMoney ((long)913.3);
                        Assert.AreEqual ( 913.0000m, CreationTest4.Value, "A08");
                }
コード例 #4
0
                public void GetReady() 
		{
			Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "en-US";			
			Test1 = new SqlMoney (6464.6464d);
			Test2 = new SqlMoney (90000.0m);
			Test3 = new SqlMoney (90000.0m);
			Test4 = new SqlMoney (-45000.0m);
		}
コード例 #5
0
 public static void FillAdjustedPrice(Object obj, out SqlInt32 itemId, out SqlMoney adjustedPrice, out SqlMoney averagePrice, out SqlChars itemName)
 {
     CCPDatum Item = (CCPDatum)obj;
     itemId = new SqlInt32(Item.item_id);
     adjustedPrice = new SqlMoney(Item.adjustedPrice);
     averagePrice = Item.averagePrice.HasValue ? new SqlMoney(Item.averagePrice.Value) : SqlMoney.Null;
     itemName = new SqlChars(Item.item_name);
 }
コード例 #6
0
ファイル: SqlMoneyTest.cs プロジェクト: dotnet/corefx
 public SqlMoneyTest()
 {
     CultureInfo.CurrentCulture = new CultureInfo("en-US");
     _test1 = new SqlMoney(6464.6464d);
     _test2 = new SqlMoney(90000.0m);
     _test3 = new SqlMoney(90000.0m);
     _test4 = new SqlMoney(-45000.0m);
 }
コード例 #7
0
ファイル: SqlMoneyTest.cs プロジェクト: LevNNN/mono
                public void GetReady() 
		{
			Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");			
			Test1 = new SqlMoney (6464.6464d);
			Test2 = new SqlMoney (90000.0m);
			Test3 = new SqlMoney (90000.0m);
			Test4 = new SqlMoney (-45000.0m);
		}
コード例 #8
0
        private async void AClient_MoneySent(AClient arg1, AClient arg2, System.Data.SqlTypes.SqlMoney arg3)
        {
            var pattern = $"Клиент {arg1} отправил\n{arg3} руб.\nклиенту {arg2}";

            await dispatcher.InvokeAsync(() => Logs.Add(new Log()
            {
                Text = pattern
            }));

            //transactionListBox.Items.Add(pattern);
        }
コード例 #9
0
        private async void Deposit_MakedPayment(AClient arg1, Deposit arg2, System.Data.SqlTypes.SqlMoney arg3)
        {
            var pattern = $"Клиент {arg1} закрыл депозит.\nСумма: {arg2.Amount}\nПроцент: {arg2.Percent}";

            await dispatcher.InvokeAsync(() => Logs.Add(new Log()
            {
                Text = pattern
            }));

            // transactionListBox.Items.Add(pattern);
        }
コード例 #10
0
        private async void AClient_MoneyReceived(AClient arg1, AClient arg2, System.Data.SqlTypes.SqlMoney arg3)
        {
            var pattern = $"Клиент {arg1} \nполучил {arg3} руб. \nот клиента {arg2}";

            await dispatcher.InvokeAsync(() => Logs.Add(new Log()
            {
                Text = pattern
            }));

            //transactionListBox.Items.Add(pattern);
        }
コード例 #11
0
ファイル: SqlTypeWorkarounds.cs プロジェクト: dotnet/corefx
        internal static long SqlMoneyToSqlInternalRepresentation(SqlMoney money)
        {
            var c = default(SqlMoneyCaster);
            c.Real = money;

            // Same implementation as the internal SqlMoney.ToSqlInternalRepresentation implementation
            if (money.IsNull)
            {
                throw new SqlNullValueException();
            }
            return c.Fake._value;
        }
コード例 #12
0
        private async void Credit_MakedPayment(AClient arg1, Credit arg2, System.Data.SqlTypes.SqlMoney arg3)
        {
            var creditInfo = $"Сумма: {arg2.Amount} \nСрок: {arg2.Month} \nПроцент: {arg2.Percent}";
            var pattern    = $"Клиент {arg1} сделал взнос по кредиту\nна сумму {arg3}. Credit: \n{creditInfo}";

            await dispatcher.InvokeAsync(() => Logs.Add(new Log()
            {
                Text = pattern
            }));

            //transactionListBox.Items.Add(pattern);
        }
コード例 #13
0
ファイル: SqlMoney.cs プロジェクト: raj581/Marvin
        /**
         * Performs a logical comparison on two instances of SqlMoney to determine if they are equal.
         * @param x A SqlMoney instance.
         * @param y A SqlMoney instance.
         * @return true if the two values are equal, otherwise false.
         * If one of the parameters is null or null value return SqlBoolean.Null.
         */
        public static SqlBoolean Equals(SqlMoney x, SqlMoney y)
        {
            if (x.IsNull || y.IsNull)
            {
                return(SqlBoolean.Null);
            }

            if (x.Equals(y))
            {
                return(SqlBoolean.True);
            }

            return(SqlBoolean.False);
        }
コード例 #14
0
ファイル: SqlMoney.cs プロジェクト: raj581/Marvin
        /**
         * Compares two instances of SqlMoney to determine if the first is greater than the second.
         * @param x A SqlMoney instance
         * @param y A SqlMoney instance
         * @return A SqlBoolean that is True if the first instance is greater than the second instance, otherwise False.
         * If either instance of SqlDouble is null, the Value of the SqlBoolean will be Null.
         */
        public static SqlBoolean GreaterThan(SqlMoney x, SqlMoney y)
        {
            if (x.IsNull || y.IsNull)
            {
                return(SqlBoolean.Null);
            }

            if (x.CompareTo(y) > 0)
            {
                return(SqlBoolean.True);
            }

            return(SqlBoolean.False);
        }
コード例 #15
0
ファイル: SqlMoney.cs プロジェクト: raj581/Marvin
        /**
         * Compares two instances of SqlMoney to determine if the first is less than the second.
         * @param x A SqlMoney instance
         * @param y A SqlMoney instance
         * @return A SqlBoolean that is True if the first instance is less than the second instance, otherwise False.
         * If either instance of SqlDouble is null, the Value of the SqlBoolean will be Null.
         */
        public static SqlBoolean LessThanOrEqual(SqlMoney x, SqlMoney y)
        {
            if (x.IsNull || y.IsNull)
            {
                return(SqlBoolean.Null);
            }

            if (x.CompareTo(y) <= 0)
            {
                return(SqlBoolean.True);
            }

            return(SqlBoolean.False);
        }
コード例 #16
0
ファイル: SqlMoney.cs プロジェクト: raj581/Marvin
        /**
         * Compares two instances of SqlMoney to determine if they are equal.
         * @param x A SqlMoney instance
         * @param y A SqlMoney instance
         * @return A SqlBoolean that is True if the two instances are not equal or False if the two instances are equal.
         * If either instance of SqlDouble is null, the Value of the SqlBoolean will be Null.
         */
        public static SqlBoolean NotEquals(SqlMoney x, SqlMoney y)
        {
            SqlBoolean eVal = Equals(x, y);

            if (eVal.IsNull)
            {
                return(eVal);
            }
            if (eVal.IsTrue)
            {
                return(SqlBoolean.False);
            }

            return(SqlBoolean.True);
        }
コード例 #17
0
ファイル: SqlByte.cs プロジェクト: zlxy/Genesis-3D
        public static SqlByte op_Explicit(SqlMoney x)
        {
            if (x.IsNull)
            {
                return(SqlByte.Null);
            }

            int val = x.ToSqlInt32().Value;

            if (val < 0 || val > 255)
            {
                throw new OverflowException("Arithmetic Overflow.");
            }

            return(new SqlByte((byte)val));
        }
コード例 #18
0
ファイル: SqlMoney.cs プロジェクト: raj581/Marvin
        /**
         * The multiplication operator computes the product of the two SqlMoney operands.
         * @param x A SqlMoney instance
         * @param y A SqlMoney instance
         * @return The product of the two SqlMoney operands.
         */
        public static SqlMoney Multiply(SqlMoney x, SqlMoney y)
        {
            if (x.IsNull || y.IsNull)
            {
                return(SqlMoney.Null);
            }

            Decimal res = Decimal.Multiply(x._value, y._value);

            if (res.CompareTo(MaxValue.Value) > 0 || res.CompareTo(MinValue.Value) < 0)
            {
                throw new OverflowException("overflow - the multiply value is out of range " + res);
            }

            return(new SqlMoney(res));
        }
コード例 #19
0
        void IXmlSerializable.ReadXml(XmlReader reader)
        {
            string attribute = reader.GetAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance");

            if ((attribute != null) && XmlConvert.ToBoolean(attribute))
            {
                reader.ReadElementString();
                this.m_fNotNull = false;
            }
            else
            {
                SqlMoney money = new SqlMoney(XmlConvert.ToDecimal(reader.ReadElementString()));
                this.m_fNotNull = money.m_fNotNull;
                this.m_value    = money.m_value;
            }
        }
コード例 #20
0
        public override bool Equals(object value)
        {
            if (!(value is SqlMoney))
            {
                return(false);
            }
            SqlMoney money = (SqlMoney)value;

            if (money.IsNull || this.IsNull)
            {
                return(money.IsNull && this.IsNull);
            }
            SqlBoolean flag = this == money;

            return(flag.Value);
        }
コード例 #21
0
ファイル: SqlMoney.cs プロジェクト: raj581/Marvin
        /**
         * Calcuates the sum of the two SqlMoney operators.
         * @param x A SqlMoney instance.
         * @param y A SqlMoney instance.
         * @return A new SqlMoney instance whose Value property contains the sum.
         * If one of the parameters or their value is null return SqlMoney.Null.
         */
        public static SqlMoney Add(SqlMoney x, SqlMoney y)
        {
            if (x.IsNull || y.IsNull)
            {
                return(SqlMoney.Null);
            }

            Decimal res = Decimal.Add(x._value, y._value);

            if (res.CompareTo(MaxValue.Value) > 0 || res.CompareTo(MinValue.Value) < 0)
            {
                throw new OverflowException("overflow - the sum of the 2 parameters can not be SqlMoney : " + res);
            }

            return(new SqlMoney(res));
        }
コード例 #22
0
ファイル: SqlMoney.cs プロジェクト: raj581/Marvin
        public override bool Equals(Object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj is SqlMoney)
            {
                SqlMoney dec = (SqlMoney)obj;

                return(Decimal.Equals(_value, dec._value));
            }

            return(false);
        }
コード例 #23
0
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        void IXmlSerializable.ReadXml(XmlReader reader)
        {
            string isNull = reader.GetAttribute("nil", XmlSchema.InstanceNamespace);

            if (isNull != null && XmlConvert.ToBoolean(isNull))
            {
                // VSTFDevDiv# 479603 - SqlTypes read null value infinitely and never read the next value. Fix - Read the next value.
                reader.ReadElementString();
                this.m_fNotNull = false;
            }
            else
            {
                SqlMoney money = new SqlMoney(XmlConvert.ToDecimal(reader.ReadElementString()));
                this.m_fNotNull = money.m_fNotNull;
                this.m_value    = money.m_value;
            }
        }
コード例 #24
0
ファイル: Material.cs プロジェクト: ugeHidalgo/TrainIt
 public Material()
 {
     matID=-1;
     matName="";
     matModel="";
     matBrand="";
     matSize="";
     matWeight=0.00M;
     matBuyDate=DateTime.Now;
     matCost=(SqlMoney)0;
     matInitTime=0;
     matInitDist=0.000M;
     matRecTime="00:00:00";
     matRecDist=0.000M;
     matBuyMemo="";
     userID=-1;
 }
コード例 #25
0
        void IXmlSerializable.ReadXml(XmlReader reader)
        {
            string isNull = reader.GetAttribute("nil", XmlSchema.InstanceNamespace);

            if (isNull != null && XmlConvert.ToBoolean(isNull))
            {
                // Read the next value.
                reader.ReadElementString();
                _fNotNull = false;
            }
            else
            {
                SqlMoney money = new SqlMoney(XmlConvert.ToDecimal(reader.ReadElementString()));
                _fNotNull = money._fNotNull;
                _value    = money._value;
            }
        }
コード例 #26
0
        // Compares this instance with a specified object
        public override bool Equals(object value)
        {
            if (!(value is SqlMoney))
            {
                return(false);
            }

            SqlMoney i = (SqlMoney)value;

            if (i.IsNull || IsNull)
            {
                return(i.IsNull && IsNull);
            }
            else
            {
                return((this == i).Value);
            }
        }
コード例 #27
0
ファイル: Material.cs プロジェクト: ugeHidalgo/TrainIt
 public Material(Int64 MatID, string MatName, string MatModel, string MatBrand, string MatSize, decimal MatWeight, DateTime MatBuyDate,
                 SqlMoney MatCost, double MatinitTime, decimal MatInitDist, string MatRecTime, decimal MatRecDist,  
                 string MatBuyMemo, Int64 UserID)
 {
     matID=MatID;
     matName=MatName;
     matModel=MatModel;
     matBrand=MatBrand;
     matSize=MatSize;
     matWeight=MatWeight;
     matBuyDate=MatBuyDate;
     matCost=MatCost;
     matInitTime=MatinitTime;
     matInitDist=MatInitDist;
     matRecTime=MatRecTime;
     matRecDist=MatRecDist;
     matBuyMemo=MatBuyMemo;
     userID=UserID;
 }
コード例 #28
0
ファイル: MaterialTest.cs プロジェクト: ugeHidalgo/TrainIt
        public void Material_FindFound()
        {
            //This object must exist on BD
            aMatID = 51;
            aMatName = "Epic MTB";
            aMatModel = "Epic Comp";
            aMatBrand = "Specialized";
            aMatSize = "17";
            aMatWeight = 12.5M;
            aMatBuyDate = Convert.ToDateTime("01/04/2011");
            aMatCost =  (SqlMoney)600.00F;
            aMatInitTime = 0;
            aMatInitDist = 2500.000M;
            aMatRecTime = "1000:00:00";
            aMatRecDist = 10000.000M;
            aMatBuyMemo = "Comprada";
            aUserID = 85;

            Material aMatToLoad = new Material();
            aMatToLoad.LoadData(aMatID, aMatName, aMatModel, aMatBrand, aMatSize, aMatWeight, aMatBuyDate, aMatCost,
                                         aMatInitTime, aMatInitDist, aMatRecTime, aMatRecDist, aMatBuyMemo, aUserID);
            aMatToLoad = aMatToLoad.findMatByMatID(connString, aMatID);

            Assert.AreEqual(aMatID, aMatToLoad.MatID);
            Assert.AreEqual(aMatName, aMatToLoad.MatName);
            Assert.AreEqual(aMatModel, aMatToLoad.MatModel);
            Assert.AreEqual(aMatBrand, aMatToLoad.MatBrand);
            Assert.AreEqual(aMatSize, aMatToLoad.MatSize);
            Assert.AreEqual(aMatWeight, aMatToLoad.MatWeight);
            Assert.AreEqual(aMatBuyDate, aMatToLoad.MatBuyDate);
            Assert.AreEqual(aMatCost, aMatToLoad.MatCost);
            Assert.AreEqual(aMatInitTime, aMatToLoad.MatInitTime);
            Assert.AreEqual(aMatInitDist, aMatToLoad.MatInitDist);
            Assert.AreEqual(aMatRecTime, aMatToLoad.MatRecTime);
            Assert.AreEqual(aMatRecDist, aMatToLoad.MatRecDist);
            Assert.AreEqual(aMatBuyMemo, aMatToLoad.MatBuyMemo);
            Assert.AreEqual(aUserID, aMatToLoad.UserID);
        }
コード例 #29
0
        public int CompareTo(SqlMoney value)
        {
            // If both Null, consider them equal.
            // Otherwise, Null is less than anything.
            if (IsNull)
            {
                return(value.IsNull ? 0 : -1);
            }
            else if (value.IsNull)
            {
                return(1);
            }

            if (this < value)
            {
                return(-1);
            }
            if (this > value)
            {
                return(1);
            }
            return(0);
        }
コード例 #30
0
 public int CompareTo(SqlMoney value)
 {
     if (this.IsNull)
     {
         if (!value.IsNull)
         {
             return(-1);
         }
         return(0);
     }
     if (value.IsNull)
     {
         return(1);
     }
     if (SqlBoolean.op_True(this < value))
     {
         return(-1);
     }
     if (SqlBoolean.op_True(this > value))
     {
         return(1);
     }
     return(0);
 }
コード例 #31
0
 // Alternative method for operator /
 public static SqlMoney Divide(SqlMoney x, SqlMoney y)
 {
     return(x / y);
 }
コード例 #32
0
 // Alternative method for operator *
 public static SqlMoney Multiply(SqlMoney x, SqlMoney y)
 {
     return(x * y);
 }
コード例 #33
0
ファイル: ValueUtilsSmi.cs プロジェクト: uQr/referencesource
        private static void SetSqlMoney_Unchecked( SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SmiMetaData metaData, SqlMoney value ) {
            if ( value.IsNull ) {
                setters.SetDBNull( sink, ordinal );
            }
            else {
                if ( SqlDbType.Variant == metaData.SqlDbType ) {
                    setters.SetVariantMetaData( sink, ordinal, SmiMetaData.DefaultMoney );
                    sink.ProcessMessagesAndThrow();
                }

                setters.SetInt64( sink, ordinal, value.ToSqlInternalRepresentation() );
             }
            sink.ProcessMessagesAndThrow();
        }
コード例 #34
0
ファイル: ValueUtilsSmi.cs プロジェクト: uQr/referencesource
        internal static void SetSqlMoney( SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SmiMetaData metaData, SqlMoney value ) {
            ThrowIfInvalidSetterAccess( metaData, ExtendedClrTypeCode.SqlMoney );

            SetSqlMoney_Checked( sink, setters, ordinal, metaData, value ); 
        }
コード例 #35
0
 // Alternative method for operator <=
 public static SqlBoolean LessThanOrEqual(SqlMoney x, SqlMoney y)
 {
     return(x <= y);
 }
コード例 #36
0
 // Alternative method for operator <
 public static SqlBoolean LessThan(SqlMoney x, SqlMoney y)
 {
     return(x < y);
 }
コード例 #37
0
 // Alternative method for operator ==
 public static SqlBoolean Equals(SqlMoney x, SqlMoney y)
 {
     return(x == y);
 }
コード例 #38
0
ファイル: SqlMetaData.cs プロジェクト: eerhardt/corefx
 private void VerifyMoneyRange(SqlMoney value)
 {
     if (SqlDbType.SmallMoney == SqlDbType && ((s_smSmallMax < value).Value || (s_smSmallMin > value).Value))
         ThrowInvalidType();
 }
コード例 #39
0
 override public void SetCapacity(int capacity) {
     SqlMoney[] newValues = new SqlMoney[capacity];
     if (null != values) {
         Array.Copy(values, 0, newValues, 0, Math.Min(capacity, values.Length));
     }
     values = newValues;
 }
コード例 #40
0
ファイル: SqlByteTest.cs プロジェクト: Profit0004/mono
		public void SqlMoneyToSqlByte()
		{
			SqlMoney TestMoney64 = new SqlMoney(64);
			SqlMoney TestMoney900 = new SqlMoney(900);

			Assert.AreEqual((byte)64, ((SqlByte)TestMoney64).Value, "SqlMoneyToByte" + Error);

			try {
				SqlByte test = (SqlByte)TestMoney900;
				Assert.Fail("SqlMoneyToByte 2" + Error);
			} catch (Exception e) {

				Assert.AreEqual(typeof(OverflowException), e.GetType(), "OverflowException");
			}

		}
コード例 #41
0
 // Alternative method for operator !=
 public static SqlBoolean NotEquals(SqlMoney x, SqlMoney y)
 {
     return(x != y);
 }
コード例 #42
0
ファイル: Convert.cs プロジェクト: mstaessen/fluorinefx
 /// <summary>
 /// Converts the value of the specified SqlMoney to its equivalent SqlSingle representation.
 /// </summary>
 /// <param name="value">An SqlMoney.</param>
 /// <returns>The equivalent SqlSingle.</returns>
 public static SqlSingle ToSqlSingle(SqlMoney value) { return value.ToSqlSingle(); }
コード例 #43
0
 // Alternative method for operator >
 public static SqlBoolean GreaterThan(SqlMoney x, SqlMoney y)
 {
     return(x > y);
 }
コード例 #44
0
ファイル: MemberMapper.cs プロジェクト: MozgC/bltoolkit
		public virtual void SetSqlMoney   (object o, SqlMoney    value) { MemberAccessor.SetSqlMoney   (o, value); }
コード例 #45
0
 // Alternative method for operator >=
 public static SqlBoolean GreaterThanOrEqual(SqlMoney x, SqlMoney y)
 {
     return(x >= y);
 }
コード例 #46
0
ファイル: MemberMapper.cs プロジェクト: MozgC/bltoolkit
			public override void SetSqlMoney   (object o, SqlMoney    value) { var obj = GetObject(o); if (obj != null) _mapper.SetSqlMoney   (obj, value); }
コード例 #47
0
		public void SetSqlMoney (int i, SqlMoney value)
		{
			throw new NotImplementedException ();
		}
コード例 #48
0
ファイル: TdsParser.cs プロジェクト: nnyamhon/corefx
        private void WriteCurrency(Decimal value, int length, TdsParserStateObject stateObj)
        {
            SqlMoney m = new SqlMoney(value);
            int[] bits = Decimal.GetBits(m.Value);

            // this decimal should be scaled by 10000 (regardless of what the incoming decimal was scaled by)
            bool isNeg = (0 != (bits[3] & unchecked((int)0x80000000)));
            long l = ((long)(uint)bits[1]) << 0x20 | (uint)bits[0];

            if (isNeg)
                l = -l;

            if (length == 4)
            {
                // validate the value can be represented as a small money
                if (value < TdsEnums.SQL_SMALL_MONEY_MIN || value > TdsEnums.SQL_SMALL_MONEY_MAX)
                {
                    throw SQL.MoneyOverflow(value.ToString(CultureInfo.InvariantCulture));
                }

                WriteInt((int)l, stateObj);
            }
            else
            {
                WriteInt((int)(l >> 0x20), stateObj);
                WriteInt((int)l, stateObj);
            }
        }
コード例 #49
0
        private Boolean ReadValues(System.IO.BinaryReader r)
        {
            Int32 count;
              if(r.BaseStream.Length == 0) return false;
              count = Sql.Read7BitEncodedInt(r);

              if (count == 0) return true;

              for (Int32 i = 0; i < count; i++)
              {
            String    name  = r.ReadString();
            SqlDbType LType = (SqlDbType)r.ReadUInt16();
            Object    value = null;
            Int32 len;
            //Int32 lcid;
            //SqlCompareOptions co;

            switch (LType)
            {
              case SqlDbType.Bit      : value = new SqlBoolean(r.ReadBoolean()); break;
              case SqlDbType.TinyInt  : value = new SqlByte(r.ReadByte()); break;
              case SqlDbType.SmallInt : value = new SqlInt16((Int16)r.ReadInt16()); break;
              case SqlDbType.Int      : value = new SqlInt32((Int32)r.ReadInt32()); break;
              case SqlDbType.BigInt   : value = new SqlInt64(r.ReadInt64()); break;

              case SqlDbType.Binary   :
              case SqlDbType.VarBinary: len = r.ReadUInt16(); value = new SqlBytes(r.ReadBytes(len)); break;

              case SqlDbType.Char     :
              case SqlDbType.VarChar  : //value = new Sql.SqlAnsiString(r); break;
              case SqlDbType.NChar:
              case SqlDbType.NVarChar:
            //co = (SqlCompareOptions)r.ReadUInt16();
            //lcid = r.ReadInt32();
            //value = new SqlString(r.ReadString(), lcid, co);
            value = new SqlString(r.ReadString());
            break;

              case SqlDbType.DateTime     : value = new SqlDateTime(DateTime.FromBinary(r.ReadInt64())); break;
              case SqlDbType.SmallDateTime:
              case SqlDbType.Date         :
              case SqlDbType.DateTime2    : value = DateTime.FromBinary(r.ReadInt64()); break;
              case SqlDbType.Time         : value = TimeSpan.FromTicks(r.ReadInt64()); break;
              case SqlDbType.DateTimeOffset:
            DateTime LDateTime = DateTime.FromBinary(r.ReadInt64());
            value = new DateTimeOffset(LDateTime, TimeSpan.FromTicks(r.ReadInt64()));
            break;

              case SqlDbType.Decimal: value = new SqlDecimal(r.ReadDecimal()); break;
              case SqlDbType.Float  : value = new SqlDouble(r.ReadDouble()); break;
              // Not support SqlDbType.Image
              case SqlDbType.Money  : value = new SqlMoney(r.ReadDecimal()); break;
              case SqlDbType.Real   : value = new SqlSingle(r.ReadDouble()); break;
              case SqlDbType.SmallMoney: value = new SqlMoney(r.ReadDecimal()); break;
              // Not support SqlDbType.Structured
              // Not support SqlDbType.Text
              // Not support SqlDbType.Timestamp
              case SqlDbType.UniqueIdentifier: value = new SqlGuid(r.ReadString()); break;
              // Not support SqlDbType.Variant
              case SqlDbType.Xml:
            XmlReader rXml = XmlReader.Create(new System.IO.StringReader(r.ReadString()));
            value = new SqlXml(rXml);
            break;

              case SqlDbType.Udt:
            // TODO: Пока поддержа только TParams
            //String LTypeName = r.ReadString();
            //value = CreateUdtObject(LTypeName);
            //if (value is IBinarySerialize)
            //  (value as IBinarySerialize).Read(r);
            //else
            //  throw new Exception(String.Format("Невозможно прочитать данные типа UDT '{0}' - не поддерживается IBinarySerialize", LTypeName));
            value = new SqlUdt(r);
            break;

              default:
            throw new Exception(String.Format("Невозможно прочитать данные, тип '{0}' не поддерживается текущей версией {1}", LType.ToString(), this.GetType().Name));
              // Not support SqlDbType.NText
            }
            if (value != null) FData.Add(name, value);
              }

              return true;
        }
コード例 #50
0
        //--------------------------------------------------
        // Alternative methods for overloaded operators
        //--------------------------------------------------

        // Alternative method for operator +
        public static SqlMoney Add(SqlMoney x, SqlMoney y)
        {
            return(x + y);
        }
コード例 #51
0
ファイル: ValueUtilsSmi.cs プロジェクト: uQr/referencesource
 private static void SetSqlMoney_Checked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SmiMetaData metaData, SqlMoney value) {
     if (!value.IsNull && SqlDbType.SmallMoney == metaData.SqlDbType) {
         decimal decimalValue = value.Value;
         if (TdsEnums.SQL_SMALL_MONEY_MIN > decimalValue || TdsEnums.SQL_SMALL_MONEY_MAX < decimalValue) {
             throw SQL.MoneyOverflow(decimalValue.ToString(CultureInfo.InvariantCulture));
         }
     }
     SetSqlMoney_Unchecked(sink, setters, ordinal, metaData, value);
 }
コード例 #52
0
 // Alternative method for operator -
 public static SqlMoney Subtract(SqlMoney x, SqlMoney y)
 {
     return(x - y);
 }
コード例 #53
0
		public void SqlMoneyToSqlInt64 ()
		{
			SqlMoney TestMoney64 = new SqlMoney (64);
			Assert.AreEqual ((long) 64, ((SqlInt64) TestMoney64).Value, "#AD01");
		}
コード例 #54
0
 public int CompareTo(SqlMoney value)
 {
     return(CompareSqlMoney(value));
 }
コード例 #55
0
ファイル: TblPayrollEntries.cs プロジェクト: kimykunjun/test
        /// <summary>
        /// Purpose: Select method. This method will Select one existing row from the database, based on the Primary Key.
        /// </summary>
        /// <returns>DataTable object if succeeded, otherwise an Exception is thrown. </returns>
        /// <remarks>
        /// Properties needed for this method: 
        /// <UL>
        ///		 <LI>NPayrollID</LI>
        ///		 <LI>NEmployeeID</LI>
        /// </UL>
        /// Properties set after a succesful call of this method: 
        /// <UL>
        ///		 <LI>ErrorCode</LI>
        ///		 <LI>NPayrollID</LI>
        ///		 <LI>NEmployeeID</LI>
        ///		 <LI>NNormalOT</LI>
        ///		 <LI>NPublicHolidayOT</LI>
        ///		 <LI>NOffDayOT</LI>
        ///		 <LI>NPartTimeWorkHours</LI>
        ///		 <LI>NALEntitlementHours</LI>
        ///		 <LI>NPHEntitlementHours</LI>
        ///		 <LI>MServiceReimbursements</LI>
        ///		 <LI>NTotalLateness</LI>
        ///		 <LI>NUnpaidAL</LI>
        ///		 <LI>NUnpaidTO</LI>
        ///		 <LI>NUnpaidMedical</LI>
        ///		 <LI>MCommission</LI>
        ///		 <LI>MCommissionLatenessPenalty</LI>
        /// </UL>
        /// Will fill all properties corresponding with a field in the table with the value of the row selected.
        /// </remarks>
        public override DataTable SelectOne()
        {
            SqlCommand	cmdToExecute = new SqlCommand();
            cmdToExecute.CommandText = "dbo.[sp_tblPayrollEntries_SelectOne]";
            cmdToExecute.CommandType = CommandType.StoredProcedure;
            DataTable toReturn = new DataTable("tblPayrollEntries");
            SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute);

            // Use base class' connection object
            cmdToExecute.Connection = _mainConnection;

            try
            {
                cmdToExecute.Parameters.Add(new SqlParameter("@inPayrollID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _nPayrollID));
                cmdToExecute.Parameters.Add(new SqlParameter("@inEmployeeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _nEmployeeID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode));

                if(_mainConnectionIsCreatedLocal)
                {
                    // Open connection.
                    _mainConnection.Open();
                }
                else
                {
                    if(_mainConnectionProvider.IsTransactionPending)
                    {
                        cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
                    }
                }

                // Execute query.
                adapter.Fill(toReturn);
                _errorCode = (SqlInt32)cmdToExecute.Parameters["@iErrorCode"].Value;

                if(_errorCode != (int)LLBLError.AllOk)
                {
                    // Throw error.
                    throw new Exception("Stored Procedure 'sp_tblPayrollEntries_SelectOne' reported the ErrorCode: " + _errorCode);
                }

                if(toReturn.Rows.Count > 0)
                {
                    _nPayrollID = (Int32)toReturn.Rows[0]["nPayrollID"];
                    _nEmployeeID = (Int32)toReturn.Rows[0]["nEmployeeID"];
                    _nNormalOT = toReturn.Rows[0]["nNormalOT"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nNormalOT"];
                    _nPublicHolidayOT = toReturn.Rows[0]["nPublicHolidayOT"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nPublicHolidayOT"];
                    _nOffDayOT = toReturn.Rows[0]["nOffDayOT"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nOffDayOT"];
                    _nPartTimeWorkHours = toReturn.Rows[0]["nPartTimeWorkHours"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nPartTimeWorkHours"];
                    _nALEntitlementHours = toReturn.Rows[0]["nALEntitlementHours"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nALEntitlementHours"];
                    _nPHEntitlementHours = toReturn.Rows[0]["nPHEntitlementHours"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nPHEntitlementHours"];
                    _mServiceReimbursements = toReturn.Rows[0]["mServiceReimbursements"] == System.DBNull.Value ? SqlMoney.Null : (Decimal)toReturn.Rows[0]["mServiceReimbursements"];
                    _nTotalLateness = toReturn.Rows[0]["nTotalLateness"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nTotalLateness"];
                    _nUnpaidAL = toReturn.Rows[0]["nUnpaidAL"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nUnpaidAL"];
                    _nUnpaidTO = toReturn.Rows[0]["nUnpaidTO"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nUnpaidTO"];
                    _nUnpaidMedical = toReturn.Rows[0]["nUnpaidMedical"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nUnpaidMedical"];
                    _mCommission = toReturn.Rows[0]["mCommission"] == System.DBNull.Value ? SqlMoney.Null : (Decimal)toReturn.Rows[0]["mCommission"];
                    _mCommissionLatenessPenalty = toReturn.Rows[0]["mCommissionLatenessPenalty"] == System.DBNull.Value ? SqlMoney.Null : (Decimal)toReturn.Rows[0]["mCommissionLatenessPenalty"];
                }
                return toReturn;
            }
            catch(Exception ex)
            {
                // some error occured. Bubble it to caller and encapsulate Exception object
                throw new Exception("TblPayrollEntries::SelectOne::Error occured.", ex);
            }
            finally
            {
                if(_mainConnectionIsCreatedLocal)
                {
                    // Close connection.
                    _mainConnection.Close();
                }
                cmdToExecute.Dispose();
                adapter.Dispose();
            }
        }
コード例 #56
0
ファイル: Convert.cs プロジェクト: mstaessen/fluorinefx
 /// <summary>
 /// Converts the value of the specified SqlMoney to its equivalent SqlInt16 representation.
 /// </summary>
 /// <param name="value">An SqlMoney.</param>
 /// <returns>The equivalent SqlInt16.</returns>
 public static SqlInt16 ToSqlInt16(SqlMoney value) { return value.ToSqlInt16(); }
コード例 #57
0
        override public object ConvertXmlToObject(string s) {
            SqlMoney newValue = new SqlMoney();
            string tempStr =string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader, 
            StringReader strReader = new  StringReader(tempStr);

            IXmlSerializable tmp = newValue;
            
            using (XmlTextReader xmlTextReader = new XmlTextReader(strReader)) {
                tmp.ReadXml(xmlTextReader);
            }
            return ((SqlMoney)tmp);
        }
コード例 #58
0
ファイル: Convert.cs プロジェクト: mstaessen/fluorinefx
 /// <summary>
 /// Converts the value of the specified SqlMoney to its equivalent SqlInt32 representation.
 /// </summary>
 /// <param name="value">An SqlMoney.</param>
 /// <returns>The equivalent SqlInt32.</returns>
 public static SqlInt32 ToSqlInt32(SqlMoney value) { return value.ToSqlInt32(); }
コード例 #59
0
ファイル: SqlMetaData.cs プロジェクト: eerhardt/corefx
        public SqlMoney Adjust(SqlMoney value)
        {
            if (SqlDbType.Money != SqlDbType &&
                SqlDbType.SmallMoney != SqlDbType)
                ThrowInvalidType();

            if (!value.IsNull)
                VerifyMoneyRange(value);

            return value;
        }
コード例 #60
0
ファイル: Convert.cs プロジェクト: mstaessen/fluorinefx
 /// <summary>
 /// Converts the value of the specified SqlMoney to its equivalent SqlInt64 representation.
 /// </summary>
 /// <param name="value">An SqlMoney.</param>
 /// <returns>The equivalent SqlInt64.</returns>
 public static SqlInt64 ToSqlInt64(SqlMoney value) { return value.ToSqlInt64(); }