addproduceAction.java
上传用户:flow_meter
上传日期:2022-03-21
资源大小:40k
文件大小:2k
- package sql_lab;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import org.eclipse.jface.action.Action;
- 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 sql_lab.salequeryAction.saleValidator;
- public class addproduceAction extends Action {
- public addproduceAction(){
- super();
- this.setText("查看所有产品(&A)");
- this.setToolTipText("查看所有产品");
- }
- public void run(){
- if(MainWindow.log==false){
- Text content=MainWindow.getApp().getContent();
- content.append("请您先登陆n");
- return ;
- }
- String str="select * from "+sqlManager.tb_produce;
- 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("产品ID: "+set.getString(1)+" n");
- content.append("产品名称: "+set.getString(2)+"n");
-
- content.append("产品描述: "+set.getString(3)+"n");
- content.append("产品价格: "+set.getDouble(4)+"n");
-
-
- content.append("产品类别: "+set.getString(5)+"n");
- content.append("厂家ID: "+set.getString(6)+"n");
- }
- }
- catch(SQLException e){
- e.printStackTrace();
- }
- content.append(s);
- if(flag==false)content.append("查询结果为空n");
- }
- }