⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datehistorysearch.java

📁 小区物业管理系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
					t++;
					inuptownname=new String(uptown_name3[i]);
					inuptownid=new String(uptown_id3[i]);
					if(t==1)
					{
						DateHistorySearch dhs1=new DateHistorySearch(3,inuptownid, inuptownname);
					}
					DateHistorySearch.this.setVisible(false);
				}
			}
			);
		dateLabel[2]=new JLabel("时间");
		c = new GridBagConstraints(5,7,1,1,0,0,10,0,inset,0,0);
		gridbag.setConstraints(dateLabel[2],c);
		panelin.add(dateLabel[2]);
		
		date3=new String[4];
		date3[0]=new String("选择时间");
		dateBox3=new JComboBox(date3);
		dateBox3.setMaximumRowCount( 5 );
		c = new GridBagConstraints(6,7,1,1,0,0,10,0,inset,0,0);
		gridbag.setConstraints(dateBox3,c);
		panelin.add(dateBox3);
		
		button3=new JButton("确定");
		c = new GridBagConstraints(11,7,1,1,0,0,10,0,inset,0,0);
		gridbag.setConstraints(button3,c);
		panelin.add(button3);
		button3.setEnabled(false);
		
		System.out.println("step 3 end");
		
		titleLabel4=new JLabel("4、查询小区内某栋楼的全部业主");
		c = new GridBagConstraints(2,8,2,1,0,0,10,0,inset,0,0);
		gridbag.setConstraints(titleLabel4,c);
		panelin.add(titleLabel4);
		
		uptownLabel[2]=new JLabel("小区选择");
		c = new GridBagConstraints(2,9,1,1,0,0,10,0,inset,0,0);
		gridbag.setConstraints(uptownLabel[2],c);
		panelin.add(uptownLabel[2]);
		
		uptownBox[2]=new JComboBox(uptown_name4);
		uptownBox[2].setMaximumRowCount( 5 );
		c = new GridBagConstraints(3,9,1,1,0,0,10,0,inset,0,0);
		gridbag.setConstraints(uptownBox[2],c);
		panelin.add(uptownBox[2]);
		uptownBox[2].addItemListener(
			new ItemListener() {
				public void itemStateChanged( ItemEvent event )
				{
					int i=0;
					i = uptownBox[2].getSelectedIndex();
					t++;
					inuptownname=new String(uptown_name4[i]);
					inuptownid=new String(uptown_id4[i]);
					if(t==1)
					{
						DateHistorySearch dhs1=new DateHistorySearch(4,inuptownid, inuptownname);
					}
					DateHistorySearch.this.setVisible(false);
				}
			}
			);
		
		buildingLabel=new JLabel("楼宇选择");
		c = new GridBagConstraints(5,9,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(6,9,1,1,0,0,10,0,inset,0,0);
		gridbag.setConstraints(buildingBox,c);
		panelin.add(buildingBox);
		buildingBox.addItemListener(
			new ItemListener() {
				public void itemStateChanged( ItemEvent event )
				{
					int i=0;
					i = buildingBox.getSelectedIndex();
					t++;
					inbuilding=new String(building_id[i]);
					if(t==1)
					{
						DateHistorySearch dhs1=new DateHistorySearch(inuptownid, inuptownname, inbuilding);
					}
					DateHistorySearch.this.setVisible(false);
				}
			}
			);
		
		dateLabel[3]=new JLabel("时间");
		c = new GridBagConstraints(8,9,1,1,0,0,10,0,inset,0,0);
		gridbag.setConstraints(dateLabel[3],c);
		panelin.add(dateLabel[3]);
		
		
		dateBox4=new JComboBox(date4);
		dateBox4.setMaximumRowCount( 5 );
		c = new GridBagConstraints(9,9,1,1,0,0,10,0,inset,0,0);
		gridbag.setConstraints(dateBox4,c);
		panelin.add(dateBox4);
		dateBox4.addItemListener(
			new ItemListener() {
				public void itemStateChanged( ItemEvent event )
				{
					int i=0;
					i = dateBox4.getSelectedIndex();
					t++;
					indate=new String(date4[i]);
				}
			}
			);
		
		button4=new JButton("确定");
		c = new GridBagConstraints(11,9,1,1,0,0,10,0,inset,0,0);
		gridbag.setConstraints(button4,c);
		panelin.add(button4);
		button4.addActionListener( 
			new ActionListener(){
				public void actionPerformed( ActionEvent event) {
					if(indate.equals("选择日期"))
					{
						JOptionPane.showMessageDialog(null,"请选择日期后再按确定","Error",JOptionPane.PLAIN_MESSAGE);
					}
					else
					{
						UptownBuildingRoomShow ubrs=new UptownBuildingRoomShow(inuptownid,inuptownname,inbuilding,indate);
						DateHistorySearch.this.setVisible(false);
					}
				}
			}
			);
		//button4.setVisible(false);
		
		setSize(800,600);
		setVisible(true);
	}
	
	public void getdate1()
	{
		date1 =new String[6];
		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 ORDER BY date";
			ResultSet rs1 = stmt1.executeQuery(sqlUptown);
			
			System.out.println("the 00");
		
			int i= 1;
			date1[0]=new String("选择日期");
			while( rs1.next() )
			{
				date1[i] = rs1.getString( "date" );
				i++;
			}
			
			//System.out.println("the 01");
			
			rs1.close();
			connection1.close();
		}
		
		catch( Exception ex ) {
			System.out.println(ex);
			//System.exit(0);
		}
	}
	
	public void getdate2(String uptownid)
	{
		date2=new String[6];
		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 building_elec_reading WHERE district_id="+uptownid+" ORDER BY date";
			ResultSet rs1 = stmt1.executeQuery(sqlUptown);
			
			System.out.println("the 00");
		
			int i= 1;
			date2[0]=new String("选择日期");
			while( rs1.next() )
			{
				date2[i] = rs1.getString( "date" );
				i++;
			}
			
			//System.out.println("the 01");
			
			rs1.close();
			connection1.close();
		}
		
		catch( Exception ex ) {
			System.out.println(ex);
			//System.exit(0);
		}
	}
	
	public void getdate3(String uptownid)
	{
		date3=new String[6];
		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 user_reading WHERE district_id="+uptownid+" ORDER BY date";
			ResultSet rs1 = stmt1.executeQuery(sqlUptown);
			
			System.out.println("the 00");
		
			int i= 1;
			date3[0]=new String("选择日期");
			while( rs1.next() )
			{
				date3[i] = rs1.getString( "date" );
				i++;
			}
			
			//System.out.println("the 01");
			
			rs1.close();
			connection1.close();
		}
		
		catch( Exception ex ) {
			System.out.println(ex);
			//System.exit(0);
		}
	}
	
	public void getdate4(String uptownid, String buildingid)
	{
		date4=new String[6];
		try
		{
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			String url1 = "jdbc:odbc:estate";
			Connection connection1 = DriverManager.getConnection(url1);
			Statement stmt1 = connection1.createStatement(); 
			String sqlUptown = "SELECT distinct date FROM user_reading WHERE district_id="+uptownid+" AND building_id="+buildingid+" ORDER BY date";
			ResultSet rs1 = stmt1.executeQuery(sqlUptown);
			
			System.out.println("the 00");
		
			int i= 1;
			date4[0]=new String("选择日期");
			while( rs1.next() )
			{
				date4[i] = rs1.getString( "date" );
				i++;
			}
			
			//System.out.println("the 01");
			
			rs1.close();
			connection1.close();
		}
		
		catch( Exception ex ) {
			System.out.println(ex);
			//System.exit(0);
		}
	}
	
	public void getuptown()//获取小区信息
	{
		uptown_name2=new String[50];
		uptown_id2=new String[50];
		uptown_name3=new String[50];
		uptown_id3=new String[50];
		uptown_name4=new String[50];
		uptown_id4=new String[50];
		
		try
		{
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			String url1 = "jdbc:odbc:estate";
			Connection connection1 = DriverManager.getConnection(url1);
			Statement stmt1 = connection1.createStatement(); 
			String sqlUptown = "SELECT district_id,district_name FROM district_info ORDER BY district_id";
			ResultSet rs1 = stmt1.executeQuery(sqlUptown);
			
			System.out.println("the 00");
		
			int i= 1;
			while( rs1.next() )
			{
				uptown_id2[i] = rs1.getString( "district_id" );
				uptown_name2[i] = rs1.getString( "district_name" );
				//uptown_id3[i] = rs1.getString( "district_id" );
				//uptown_name3[i] = rs1.getString( "district_name" );
				//uptown_id4[i] = rs1.getString( "district_id" );
				//uptown_name4[i] = rs1.getString( "district_name" );
				i++;
			}
			
			for(int j=1;j<i;j++)
			{
				uptown_id3[j] = new String(uptown_id2[j]);
				uptown_name3[j] = new String(uptown_name2[j]);
				uptown_id4[j] = new String(uptown_id2[j]);
				uptown_name4[j] = new String(uptown_name2[j]);
			}
			uptown_name2[0]=new String("选择小区");
			uptown_name3[0]=new String("选择小区");
			uptown_name4[0]=new String("选择小区");
			//System.out.println("the 01");
			
			rs1.close();
			connection1.close();
		}
		
		catch( Exception ex ) {
			System.out.println(ex);
			System.out.println("getuptown() error");
			uptown_name2[0]=new String("没有小区");
			uptown_name3[0]=new String("没有小区");
			uptown_name4[0]=new String("没有小区");
			//System.exit(0);
		}//完成取小区信息
	}
	
	public void getbuilding(String uptown)//获取小区内的楼宇信息
	{
		
		System.out.println("the 04");
		building_id=new String[100];
		try{
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			String url2 = "jdbc:odbc:estate";
			Connection connection2 = DriverManager.getConnection(url2);
			Statement stmt2 = connection2.createStatement();
			String sqlBuilding = "SELECT building_id FROM building_info WHERE district_id="+uptown+" ORDER BY building_id";
			System.out.println("the 041");
			ResultSet rs2 = stmt2.executeQuery(sqlBuilding);
						
			int i = 1;
			while( rs2.next() )
			{
				building_id[i] = rs2.getString( "building_id" );
				i++;
			}
			building_id[0]=new String("选择楼宇");
			//count = i;
			//System.out.println("the 11");
			//panelin.repaint();
			rs2.close();
			connection2.close();
		}
					
		catch( Exception ex )
		{
			System.out.println( ex );
			//System.exit(0);
		}
	}
	
	public static void main(String args[])
	{
		DateHistorySearch ap = new DateHistorySearch();
		ap.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -