package com.lsn.ui;
import java.awt.Button;
import java.awt.Color;
import java.awt.Label;
import java.awt.Rectangle;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import com.lsn.dao.WaterDAO;
import com.lsn.model.Water;
import com.lsn.util.ManageCharacter;
public class UpdateDialog extends JDialog implements ActionListener{
private Label logo;
private Label customerName;
private Label waterCount;
private Label backtongCount;
private Label shouwaterCount;
private Label moneyCount;
private Label qianCount;
private Label maiwaterCount;
private Label qingqianCount;
private Label swName;
private Label cNumber;
private Label driverName;
private Label waterDate;
private JLabel colockLael1,colockLael2,colockLael3,colockLael4,colockLael5,colockLael6,colockLael7;
private JTextField nametext,customerNametext,waterCounttext,backtongCounttext,shouwaterCounttext,
moneyCounttext,qianCounttext,maiwaterCounttext,qingqianCounttext,swNametext,cNumbertext, driverNametext,waterDatetext;
private boolean colockLael1flag,colockLael2flag,colockLael3flag,colockLael4flag,colockLael5flag,colockLael6flag,colockLael7flag;
private Button ok = new Button("确定");
private Button cancel = new Button("取消");
private Water water ;
WaterDAO wo = new WaterDAO();
private ManageCharacter mc = new ManageCharacter();
public UpdateDialog(Water w){
this.setTitle("水站数据设置");
this.setLayout(null);
this.setBounds(100,63,320,340);
this.setResizable(false);
this.setVisible(true);
logo = new Label("请设置您的数据");
logo.setBounds(107,12,100,15);
customerName =new Label ();
customerName.setText("客 户 名 ");
customerName.setBounds(47,42, 50,15);
nametext = new JTextField();
nametext.setBounds(102,39,56,19);
nametext.setEditable(false);
waterCount = new Label();
waterCount.setText("送水数量");
waterCount.setBounds(47,72, 50,15);
colockLael1 = new JLabel();
colockLael1.setText("必须是整数(>=0)");
colockLael1.setBounds(160,69,140,19);
colockLael1.setForeground(Color.red);
backtongCount = new Label();
backtongCount.setText("返桶数量");
backtongCount.setBounds(47,102,50,15);
colockLael2 = new JLabel("必须是整数(>=0)");
colockLael2.setBounds(160,99,140,19);
colockLael2.setForeground(Color.red);
shouwaterCount = new Label();
shouwaterCount.setText("收水票数");
shouwaterCount.setBounds(47,132,50,15);
colockLael3 = new JLabel("必须是整数(>=0)");
colockLael3.setBounds(160,129,140,19);
colockLael3.setForeground(Color.red);
moneyCount = new Label();
moneyCount.setText("现金数量");
moneyCount.setBounds(47,162,50,15);
colockLael4 = new JLabel("必须是数字(>=0)");
colockLael4.setBounds(160,159,140,19);
colockLael4.setForeground(Color.red);
qianCount = new Label();
qianCount.setText("欠水票数 ");
qianCount.setBounds(47,192,50,15);
colockLael5 = new JLabel("必须是整数(>=0)");
colockLael5.setBounds(160,189,140,19);
colockLael5.setForeground(Color.red);
maiwaterCount = new Label();
maiwaterCount.setText("卖水票数");
maiwaterCount.setBounds(47,222,50,15);
colockLael6 = new JLabel("必须是整数(>=0)");
colockLael6.setBounds(160,219,140,19);
colockLael6.setForeground(Color.red);
qingqianCount = new Label();
qingqianCount.setText("清欠数量");
qingqianCount.setBounds(47,252,50,15);
colockLael7 = new JLabel("必须是整数(>=0)");
colockLael7.setBounds(160,249,140,19);
colockLael7.setForeground(Color.red);
ok.setBounds(60,279, 44, 22);
cancel.setBounds(130,279, 44, 22);
this.add(logo);
this.add(customerName);
this.add(nametext);
this.add(waterCount);
this.add(backtongCount);
this.add(shouwaterCount);
this.add(moneyCount);
this.add(qianCount);
this.add(maiwaterCount);
this.add(qingqianCount);
this.add(colockLael1);
this.add(colockLael2);
this.add(colockLael3);
this.add(colockLael4);
this.add(colockLael5);
this.add(colockLael6);
this.add(colockLael7);
this.add(this.getWaterCounttextTextField());
this.add(this.getBacktongCounttextTextField());
this.add(this.getShouwaterCounttextTextField());
this.add(this.getMoneyCounttextTextField());
this.add(this.getQianCounttextTextField());
this.add(this.getMaiwaterCounttextTextField());
this.add(this.getQingqianCounttextTextField());
this.add(ok);
this.add(cancel);
ok.addActionListener(this);
cancel.addActionListener(this);
nametext.setText(w.getCName());
water = w;
}
private JTextField getWaterCounttextTextField() {
if (waterCounttext == null) {
waterCounttext = new JTextField();
waterCounttext.setBounds(new Rectangle(102,69,56,19));
waterCounttext.setActionCommand("waterCounttext");
waterCounttext.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent e) {
String ss = waterCounttext.getText();
if (mc.checkInt(ss)) {
colockLael1.setText("");colockLael1flag = true;
} else {
colockLael1.setText("必须是整数(>=0)");
colockLael1flag = false;
}
}
});
}
return waterCounttext;
}
private JTextField getBacktongCounttextTextField() {
if (backtongCounttext == null) {
backtongCounttext = new JTextField();
backtongCounttext.setBounds(new Rectangle(102,99,56,19));
backtongCounttext.setActionCommand("backtongCounttext");
backtongCounttext.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent e) {
String ss = backtongCounttext.getText().trim();
if (mc.checkInt(ss)) {
colockLael2.setText("");
colockLael2flag = true;
} else {
colockLael2.setText("必须是整数(>=0)");
colockLael2flag = false;
}
}
});
}
return backtongCounttext;
}
private JTextField getShouwaterCounttextTextField() {
if (shouwaterCounttext == null) {
shouwaterCounttext = new JTextField();
shouwaterCounttext.setBounds(new Rectangle(102,129,56,19));
shouwaterCounttext.setActionCommand("shouwaterCounttext");
shouwaterCounttext.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent e) {
String ss = shouwaterCounttext.getText().trim();
if (mc.checkInt(ss)) {
colockLael3.setText("");
colockLael3flag = true;
} else {
colockLael3.setText("必须是整数(>=0)");
colockLael3flag = false;
}
}
});
}
return shouwaterCounttext;
}
private JTextField getMoneyCounttextTextField() {
if (moneyCounttext == null) {
moneyCounttext = new JTextField();
moneyCounttext.setBounds(new Rectangle(102,159,56,19));
moneyCounttext.setActionCommand("moneyCounttext");
moneyCounttext.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent e) {
String ss = moneyCounttext.getText().trim();
if (mc.checkFloat(ss)) {
colockLael4.setText("");
colockLael4flag = true;
} else {
colockLael4.setText("必须是整数(>=0)");
colockLael4flag = false;
}
}
});
}
return moneyCounttext;
}
private JTextField getQianCounttextTextField() {
if (qianCounttext == null) {
qianCounttext = new JTextField();
qianCounttext.setBounds(new Rectangle(102,189,56,19));
qianCounttext.setActionCommand("qianCounttext");
qianCounttext.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent e) {
String ss = qianCounttext.getText().trim();
if (mc.checkInt(ss)