返回首页
当前位置: 主页 > 网络编程 > .Net实例教程 >

实现用程序自动生成流水号程序代码

时间:2011-05-24 14:04来源:知行网www.zhixing123.cn 编辑:麦田守望者

//获得流水号 规则 RK-日期-编号
string LiuSH = "";
string BianH = "RK-" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("D2") + DateTime.Now.Day.ToString("D2");
if (SqlGetDataBinder.GetDataHasRows("select * from ChuRKD where LiuSDH like '%" + BianH + "%'"))
{
BianH = SqlGetDataBinder.GetFirst("select top 1 LiuSDH from ChuRKD where LiuSDH like '%" + BianH + "%' order by LiuSDH desc").ToString();
string num= BianH.Split('-')[2];
num = (Convert.ToInt32(num) + 1).ToString("D3");
LiuSH = "RK-" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("D2") + DateTime.Now.Day.ToString("D2") + "-" + num;
}
else
{
LiuSH = "RK-" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("D2") + DateTime.Now.Day.ToString("D2") + "-001";
}
递归流水号
//获得验证流水号
protected string GetLiuSDH(string LiuSDH)
{
string result = "";
bool flag1 = SqlGetDataBinder.GetDataHasRows("select LiuSDH from ChuRKD where LiuSDH='" + LiuSDH + "'");
bool flag2 = SqlGetDataBinder.GetDataHasRows("select DanH from ChuLKDMXB where DanH='"+LiuSDH+"'");
if (flag1 || flag2)
{
string num = (Convert.ToInt32(LiuSDH.Split('-')[2]) + 1).ToString("D3");
result = "RK-" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("D2") + DateTime.Now.Day.ToString("D2") + "-" + num;
result = this.GetLiuSDH(result);
}
else
{
result = LiuSDH;
}
return result;
}

------分隔线----------------------------
标签(Tag):C# C#实例教程 c#基础教程 C#源代码
------分隔线----------------------------
推荐内容
猜你感兴趣