且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SaveChanges CRM 2011插件未处理的异常

更新时间:2023-11-17 18:17:46

在您的堆栈跟踪中,有一个System.InvalidCastException

From your stack trace there is a System.InvalidCastException

这意味着某些属性的值具有错误的类型.由于仅更改税"属性,因此其类型不正确.最有可能的税"是一个Money字段,因此我想您应该为其分配类型为decimal的变量,而不是double.尝试这样的事情:

It means value of some attribute has incorrect type. Since you are changing only 'tax' attribute, then its type is incorrect. Most probably "tax" is a Money field, so I guess you should assign variable of type decimal to it, not double. Try something like this:

decimal Tax = (decimal)((QuoteProduct.BaseAmount 
  - QuoteProduct.ManualDiscountAmount.GetValueOrDefault() 
  - QuoteProduct.VolumeDiscountAmount.GetValueOrDefault()) / 20);