zoukankan      html  css  js  c++  java
  • 转载代码生成条形码2。

      1 public string GetCode128A(string inputData)
      2         {
      3             string result = "";
      4             int checksum = 103;
      5             int j = 1;
      6             for (int ii = 0; ii < inputData.Length; ii++)
      7             {
      8                 if (inputData[ii] >= 32)
      9                 {
     10                     checksum += (inputData[ii] - 32) * (ii + 1);
     11                 }
     12                 else
     13                 {
     14                     checksum += (inputData[ii] + 64) * (ii + 1);
     15                 }
     16             }
     17             checksum = checksum % 103;
     18             if (checksum < 95)
     19             {
     20                 checksum += 32;
     21             }
     22             else
     23             {
     24                 checksum += 100;
     25             }
     26             result = Convert.ToChar(203) + inputData.ToString() + Convert.ToChar(checksum) + Convert.ToChar(206);
     27             return result;
     28         }
     29 
     30 复制代码
     31 
     32   Code128B
     33 
     34 
     35 复制代码
     36 public string GetCode128B(string inputData)
     37         {
     38             string result = "";
     39             int checksum = 104;
     40             int j = 1;
     41             for (int ii = 0; ii < inputData.Length; ii++)
     42             {
     43                 if (inputData[ii] >= 32)
     44                 {
     45                     checksum += (inputData[ii] - 32) * (ii + 1);
     46                 }
     47                 else
     48                 {
     49                     checksum += (inputData[ii] + 64) * (ii + 1);
     50                 }
     51             }
     52             checksum = checksum % 103;
     53             if (checksum < 95)
     54             {
     55                 checksum += 32;
     56             }
     57             else
     58             {
     59                 checksum += 100;
     60             }
     61             result = Convert.ToChar(204) + inputData.ToString() + Convert.ToChar(checksum) + Convert.ToChar(206);
     62             return result;
     63         }
     64 
     65 复制代码
     66 
     67   Code128C
     68 
     69 
     70 复制代码
     71 public static string GetCode128C(string inputData)
     72         {
     73             string result = "";
     74             int checksum = 105;
     75             int j = 1;
     76             for (int ii = 0; ii < inputData.Length; ii++)
     77             {
     78                 if (ii % 2 == 0)
     79                 {
     80                     checksum += Convert.ToInt32(inputData.Substring(ii, 2)) * j;
     81                     if (Convert.ToInt32(inputData.Substring(ii, 2)) < 95)
     82                     {
     83                         result += Convert.ToChar(Convert.ToInt32(inputData.Substring(ii, 2)) + 32);
     84                     }
     85                     else
     86                     {
     87                         result += Convert.ToChar(Convert.ToInt32(inputData.Substring(ii, 2)) + 100);
     88                     }
     89                     j++;
     90                 }
     91                 ii++;
     92             }
     93             checksum = checksum % 103;
     94             if (checksum < 95)
     95             {
     96                 checksum += 32;
     97             }
     98             else
     99             {
    100                 checksum += 100;
    101             }
    102             result = Convert.ToChar(205) + result + Convert.ToChar(checksum) + Convert.ToChar(206);
    103             return result;
    104         }
  • 相关阅读:
    SpringMVC之@RequestMapping、ThreadLocal、DBCP、JNDI数据源管理
    安全威胁的分类
    软件可靠性的一些关注点
    LibTomMath + vs2008,安装和测试程序
    winxp下,Ice3.4.1 + VS2008_sp1,这个组合安装有点麻烦
    逗号操作符简化代码
    转,F5负载均衡算法及基本原理(Intro to Load Balancing)
    JVM大内存分析,不推荐jmap+jhat,推荐JProfiler
    选择soapUI做性能测试,这就是悲剧的开始
    关于linux LVM的好图 (Logic Volume Management,逻辑卷管理)
  • 原文地址:https://www.cnblogs.com/pengpengzhang/p/5329017.html
Copyright © 2011-2022 走看看