📄 newcar.java~50~
字号:
this.getContentPane().add(carid_t, new XYConstraints(139, 45, 97, 31));
this.getContentPane().add(jLabel18, new XYConstraints(40, 391, 93, 31));
this.getContentPane().add(jComboBox2,
new XYConstraints(137, 391, 99, 31));
this.getContentPane().add(jLabel14, new XYConstraints(40, 309, 94, 31));
this.getContentPane().add(jLabel16, new XYConstraints(40, 350, 93, 32));
this.getContentPane().add(jLabel12, new XYConstraints(40, 267, 95, 31));
this.getContentPane().add(jLabel4, new XYConstraints(39, 89, -1, 31));
this.getContentPane().add(jLabel1, new XYConstraints(39, 45, -1, 31));
this.getContentPane().add(yingdate,
new XYConstraints(139, 267, 97, 31));
this.getContentPane().add(yeardate,
new XYConstraints(138, 309, 98, 31));
this.getContentPane().add(toudate,
new XYConstraints(138, 350, 98, 32));
this.getContentPane().add(nextyingdate,
new XYConstraints(411, 266, 96, 30));
this.getContentPane().add(nextyeardate,
new XYConstraints(411, 309, 95, 30));
this.getContentPane().add(breaklowcount_t,
new XYConstraints(411, 390, 95, 31));
this.getContentPane().add(jButton1, new XYConstraints(81, 453, 95, 47));
this.getContentPane().add(jButton3, new XYConstraints(231, 453, 96, 47));
this.getContentPane().add(jButton2, new XYConstraints(382, 454, 99, 47));
this.setSize(553, 553);
this.setLocation(170, 50);
this.setVisible(true);
addWindowListener(new WindowAdapter() {
public void WindowClosing(WindowEvent e) {
if(db!=null)
db.closeConnection();
dispose();
}
});
}
DataBaseManager db=null;
ResultSet r;
XYLayout xYLayout1 = new XYLayout();
Border border1 = BorderFactory.createEtchedBorder(EtchedBorder.RAISED,
Color.white, new Color(148, 145, 140));
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel1 = new JLabel();
JTextField carid_t = new JTextField();
JTextField factory_t = new JTextField();
JTextField actionid_t = new JTextField();
JLabel jLabel2 = new JLabel();
JTextField under_t = new JTextField();
JLabel jLabel5 = new JLabel();
JComboBox jComboBox1 = new JComboBox();
JLabel jLabel6 = new JLabel();
JTextField businessid_t = new JTextField();
JLabel jLabel7 = new JLabel();
JLabel jLabel8 = new JLabel();
JTextField countmoney_t = new JTextField();
JLabel jLabel9 = new JLabel();
JTextField lightid_t = new JTextField();
JLabel jLabel10 = new JLabel();
JTextField drivername_t = new JTextField();
JLabel jLabel11 = new JLabel();
JTextField driveid_t = new JTextField();
JLabel jLabel12 = new JLabel();
JLabel jLabel13 = new JLabel();
JLabel jLabel14 = new JLabel();
JLabel jLabel15 = new JLabel();
JLabel jLabel16 = new JLabel();
JLabel jLabel17 = new JLabel();
JLabel jLabel18 = new JLabel();
JComboBox jComboBox2 = new JComboBox();
JLabel jLabel19 = new JLabel();
JTextField breaklowcount_t = new JTextField();
JButton jButton1 = new JButton(new ImageIcon("image\\163.gif"));
JButton jButton2 = new JButton(new ImageIcon("image\\48.gif"));
JButton jButton3 = new JButton(new ImageIcon("image\\back.gif"));
JTextField protecthour_t = new JTextField();
JTextField jTextField1 = new JTextField();
JTextField yingdate = new JTextField();
JTextField yeardate = new JTextField();
JTextField toudate = new JTextField();
JTextField nextyingdate = new JTextField();
JTextField nextyeardate = new JTextField();
public void jTextField6_actionPerformed(ActionEvent e) {
}
public void jButton1_actionPerformed(ActionEvent e) {
db=new DataBaseManager();
String str = "select * from car where 车牌号='"+carid_t.getText() .trim()+"'" ;
try {
// r = db.getResult(str);
// r.first();
if (db.getResult(str).first()) {
JOptionPane.showMessageDialog(null, "该车辆已存在!");
carid_t.setText("");
factory_t.setText("");
actionid_t.setText("");
under_t.setText("");
businessid_t.setText("");
countmoney_t.setText("");
lightid_t.setText("");
drivername_t.setText("");
yeardate.setText("");
nextyeardate.setText("");
yingdate.setText("");
nextyingdate.setText("");
toudate.setText("");
driveid_t.setText("");
breaklowcount_t.setText("0");
protecthour_t.setText("");
} else {
str = "insert into car(车牌号,制造商,发动机号,底盘编号,燃油类型,营运证号,计价器号,顶灯号,驾驶员姓名,驾驶证号,营审日期,次营审日期,年审日期,下次年审,投保日期,投保时长,车辆状态,违章次数) values('" +
carid_t.getText().trim() + "','" +
factory_t.getText().trim() + "','" +
actionid_t.getText().trim() + "','" +
under_t.getText().trim() + "','" +
jComboBox1.getSelectedItem() + "','" +
businessid_t.getText().trim() + "','" +
countmoney_t.getText().trim() + "','" +
lightid_t.getText().trim() + "','" +
drivername_t.getText().trim() + "','" +
driveid_t.getText().trim() + "','" +
yingdate.getText().trim() + "','" +
nextyingdate.getText().trim() + "','" +
yeardate.getText().trim() + "','" +
nextyeardate.getText().trim() + "','" +
toudate.getText().trim() + "','" +
protecthour_t.getText().trim() + "','" +
jComboBox2.getSelectedItem() + "'," +
breaklowcount_t.getText().trim() + "" + ")";
if (db.updateSql(str)) {
JOptionPane.showMessageDialog(null, "添加车辆成功!");
carid_t.setText("");
factory_t.setText("");
actionid_t.setText("");
under_t.setText("");
businessid_t.setText("");
countmoney_t.setText("");
lightid_t.setText("");
drivername_t.setText("");
yeardate.setText("");
nextyeardate.setText("");
yingdate.setText("");
nextyingdate.setText("");
toudate.setText("");
driveid_t.setText("");
breaklowcount_t.setText("0");
protecthour_t.setText("");
} else {
JOptionPane.showMessageDialog(null, "添加车辆失败!");
}
}
} catch (HeadlessException ex) {
} catch (SQLException ex) {
}
}
public void jButton2_actionPerformed(ActionEvent e) {
carid_t.setText("");
factory_t.setText("");
actionid_t.setText("");
under_t.setText("");
businessid_t.setText("");
countmoney_t.setText("");
lightid_t.setText("");
drivername_t.setText("");
yeardate.setText("");
nextyeardate.setText("");
yingdate.setText("");
nextyingdate.setText("");
toudate.setText("");
driveid_t.setText("");
breaklowcount_t.setText("0");
protecthour_t.setText("");
}
public void jButton3_actionPerformed(ActionEvent e) {
if(db!=null)
db.closeConnection();
this.dispose();
}
public void carid_t_focusLost(FocusEvent e) {
if (carid_t.getText().trim().equals(""))
JOptionPane.showMessageDialog(null, "车号不能为空!");
}
public void factory_t_focusLost(FocusEvent e) {
if (factory_t.getText().trim().equals(""))
JOptionPane.showMessageDialog(null, "制造商不能为空!");
}
public void actionid_t_focusLost(FocusEvent e) {
if (actionid_t.getText().trim().equals(""))
JOptionPane.showMessageDialog(null, "发动机号不能为空!");
}
public void under_t_focusLost(FocusEvent e) {
if (under_t.getText().trim().equals(""))
JOptionPane.showMessageDialog(null, "底盘号不能为空!");
}
public void businessid_t_focusLost(FocusEvent e) {
if (businessid_t.getText().trim().equals(""))
JOptionPane.showMessageDialog(null, "营运证号不能为空!");
}
public void countmoney_t_focusLost(FocusEvent e) {
if (countmoney_t.getText().trim().equals(""))
JOptionPane.showMessageDialog(null, "计价器号不能为空!");
}
public void lightid_t_focusLost(FocusEvent e) {
if (lightid_t.getText().trim().equals(""))
JOptionPane.showMessageDialog(null, "顶灯号不能为空!");
}
public void drivername_t_focusLost(FocusEvent e) {
if (drivername_t.getText().trim().equals(""))
JOptionPane.showMessageDialog(null, "驾驶员姓名不能为空!");
}
public void driveid_t_focusLost(FocusEvent e) {
if (driveid_t.getText().trim().equals(""))
JOptionPane.showMessageDialog(null, "驾驶证号不能为空!");
}
public void protecthour_t_focusLost(FocusEvent e) {
if (protecthour_t.getText().trim().equals(""))
JOptionPane.showMessageDialog(null, "投保时长不能为空!");
}
public void yingdate_focusLost(FocusEvent e) {
if (yingdate.getText().trim().equals(""))
JOptionPane.showMessageDialog(null, "营审日期不能为空!");
else {
String s = yingdate.getText().trim() + "!";
char date[] = new char[20];
int i;
date = s.toCharArray();
for (i = 0; date[i] != '!'; i++)
if ((date[i] >= '0' && date[i] <= '9') || date[i] == '.')
;
else {
JOptionPane.showMessageDialog(null,
"您输入的日期非法或您输入的日期格式不正确,请以“.”为分隔符!");
yingdate.setText("");
yingdate.setFocusable(true);
break;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -