【文件属性】:
文件名称:VS中流水号自动生成
文件大小:267KB
文件格式:RAR
更新时间:2012-11-22 04:20:43
VS中流水号
自动生成带前缀+日期+尾号的单据号码
///
/// 根据时间生成流水号
/// 流水号组成如XS200811050001
/// XS:销售
/// 20081105:日期
/// 0001:20081105日的第一个订单
///
///
private string GetNumberString()
{
string orderNumber = null;
//取得当天的最大订单号
DateTime today = DateTime.Now;
string sql = "select * from Orders where OrderNumber like 'XS"+today.Year.ToString("d4")+today.Month.ToString("d2")+today.Day.ToString("d2")+"%' and convert(int,substring(OrderNumber,11,4))=(select max(convert(int,substring(OrderNumber,11,4))) from Orders)";
DataSet ds = null;
using (DatabaseOperater2 op = new DatabaseOperater2())
{
ds = op.ExcuteSelectByAdater(sql);
}
if (ds.Tables[0].Rows.Count == 0)
{
//如果今天还没有订单
orderNumber = "XS" + today.Year.ToString("d4") + today.Month.ToString("d2") + today.Day.ToString("d2") + "0001";
}
else
{
//如果有订单,则在最大订单号上+1
int number = Convert.ToInt32(ds.Tables[0].Rows[0]["OrderNumber"].ToString().Substring(10,4))+1;
orderNumber = "XS" + today.Year.ToString("d4") + today.Month.ToString("d2")+today.Day.ToString("d2") + number.ToString("d4");
}
return orderNumber;
}
【文件预览】:
流水号的生成
----流水号的生成()
--------bin()
--------Form1.Designer.cs(5KB)
--------DatabaseOperater2.cs(3KB)
--------Program.cs(477B)
--------obj()
--------流水号的生成.csproj(3KB)
--------Form1.cs(3KB)
--------Form1.resx(6KB)
--------Properties()
----流水号的生成.suo(15KB)
----DemoDB_log.ldf(1024KB)
----DemoDB.mdf(3MB)
----流水号的生成.sln(943B)