• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SqlTypes.SqlMoney类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Data.SqlTypes.SqlMoney的典型用法代码示例。如果您正苦于以下问题:C# SqlMoney类的具体用法?C# SqlMoney怎么用?C# SqlMoney使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SqlMoney类属于System.Data.SqlTypes命名空间,在下文中一共展示了SqlMoney类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Create

        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);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:34,代码来源:SqlMoneyTest.cs


示例2: ConvertMoneyToCN

 public static SqlString ConvertMoneyToCN(SqlMoney money)
 {
     if (money.IsNull)
         return SqlString.Null;
     // 在此处放置代码
     return new SqlString(MoneyConverter.GetCnString(money.ToString()));
 }
开发者ID:JodenSoft,项目名称:JodenSoft,代码行数:7,代码来源:ConvertMoneyToCN.cs


示例3: Create

                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");
                }
开发者ID:LevNNN,项目名称:mono,代码行数:30,代码来源:SqlMoneyTest.cs


示例4: GetReady

                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);
		}
开发者ID:LevNNN,项目名称:mono,代码行数:8,代码来源:SqlMoneyTest.cs


示例5: SqlMoneyTest

 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);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:SqlMoneyTest.cs


示例6: FillAdjustedPrice

 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);
 }
开发者ID:Caleth,项目名称:EVE-SDE-tools,代码行数:8,代码来源:AdjustedPrices.cs


示例7: GetReady

                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);
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:8,代码来源:SqlMoneyTest.cs


示例8: SqlMoneyToSqlInternalRepresentation

        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;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:12,代码来源:SqlTypeWorkarounds.cs


示例9: Material

 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;
 }
开发者ID:ugeHidalgo,项目名称:TrainIt,代码行数:17,代码来源:Material.cs


示例10: Material_FindFound

        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);
        }
开发者ID:ugeHidalgo,项目名称:TrainIt,代码行数:38,代码来源:MaterialTest.cs


示例11: ReadValues

        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;
        }
开发者ID:APouchkov,项目名称:ExtendedStoredProcedures,代码行数:84,代码来源:TParams.cs


示例12: WriteCurrency

        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);
            }
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:28,代码来源:TdsParser.cs


示例13: SetSqlMoney

		public void SetSqlMoney (int i, SqlMoney value)
		{
			throw new NotImplementedException ();
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:4,代码来源:SqlResultSet.cs


示例14: SetSqlMoney

			public override void SetSqlMoney   (object o, SqlMoney    value) { var obj = GetObject(o); if (obj != null) _mapper.SetSqlMoney   (obj, value); }
开发者ID:MozgC,项目名称:bltoolkit,代码行数:1,代码来源:MemberMapper.cs


示例15: VerifyMoneyRange

 private void VerifyMoneyRange(SqlMoney value)
 {
     if (SqlDbType.SmallMoney == SqlDbType && ((s_smSmallMax < value).Value || (s_smSmallMin > value).Value))
         ThrowInvalidType();
 }
开发者ID:eerhardt,项目名称:corefx,代码行数:5,代码来源:SqlMetaData.cs


示例16: SetCapacity

 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;
 }
开发者ID:uQr,项目名称:referencesource,代码行数:7,代码来源:SQLMoneyStorage.cs


示例17: SqlMoneyToSqlByte

		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");
			}

		}
开发者ID:Profit0004,项目名称:mono,代码行数:16,代码来源:SqlByteTest.cs


示例18: SetSqlMoney_Unchecked

        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();
        }
开发者ID:uQr,项目名称:referencesource,代码行数:14,代码来源:ValueUtilsSmi.cs


示例19: SetSqlMoney

        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 ); 
        }
开发者ID:uQr,项目名称:referencesource,代码行数:5,代码来源:ValueUtilsSmi.cs


示例20: SetSqlMoney_Checked

 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);
 }
开发者ID:uQr,项目名称:referencesource,代码行数:9,代码来源:ValueUtilsSmi.cs



注:本文中的System.Data.SqlTypes.SqlMoney类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SqlTypes.SqlSingle类代码示例发布时间:2022-05-26
下一篇:
C# SqlTypes.SqlInt64类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap