You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
163 lines
5.2 KiB
163 lines
5.2 KiB
package com.ym.view;
|
|
|
|
import java.awt.Component;
|
|
|
|
import java.awt.Font;
|
|
import java.awt.GridLayout;
|
|
import java.awt.event.MouseAdapter;
|
|
import java.awt.event.MouseEvent;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import javax.swing.JButton;
|
|
import javax.swing.JComboBox;
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JOptionPane;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JRadioButton;
|
|
import javax.swing.JTextField;
|
|
import javax.swing.SwingConstants;
|
|
import javax.swing.border.EmptyBorder;
|
|
|
|
import com.eltima.components.ui.DatePicker;
|
|
import com.ym.dao.ShouruqingkuangymDao;
|
|
//import dao.ZhuhuDao;
|
|
import com.ym.dao.impl.ShouruqingkuangymImpl;
|
|
//import dao.impl.ZhuhuImpl;
|
|
import com.ym.entity.Shouruqingkuangym;
|
|
//import entity.Zhuhu;
|
|
public class ShouruqingkuangUpdateUI extends JFrame {
|
|
|
|
private JPanel contentPane;
|
|
|
|
|
|
|
|
ShouruqingkuangymDao dao = new ShouruqingkuangymImpl();
|
|
//ZhuhuDao zhuhuhuzhuymdao = new ZhuhuImpl();
|
|
public ShouruqingkuangUpdateUI() {
|
|
init(null);
|
|
}
|
|
public ShouruqingkuangUpdateUI(Tableinter mui) {
|
|
init(mui);
|
|
}
|
|
public void init(Tableinter mui) {
|
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
|
setBounds(100, 100, 643, 646);
|
|
contentPane = new JPanel();
|
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
|
setContentPane(contentPane);
|
|
contentPane.setLayout(null);
|
|
Shouruqingkuangym shouruqingkuang = dao.findByIdym((String) mui.getTable().getValueAt(mui.getTable().getSelectedRow(), 0));
|
|
JPanel panel = new BackgroundPanel();
|
|
contentPane.add(panel);
|
|
panel.setLayout(new GridLayout(0, 2, 0, 0));
|
|
JLabel idlabel = new JLabel("id");
|
|
idlabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
panel.add(idlabel);
|
|
JTextField idtextField = new JTextField(shouruqingkuang.getId().toString());
|
|
idtextField.setEnabled(false);
|
|
panel.add(idtextField);
|
|
JLabel mingxiymlabel = new JLabel("明细");
|
|
mingxiymlabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
panel.add(mingxiymlabel);
|
|
JTextField mingxiymtextField = new JTextField(shouruqingkuang.getMingxiym());
|
|
panel.add(mingxiymtextField);
|
|
|
|
JLabel fashengriqiymlabel = new JLabel("发生日期");
|
|
fashengriqiymlabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
panel.add(fashengriqiymlabel);
|
|
DatePicker fashengriqiymtextField = new DatePicker(this);
|
|
fashengriqiymtextField.setPattern("yyyy-MM-dd");
|
|
fashengriqiymtextField.setTimePanleVisible(true);
|
|
fashengriqiymtextField.setEditorable(false);
|
|
try {
|
|
fashengriqiymtextField.setDate(new SimpleDateFormat("yyyy-MM-dd").parse(shouruqingkuang.getFashengriqiym()));
|
|
} catch (ParseException e1) {
|
|
e1.printStackTrace();
|
|
}
|
|
panel.add(fashengriqiymtextField);
|
|
|
|
JLabel fashengfeiyongymlabel = new JLabel("发生费用");
|
|
fashengfeiyongymlabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
panel.add(fashengfeiyongymlabel);
|
|
JTextField fashengfeiyongymtextField = new JTextField(shouruqingkuang.getFashengfeiyongym());
|
|
panel.add(fashengfeiyongymtextField);
|
|
|
|
JLabel huzhuymlabel = new JLabel("户主");
|
|
huzhuymlabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
panel.add(huzhuymlabel);
|
|
|
|
JComboBox huzhuymcomboBox = new JComboBox();
|
|
//List<Zhuhu> zhuhuhuzhuymlist=zhuhuhuzhuymdao.findAll();
|
|
huzhuymcomboBox.addItem("");
|
|
for (int i = 0; i < zhuhuhuzhuymlist.size(); i++) {
|
|
huzhuymcomboBox.addItem(zhuhuhuzhuymlist.get(i).getHuzhudxy());
|
|
}
|
|
huzhuymcomboBox.setSelectedItem(shouruqingkuang.getHuzhuym());
|
|
panel.add(huzhuymcomboBox);
|
|
|
|
|
|
|
|
panel.setBounds(10, 10, 607, 150);
|
|
JButton button = new JButton("修改");
|
|
/**
|
|
修改按钮触发事件
|
|
*/
|
|
button.addMouseListener(new MouseAdapter() {
|
|
public void mouseClicked(MouseEvent e) {
|
|
|
|
Shouruqingkuangym bean=new Shouruqingkuangym();
|
|
bean.setMingxiym(mingxiymtextField.getText());
|
|
|
|
bean.setFashengriqiym(fashengriqiymtextField.getText());
|
|
|
|
bean.setFashengfeiyongym(fashengfeiyongymtextField.getText());
|
|
|
|
if(huzhuymcomboBox.getSelectedItem()!=null){
|
|
bean.setHuzhuym(huzhuymcomboBox.getSelectedItem().toString());
|
|
}else{
|
|
bean.setHuzhuym("");
|
|
}
|
|
|
|
bean.setId(Integer.valueOf(idtextField.getText()));
|
|
|
|
|
|
dao.modify(bean);
|
|
JOptionPane.showMessageDialog(null, "修改成功");
|
|
//刷新主界面列表
|
|
if(mui!=null)
|
|
mui.refresh(dao.findAll());
|
|
dispose();
|
|
}
|
|
});
|
|
button.setFont(new Font("宋体", Font.PLAIN, 20));
|
|
button.setBounds(173, 550, 93, 47);
|
|
contentPane.add(button);
|
|
|
|
JButton button_1 = new JButton("取消");
|
|
/**
|
|
取消按钮触发事件
|
|
*/
|
|
button_1.addMouseListener(new MouseAdapter() {
|
|
public void mouseClicked(MouseEvent e) {
|
|
dispose();
|
|
}
|
|
});
|
|
button_1.setFont(new Font("宋体", Font.PLAIN, 20));
|
|
button_1.setBounds(334, 550, 93, 47);
|
|
contentPane.add(button_1);
|
|
this.setLocationRelativeTo(null);
|
|
}
|
|
public String getRadioValue(JPanel panel){
|
|
for(Component c:panel.getComponents()){
|
|
if(c instanceof JRadioButton){
|
|
if(((JRadioButton) c).isSelected()){
|
|
return ((JRadioButton)c).getText();
|
|
}
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
}
|