📄 fuwuqi.java
字号:
if(xinxis[0].trim().equals("初始化")) //如果得到的是初始化的消息
{
String chushihua="初始化";
this.resultset=this.stmt.executeQuery(xinxis[1]);
while(this.resultset.next()) //将课程信息传给客户端
{
chushihua=chushihua+":"+ resultset.getString(1) +","+resultset.getString(2)
+","+resultset.getString(3);
}
if(chushihua.trim().equals("初始化"))
{
chushihua="无课程初始化信息";
}
this.dataout.writeUTF(chushihua);
}
if(xinxis[0].trim().equals("查询用户合法性")) //查询用户合法性的语句
{
System.out.println(xinxis[1]);
this.resultset=this.stmt.executeQuery(xinxis[1]);
if(this.resultset.next())
{
System.out.println("dasj;fjaskfjasdjfa;sdjfsadjf;lasdjflsadjf");
this.dataout.writeUTF("是合法用户");
String str=this.datain.readUTF();
System.out.println(str);
xinxis=str.split(":");
int i=0;
int j=0;
try
{
this.stmt.executeUpdate(xinxis[1]);
i=this.stmt.executeUpdate(xinxis[2]);
if(xinxis.length==5)
{
this.stmt.executeUpdate(xinxis[3]);
j=this.stmt.executeUpdate(xinxis[4]);
}
else
{
j=1;
}
}
catch(Exception ex)
{
this.dataout.writeUTF(ex.toString());
}
if(i>0 && j>0)
{
this.dataout.writeUTF("成绩上传成功!");
}
else
{
this.dataout.writeUTF("成绩上传失败!");
}
}
else
{
this.dataout.writeUTF("用户不存在");
}
}
if(xinxis[0].equals("密码修改"))
{
System.out.println(xinxis[1]);
try
{
this.resultset=this.stmt.executeQuery(xinxis[1]);
if(this.resultset.next())
{
this.dataout.writeUTF("密码修改合法用户");
String sqlxiugai=this.datain.readUTF();
int i=this.stmt.executeUpdate(sqlxiugai);
if(i>0)
{
this.dataout.writeUTF("密码修改成功");
}
else
{
this.dataout.writeUTF("密码修改失败!");
}
}
else
{
this.dataout.writeUTF("密码修改的非法用户");
}
}
catch(Exception ex)
{
this.dataout.writeUTF("修改过程中发生异常!");
}
}
if(xinxis[0].trim().equals("精确查询"))
{
String jieguo="";
String name="";
int i=0;
this.resultset=this.stmt.executeQuery("select 姓名 from 用户信息表 where 学号='"+xinxis[1].trim()+"'");
while(this.resultset.next())
{
name=this.resultset.getString("姓名");
jieguo=xinxis[1]+","+name;
}
if(name.length()==0)
{
this.dataout.writeUTF("无结果");
}
else
{
this.resultset=this.stmt.executeQuery("select * from 综合测评成绩表 order by 综合测评得分 desc");
while(this.resultset.next())
{
i++;
if(this.resultset.getString(1).equals(xinxis[1].trim()))
{
jieguo+=","+this.resultset.getFloat(2)+","
+this.resultset.getFloat(3)+","+this.resultset.getFloat(4)
+","+this.resultset.getFloat(5)+","+this.resultset.getFloat(6)
+","+i;
break;
}
}
System.out.println(i);
i=0;
this.resultset=this.stmt.executeQuery("select * from 综合测评成绩表 order by 业务学习 desc");
while(this.resultset.next())
{
i++;
if(this.resultset.getString(1).equals(xinxis[1]))
break;
}
jieguo=jieguo+"," +i;
this.dataout.writeUTF(jieguo);
}
}
if(xinxis[0].trim().equals("模糊查询"))
{
try
{
String mohuchaxunjieguo="模糊查询结果";
this.resultset=this.stmt.executeQuery(xinxis[1]);
while(this.resultset.next())
{
mohuchaxunjieguo+=":"+this.resultset.getString("学号")+","+this.resultset.getString("姓名")+
","+this.resultset.getFloat("政治素质")+","+this.resultset.getFloat("业务学习")+
","+this.resultset.getFloat("智能素质")+","+this.resultset.getFloat("体育素质")+
","+this.resultset.getFloat("综合测评得分");
}
this.dataout.writeUTF(mohuchaxunjieguo);
}
catch(Exception ex )
{
this.dataout.writeUTF("查询发生异常");
}
}
if(xinxis[0].trim().equals("比例查询"))
{
try
{
String temp="比例查询结果";
this.resultset=this.stmt.executeQuery("select count(*) from 综合测评成绩表");
this.resultset.next();
temp+=":"+this.resultset.getInt(1);
this.resultset=this.stmt.executeQuery("select count(*) from 综合测评成绩表 where 综合测评得分<80");
this.resultset.next();
temp+=":"+this.resultset.getInt(1);
this.resultset=this.stmt.executeQuery("select count(*) from 综合测评成绩表 where 综合测评得分>=80 and 综合测评得分<85");
this.resultset.next();
temp+=":"+this.resultset.getInt(1);
this.resultset=this.stmt.executeQuery("select count(*) from 综合测评成绩表 where 综合测评得分>=85 and 综合测评得分<90");
this.resultset.next();
temp+=":"+this.resultset.getInt(1);
this.resultset=this.stmt.executeQuery("select count(*) from 综合测评成绩表 where 综合测评得分>=90");
this.resultset.next();
temp+=":"+this.resultset.getInt(1);
this.resultset=this.stmt.executeQuery("select count(*) from 综合测评成绩表");
this.resultset.next();
temp+=":"+this.resultset.getInt(1);
this.resultset=this.stmt.executeQuery("select count(*) from 综合测评成绩表 where 业务学习<40");
this.resultset.next();
temp+=":"+this.resultset.getInt(1);
this.resultset=this.stmt.executeQuery("select count(*) from 综合测评成绩表 where 业务学习>=40 and 业务学习<45");
this.resultset.next();
temp+=":"+this.resultset.getInt(1);
this.resultset=this.stmt.executeQuery("select count(*) from 综合测评成绩表 where 业务学习>=45 and 业务学习<50");
this.resultset.next();
temp+=":"+this.resultset.getInt(1);
this.resultset=this.stmt.executeQuery("select count(*) from 综合测评成绩表 where 业务学习>=50");
this.resultset.next();
temp+=":"+this.resultset.getInt(1);
dataout.writeUTF(temp);
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
this.datain.close();
this.dataout.close();
this.socket.close();
this.datain=null;
this.dataout=null;
this.socket=null;
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
}
class Intext extends TextField implements TextListener //输入float 文本眶
{
public Intext()
{
super(15);
this.addTextListener(this);
}
public void textValueChanged(TextEvent e) //实现文本监听器,检测输入的合法性
{
String s=this.getText();
char[] c=s.toCharArray();
for(int i=0;i<c.length;i++)
{
if(!Character.isDigit(c[i]) && c[i]!='.')
{
JOptionPane.showMessageDialog(null,"你输入的应该为数字!");
this.setText("0");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -