欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

利用asp.net实现生成不重复订单号

程序员文章站 2024-03-04 22:36:00
复制代码 代码如下: #region 生成单据号 /// /// 生成单据号 /// ///
复制代码 代码如下:

#region 生成单据号
/// <summary>
/// 生成单据号
/// </summary>
/// <param name="pfromtype"></param>
/// <returns></returns>
public static string getformcode(formtype pfromtype)
{
string formcode = "";
switch(pfromtype)
{
case formtype.caigou:
{
formcode = "cg";
break;
}
case formtype.chaixie:
{
formcode = "cx";
break;
}
case formtype.chuku:
{
formcode = "ck";
break;
}
case formtype.lingliao:
{
formcode = "ll";
break;
}
case formtype.peichang:
{
formcode = "pc";
break;
}
case formtype.ruku:
{
formcode = "rk";
break;
}
case formtype.shengchan:
{
formcode = "sc";
break;
}
case formtype.sunyi:
{
formcode = "sy";
break;
}
case formtype.tuihuo:
{
formcode = "th";
break;
}
case formtype.xiaoshou:
{
formcode = "xs";
break;
}
case formtype.peisong:
{
formcode = "ps";
break;
}
case formtype.zengpin:
{
formcode = "zp";
break;
}
case formtype.fukuan:
{
formcode = "fk";
break;
}
case formtype.shoukuan:
{
formcode = "sk";
break;
}
}
formcode += datetime.now.year.tostring();
formcode += datetime.now.month.tostring().length == 1?"0" + datetime.now.month.tostring() : datetime.now.month.tostring();
formcode += datetime.now.day.tostring().length == 1?"0" + datetime.now.day.tostring() : datetime.now.day.tostring();
formcode += datetime.now.hour.tostring().length == 1?"0" + datetime.now.hour.tostring() : datetime.now.hour.tostring();
formcode += datetime.now.minute.tostring().length == 1?"0" + datetime.now.minute.tostring() : datetime.now.minute.tostring();
formcode += datetime.now.second.tostring().length == 1?"0" + datetime.now.second.tostring() : datetime.now.second.tostring();
if(datetime.now.millisecond.tostring().length == 1)
{
formcode += "00" + datetime.now.millisecond.tostring();
}
else if (datetime.now.millisecond.tostring().length == 2)
{
formcode += "0" + datetime.now.millisecond.tostring();
}
else
{
formcode += datetime.now.millisecond.tostring();
}
return formcode;
}
#endregion