parent
2993c270ed
commit
402a8b9a29
@ -0,0 +1,141 @@
|
||||
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.util.List;
|
||||
|
||||
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 com.ym.dao.impl.ShouruqingkuangymImpl;
|
||||
import com.ym.entity.Shouruqingkuangym;
|
||||
|
||||
|
||||
public class ShouruqingkuangAddUI extends JFrame {
|
||||
|
||||
private JPanel contentPane;
|
||||
ShouruqingkuangymDao dao = new ShouruqingkuangymImpl();
|
||||
//ZhuhuDao zhuhuhuzhuymdao = new ZhuhuImpl();
|
||||
public ShouruqingkuangAddUI() {
|
||||
init(null);
|
||||
}
|
||||
public ShouruqingkuangAddUI(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);
|
||||
JPanel panel = new JPanel();
|
||||
contentPane.add(panel);
|
||||
panel.setLayout(new GridLayout(0, 2, 0, 0));
|
||||
JLabel mingxiymlabel = new JLabel("明细");
|
||||
mingxiymlabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
panel.add(mingxiymlabel);
|
||||
JTextField mingxiymtextField = new JTextField();
|
||||
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);
|
||||
panel.add(fashengriqiymtextField);
|
||||
|
||||
JLabel fashengfeiyongymlabel = new JLabel("发生费用");
|
||||
fashengfeiyongymlabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
panel.add(fashengfeiyongymlabel);
|
||||
JTextField fashengfeiyongymtextField = new JTextField();
|
||||
panel.add(fashengfeiyongymtextField);
|
||||
|
||||
JLabel huzhuymlabel = new JLabel("户主");
|
||||
huzhuymlabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
panel.add(huzhuymlabel);
|
||||
|
||||
JComboBox huzhuymcomboBox = new JComboBox();
|
||||
List<Zhuhu> zhuhuhuzhuymlist=zhuhuhuzhudao.findAll();
|
||||
huzhuymcomboBox.addItem("");
|
||||
for (int i = 0; i < zhuhuhuzhuymlist.size(); i++) {
|
||||
huzhuymcomboBox.addItem(zhuhuhuzhuymlist.get(i).getHuzhudxy());
|
||||
}
|
||||
panel.add(huzhuymcomboBox);
|
||||
|
||||
|
||||
|
||||
panel.setBounds(10, 10, 607, 120);
|
||||
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("");
|
||||
}
|
||||
|
||||
|
||||
dao.create(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 "";
|
||||
}
|
||||
}
|
Loading…
Reference in new issue