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

📄 market.java

📁 JAVA编写的超市管理系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	          //首先要删除table中的数据
	          int rowCount=defaultModel.getRowCount()-1;//取得table中的数据行;
	          int j=rowCount;
	          for(int i=0;i<=rowCount;i++)
	          {
	        	  defaultModel.removeRow(j);//删除rowCount行的数据;
	        	  defaultModel.setRowCount(j);//重新设置行数;
	        	  j=j-1;
	          }
		      while(rs.next())
	    	  {
	    	  	Vector data=new Vector();
	    	  	String gno = rs.getString(1);
        		String gname = rs.getString(2);
        		String gKind = rs.getString(3);
        		java.sql.Date proDate = rs.getDate(4);
        		int keepDate = rs.getInt(5);
        		double gPrice = rs.getDouble(6);
        		/////////////////////////////    		
        		int days = (now.getYear()-proDate.getYear())*365+(now.getMonth()-proDate.getMonth())*30+(now.getDay()-proDate.getDay());
        		if(days>0.8*keepDate)
        		{
        			//显示的地方
        	//		System.out.println(gno);
        			data.addElement(gno);
		    	    data.addElement(gname);
		            data.addElement(gKind);
		    	 sumOutOfDate++;
			     defaultModel.addRow(data);
        		}
	     
	    	 }
		     table.revalidate();//更新表格
	      }
	      
	      catch(Exception ex)
		 {
			 System.out.println(ex.toString());
		 }
		 warn.setSize(600,400);
    	warn.setLocation(300,180);
		warn.setVisible(true);	
    }
    
    //////////////////////////////*****************main*****************///////////////////////////
    public static void main(String[] args)
    {
    	 new Market();
    }
    ////////////////////////////////////////////////////////////////////
    public void IntoL()
    {
    	try
    	{
    		rs = stmt.executeQuery("select top 1 * from IntoL order  by ILD desc");	
            while(rs.next())
	        {
		        ItemNoStr = rs.getString("ItemNo");			
	        }			
             System.out.println(ItemNoStr);
    	}catch(Exception eeee)
    	{eeee.printStackTrace();	}
    
    	InDiag = new JDialog(f,"入库管理",true);
    	InDiag.addWindowListener(new curentJDialog(InDiag));
    	JLabel l = new JLabel("入库单-供应商表填写");
    //    java.sql.Date ndate = new java.sql.Date(System.currentTimeMillis());
        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);
    	sname.addActionListener(mo);
    	ItemNo.addActionListener(mo);
    	String q = ItemNoStr.substring(3);
    	
    	System.out.println("q"+q);
    	ItemNoStr = q.toString();
    	int x = Integer.parseInt(ItemNoStr);
    	System.out.println(ItemNoStr);
    	int y = x+1;
    	String ItemNoStr2 = "In_"+y;
    	ItemNo.setText(ItemNoStr2);
    	ItemNo.setEditable(false);
    	ILD.addActionListener(mo);
    	price.addActionListener(mo);
    	payed.addActionListener(mo);
    	amount.addActionListener(mo);
    	
    	sno.addActionListener(mo);
    	sAddress.addActionListener(mo);
    	sPhoneNo.addActionListener(mo);
    	sEmail.addActionListener(mo);
    	sFax.addActionListener(mo);
    	sHonor.addActionListener(mo);
//    	sLoad.addActionListener(mo);
   // 	s2name.setText(sname.getText());
    	
    	price.setText("0");
    	payed.setText("0");
    	amount.setText("0");
//    	sLoad.setText("0");
    	
    	JPanel I1 = new JPanel();
    	I1.setLayout(new GridLayout(8,2));
    	I1.add(new JLabel("商品代码"));I1.add(gno);
    	
    	I1.add(new JLabel("入库单号"));I1.add(ItemNo);    	    
    	I1.add(new JLabel("价格-----数字类型"));I1.add(price);
    	I1.add(new JLabel("已付款项-----数字类型 "));I1.add(payed);
    	I1.add(new JLabel("数量-----数字类型"));I1.add(amount);
    	I1.add(new JLabel("入库日期"));I1.add(ILD);
    	I1.add(new JLabel());I1.add(new JLabel());
    
    	JPanel I2 = new JPanel();
    	I2.setLayout(new GridLayout(8,2));
    	ch = new Choice();
    	ch.add("A");ch.add("B");ch.add("C");ch.add("D");
    	ch.addItemListener(mo2);
    	I2.add(new JLabel("供应商代码"));I2.add(sno);
    	I1.add(new JLabel("供应商名称"));I1.add(sname);
    	I2.add(new JLabel("地址"));I2.add(sAddress);    	    
    	I2.add(new JLabel("电话"));I2.add(sPhoneNo);
        I2.add(new JLabel("E-mail"));I2.add(sEmail);
    	I2.add(new JLabel("传真 "));I2.add(sFax);
    	I2.add(new JLabel("信誉"));I2.add(ch);
   // 	I2.add(new JLabel("贷款结算-----数字类型"));I2.add(sLoad);
    
        JPanel I3 = new JPanel();
        I3.setLayout(new FlowLayout());
        verify  = new JButton("核实信息无误");
        reFill  = new JButton("信息出错重填");
        verify.addActionListener(mo);
        reFill.addActionListener(mo);
        I3.add(new JLabel(""));I3.add(verify);
        I3.add(new JLabel(""));I3.add(reFill);
        
        JPanel I0 = new JPanel();
        I0.setLayout(new GridLayout(2,1));
        I0.add(I1);
        I0.add(I2);
        JPanel I = new JPanel();   //列选项
    	I.setLayout(new BorderLayout());
    	I.add(l,BorderLayout.NORTH);
    	I.add(I0,BorderLayout.CENTER);
    	I.add(new JPanel(),BorderLayout.EAST);
    	I.add(new JPanel(),BorderLayout.WEST);
    	I.add(I3,BorderLayout.SOUTH);
    	InDiag.add(I);
    	InDiag.setSize(600,400);
    	InDiag.setLocation(300,180);
    	InDiag.setVisible(true);
    }
    ArrayList BuyList = new ArrayList();
    JLabel SaleFrame_JL;
    public void SaleFrame()
    {
    	SaleFrame_JL = new JLabel("请输入");
    	PriceList.clear();
    	BuyList.clear();
    	SF = new JDialog(f,"销售",true);
    	SF.addWindowListener(new curentJDialog(SF));
    	JLabel l = new JLabel("             请输入产品相关信息");  	
    	JPanel s = new JPanel();
    	JPanel s2 = new JPanel();
    	s.setLayout(new GridLayout(5,2));
    	s.add(SaleFrame_JL);s.add(new JLabel(" "));
    	s.add(new JLabel("商品代码"));s.add(gno);
    	s.add(new JLabel(" "));s.add(new JLabel(" "));
    	s.add(new JLabel("商品数量"));s.add(amount);  
    	s.add(new JLabel(" "));s.add(new JLabel(" ")); 
    	s2.add(new JLabel(" "));s2.add(next);s2.add(finish);s2.add(cancel);s2.add(new JLabel(" "));
    	SF.add(new JLabel("        "),BorderLayout.EAST);
    	SF.add(new JLabel("        "),BorderLayout.WEST);
    	SF.add(l,BorderLayout.NORTH);	
    	SF.add(s,BorderLayout.CENTER);
    	SF.add(s2,BorderLayout.SOUTH);
    	next.addActionListener(new Monitor());
    	finish.addActionListener(new Monitor());
    	cancel.addActionListener(new Monitor());
    	SF.setSize(600,400);
    	SF.setLocation(300,180);
    	SF.setVisible(true);
    }
    
    public void OutOfL()
    {
    	int nowAmount = 0;
    	double Sload =  Double.parseDouble(price.getText())*Integer.parseInt(amount.getText())- Double.parseDouble(payed.getText());
    	double Sload2 = - Sload;
    	String strSql = "insert into OutL (gno,sno,outNo ,price ,payed ,amount,OLD )" + "values( "+
				"'" +gno.getText() 
				    + "','" + sno.getText()
					+ "', '" + OutNo.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() 
				    + "','" + ""
					+ "', '" + ""
					+ "', '" + ""
					+ "', '" + ""
					+ "', '" +""
					+ "', '" + "A"
					+ "', " + Sload2
					+ ")" ;
        try
        {
        	rs = stmt.executeQuery("select amount from LiaStock where gno = '"+ gno.getText() + "'");
        	if(rs.next())		//库存已经存在的号,修改
        	{
     		    s= rs.getString("amount");
    			nowAmount = Integer.parseInt(s);
	            int newAmount = nowAmount - Integer.parseInt(amount.getText());
        		String strSql5 = "update LiaStock set amount =" + newAmount +" where gno='"+ gno.getText() + "'"; 		  
		        stmt.executeUpdate(strSql5);
		        stmt.executeUpdate(strSql);
		        		System.out.println("     strSql    "+ strSql);
        	}
        	else	   //库存不存在的号,插入
        	{
        		outS= new JDialog(f,"",true);
    	        outS.setLayout(new BorderLayout());
    		outS.add(new JLabel("-----库存不存在的号!-----"),BorderLayout.NORTH);
    		outS.add(sure4,BorderLayout.SOUTH);
    		sure4.addActionListener(mo);
    		outS.setSize(300,180);
    		outS.setLocation(450,180);
    		outS.setResizable(false);
    		outS.setVisible(true);//最后写
    		System.out.println("库存不存在的号");
        		//修改chu库单表
   		    
        	}
        	
   		    rs2 = stmt.executeQuery("select * from suplyer where sno = '"+sno.getText()+"'");
         	
         	//System.out.println("sssssssssssssssssssss  2");
         	if(rs2.next())   //已经存在的供应商,修改LOAD
         	{         		
         		double 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);//修改供应商表	
         	}
        }
        catch(Exception eeee)
    	{
    	//	redoIt();
    		System.out.println("redoIt()  ok");
    	}
    	OutDiag.isValid();
    }
    public void outL()
    {
    	try
    	{
    		rs = stmt.executeQuery("select top 1 * from OutL order  by OLD desc");	
            while(rs.next())
	        {
		        OutNoStr = rs.getString("outNo");			
	        }			
             System.out.println("OutNoStr  is   "+OutNoStr);
    	}catch(Exception eeee)
    	{eeee.printStackTrace();	}
    
    	OutDiag = new JDialog(f,"出库管理",true);
    	OutDiag.addWindowListener(new curentJDialog(OutDiag));
    	JLabel l = new JLabel("出库单填写");
        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();
        OLD.setText(time.toString());
    	OLD.setEditable(false);
    	gno.addActionListener(mo);
    	sname.addActionListener(mo);
    	ItemNo.addActionListener(mo);
    	String q = OutNoStr.substring(4);
    	
    	System.out.println("q"+q);
    	OutNoStr = q.toString();
    	int x = Integer.parseInt(OutNoStr);
    	System.out.println(OutNoStr);
    	int y = x+1;
    	String ItemNoStr2 = "Out_"+y;
    	OutNo.setText(ItemNoStr2);
    	OutNo.setEditable(false);
    	OLD.addActionListener(mo);
    	price.addActionListener(mo);
    	payed.addActionListener(mo);
    	amount.addActionListener(mo);
    	
    	price.setText("0");
    	payed.setText("0");
    	amount.setText("0");
    	
    	JPanel I1 = new JPanel();
    	I1.setLayout(new GridLayout(8,2));
    	I1.add(new JLabel("商品代码"));I1.add(gno);
    	I1.add(new JLabel("供应商代码"));I1.add(sno);
    	I1.add(new JLabel("出库单号"));I1.add(OutNo);    	    
    	I1.add(new JLabel("价格-----数字类型"));I1.add(price);
    	I1.add(new JLabel("已付款项-----数字类型 "));I1.add(payed);
    	I1.add(new JLabel("数量-----数字类型"));I1.add(amount);
    	I1.add(new JLabel("出库日期"));I1.add(OLD);
    	I1.add(new JLabel());I1.add(new JLabel());
        
        JPanel I3 = new JPanel();
        I3.setLayout(new FlowLayout());
        verify2  = new JButton("核实信息无误");
        verify2.addActionListener(mo);
        I3.add(new JLabel(""));I3.add(verify2);
        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);
    	OutDiag.add(I);
    	OutDiag.setSize(600,400);
    	OutDiag.setLocation(300,180);
    	OutDiag.setVisible(true);
    }
    
    public void Success()
    {
    	
    }
    
/*    public void ok()
    {
    	System.out.println("o4");
    	ok = new JDialog(f,"操作成功",true);
    	JPanel o1 = new JPanel();
    	JPanel o2 = new JPanel();
    	JPanel o = new JPanel();
    
    	o1.setLayout(new BorderLayout());
    	o1.add(new JLabel("                                                                    ---------------------------"),BorderLayout.NORTH);
    	o1.add(new JLabel("                                                                    ---------操作成功!---------"),BorderLayout.CENTER);
    	o1.add(new JLabel("                                                                    ---------------------------"),BorderLayout.SOUTH);
        dispaundry = new JButton("查看流水账");
    //    dispL = new JButton("查看库存账");
        o2.add(new JLabel(""));   
        o2.add(dispaundry);
    	o2.add(dispL);
    	o2.add(retoMain);
    	o2.add(new JLabel(""));
    	dispaundry.addActionListener(mo);
    	dispL.addActionListener(mo);
    	retoMain.addActionListener(mo);
    	o.setLayout(new GridLayout(2,1));
    	o.add(o1);o.add(o2);
    	ok.setLayout(new BorderLayout());
    	ok.add(o,BorderLayout.CENTER);
    	ok.add(new JLabel(""),BorderLayout.SOUTH);
    	ok.setSize(600,400);
    	ok.setLocation(300,180);
    	ok.setVisible(true);
    }

⌨️ 快捷键说明

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