生成类似 LS14120002 private String GenNewOrder()
{
String newOrder;
var orders = LYOrder.Items;
String lastOrder = ((Order)orders[orders.Count - 1]).OrderNum;
//int len = lastOrder.Length;
String dateOld = lastOrder.Substring(2, 4);
int indexOld = Convert.ToInt32(lastOrder.Substring(6, 4));
String indexNew = (indexOld + 1).ToString();
String dateNow = System.DateTime.Now.ToString("yyMM");//获取年月
if (dateOld.Equals(dateNow))//同一个月的单
{
switch (indexNew.Length)
{
case 1:
indexNew = "000" + indexNew;
break;
case 2:
indexNew = "00" + indexNew;
break;
case 3:
indexNew = "0" + indexNew;
break;
}
newOrder = " LS" + dateNow + indexNew;
}
else
{
newOrder = " LS" + dateNow + "0001";
}
return newOrder;
}
|
请发表评论