EMS单号规律与顺丰单号规律(c)

发布时间:2020-02-23 00:53:10   来源:文档文库   
字号:

///

/// 获取EMS物流单号

///

/// 当前物流单号

///

public static string GetNewEmsNo(string strNo)

{

try

{

string fri = "";

int res;

int num3, num4, num5, num6, num7, num8, num9, num0;

int mid;

string strZero = "00000000";

fri = (Convert.ToUInt32(strNo.Substring(2, 8)) + 1).ToString();

//不足零自动补零

//if (fri.Length < 8)

//{

// string strTmp = strZero + fri;

// fri = strTmp.Substring(strTmp.Length - 8);

//}

fri=fri.PadLeft(8, '0');

num3 = Convert.ToInt32(fri.Substring(0, 1));

num4 = Convert.ToInt32(fri.Substring(1, 1));

num5 = Convert.ToInt32(fri.Substring(2, 1));

num6 = Convert.ToInt32(fri.Substring(3, 1));

num7 = Convert.ToInt32(fri.Substring(4, 1));

num8 = Convert.ToInt32(fri.Substring(5, 1));

num9 = Convert.ToInt32(fri.Substring(6, 1));

num0 = Convert.ToInt32(fri.Substring(7, 1));

mid = 8 * num3 + 6 * num4 + 4 * num5 + 2 * num6 + 3 * num7 + 5 * num8 + 9 * num9 + 7 * num0;

res = 11 - (mid) % (11);

if (res == 10)

res = 0;

if (res == 11)

res = 5;

string strHead = strNo.Substring(0, 2);

if (!IsLetter(strHead))

{

throw new Exception("EMS单号前2位不为字母");

}

string strEnd = strNo.Substring(strNo.Length - 2);

if (!IsLetter(strEnd))

{

throw new Exception("EMS单号末2位不为字母");

}

string strEMSres = (strHead + fri + res.ToString() + strEnd);

return strEMSres;

}

catch (Exception ex)

{

MessageForm.Error(ex.Message);

return string.Empty;

}

}

///

/// 获取顺丰物流单号

///

///

///

public static string GetNewShunfengNo(string strNo)

{

try

{

if (strNo.Length != 12)

{

throw new Exception("顺丰单号为12,请检测单号是否正确");

}

string fri, Nfri, Yuandanhao, strNewNo;

int num9, num10, num11, num12;

本文来源:https://www.2haoxitong.net/k/doc/1eb24efcbf1e650e52ea551810a6f524cdbfcb3d.html

《EMS单号规律与顺丰单号规律(c).doc》
将本文的Word文档下载到电脑,方便收藏和打印
推荐度:
点击下载文档

文档为doc格式