📄 monthdatainputframe.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import java.util.*;
import javax.swing.event.*;
public class MonthDataInputFrame extends JFrame //implements ActionListener
{
private JButton button1, button2, button3;
private JLabel uptownlabel, buildinglabel, roomlabel[], waterlabel[], elelabel[], gaslabel[], datelabel;
private JTextField waterfield[], elefield[], gasfield[], datefield;
private JComboBox uptownselect, buildingselect;
private String uptownname[], uptownid[], buildingid[], roomid[], building_select, selectuptown, selectbuilding, sqlinsert[], uptownid_select;
private String water[], ele[], gas[], delsql, date_in;
//private Box boxes[], subboxes[];
private int roomcount,lastwater[],lastele[],lastgas[],checktime,inputdate,lastdate,deldate,lastyear,lastmonth,delyear,delmonth,uptowncount,buildingcount;
private String lastroomid[], uptown, building, inputbuilding, in_uptown, in_building, message2;
//private JPanel panelin;
//private int state;
private GridBagConstraints c;
private Insets inset;
private GridBagLayout gridbag;
private int time,t,type,nullvalue;
//final Container panelin;
/*public MonthDataInputFrame(JPanel p)
{
this.panelin=p;
panelin.removeAll();
mainperform();
setSize(350,300);
setVisible(true);
}*/
public MonthDataInputFrame(int tt)
{
super("选择小区和楼宇");
type=tt;
mainperform(type);
//mainperform("qwqw");
time = 0;
t=0;
}
public MonthDataInputFrame(String uptown, String uptown_id, int tt)
{
super("选择小区和楼宇");
type = tt;
mainperform(uptown,uptown_id,type);
//mainperform("qwqw");
time = 0;
}
public MonthDataInputFrame(String uptown,String building,String uptown_id)
{
super("输入数据");
mainperform(uptown,building,uptown_id);
//mainperform("qwqw");
time = 0;
}
/*public void actionPerformed(ActionEvent e)
{
mainperform();
}*/
public void mainperform(int tt)//无参数输入
{
Container panelin = getContentPane();
panelin.removeAll();
gridbag=new GridBagLayout();
panelin.setLayout(gridbag);
buildingid=new String[150];
buildingid[0]=new String("选择楼宇");
uptownid = new String[100];
uptownname = new String[100];
uptownname[0]=new String("选择小区");
roomid = new String[150];
type = tt;
getuptown();
uptownlabel = new JLabel( "选择小区" );
uptownlabel.setToolTipText("从下拉菜单中选择小区" );
inset = new Insets(5,5,5,5);
c = new GridBagConstraints(2,1,1,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(uptownlabel,c);
panelin.add(uptownlabel);
uptownselect = new JComboBox( uptownname );
uptownselect.setMaximumRowCount( 5 );
uptownselect.addItemListener(
new ItemListener() {
public void itemStateChanged( ItemEvent event )
{
int i=0;
i = uptownselect.getSelectedIndex();
t++;
getbuilding(uptownid[i]);
if(t<2) {
MonthDataInputFrame mdif2 = new MonthDataInputFrame(uptownname[i],uptownid[i], type);
}
MonthDataInputFrame.this.setVisible(false);
}
}
);
c = new GridBagConstraints(4,1,2,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(uptownselect,c);
panelin.add(uptownselect);
buildinglabel = new JLabel( "选择楼宇" );
buildinglabel.setToolTipText( "从下拉菜单中选择楼宇" );
c = new GridBagConstraints(2,2,1,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(buildinglabel,c);
panelin.add(buildinglabel);
buildingselect = new JComboBox( buildingid );
buildingselect.setMaximumRowCount(5);
c = new GridBagConstraints(4,2,2,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(buildingselect,c);
panelin.add(buildingselect);
button1 = new JButton( "确定" );
button1.setEnabled( false );
c = new GridBagConstraints(3,4,1,2,0,0,10,0,inset,0,0);
gridbag.setConstraints(button1,c);
panelin.add(button1);
button2 = new JButton( "返回" );
button2.addActionListener(
new ActionListener(){
public void actionPerformed( ActionEvent event){
MonthDataInputFrame.this.setVisible(false);
//MonthDataInputFrame mdif1 = new MonthDataInputFrame();
}
}
);
c = new GridBagConstraints(5,4,1,2,0,0,10,0,inset,0,0);
gridbag.setConstraints(button2,c);
panelin.add(button2);
/*button3 = new JButton( "重置" );
button3.setEnabled( false );
button3.setToolTipText( "清空输入的内容,以重新输入" );
c = new GridBagConstraints(7,4,1,2,0,0,10,0,inset,0,0);
gridbag.setConstraints(button3,c);
panelin.add(button3);*/
panelin.setVisible(true);
setSize(350,300);
setVisible(true);
}
public void mainperform( String inuptown, String inuptownid, int tt)//输入参数小区名
{
time++;
Container panelin = getContentPane();
gridbag=new GridBagLayout();
panelin.setLayout(gridbag);
//buildingid=new String[150];
uptownid = new String[100];
uptownname = new String[100];
uptownname[0] = new String(inuptown);
getuptown();
type=tt;
int i=0;
do{
i++;
}while(!uptownname[i].equals(inuptown));
buildingid=new String[150];
getbuilding(inuptownid);
buildingid[0] = new String("选择楼宇");
roomid = new String[150];
uptown = new String(inuptown);
uptownid_select = new String(inuptownid);
uptownlabel = new JLabel( "选择小区" );
uptownlabel.setToolTipText("点击选择小区" );
inset = new Insets(5,5,5,5);
c = new GridBagConstraints(2,1,1,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(uptownlabel,c);
panelin.add(uptownlabel);
//panelin.remove(uptownselect);
uptownselect = new JComboBox( uptownname );
uptownselect.setSelectedIndex(i);
uptownselect.setMaximumRowCount( 5 );
uptownselect.addItemListener(
new ItemListener() {
public void itemStateChanged( ItemEvent event )
{
int i=0;
i = uptownselect.getSelectedIndex();
t++;
getbuilding(uptownid[i]);
//while(i==0)JOptionPane.showMessageDialog(null,"请选择正确的小区名称");
//getbuilding(uptownid[i]);
//System.out.println(uptown[i]);
if(t<2) {
MonthDataInputFrame mdif2 = new MonthDataInputFrame(uptownname[i],uptownid[i], type);
}
//panelin.repaint();
MonthDataInputFrame.this.setVisible(false);
}
}
);
c = new GridBagConstraints(4,1,2,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(uptownselect,c);
panelin.add(uptownselect);
buildinglabel = new JLabel( "选择楼宇" );
buildinglabel.setToolTipText( "点击选择楼宇" );
c = new GridBagConstraints(2,2,1,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(buildinglabel,c);
panelin.add(buildinglabel);
buildingselect = new JComboBox( buildingid );
buildingselect.setMaximumRowCount(5);
buildingselect.addItemListener(
new ItemListener() {
public void itemStateChanged( ItemEvent event )
{
int i=0;
i = buildingselect.getSelectedIndex();
inputbuilding = buildingid[i];
//MonthDataInputFrame mdif3 = new MonthDataInputFrame(uptown,buildingid[i]);
}
}
);
c = new GridBagConstraints(4,2,2,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(buildingselect,c);
panelin.add(buildingselect);
button1 = new JButton( "确定" );
button1.addActionListener(
new ActionListener(){
public void actionPerformed( ActionEvent event) {
if(type==1) {
MonthDataInputFrame mdif3 = new MonthDataInputFrame( uptown, inputbuilding, uptownid_select);
MonthDataInputFrame.this.setVisible(false);
}
else if(type==2){
ChargeReport elecReport = new ChargeReport("电费收费报表",Integer.parseInt(uptownid_select),Integer.parseInt(inputbuilding));
}
else if(type==3){
ChargeReport waterReport = new ChargeReport("水费收费报表",Integer.parseInt(uptownid_select),Integer.parseInt(inputbuilding));
}
else if(type==4){
ChargeReport gasReport = new ChargeReport("煤气费收费报表",Integer.parseInt(uptownid_select),Integer.parseInt(inputbuilding));
}
MonthDataInputFrame.this.setVisible(false);
}
}
);
c = new GridBagConstraints(3,4,1,2,0,0,10,0,inset,0,0);
gridbag.setConstraints(button1,c);
panelin.add(button1);
button2 = new JButton( "返回" );
button2.addActionListener(
new ActionListener(){
public void actionPerformed( ActionEvent event){
MonthDataInputFrame.this.setVisible(false);
}
}
);
c = new GridBagConstraints(5,4,1,2,0,0,10,0,inset,0,0);
gridbag.setConstraints(button2,c);
panelin.add(button2);
/*button3 = new JButton( "重置" );
button3.setEnabled( false );
button3.setToolTipText( "清空输入的内容,以重新输入" );
button3.setToolTipText( "清空输入的内容,以重新输入" );
c = new GridBagConstraints(7,4,1,2,0,0,10,0,inset,0,0);
gridbag.setConstraints(button3,c);
panelin.add(button3);*/
panelin.repaint();
panelin.setVisible(true);
setSize(350,300);
setVisible(true);
}
public void mainperform( String inuptown,String inbuilding, String id)//输入参数楼房号和小区号
{
Container panelin = getContentPane();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -