1
//数字转换称大写#region//数字转换称大写
2
public static string GetThousandNumberName(string p_strThousandNumberName)
3
{
4
string v_strThousand = p_strThousandNumberName;
5
string v_strThousandNumberName = "";
6
if (v_strThousand.Length == 1)
7
v_strThousand = "000" + v_strThousand;
8
if (v_strThousand.Length == 2)
9
v_strThousand = "00" + v_strThousand;
10
if (v_strThousand.Length == 3)
11
v_strThousand = "0" + v_strThousand;
12
13
for (int i = 0; i < v_strThousand.Length; i++)
14
{
15
if (i == 0 && Convert.ToInt32(v_strThousand[i].ToString()) > 0)
16
v_strThousandNumberName = v_strThousandNumberName + GetEngNumberName(Convert.ToInt32(v_strThousand[i].ToString())) + "千";
17
if (i == 1 && Convert.ToInt32(v_strThousand[i].ToString()) > 0)
18
v_strThousandNumberName = v_strThousandNumberName + GetEngNumberName(Convert.ToInt32(v_strThousand[i].ToString())) + "百";
19
else
20
if (i == 1 && Convert.ToInt32(v_strThousand[i - 1].ToString()) > 0)
21
v_strThousandNumberName = v_strThousandNumberName + GetEngNumberName(Convert.ToInt32(v_strThousand[i].ToString()));
22
if (i == 2 && Convert.ToInt32(v_strThousand[i].ToString()) > 0)
23
v_strThousandNumberName = v_strThousandNumberName + GetEngNumberName(Convert.ToInt32(v_strThousand[i].ToString()) * 10);
24
else
25
if (i == 2 && Convert.ToInt32(v_strThousand[i - 1].ToString()) > 0)
26
v_strThousandNumberName = v_strThousandNumberName + GetEngNumberName(Convert.ToInt32(v_strThousand[i].ToString()));
27
if (i == 3 && Convert.ToInt32(v_strThousand[i].ToString()) > 0)
28
v_strThousandNumberName = v_strThousandNumberName + GetEngNumberName(Convert.ToInt32(v_strThousand[i].ToString()));
29
}
30
return v_strThousandNumberName;
31
}
32
public static string GetUpperNumber(string p_strThousandNumberName)
33
{
34
string v_strThousand = p_strThousandNumberName;
35
string v_strThousandNumberName = "";
36
if (v_strThousand.Length == 1)
37
v_strThousand = "000" + v_strThousand;
38
if (v_strThousand.Length == 2)
39
v_strThousand = "00" + v_strThousand;
40
if (v_strThousand.Length == 3)
41
v_strThousand = "0" + v_strThousand;
42
int dotnum = 100;
43
for (int i = 0; i < v_strThousand.Length; i++)
44
{
45
if (v_strThousand[i].ToString() == ".")
46
{
47
dotnum = i;
48
}
49
else if (dotnum < i)
50
{
51
if ((dotnum + 1) == i && Convert.ToInt32(v_strThousand[i].ToString())!=0)
52
{
53
v_strThousandNumberName = v_strThousandNumberName +"元"+ GetEngNumberName(Convert.ToInt32(v_strThousand[i].ToString())) + "角";
54
}
55
if ((dotnum + 2) == i && Convert.ToInt32(v_strThousand[i].ToString())!=0)
56
{
57
v_strThousandNumberName = v_strThousandNumberName + GetEngNumberName(Convert.ToInt32(v_strThousand[i].ToString())) + "分";
58
}
59
}
60
else
61
{
62
if (i == 0 && Convert.ToInt32(v_strThousand[i].ToString()) > 0)
63
v_strThousandNumberName = v_strThousandNumberName + GetEngNumberName(Convert.ToInt32(v_strThousand[i].ToString())) + "千";
64
if (i == 1 && Convert.ToInt32(v_strThousand[i].ToString()) > 0)
65
v_strThousandNumberName = v_strThousandNumberName + GetEngNumberName(Convert.ToInt32(v_strThousand[i].ToString())) + "百";
66
else
67
if (i == 1 && Convert.ToInt32(v_strThousand[i - 1].ToString()) > 0)
68
v_strThousandNumberName = v_strThousandNumberName + GetEngNumberName(Convert.ToInt32(v_strThousand[i].ToString()));
69
if (i == 2 && Convert.ToInt32(v_strThousand[i].ToString()) > 0)
70
v_strThousandNumberName = v_strThousandNumberName + GetEngNumberName(Convert.ToInt32(v_strThousand[i].ToString()) * 10);
71
else
72
if (i == 2 && Convert.ToInt32(v_strThousand[i - 1].ToString()) > 0)
73
v_strThousandNumberName = v_strThousandNumberName + GetEngNumberName(Convert.ToInt32(v_strThousand[i].ToString()));
74
if (i == 3 && Convert.ToInt32(v_strThousand[i].ToString()) > 0)
75
v_strThousandNumberName = v_strThousandNumberName + GetEngNumberName(Convert.ToInt32(v_strThousand[i].ToString()));
76
}
77
78
}
79
return v_strThousandNumberName;
80
81
}
82
public static string convertToChineseMoney(decimal num)
83
{
84
string strChina = "零壹贰叁肆伍陆柒捌玖"; //0-9所对应的汉字
85
string strUnit = "万仟佰拾亿仟佰拾万仟佰拾元角分"; //数字位所对应的汉字
86
string strSingleNum = ""; //从原num值中取出的值
87
string strNum = ""; //数字的字符串形式
88
string strResult = ""; //人民币大写金额形式
89
string chChina = ""; //数字的汉语读法
90
string chUnit = ""; //数字位的汉语读法
91
92
int i; //循环变量
93
int lenth; //num的值乘以100的字符串长度
94
int nZero = 0; //用来计算连续的零值是几个
95
int temp; //从原num值中取出的值
96
num = Math.Round(Math.Abs(num), 2); //将num取绝对值并四舍五入取2位小数
97
strNum = ((long)(num * 100)).ToString(); //将num乘100并转换成字符串形式
98
lenth = strNum.Length; //找出最高位
99
100
if (lenth > 15)
101
{
102
return "位数过大,无法转换!";
103
}
104
//取出对应位数的strUnit的值。如:200.55,lenth为5所以strUnit=佰拾元角分
105
strUnit = strUnit.Substring(15 - lenth);
106
//循环取出每一位需要转换的值
107
for (i = 0; i < lenth; i++)
108
{
109
strSingleNum = strNum.Substring(i, 1); //取出需转换的某一位的值
110
temp = Convert.ToInt32(strSingleNum); //转换为数字
111
if (i != (lenth - 3) && i != (lenth - 7) && i != (lenth - 11) && i != (lenth - 15))
112
{
113
//当所取位数不为元、万、亿、万亿上的数字时
114
if (strSingleNum == "0")
115
{
116
chChina = "";
117
chUnit = "";
118
nZero = nZero + 1;
119
}
120
else
121
{
122
if (strSingleNum != "0" && nZero != 0)
123
{
124
chChina = "零" + strChina.Substring(temp, 1);
125
chUnit = strUnit.Substring(i, 1);
126
nZero = 0;
127
}
128
else
129
{
130
chChina = strChina.Substring(temp, 1);
131
chUnit = strUnit.Substring(i, 1);
132
nZero = 0;
133
}
134
}
135
}
136
else
137
{
138
//该位是万亿,亿,万,元位等关键位
139
if (strSingleNum != "0" && nZero != 0)
140
{
141
chChina = "零" + strChina.Substring(temp, 1);
142
chUnit = strUnit.Substring(i, 1);
143
nZero = 0;
144
}
145
else
146
{
147
if (strSingleNum != "0" && nZero == 0)
148
{
149
chChina = strChina.Substring(temp, 1);
150
chUnit = strUnit.Substring(i, 1);
151
nZero = 0;
152
}
153
else
154
{
155
if (strSingleNum == "0" && nZero >= 3)
156
{
157
chChina = "";
158
chUnit = "";
159
nZero = nZero + 1;
160
}
161
else
162
{
163
if (lenth >= 11)
164
{
165
chChina = "";
166
nZero = nZero + 1;
167
}
168
else
169
{
170
chChina = "";
171
chUnit = strUnit.Substring(i, 1);
172
nZero = nZero + 1;
173
}
174
}
175
}
176
}
177
}
178
179
if (i == (lenth - 11) || i == (lenth - 3))
180
{
181
//如果该位是亿位或元位,则必须写上
182
chUnit = strUnit.Substring(i, 1);
183
}
184
185
strResult = strResult + chChina + chUnit;
186
if (i == lenth - 1 && strSingleNum == "0")
187
{
188
//最后一位(分)为0时,加上“整”
189
strResult = strResult + '整';
190
}
191
}
192
if (num == 0)
193
{
194
strResult = "零元整";
195
}
196
197
return strResult;
198
}
199
200
public static string GetInvertingNumberName(string p_strIntNumberName)
201
{
202
string v_InvertingNumberName = "", v_IntNumberName = p_strIntNumberName;
203
for (int i = p_strIntNumberName.Length - 1; i >= 0; i--)
204
{
205
v_InvertingNumberName = v_InvertingNumberName + v_IntNumberName[i].ToString();
206
}
207
return v_InvertingNumberName;
208
}
209
210
public static string GetEngNumberName(int p_intNumber)
211
{
212
string v_strEngNumberName = "";
213
switch (p_intNumber)
214
{
215
case 0:
216
v_strEngNumberName = "零";
217
break;
218
case 1:
219
v_strEngNumberName = "壹";
220
break;
221
case 2:
222
v_strEngNumberName = "贰";
223
break;
224
case 3:
225
v_strEngNumberName = "叁";
226
break;
227
case 4:
228
v_strEngNumberName = "肆";
229
break;
230
case 5:
231
v_strEngNumberName = "伍";
232
break;
233
case 6:
234
v_strEngNumberName = "陆";
235
break;
236
case 7:
237
v_strEngNumberName = "柒";
238
break;
239
case 8:
240
v_strEngNumberName = "捌";
241
break;
242
case 9:
243
v_strEngNumberName = "玖";
244
break;
245
case 10:
246
v_strEngNumberName = "壹拾";
247
break;
248
case 20:
249
v_strEngNumberName = "贰拾";
250
break;
251
case 30:
252
v_strEngNumberName = "叁拾";
253
break;
254
case 40:
255
v_strEngNumberName = "肆拾";
256
break;
257
case 50:
258
v_strEngNumberName = "伍拾";
259
break;
260
case 60:
261
v_strEngNumberName = "陆拾";
262
break;
263
case 70:
264
v_strEngNumberName = "柒拾";
265
break;
266
case 80:
267
v_strEngNumberName = "捌拾";
268
break;
269
case 90:
270
v_strEngNumberName = "玖拾";
271
break;
272
}
273
return v_strEngNumberName;
274
}
275
#endregion


2

3



4

5

6

7

8

9

10

11

12

13

14



15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33



34

35

36

37

38

39

40

41

42

43

44



45

46



47

48

49

50



51

52



53

54

55

56



57

58

59

60

61



62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83



84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101



102

103

104

105

106

107

108



109

110

111

112



113

114

115



116

117

118

119

120

121



122

123



124

125

126

127

128

129



130

131

132

133

134

135

136

137



138

139

140



141

142

143

144

145

146



147

148



149

150

151

152

153

154



155

156



157

158

159

160

161

162



163

164



165

166

167

168

169



170

171

172

173

174

175

176

177

178

179

180



181

182

183

184

185

186

187



188

189

190

191

192

193



194

195

196

197

198

199

200

201



202

203

204



205

206

207

208

209

210

211



212

213

214



215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275
