📄 historydata.java
字号:
c = new GridBagConstraints(2,4,1,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(dateLabel,c);
panelin.add(dateLabel);
datebox=new JComboBox( date );
datebox.setMaximumRowCount( 5 );
c = new GridBagConstraints(4,4,2,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(datebox,c);
panelin.add(datebox);
button3 = new JButton( "确定" );
button3.setEnabled( false );
c = new GridBagConstraints(3,6,1,2,0,0,10,0,inset,0,0);
gridbag.setConstraints(button3,c);
panelin.add(button3);
button4 = new JButton( "返回" );
button4.addActionListener(
new ActionListener(){
public void actionPerformed( ActionEvent event){
HistoryData.this.setVisible(false);
//MonthDataInputFrame mdif1 = new MonthDataInputFrame();
}
}
);
c = new GridBagConstraints(5,6,1,2,0,0,10,0,inset,0,0);
gridbag.setConstraints(button4,c);
panelin.add(button4);
setSize(350,300);
setVisible(true);
}
public void uptowndata(String uptownid, String uptownname)
{
Container panelin = getContentPane();
gridbag=new GridBagLayout();
panelin.setLayout(gridbag);
inuptownid=new String(uptownid);
inuptownname=new String(uptownname);
uptown_name=new String[100];
uptown_id=new String[100];
date=new String[4];
uptown_name[0]=new String(uptownname);
getuptown();
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url1 = "jdbc:odbc:estate";
Connection connection1 = DriverManager.getConnection(url1);
Statement stmt1 = connection1.createStatement();
String sqlUptown = "SELECT date FROM district_reading WHERE district_id="+inuptownid;
ResultSet rs1 = stmt1.executeQuery(sqlUptown);
System.out.println("the 00");
int i= 1;
while( rs1.next() )
{
date[i] = rs1.getString( "date" );
i++;
}
date[0]=new String("全部");
//System.out.println("the 01");
rs1.close();
connection1.close();
}
catch( Exception ex ) {
System.out.println(ex);
date[0]=new String("没有数据");
//System.exit(0);
}
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);
uptownbox = new JComboBox( uptown_name );
uptownbox.setMaximumRowCount( 5 );
System.out.println("the out");
uptownbox.addItemListener(
new ItemListener() {
public void itemStateChanged( ItemEvent event )
{
int i=0;
i = uptownbox.getSelectedIndex();
//getbuilding(uptownid[i]);
inuptownid = new String(uptown_id[i]);
inuptownname = new String( uptown_name[i]);
//setVisible(true);
if(t==0)
{
HistoryData hd1= new HistoryData(1,inuptownid,inuptownname);
}
HistoryData.this.setVisible(false);
t++;
}
}
);
c = new GridBagConstraints(4,1,2,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(uptownbox,c);
panelin.add(uptownbox);
dateLabel = new JLabel("选择日期");
c = new GridBagConstraints(2,4,1,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(dateLabel,c);
panelin.add(dateLabel);
datebox=new JComboBox( date );
datebox.setMaximumRowCount( 5 );
datebox.addItemListener(
new ItemListener(){
public void itemStateChanged( ItemEvent event )
{
int i=0;
i=datebox.getSelectedIndex();
if(i>0)
{
indate=Integer.parseInt(date[i] );
}
else
{
indate=0;
}
}
}
);
c = new GridBagConstraints(4,4,2,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(datebox,c);
panelin.add(datebox);
button3 = new JButton( "确定" );
button3.setEnabled( true );
button3.addActionListener(
new ActionListener(){
public void actionPerformed( ActionEvent event){
if(indate==0){
HistoryData hd1= new HistoryData(inuptownid,inuptownname);
}
else
{
HistoryData hd1= new HistoryData(inuptownid,inuptownname,indate);
}
HistoryData.this.setVisible(false);
//MonthDataInputFrame mdif1 = new MonthDataInputFrame();
}
}
);
c = new GridBagConstraints(3,6,1,2,0,0,10,0,inset,0,0);
gridbag.setConstraints(button3,c);
panelin.add(button3);
button4 = new JButton( "返回" );
button4.addActionListener(
new ActionListener(){
public void actionPerformed( ActionEvent event){
HistoryData.this.setVisible(false);
//MonthDataInputFrame mdif1 = new MonthDataInputFrame();
}
}
);
c = new GridBagConstraints(5,6,1,2,0,0,10,0,inset,0,0);
gridbag.setConstraints(button4,c);
panelin.add(button4);
setSize(350,300);
setVisible(true);
}
public void buildingdata()
{
Container panelin = getContentPane();
gridbag=new GridBagLayout();
panelin.setLayout(gridbag);
uptown_id=new String[100];
uptown_name=new String[100];
building_id=new String[150];
date=new String[4];
uptown_name[0]=new String("选择小区");
building_id[0]=new String("选择楼号");
date[0]=new String("选择日期");
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);
uptownbox = new JComboBox( uptown_name );
uptownbox.setMaximumRowCount( 5 );
System.out.println("the out");
uptownbox.addItemListener(
new ItemListener() {
public void itemStateChanged( ItemEvent event )
{
int i=0;
i = uptownbox.getSelectedIndex();
getbuilding(uptown_id[i]);
inuptownid = new String(uptown_id[i]);
inuptownname = new String( uptown_name[i]);
//setVisible(true);
if(t==0)
{
HistoryData hd1= new HistoryData(2,inuptownid,inuptownname);
}
t++;
HistoryData.this.setVisible(false);
}
}
);
c = new GridBagConstraints(4,1,2,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(uptownbox,c);
panelin.add(uptownbox);
buildingLabel=new JLabel("选择楼号");
c = new GridBagConstraints(2,4,1,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(buildingLabel,c);
panelin.add(buildingLabel);
buildingbox=new JComboBox( building_id );
buildingbox.setMaximumRowCount( 5 );
c = new GridBagConstraints(4,4,2,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(buildingbox,c);
panelin.add(buildingbox);
dateLabel=new JLabel("选择日期");
c = new GridBagConstraints(2,6,1,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(dateLabel,c);
panelin.add(dateLabel);
datebox=new JComboBox( date );
datebox.setMaximumRowCount( 5 );
c = new GridBagConstraints(4,6,2,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(datebox,c);
panelin.add(datebox);
button3 = new JButton( "确定" );
button3.setEnabled( false );
c = new GridBagConstraints(3,8,1,2,0,0,10,0,inset,0,0);
gridbag.setConstraints(button3,c);
panelin.add(button3);
button4 = new JButton( "返回" );
button4.addActionListener(
new ActionListener(){
public void actionPerformed( ActionEvent event){
HistoryData.this.setVisible(false);
//MonthDataInputFrame mdif1 = new MonthDataInputFrame();
}
}
);
c = new GridBagConstraints(5,8,1,2,0,0,10,0,inset,0,0);
gridbag.setConstraints(button4,c);
panelin.add(button4);
setSize(350,300);
setVisible(true);
}
public void buildingdata(String uptownid, String uptownname)
{
Container panelin = getContentPane();
gridbag=new GridBagLayout();
panelin.setLayout(gridbag);
uptown_id=new String[100];
uptown_name=new String[100];
building_id=new String[150];
date=new String[4];
uptown_name[0]=new String(uptownname);
building_id[0]=new String("选择楼号");
date[0]=new String("选择日期");
inuptownid=new String(uptownid);
inuptownname=new String(uptownname);
getuptown();
getbuilding(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);
uptownbox = new JComboBox( uptown_name );
uptownbox.setMaximumRowCount( 5 );
System.out.println("the out");
uptownbox.addItemListener(
new ItemListener() {
public void itemStateChanged( ItemEvent event )
{
int i=0;
i = uptownbox.getSelectedIndex();
getbuilding(uptown_id[i]);
inuptownid = new String(uptown_id[i]);
inuptownname = new String( uptown_name[i]);
//setVisible(true);
if(t==0)
{
HistoryData hd1= new HistoryData(2,inuptownid,inuptownname);
}
t++;
HistoryData.this.setVisible(false);
}
}
);
c = new GridBagConstraints(4,1,2,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(uptownbox,c);
panelin.add(uptownbox);
buildingLabel=new JLabel("选择楼号");
c = new GridBagConstraints(2,4,1,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(buildingLabel,c);
panelin.add(buildingLabel);
buildingbox=new JComboBox( building_id );
buildingbox.addItemListener(
new ItemListener() {
public void itemStateChanged( ItemEvent event )
{
int i=0;
i = buildingbox.getSelectedIndex();
//getroom(building_id[i]);
//setVisible(true);
inbuilding=new String(building_id[i]);
if(t==0)
{
HistoryData hd2= new HistoryData(2,inuptownid,inuptownname,inbuilding);
}
t++;
HistoryData.this.setVisible(false);
}
}
);
buildingbox.setMaximumRowCount( 5 );
c = new GridBagConstraints(4,4,2,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(buildingbox,c);
panelin.add(buildingbox);
dateLabel=new JLabel("选择日期");
c = new GridBagConstraints(2,6,1,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(dateLabel,c);
panelin.add(dateLabel);
datebox=new JComboBox( date );
datebox.setMaximumRowCount( 5 );
c = new GridBagConstraints(4,6,2,1,0,0,10,0,inset,0,0);
gridbag.setConstraints(datebox,c);
panelin.add(datebox);
button3 = new JButton( "确定" );
button3.setEnabled( false );
c = new GridBagConstraints(3,8,1,2,0,0,10,0,inset,0,0);
gridbag.setConstraints(button3,c);
panelin.add(button3);
button4 = new JButton( "返回" );
button4.addActionListener(
new ActionListener(){
public void actionPerformed( ActionEvent event){
HistoryData.this.setVisible(false);
//MonthDataInputFrame mdif1 = new MonthDataInputFrame();
}
}
);
c = new GridBagConstraints(5,8,1,2,0,0,10,0,inset,0,0);
gridbag.setConstraints(button4,c);
panelin.add(button4);
setSize(350,300);
setVisible(true);
}
public void buildingdata(String uptownid,String buildingid, String uptownname)
{
Container panelin = getContentPane();
gridbag=new GridBagLayout();
panelin.setLayout(gridbag);
uptown_id=new String[100];
uptown_name=new String[100];
building_id=new String[150];
date=new String[4];
uptown_name[0]=new String(uptownname);
building_id[0]=new String(buildingid);
date[0]=new String("选择日期");
inuptownid=new String(uptownid);
inuptownname=new String(uptownname);
inbuilding=new String(buildingid);
getuptown();
getbuilding(inuptownid);
//getroom(inuptownid,inbuilding);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url2 = "jdbc:odbc:estate";
Connection connection2 = DriverManager.getConnection(url2);
Statement stmt2 = connection2.createStatement();
String sqlBuilding = "SELECT date FROM building_elec_reading WHERE district_id="+uptownid+" AND building_id="+buildingid;
System.out.println("the 041");
ResultSet rs2 = stmt2.executeQuery(sqlBuilding);
int i = 1;
while( rs2.next() )
{
date[i] = rs2.getString( "date" );
i++;
}
date[0]=new String("全部");
//System.out.println("the 11");
//panelin.repaint();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -