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

📄 market.java

📁 JAVA编写的超市管理系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
				    String strSql3 = "update Rejection set reReason = '" + reasons +"' where  gno='"+ gno.getText() + "'";
				    
					System.out.println("退货中有 ");
					stmt.executeUpdate(strSql2);
					stmt.executeUpdate(strSql3);
					System.out.println("strSql3    "+strSql3);
				}
				else
				{
					System.out.println("退货中mei有 ");
					stmt.executeUpdate(strSql);
				}
				
			}
			else
			{
			    	 System.out.println("不存在 ");
			}
		
		}catch(SQLException sqle)
    	     {
    	//	redoIt();
    		 System.out.println(sqle.toString());}
	
    }
    
    public void ReOK()
    {
    		ReS= new JDialog(f,"",true);
    	    ReS.setLayout(new BorderLayout());
    		ReS.add(new JLabel("-----操作成功!-----"),BorderLayout.NORTH);
    		ReS.add(sure6,BorderLayout.SOUTH);
    		sure6.addActionListener(mo);
    		ReS.setSize(300,180);
    		ReS.setLocation(450,180);
    		ReS.setResizable(false);
    		ReS.setVisible(true);//最后写
    }
    public void InterGoods()
    {
    	
    	IG = new JDialog(f,"商品信息录入",true); 
    	JLabel l = new JLabel("商品信息录入【注】各项均为必填!");
        clear2();   
        Calendar now=Calendar.getInstance();
        String time=now.get(Calendar.YEAR)+"-"+(now.get(Calendar.MONTH)+1)+"-"+now.get(Calendar.DAY_OF_MONTH)+" "+now.get(Calendar.HOUR_OF_DAY)+":"+now.get(Calendar.MINUTE)+":"+now.get(Calendar.SECOND);
        clear();
        ILD.setText(time.toString());
    	ILD.setEditable(false);
   
     	gno.addActionListener(mo);
    	gname.addActionListener(mo);
    	proY.addActionListener(mo);
    	proM.addActionListener(mo);
    	proD.addActionListener(mo);
    	keepDate.addActionListener(mo);
    	gPrice.addActionListener(mo);
    	gKind = new Choice();
    	gKind.addItem("牛奶");gKind.addItem("冰淇淋");gKind.addItem("其他");    	
    	gKind.addItemListener(mo2);
    	JPanel I1 = new JPanel();
    	JPanel proDate = new JPanel();
    	I1.setLayout(new GridLayout(7,2));
    	keepDate.setText("0");
    	I1.add(new JLabel("商品代码"));I1.add(gno);
    	I1.add(new JLabel("名称"));I1.add(gname);
    	I1.add(new JLabel("类别"));I1.add(gKind);    	    
    	I1.add(new JLabel("生产日期"));I1.add(proDate);
    	proDate.add(proY);proDate.add(new JLabel("年"));
    	proDate.add(proM);proDate.add(new JLabel("月"));
    	proDate.add(proD);proDate.add(new JLabel("日"));
    	
    	I1.add(new JLabel("保质期(天)"));I1.add(keepDate);
    	I1.add(new JLabel("价格(元)"));I1.add(gPrice);
   
        JPanel I3 = new JPanel();
        I3.setLayout(new FlowLayout());
        addG  = new JButton("添加商品");
  
        addG.addActionListener(mo);

        I3.add(new JLabel(""));I3.add(addG);
        I3.add(new JLabel(""));
        
        JPanel I = new JPanel();   //列选项
    	I.setLayout(new BorderLayout());
    	I.add(l,BorderLayout.NORTH);
    	I.add(I1,BorderLayout.CENTER);
    	I.add(new JPanel(),BorderLayout.EAST);
    	I.add(new JPanel(),BorderLayout.WEST);
    	I.add(I3,BorderLayout.SOUTH);
    	IG.add(I);
    	IG.setSize(600,400);
    	IG.setLocation(300,180);
    	IG.setVisible(true);    	
    }
    
    public void L()
    {
    	String sDispL= "select * from LiaStock";
    	L = new JDialog(f,"库存账",true);  
    	L.setLayout(new BorderLayout());  	
        try
    	{
    		rs = stmt.executeQuery(sDispL);
    	} 
    	 catch(SQLException sqle)
		 {
			  System.out.println(sqle.toString());
		 } 
	    Lc=L.getContentPane();	//????????????//
	    
	    //Lc = new Container();
		Lpanel3=new JPanel();
   	    String[] name2={"商品代码 ","名称","库存量"}; //保存在String数组里
		String[][] data2=new String[0][0];
		defaultModel2=new DefaultTableModel(data2,name2);
		table2=new JTable(defaultModel2);
		table2.setPreferredScrollableViewportSize(new Dimension(500,300));//设定高度和宽度
		JScrollPane s2=new JScrollPane(table2);//创建JScrollPane对象并指定内部控件
		Lpanel3.add(s2);
		Lc.add(Lpanel3,BorderLayout.CENTER);
		L.add(new Label("                                                   库存账如下"),BorderLayout.NORTH);
		//L.add(Lc,BorderLayout.CENTER);
		JPanel cD = new JPanel();
		cD.add(new JLabel(""));cD.add(closeL);
		L.add(cD,BorderLayout.SOUTH);
		closeL.addActionListener(mo);
    		try
		   {
	          //首先要删除table中的数据
	          int rowCount=defaultModel2.getRowCount()-1;//取得table中的数据行;
	          int j=rowCount;
	          for(int i=0;i<=rowCount;i++)
	          {
	        	  defaultModel2.removeRow(j);//删除rowCount行的数据;
	        	  defaultModel2.setRowCount(j);//重新设置行数;
	        	  j=j-1;
	          }
		      while(rs.next())
	    	  {
		    	 Vector data0=new Vector();
			     data0.addElement(rs.getString(1));
		    	 data0.addElement(rs.getString(2));
		         data0.addElement(rs.getString(3));
			     defaultModel2.addRow(data0);
	    	 }
		     table2.revalidate();//更新表格
	      }
	      
	      catch(Exception ex)
		 {
			 System.out.println(ex.toString());
		 }
		L.setSize(600,400);
    	L.setLocation(300,180);
		L.setVisible(true);
 	
    }
    public void MainMenu()
    {
    	
    }
    public void redoIt()
    {
    	rd= new JDialog(f,"出错啦",true);
    	rd.setLayout(new GridLayout(2,1));
        rd.addWindowListener(new WindowAdapter(){//设置窗口监听器,以关闭窗口
		public void windowClosing(WindowEvent e)
		{
			System.exit(0);
		}
		});
		JPanel rd1 = new JPanel();
		rd1.setLayout(new BorderLayout());
		rd1.add(new JLabel("-----操作失败!-----"),BorderLayout.NORTH);
		rd1.add(new JLabel("有可能输入非法字符引起"),BorderLayout.CENTER);
	    rd1.add(new JLabel("     请选择操作"),BorderLayout.WEST);
	    JPanel rd2 = new JPanel();
	//	
	    rd2.add(new JLabel());	
	    rd2.add(exit);
	    rd2.add(reDo);
	   
        exit.addActionListener(mo);
    	reDo.addActionListener(mo); 
    	
    	rd.add(rd1);rd.add(rd2);
    	rd.setSize(300,180);
    	rd.setLocation(450,180);
    	rd.setResizable(false);
    	rd.setVisible(true);//最后写  
    }
    
    public void addG()
    {
    	
    	try
    	{
    		rs = stmt.executeQuery("select gno from Goods where gno = '"+ gno.getText() 

+ "'");
            if(gno.equals(""))//商品代码空
    	    {
    	    	addW = new JDialog(f,"",true);
    	    	addW.setLayout(new BorderLayout());
    			addW.add(new JLabel("-----商品代码不能为空!-----"),BorderLayout.NORTH);
    			addW.add(sure2,BorderLayout.SOUTH);
    			sure2.addActionListener(mo);
    			addW.setSize(300,180);
    			addW.setLocation(450,180);
    			addW.setResizable(false);
    			addW.setVisible(true);//最后写 
    		
    	    }
        	else if(rs.next())//已经添加过该商品
    	    {
    	    	added = new JDialog(f,"",true);
    	    	added.setLayout(new BorderLayout());
    			added.add(new JLabel("-----该商品已经添加过!-----"),BorderLayout.NORTH);
    			added.add(sure2,BorderLayout.SOUTH);
    			sure2.addActionListener(mo);
    			added.setSize(300,180);
    			added.setLocation(450,180);
    			added.setResizable(false);
    			added.setVisible(true);//最后写 
    		
    	    }
    	    
    	    else
    	    {
    	    	String pD = proY.getText()+"/"+ proM.getText()+"/"+proD.getText();	
    	        String strSql = "insert into Goods (gno,gname,gKind ,proDate ,keepDate ,gPrice )" + "values( "+
				"'" +gno.getText() 
				    + "','" + gname.getText()
					+ "', '" + gKind.getSelectedItem().toString()
					+ "', '" + pD
					+ "', " + Integer.parseInt(keepDate.getText()) 
					+ ", " + Double.parseDouble(gPrice.getText())
					+ ")" ;
				stmt.executeUpdate(strSql);
		        //修改库中商品名称 
	       	    String strSql5 = "update LiaStock set gname ='" + gname.getText() 

+"' where gno='"+ gno.getText() + "'"; 		  	    		
	            System.out.println("strSql         "+strSql) ;	
		    	rs = stmt.executeQuery("select amount from LiaStock where gno = '"+ 

gno.getText() + "'");
            	if(rs.next())		//库存已经存在的号,修改
            	{
     		       stmt.executeUpdate(strSql5); 
     		       System.out.println("ooooooo1ooooooo") ;	
            	}
            	else	   //库存不存在的号,插入
            	{
        		stmt.executeUpdate("insert into LiaStock (gno,gname,amount)" + 

"values( "+
				"'" +gno.getText() 
				    + "','" + gname.getText()
					+ "', " + 0
					+ ")" );
        	    }			
             	addS= new JDialog(f,"",true);
    	    	addS.setLayout(new BorderLayout());
    			addS.add(new JLabel("-----商品添加成功!-----"),BorderLayout.NORTH);
    			addS.add(sure3,BorderLayout.SOUTH);
    			sure3.addActionListener(mo);
    			addS.setSize(300,180);
    			addS.setLocation(450,180);
    			addS.setResizable(false);
    			addS.setVisible(true);//最后写
            }
        }catch(Exception eeee)
    	     {
    	//	redoIt();
    		System.out.println("redoIt()  ok");}	
    }
    
 
    public void AddtoL()
    {
    	int nowAmount = 0;
    	double sl =0.0;
    	double Sload =  Double.parseDouble(price.getText())*Integer.parseInt(amount.getText())- Double.parseDouble(payed.getText());
    	String strSql = "insert into IntoL (gno,sno,ItemNo ,price ,payed ,amount,ILD )" + "values( "+
				"'" +gno.getText() 
				    + "','" + sno.getText()
					+ "', '" + ItemNo.getText() 
					+ "', " + Double.parseDouble(price.getText())
					+ ", " + Double.parseDouble(payed.getText())
					+ ", " + Integer.parseInt(amount.getText()) 
					+ ", now() )" ;
		String strSql2 = "insert into suplyer (sno,sname,sAddress ,sPhoneNo ,sEmail ,sFax,sHonor,sLoad)" + "values( "+
				"'" +sno.getText() 
				    + "','" + sname.getText()
					+ "', '" + sAddress.getText() 
					+ "', '" + sPhoneNo.getText()
					+ "', '" + sEmail.getText() 
					+ "', '" + sFax.getText() 
					+ "', '" + ch.getSelectedItem().toString() 
					+ "', " + Sload
					+ ")" ;
		String strSql3 = "insert into LiaStock (gno,gname,amount)" + "values( "+
				"'" +gno.getText() 
				    + "','" + ""
					+ "', " + Integer.parseInt(amount.getText())
					+ ")" ;        
        try
        {
        	rs = stmt.executeQuery("select amount from LiaStock where gno = '"+ gno.getText() + "'");
        
        	if(rs.next())		//库存已经存在的号,修改
        	{
     		    s= rs.getString("amount");
    			nowAmount = Integer.parseInt(s);
		    	System.out.println("            In       ss    "+ s);
			    System.out.println("nowAmount:  值   ========="+nowAmount);
	            int newAmount = Integer.parseInt(amount.getText())+ nowAmount ;
        		String strSql5 = "update LiaStock set amount =" + newAmount +" where gno='"+ gno.getText() + "'"; 		  
		        System.out.println("strSql5"+strSql5);
		        stmt.executeUpdate(strSql5);
        	}
        	else	   //库存不存在的号,插入
        	{
        		stmt.executeUpdate(strSql3);
        	}
        	System.out.println("strSql3           1          "+strSql3);
		    stmt.executeUpdate(strSql);//修改入库单表
		    
////////////////////////////////////////////////////////////////////////////////////////////////////////////
			//System.out.println("select sno from suplyer where sno = '"+sno.getText()+"'");		    
         	rs2 = stmt.executeQuery("select * from suplyer where sno = '"+sno.getText()+"'");
         	
         	//System.out.println("sssssssssssssssssssss  2");
         	if(rs2.next())   //已经存在的供应商,修改LOAD
         	{
         		sl= rs2.getDouble("sLoad");
         		System.out.println("sl      "+sl);
         		double newsLoad = sl+Sload;
         		System.out.println("newsLoad"+newsLoad);
         		String strSql6 = "update suplyer set sLoad =" + newsLoad +" where sno='"+ sno.getText() + "'"; 		  
		        System.out.println("strSql6"+strSql6);
		        stmt.executeUpdate(strSql6);
         	}
         	else
         	{
         		stmt.executeUpdate(strSql2);//修改供应商表
            	System.out.println("strSql2           2           "+strSql2);	
         	}
         	
	        InS= new JDialog(f,"",true);
    	    InS.setLayout(new BorderLayout());
    		InS.add(new JLabel("-----操作成功!-----"),BorderLayout.NORTH);
    		InS.add(sure5,BorderLayout.SOUTH);
    		sure5.addActionListener(mo);
    		InS.setSize(300,180);
    		InS.setLocation(450,180);
    		InS.setResizable(false);
    		InS.setVisible(true);//最后写
        }
        catch(Exception eeee)
    	{
    	//	redoIt();
    		eeee.printStackTrace();
    	}
    	InDiag.isValid();
    }
    
  
    public void pay()
    {
    	pDiag = new JDialog(f,"支付管理",true);
    	pDiag.addWindowListener(new curentJDialog(pDiag));

⌨️ 快捷键说明

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