📄 vendata.java
字号:
package jMaint;import java.util.*;public class VenData { Vector name,add1,add2,add3,add4,pho1,pho2,fax,mob,email,web,com,id; public VenData() { name = new Vector(); add1 = new Vector(); add2 = new Vector(); add3 = new Vector(); add4 = new Vector(); pho1 = new Vector(); pho2 = new Vector(); fax = new Vector(); mob = new Vector(); email = new Vector(); web = new Vector(); com = new Vector(); id = new Vector(); } public void addRecord(String Name, String Address1, String Address2, String Address3, String Address4, String Phone1, String Phone2, String Fax, String Mobil, String Email, String Web, String Comment, int ID) { this.name.addElement(new String(Name)); this.add1.addElement(new String(Address1)); this.add2.addElement(new String(Address2)); this.add3.addElement(new String(Address3)); this.add4.addElement(new String(Address4)); this.pho1.addElement(new String(Phone1)); this.pho2.addElement(new String(Phone2)); this.fax.addElement(new String(Fax)); this.mob.addElement(new String(Mobil)); this.email.addElement(new String(Email)); this.web.addElement(new String(Web)); this.com.addElement(new String(Comment)); this.id.addElement(new Integer(ID)); } public String convertIDtoName(int ID) { return this.getName(this.indexOf(ID)); } public Vector createNameVector() { Vector v = new Vector(); for (int i = 0; i < this.size(); i++) v.addElement(new String(this.getName(i))); return v; } public void deleteRecord(int x) { this.name.removeElementAt(x); this.add1.removeElementAt(x); this.add2.removeElementAt(x); this.add3.removeElementAt(x); this.add4.removeElementAt(x); this.pho1.removeElementAt(x); this.pho2.removeElementAt(x); this.fax.removeElementAt(x); this.mob.removeElementAt(x); this.email.removeElementAt(x); this.web.removeElementAt(x); this.com.removeElementAt(x); this.id.removeElementAt(x); } public void editRecord(int x, String Name, String Address1, String Address2, String Address3, String Address4, String Phone1, String Phone2, String Fax, String Mobil, String Email, String Web, String Comment) { int ID = this.getID(x); this.deleteRecord(x); this.insertRecord(ID, Name, Address1, Address2, Address3, Address4, Phone1, Phone2, Fax, Mobil, Email, Web, Comment); } public String exportRecord(int x) { String t = String.valueOf('\t'); String nl = String.valueOf('\n'); return this.getName(x)+t+this.getAddress1(x)+t+this.getAddress2(x)+t+this.getAddress3(x)+t+this.getAddress4(x)+t+this.getPhone1(x)+t+this.getPhone2(x)+t+this.getFax(x)+t+this.getMobil(x)+t+this.getEmail(x)+t+this.getWeb(x)+t+this.getComment(x)+t+this.getID(x)+nl; } public String getAddress1(int x) { return this.add1.get(x).toString(); } public String getAddress2(int x) { return this.add2.get(x).toString(); } public String getAddress3(int x) { return this.add3.get(x).toString(); } public String getAddress4(int x) { return this.add4.get(x).toString(); } public String getComment(int x) { return this.com.get(x).toString(); } public String getEmail(int x) { return this.email.get(x).toString(); } public String getFax(int x) { return this.fax.get(x).toString(); } public int getID(int x) { return Integer.parseInt(this.id.get(x).toString()); } public String getMobil(int x) { return this.mob.get(x).toString(); } public String getName(int x) { return this.name.get(x).toString(); } public String getPhone1(int x) { return this.pho1.get(x).toString(); } public String getPhone2(int x) { return this.pho2.get(x).toString(); } public String getWeb(int x) { return this.web.get(x).toString(); } public int indexOf(int ID) { int y = -1; for (int i = 0; i < this.size(); i++) if (this.id.get(i).toString().equalsIgnoreCase(String.valueOf(ID))) y=i; return y; } public int indexOf(String Name) { int y = -1; for (int i = 0; i < this.size(); i++) if (this.getName(i).equals(Name)) y=i; return y; } public void insertRecord(int ID, String Name, String Address1, String Address2, String Address3, String Address4, String Phone1, String Phone2, String Fax, String Mobil, String Email, String Web, String Comment){ if (ID == -1) { ID = 0; while (this.indexOf(ID) != -1) ID++; } int i = 0; while ((i < this.size()) && (this.getName(i).compareToIgnoreCase(Name) < 0)) i++; if ((i == this.size()) && (ID > -1)) this.addRecord(Name,Address1,Address2,Address3,Address4,Phone1,Phone2,Fax,Mobil,Email,Web,Comment,ID); else if (!this.getName(i).equals(Name)) { this.name.insertElementAt(new String(Name), i); this.add1.insertElementAt(new String(Address1), i); this.add2.insertElementAt(new String(Address2), i); this.add3.insertElementAt(new String(Address3), i); this.add4.insertElementAt(new String(Address4), i); this.pho1.insertElementAt(new String(Phone1), i); this.pho2.insertElementAt(new String(Phone2), i); this.fax.insertElementAt(new String(Fax), i); this.mob.insertElementAt(new String(Mobil), i); this.email.insertElementAt(new String(Email), i); this.web.insertElementAt(new String(Web), i); this.com.insertElementAt(new String(Comment), i); this.id.insertElementAt(new Integer(ID), i); } } public int size() { return this.id.size(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -