Code Tips
1.String Format
(1).小数保留2位小数
decimal.Parse(weight).ToString("F2")
(2).String.Format
string.Format("{0:000.000}", 12.2) 012.200
string.Format("{0:D3}", 2) 002
字符 | 说明 | 示例 | 输出 |
C | 货币 | string.Format("{0:C3}", 2) | $2.000 |
D | 十进制 | string.Format("{0:D3}", 2) | 002 |
E | 科学计数法 | string.Format("{0:E}", 250000); | 2.500000E+005 |
F | Fixed-point | string.Format("{0:F2}", 25); string.Format("{0:F0}", 25); | 25.00 25 |
G | 常规 | string.Format("{0:G}", 2.5); | 2.5 |
N | 用分号隔开的数字 | string.Format("{0:N}", 2500000); | 2,500,000.00 |
X | 十六进制 | string.Format("{0:X}", 250); | FA |
string.Format("{0:000.000}", 12.2) | 012.200 |
2.RosettaNet 中获取 Partner 配置信息
using Microsoft.Solutions.BTARN.Shared;
1: private string m_Classification = "";
2: private string m_ContactName = "";
3: private string m_EmailAddress = "";
4: private string m_FaxNumber = "";
5: private string m_GbiNumber = "";
6: private string m_SupplyChainCode = "";
7: private string m_TelephoneNumber = "";
8:
9: private Microsoft.Solutions.BTARN.Shared.PartyInfo m_partyInfo;
10: public PartnerInfo():this("Intel")
11: {
12: }
13:
14: public PartnerInfo(string partnerName)
15: {
16: m_partyInfo = new PartyInfo(partnerName);
17:
18: m_Classification=m_partyInfo.GetAliasValue(PartnerPropertyFields.Classification);
19: m_ContactName=m_partyInfo.GetAliasValue(PartnerPropertyFields.ContactName);
20: m_EmailAddress=m_partyInfo.GetAliasValue(PartnerPropertyFields.EmailAddress);
21: m_FaxNumber=m_partyInfo.GetAliasValue(PartnerPropertyFields.FaxNumber);
22: m_GbiNumber=m_partyInfo.GetAliasValue(PartnerPropertyFields.GbiNumber);
23: m_SupplyChainCode = m_partyInfo.GetAliasValue(PartnerPropertyFields.SupplyChainCode);
24: m_TelephoneNumber=m_partyInfo.GetAliasValue(PartnerPropertyFields.TelephoneNumber);
25: }
3.SQL 去除 Tab
set @PlantCode=ltrim(rtrim(replace(@PlantCode,char(9),'')))
4.SQL XML 查询
with TmpTable as ( select convert(xml,a.ServiceContent) as ServiceContent,b.ExternOrderKey from PIPsOutHandling a,MessageOutHandling b where a.PIPInstanceID collate SQL_Latin1_General_CP1_CI_AS =b.PIPInstanceID and a.PIPInstanceID collate SQL_Latin1_General_CP1_CI_AS in (select PIPsInstancesID from EventLog where PIPCode='3B12' and datediff(d,CreateTime,getdate())=1 and Status<>100) --order by ExternOrderKey asc ) select ExternOrderKey,ServiceContent.value(N'(/Pip3B12ShippingOrderConfirmation/ShippingOrder/OrderConfirmation/GlobalShippingOrderStatusCode/text())[1]','nvarchar(max)') as [Confirm], ServiceContent.value(N'(/Pip3B12ShippingOrderConfirmation/ShippingOrder/OrderConfirmation/GlobalShippingOrderStatusReasonCode/text())[1]','nvarchar(max)') AS [ReasonCode] FROM TmpTable order by ExternOrderKey asc