[C#]ToString("##")格式化用法案例一:自动编码单据流水码
2013-11-12 08:01
363 查看
之前的写的自动编码单据流水码是写在存储过程或者函数中的,今天用程序写一个发现TOSTRING可以格式化方便。
/// <summary> /// 年月日+两位流水码 /// </summary> /// <returns></returns> public static string AutoCode() { string yearmonthday =System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString("00") + System.DateTime.Now.Day.ToString("00"); string flowcode = string.Empty;//流水码 StringBuilder sb = new StringBuilder(); sb.Append(" select 报价单号 from [dbo].[UF_Quotation]"); sb.Append(" where Left(报价单号,8)='" + yearmonthday + "'"); using (SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.conn, CommandType.Text, sb.ToString())) { if (dr.Read()) { int tempcode=int.Parse(dr[0].ToString().Substring (8,2))+1; flowcode = tempcode.ToString("00"); ; } else { flowcode = "01"; } } return yearmonthday + flowcode; }
相关文章推荐
- [C#]ToString("##")格式化用法案例一:自动编码单据流水码
- C#中格式化方法ToString("...")
- 【C#】toString("Format") 格式化
- 自动生成C# 年月日加流水号的单据号、及日期时间相关函数的用法
- unity 3D c# 协程的典型用法-Unity官方案例精讲笔记
- C#读取文件时自动判断编码函数
- C#小数点格式化用法小结
- C# 字符串 格式化 的用法
- C#.NET中的ToString()数字格式化
- C# .ToString() 格式化
- C# .ToString() 格式化
- 黄聪:C#中WebClient自动判断编码是UTF-8还是GBK,并且有超时判断功能
- C# Meta Programming - Let Your Code Generate Code - 利用反射重写自动的ToString()
- C#获取网页源码并且自动判断网页字符集编码
- C# DateTime ToString方法格式化示例
- C#中.tostring(X2)的用法
- C#中ToString() 的一些常用用法
- C# 获取文本文件的编码,自动区分GB2312和UTF8
- C# ("a"+1).ToString(),你认为正确吗
- String.Format("{0:yyyy-MM-dd}" ,dr["ar_time"].toString())不能格式化的问题