本文整理汇总了C#中System.Data.SqlTypes.SqlMoney类的典型用法代码示例。如果您正苦于以下问题:C# SqlMoney类的具体用法?C# SqlMoney怎么用?C# SqlMoney使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlMoney类属于System.Data.SqlTypes命名空间,在下文中一共展示了SqlMoney类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: ConvertMoneyToCN
public static SqlString ConvertMoneyToCN(SqlMoney money)
{
if (money.IsNull)
return SqlString.Null;
// 在此处放置代码
return new SqlString(MoneyConverter.GetCnString(money.ToString()));
}
示例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");
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例13: SetSqlMoney
public void SetSqlMoney (int i, SqlMoney value)
{
throw new NotImplementedException ();
}
示例14: SetSqlMoney
public override void SetSqlMoney (object o, SqlMoney value) { var obj = GetObject(o); if (obj != null) _mapper.SetSqlMoney (obj, value); }
示例15: VerifyMoneyRange
private void VerifyMoneyRange(SqlMoney value)
{
if (SqlDbType.SmallMoney == SqlDbType && ((s_smSmallMax < value).Value || (s_smSmallMin > value).Value))
ThrowInvalidType();
}