salequeryAction.java
上传用户:flow_meter
上传日期:2022-03-21
资源大小:40k
文件大小:4k
- package sql_lab;
- /*
- * 售货单信息查询
- */
- import java.sql.*;
- 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.jface.action.*;
- import org.eclipse.jface.window.ApplicationWindow;
- import org.eclipse.swt.widgets.*;
- public class salequeryAction extends Action {
- public salequeryAction(){
- super();
- this.setText("售货单查询(&S)");
- this.setToolTipText("售货单查询");
- }
- public void run(){
- if(MainWindow.log==false){
- Text content=MainWindow.getApp().getContent();
- content.append("请您先登陆n");
- return ;
- }
- InputDialog inputDialog=new InputDialog(Display.getCurrent().getActiveShell(),"请输入售货单号",
- "售货单号","",new saleValidator() );//这个是自定义验证有效性的对象
- int result=inputDialog.open();
- if(result==Window.OK){//对数据库进行查询
- int saleNumber=Integer.parseInt(inputDialog.getValue());//得到售货单号
- String str="select "+
- sqlManager.tb_sell+"."+sqlManager.row_sell_id+","+//得到售货单号
- sqlManager.tb_sell+"."+sqlManager.row_sell_amount+","+ //得到数量
- sqlManager.tb_sell+"."+sqlManager.row_sell_time+","+ //出售时间
- sqlManager.tb_customer+"."+sqlManager.row_customer_name+","+ //客户姓名
- sqlManager.tb_customer+"."+sqlManager.row_customer_address+","+//客户地址
- sqlManager.tb_customer+"."+sqlManager.row_customer_call+","+//客户电话
- sqlManager.tb_customer+"."+sqlManager.row_customer_mail+","+//得到客户邮箱
- sqlManager.tb_produce+"."+sqlManager.row_produce_name+","+//产品名称
- sqlManager.tb_produce+"."+sqlManager.row_produce_price+","+//价格
- sqlManager.tb_produce+"."+sqlManager.row_produce_funtion+","+//描述
- sqlManager.tb_produce+"."+sqlManager.row_produce_sort+","+//类别
- sqlManager.tb_producer+"."+sqlManager.row_producer_name+","+ //生产商名称
- sqlManager.tb_producer+"."+sqlManager.row_producer_address+","+ //地址
- sqlManager.tb_producer+"."+sqlManager.row_producer_call+","+ //电话
- sqlManager.tb_producer+"."+sqlManager.row_producer_describe+" "+ //简介
- "from "+sqlManager.tb_sell+","+sqlManager.tb_produce+","+sqlManager.tb_customer+","+
- sqlManager.tb_producer+","+sqlManager.tb_store+" "+
- "where "+sqlManager.tb_sell+"."+sqlManager.row_sell_id+"="+saleNumber+" and "+
- sqlManager.tb_sell+"."+sqlManager.row_sell_produce_id+"="+sqlManager.tb_produce+"."+sqlManager.row_produce_id+" and "+
- sqlManager.tb_sell+"."+sqlManager.row_sell_customer_id+"="+sqlManager.tb_customer+"."+sqlManager.row_customer_id+" and "+
- sqlManager.tb_sell+"."+sqlManager.row_sell_store_id+"="+sqlManager.tb_store+"."+sqlManager.row_store_id+
- "";
- sqlManager sql=sqlManager.getSqlManager();
- ResultSet set=sql.executeQuery(str);
- Text content=MainWindow.getApp().getContent();
- boolean flag=false;
- String s="***********************************售货单查询查询结果**********************************n";
- try{
- while(set.next()){
- flag=true;
- content.append(s);
- content.append("客户姓名:"+set.getString(4)+"n");
- content.append("售货单号:"+set.getInt(1)+"n");
-
- content.append("商品数量"+set.getInt(2)+" n");
- content.append("出售时间:"+set.getString(3)+"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");
- content.append("产品价格: "+set.getDouble(9)+"n");
-
- content.append("产品描述: "+set.getString(10)+"n");
- content.append("产品类别: "+set.getString(11)+"n");
-
- content.append("生产商名称: "+set.getString(12)+" n");
- content.append("生产商地址: "+set.getString(13)+"n");
-
- content.append("生产商电话: "+set.getString(14)+" n");
- content.append("生产商简介: "+set.getString(15)+"n");
-
- }
- }
- catch(SQLException e){
- e.printStackTrace();
- }
- content.append(s);
- if(flag==false)content.append("查询结果为空n");
- }
- else{
- System.out.println("input cancel");
- }
-
- }
- public class saleValidator implements IInputValidator{
- public String isValid(String newText){
- try{
- Integer.parseInt(newText);
- }
- catch(NumberFormatException ne){
- return "输入错误,请输入有效的售货单";
- }
- return null;
- }
- }
- }