maintainqueryAction.java
上传用户:flow_meter
上传日期:2022-03-21
资源大小:40k
文件大小:3k
- package sql_lab;
- import org.eclipse.jface.action.Action;
- import org.eclipse.jface.dialogs.IInputValidator;
- import org.eclipse.jface.dialogs.InputDialog;
- import org.eclipse.jface.window.Window;
- import org.eclipse.swt.widgets.Display;
- import org.eclipse.swt.widgets.Text;
- import java.sql.*;
- public class maintainqueryAction extends Action {
- public maintainqueryAction(){
- super();
- this.setText("维修单查询(&W)");
- this.setToolTipText("维修单查询");
- }
-
- public void run(){
- Text content=MainWindow.getApp().getContent();
- if(MainWindow.log==false){
-
- content.append("请您先登陆n");
- return ;
- }
- InputDialog inputDialog=new InputDialog(Display.getCurrent().getActiveShell(),"请输入维修单号",
- "维修单号","",new maintainValidator() );//这个是自定义验证有效性的对象
- int result=inputDialog.open();
- String s="***********************************维修单查询结果**********************************n";
- if(result==Window.OK){
-
- int repairNumber=Integer.parseInt(inputDialog.getValue());//得到维修单号
- String str="select "+
- sqlManager.tb_repair+"."+sqlManager.row_repair_id+","+ //维修单号
- sqlManager.tb_repair+"."+sqlManager.row_repair_time+","+//维修时间
- sqlManager.tb_repair+"."+sqlManager.row_repair_information+","+//维修记录
- sqlManager.tb_customer+"."+sqlManager.row_customer_name+","+//客户姓名
- sqlManager.tb_produce+"."+sqlManager.row_produce_name+","+//维修商品名称
- sqlManager.tb_repair_shop+"."+sqlManager.row_repair_shop_name+","+//维修店铺
- sqlManager.tb_repair_shop+"."+sqlManager.row_repair_shop_keeper+","+//维修人
- sqlManager.tb_repair_shop+"."+sqlManager.row_repair_shop_call+" " +//维修店联系电话
- "from "+sqlManager.tb_produce+","+sqlManager.tb_customer+","+sqlManager.tb_repair_shop+","+sqlManager.tb_repair+" "+
- "where "+sqlManager.tb_repair+"."+sqlManager.row_repair_id+"="+repairNumber+" and "+
- sqlManager.tb_repair+"."+sqlManager.row_repair_repair_shop_id+"="+sqlManager.tb_repair_shop+"."+sqlManager.row_repair_shop_id+" and "+
- sqlManager.tb_repair+"."+sqlManager.row_repair_customer_id+"="+sqlManager.tb_customer+"."+sqlManager.row_customer_id+" and "+
- sqlManager.tb_repair+"."+sqlManager.row_repair_produce_id+"="+sqlManager.tb_produce+"."+sqlManager.row_produce_id+
- "";
- sqlManager sql=sqlManager.getSqlManager();
- ResultSet set=sql.executeQuery(str);
- boolean flag=false;
- try{
- while(set.next()){
- flag=true;
- content.append(s);
- content.append("维修单号:"+set.getInt(1)+"n");
-
- content.append("维修时间:"+set.getString(2)+"n");
- content.append("维修记录:"+set.getString(3)+"n");
-
- content.append("客户姓名:"+set.getString(4)+"n");
- content.append("维修商品名称:"+set.getString(5)+"n");
-
- content.append("维修店铺: "+set.getString(6)+"n");
- content.append("维修人: "+set.getString(7)+"n");
- content.append("维修店联系电话: "+set.getString(8)+"n");
- }
- }
- catch(SQLException e){
- e.printStackTrace();
- }
- content.append(s);
- if(flag==false)
- content.append("查询结果为空n");
- }
- else {
-
- }
-
-
- }
- public class maintainValidator implements IInputValidator{
- public String isValid(String newText){
- try{
- Integer.parseInt(newText);
- }
- catch(NumberFormatException ne){
- return "输入错误,请输入有效的售货单";
- }
- return null;
- }
- }
- }