组织机构代码生成器
2018-01-15 13:24
477 查看
/** * 全国组织机构代码校验码生成程序 * 00251805 7 中共温州市委办公室 * 00251807 3 中共温州市委组织部 * 00251808 1 中共温州市委老干部局 沈伟 2002-04-09 2008-05-05 0.0000 详细 * 00251809 X **/ public class G_Code { public static char[] a = new char[8]; public String jy(char[] a) { int[] ww = { 3, 7, 9, 10, 5, 8, 4, 2 }; int[] cc = new int[8]; int DD = 0; int C9 = 0; for (int i = 0; i < 8; i++) { cc[i] = a[i]; if (47 < cc[i] && cc[i] < 58) cc[i] = cc[i] - 48; else cc[i] = cc[i] - 65; } for (int i = 0; i < 8; i++) { DD += cc[i] * ww[i]; } C9 = 11 - DD % 11; if (C9 == 10) { for (int i = 0; i < 8; i++) System.out.print(G_Code.a[i]); System.out.println("-X"); return new String(a) + "-X"; } else if (C9 == 11) { for (int i = 0; i < 8; i++) System.out.print(G_Code.a[i]); System.out.println("-" + (char) (48)); return new String(a) + "-" + (char) (48); } else { for (int i = 0; i < 8; i++) System.out.print(G_Code.a[i]); System.out.println("-" + (char) (C9 + 48)); return new String(a) + "-" + (char) (C9 + 48); } } /* * public static void main(String[] args){ try{ * * System.out.println("请输入长8位的本体代码!"); for(int i=0;i<8;i++){ * * * G_Code.a[i] =(char)System.in.read(); } }catch (IOException e) { } G_Code * G=new G_Code(); G.jy(a); * * } */ } import java.awt.Color; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; @SuppressWarnings("serial") public class UI extends JFrame implements ActionListener{ JPanel panel; JLabel oneLabel; JButton genButton; JTextField oneTextField; JTextField threeTextField; public UI() { super("组织机构代码生成器"); panel = new JPanel(); panel.setBackground(new Color(192, 192, 192)); panel.setLayout(new FlowLayout()); this.add(panel); oneLabel = new JLabel("请输入长8位的本体代码!"); oneTextField = new JTextField(15); threeTextField = new JTextField(15); genButton = new JButton("生成校验码"); oneTextField.addActionListener(this); genButton.addActionListener(this); panel.add(oneLabel); panel.add(oneTextField); panel.add(genButton); panel.add(threeTextField); this.setBounds(200, 100, 200, 240); this.setResizable(true); this.setVisible(true); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { super.windowClosing(e); System.exit(0); } }); } public static void main(String[] args) { new UI(); } @Override public void actionPerformed(ActionEvent e) { String one = oneTextField.getText().trim(); char[] a = new char[8]; for (int i = 0; i<8 ; i++) a[i] = one.charAt(i); String all = new G_Code().jy(a); threeTextField.setText(String.valueOf(all)); } }
相关文章推荐
- 企业组织机构代码验证JavaScript版和Java版 - 修正版V20090214
- 企业组织机构代码验证JavaScript版和Java版 - 修正版V20090214
- 组织机构代码和社会信用码验证
- 组织机构代码校验码 验证程序
- JS验证身份证、营业执照、组织机构代码等
- 组织机构代码
- js验证身份证营业执照组织机构代码等
- 全国组织机构代码校验码生成程序(java版)
- [iOS]XCode代码修改组织机构名
- 18位身份证和组织机构代码校验ORACLE函数
- 组织机构代码校验码生成算法(C#版)
- 实现全国组织机构代码校验
- 身份证、组织机构代码及营业执照号校验函数
- YbSoftwareFactory 代码生成插件【十一】:ASP.NET WebApi MVC下组织机构管理和菜单权限管理的实现
- 企业组织机构代码验证JavaScript版和Java版 - 修正版V20090214
- 组织机构代码生成算法(c#实现)
- oracle组织机构代码验证函数
- 18位身份证和组织机构代码校验ORACLE函数
- 身份证、组织机构代码及营业执照号校验函数
- 校验组织机构代码 合法性