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

📄 chaxun.java

📁 用JAVA编写的综合测评系统毕业设计
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
					}
					catch(Exception ex)
					{
						JOptionPane.showMessageDialog(this,"网络或其他原因查询失败,请与管理员联系!");
					}
					
					
				}
			}
			   
			if(this.mohu.getState())
			{
				this.sql="模糊查询:"+this.getmohuchaxun();
				try
				{
					socket=new Socket(InetAddress.getByName(getCodeBase().getHost()),3636) ;
					datain=new DataInputStream(socket.getInputStream());
					dataout=new DataOutputStream(socket.getOutputStream());
					dataout.writeUTF(this.sql);
					String mohuchaxunjieguo=datain.readUTF();
					System.out.println(mohuchaxunjieguo);
					if(mohuchaxunjieguo.trim().equals("无结果"))
					{
						JOptionPane.showMessageDialog(this,"无符合查询条件的结果!");
					}
					else
					{
						if(mohuchaxunjieguo.trim().equals("查询发生异常"))
						{
							JOptionPane.showMessageDialog(this,"查询发生异常,请重试!");
						}
						else
						{
							this.vector.removeAllElements();
							this.tm.fireTableStructureChanged();
							String[] strmohuxianshis=mohuchaxunjieguo.split(":");
							for(int i=1;i<strmohuxianshis.length;i++)
							{
								Vector rowvector=new Vector();
								String[] strs=strmohuxianshis[i].split(",");
								for(int j=0;j<strs.length;j++)
								{
									rowvector.addElement(strs[j]);
								}
								
								this.vector.addElement(rowvector);
							}
							this.tm.fireTableStructureChanged();
							this.cardlayout.show(this,"mohuxianshi");

							
						}
						
					}
					
					
					
					datain.close();
					dataout.close();
					socket.close();
					socket=null;
				}
				catch(Exception ex)
				{
					JOptionPane.showMessageDialog(this,"网络或其他原因查询失败,请与管理员联系!");
				}
				
			}
			   
			   
	    }
	    else
	    {
	    	if(((Button)e.getSource()).equals(this.butbilixianshi))
	    	{
	    		try
	    		{
	    			socket=new Socket(InetAddress.getByName(getCodeBase().getHost()),3636) ;
					datain=new DataInputStream(socket.getInputStream());
					dataout=new DataOutputStream(socket.getOutputStream());
					dataout.writeUTF("比例查询:");
					int[] temp=new int[5];
					String strtemp=datain.readUTF();
					String[] strs=strtemp.split(":");
					for(int i=0;i<5;i++)
					{
						temp[i]=Integer.parseInt(strs[i+1].trim());
					}
					this.left.setupdate(temp);
					for(int i=0;i<5;i++)
					{
						temp[i]=Integer.parseInt(strs[i+6].trim());
					}
					this.right.setupdate(temp);
					
	    			this.cardlayout.show(this,"bilitu");
	    			datain.close();
	    			dataout.close();
	    			socket.close();
	    			socket=null;
	    		}
	    		catch(Exception ex)
	    		{
	    			JOptionPane.showMessageDialog(this,"网络或其他原因查询数据库失败,请与管理员联系!");
	    		}
	    		
	    	}
	    	else
	    	{
	    		this.cardlayout.show(this,"chaxun");
	    	}
	    	
	    	
	    
	    }
	    
	}
	
	public String getjingquechaxun()   //获取精确查询SQL语句
	{
		if(this.xuehao.getText().trim().length()==0)
		{
			JOptionPane.showMessageDialog(this,"请输入学号:");
			return "";
		}
		
		else
		{
			return this.xuehao.getText();
		}
	}
	
	
	public String getmohuchaxun()  //获取模糊查询SQL语句
	{
		String s="";
		if(this.yewudayu.getState() && this.zonghedayu.getState())
			s="select 用户信息表.学号,姓名,政治素质,业务学习,智能素质,体育素质,综合测评得分 from 综合测评成绩表,用户信息表  where 业务学习 >=" + this.yewu.getfloat()
			    + "   and 综合测评得分 >=" + this.zonghe.getfloat()+"  and  综合测评成绩表.学号=用户信息表.学号";
		if(this.yewudayu.getState() && this.zonghexiaoyu.getState())
			s="select 用户信息表.学号,姓名,政治素质,业务学习,智能素质,体育素质,综合测评得分 from 综合测评成绩表,用户信息表  where 业务学习 >=" + this.yewu.getfloat()
			    + "   and 综合测评得分 <" + this.zonghe.getfloat()+"  and  综合测评成绩表.学号=用户信息表.学号";
		if(this.yewuxiaoyu.getState() && this.zonghedayu.getState())
			s="select 用户信息表.学号,姓名,政治素质,业务学习,智能素质,体育素质,综合测评得分 from 综合测评成绩表,用户信息表  where 业务学习 <" + this.yewu.getfloat()
			    + "   and 综合测评得分 >=" + this.zonghe.getfloat()+"  and  综合测评成绩表.学号=用户信息表.学号";
		if(this.yewuxiaoyu.getState() && this.zonghexiaoyu.getState())
			s="select 用户信息表.学号,姓名,政治素质,业务学习,智能素质,体育素质,综合测评得分 from 综合测评成绩表,用户信息表  where 业务学习 <" + this.yewu.getfloat()
			    + "   and 综合测评得分 <" + this.zonghe.getfloat()+"  and  综合测评成绩表.学号=用户信息表.学号";
		if(this.zonghe.getfloat()==0 && this.yewu.getfloat()==0 ||this.zonghe.getfloat()!=0 && this.yewu.getfloat()!=0)
		{
			s+="  order by  用户信息表.学号  asc";
		}
		else
		{
			if(this.zonghe.getfloat()==0 && this.yewu.getfloat()!=0)
			   s+="  order by  业务学习  desc";
			else
			   s+="  order by 综合测评得分 desc";
		}
		    
	    return s;
	}
}

class Tu extends Panel
{
	float[] bili=new float[4];
	public Tu()
	{
		super();
		/*for(int i=0;i<4;i++)
		{
			bili[i]=f[i];
		}
		for(int i=0;i<4;i++)
		{
		   System.out.println(bili[i]);	
		}*/
	}
	public void paint(Graphics g)
	{
		int banjin;
		int middlex=(int)(this.getWidth()/2);
		int middley=(int)(this.getHeight()/2);
		if(middlex>middley)
		{
			banjin=middley-5;
		}
		else
		{
			banjin=middlex-5;
		}
		int startx=middlex-banjin;
		int starty=middley-banjin;
		int endlen=2*banjin;
		int int_red=(int)(bili[0]*360);
		int int_green=(int)(bili[1]*360);
		int int_blue=(int)(bili[2]*360);
		int int_yellow=360-int_red-int_green-int_blue;
		g.setColor(Color.red);
		g.fillArc(startx,starty,endlen,endlen,0,int_red);
		g.setColor(Color.green);
		g.fillArc(startx,starty,endlen,endlen,int_red,int_green);
		g.setColor(Color.blue);
		g.fillArc(startx,starty,endlen,endlen,int_red+int_green,int_blue);
		g.setColor(Color.yellow);
		g.fillArc(startx,starty,endlen,endlen,int_red+int_green+int_blue,int_yellow);
	}
	
	public void setbili(float[] f)
	{
		for(int i=0;i<4;i++)
		{
			bili[i]=f[i];
		}
	}
}

class Bilitu extends Zuhemianban
{
	private Tu tu=null;
	private JPanel downjp=new JPanel();
	private Graphics graphic=null;
	private TextField tzongrenshu=new TextField(10);
	private TextField thong=new TextField(10);
	private TextField tlv=new TextField(10);
	private TextField tlan=new TextField(10);
	private TextField thuang=new TextField(10);
	public Bilitu(String[] initinfo)
	{
		super(initinfo[0]);
		this.setLayout(new GridLayout(2,1));
		JPanel jp1=new JPanel();
		JPanel jp2=new JPanel();
		JPanel jp3=new JPanel();
		JPanel jp4=new JPanel();
		JPanel jp5=new JPanel();
		jp1.setBackground(Color.white);
		jp2.setBackground(Color.white);
		jp3.setBackground(Color.white);
		jp4.setBackground(Color.white);
		jp5.setBackground(Color.white);
		this.tzongrenshu.setEditable(false);
		this.thong.setEditable(false);
		this.tlv.setEditable(false);
		this.tlan.setEditable(false);
		this.thuang.setEditable(false);
		this.downjp.setLayout(new GridLayout(5,1));
		this.downjp.add(jp1);
		this.downjp.add(jp2);
		this.downjp.add(jp3);
		this.downjp.add(jp4);
		this.downjp.add(jp5);
		jp1.add(new Label("-------------------------总人数:"));
		jp1.add(this.tzongrenshu);
		Label lhong=new Label("   ");
		lhong.setBackground(Color.red);
		jp2.add(lhong);
		jp2.add(new Label(initinfo[1]));
		jp2.add(this.thong);
		Label llv=new Label("   ");
		llv.setBackground(Color.green);
		jp3.add(llv);
		jp3.add(new Label(initinfo[2]));
		jp3.add(this.tlv);
		Label llan=new Label("   ");
		llan.setBackground(Color.blue);
		jp4.add(llan);
		jp4.add(new Label(initinfo[3]));
		jp4.add(this.tlan);
		Label lhuang=new Label("   ");
		lhuang.setBackground(Color.yellow);
		jp5.add(lhuang);
		jp5.add(new Label(initinfo[4]));
		jp5.add(this.thuang);

	    this.tu=new Tu();
	    
	    this.add(this.tu);
	    this.downjp.setBackground(Color.white);
	    this.add(this.downjp);
	    
		
		
	}
	

	public void setupdate(int[] shuju)
	{
		float[] bili=new float[4];
	    for(int i=0;i<4;i++)
	    {

	    	bili[i]=((float)(shuju[i+1]))/((float)(shuju[0]));
	    }
		this.tu.setbili(bili);
		this.tzongrenshu.setText(shuju[0]+"人");
		DecimalFormat fmt=new DecimalFormat("#%");
		this.thong.setText(fmt.format(bili[0]));
		this.tlv.setText(fmt.format(bili[1]));
		this.tlan.setText(fmt.format(bili[2]));
		this.thuang.setText(fmt.format(bili[3]));
		
	}

}

⌨️ 快捷键说明

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