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

📄 selectpanel.java

📁 用java编写的人事管理系统,很好的 学习下吧
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			txtSupplierBrief.setEditable(false);
			txtCustomerCode.setEditable(false);
			txtUsersCode.setEditable(false);
			txtPrice.setEditable(true);
			rbtBig.setEnabled(true);
			rbtEqual.setEnabled(true);
			rbtSmall.setEnabled(true);
		}
	}
	public void actionPerformed(ActionEvent e)
	{
		String strbtn=e.getActionCommand();
		if(strbtn.equals("select"))
		{
			selectTable();
		}
		else if(strbtn.equals("print"))
		{
			try
			{
				if(tabShow.print())
				{
					JOptionPane.showMessageDialog(null,"已打印,请查看","提示",JOptionPane.INFORMATION_MESSAGE);
				}
				else
				{
					JOptionPane.showMessageDialog(null,"未打印,打印被取消","提示",JOptionPane.INFORMATION_MESSAGE);
				}
			}
			catch(PrinterException pe)
			{
				JOptionPane.showMessageDialog(null,"出现异常,打印失败","提示",JOptionPane.INFORMATION_MESSAGE);	
			}
		}
	}
	public void selectTable()
	{
		sd = new SelectData();
		sop= new SelectOperate();
		String strImei=txtImei.getText().trim();
		String strMsn=txtMsn.getText().trim();
		String strModel=txtModel.getText().trim();
		String strState=txtState.getText().trim();
		String strColor=txtColor.getText().trim();
		String strUsersCode=txtUsersCode.getText().trim();
		String strSupplierBrief=txtSupplierBrief.getText().trim();
		String strCustomerCode=txtCustomerCode.getText().trim();
		String strPrice=txtPrice.getText().trim();
		sd.setImei(strImei);
		sd.setMsn(strMsn);
		sd.setModel(strModel);
		sd.setState(strState);
		sd.setColor(strColor);
		sd.setUserCode(strUsersCode);
		sd.setSupplierBrief(strSupplierBrief);
		
		if(rbtIom.isSelected())
		{
			if(rbtImei.isSelected())
			{
				if(strImei.length()!=0)
				{
					tableShowByModel(sop.getDataByOneColname(strTabname,"手机串号",strImei),odb.getColumnNamesByTabname(strTabname));
         			JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
					txtImei.setText("");
				}
				else
				{
					JOptionPane.showMessageDialog(null,"查询条件不能为空","提示",JOptionPane.INFORMATION_MESSAGE);
					txtImei.requestFocus();
				}
			}
			else if(rbtMsn.isSelected())
			{
				if(chkModel.isSelected()&&chkColor.isSelected()&&chkState.isSelected())
				{
					if(strMsn.length()!=0&&strModel.length()!=0&&strColor.length()!=0&&strState.length()!=0)
					{
						tableShowByModel(sop.getDataByMamasac(strTabname,sd),odb.getColumnNamesByTabname(strTabname));
         				JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
						txtMsn.setText("");
						txtModel.setText("");
						txtState.setText("");
						txtColor.setText("");
					}
					else
					{
						JOptionPane.showMessageDialog(null,"查询条件不能为空","提示",JOptionPane.INFORMATION_MESSAGE);
					}
				}
				else if(chkModel.isSelected()&&chkColor.isSelected())
				{
					if(strMsn.length()!=0&&strModel.length()!=0&&strColor.length()!=0)
					{
						tableShowByModel(sop.getDataByMamac(strTabname,sd),odb.getColumnNamesByTabname(strTabname));
         				JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
						txtMsn.setText("");
						txtModel.setText("");
						txtColor.setText("");
					}
					else
					{
						JOptionPane.showMessageDialog(null,"查询条件不能为空","提示",JOptionPane.INFORMATION_MESSAGE);
					}
				}
				else if(chkColor.isSelected()&&chkState.isSelected())
				{
					if(strMsn.length()!=0&&strColor.length()!=0&&strState.length()!=0)
					{
						tableShowByModel(sop.getDataByMasac(strTabname,sd),odb.getColumnNamesByTabname(strTabname));
         				JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
						txtMsn.setText("");
						txtState.setText("");
						txtColor.setText("");
					}
					else
					{
						JOptionPane.showMessageDialog(null,"查询条件不能为空","提示",JOptionPane.INFORMATION_MESSAGE);
					}
				}
				else if(chkModel.isSelected()&&chkState.isSelected())
				{
					if(strMsn.length()!=0&&strModel.length()!=0&&strState.length()!=0)
					{
						tableShowByModel(sop.getDataByMamas(strTabname,sd),odb.getColumnNamesByTabname(strTabname));
         				JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
						txtMsn.setText("");
						txtModel.setText("");
						txtState.setText("");
					}
					else
					{
						JOptionPane.showMessageDialog(null,"查询条件不能为空","提示",JOptionPane.INFORMATION_MESSAGE);
					}
				}
				else if(chkModel.isSelected())
				{
					if(strMsn.length()!=0&&strModel.length()!=0)
					{
						tableShowByModel(sop.getDataByMam(strTabname,sd),odb.getColumnNamesByTabname(strTabname));
         				JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
						txtMsn.setText("");
						txtModel.setText("");
					}
					else
					{
						JOptionPane.showMessageDialog(null,"查询条件不能为空","提示",JOptionPane.INFORMATION_MESSAGE);
					}
				}
				else if(chkColor.isSelected())
				{
					if(strMsn.length()!=0&&strColor.length()!=0)
					{
						tableShowByModel(sop.getDataByMac(strTabname,sd),odb.getColumnNamesByTabname(strTabname));
         				JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
						txtMsn.setText("");
						txtColor.setText("");
					}
					else
					{
						JOptionPane.showMessageDialog(null,"查询条件不能为空","提示",JOptionPane.INFORMATION_MESSAGE);
					}
				}
				else if(chkState.isSelected())
				{
					if(strMsn.length()!=0&&strState.length()!=0)
					{
						tableShowByModel(sop.getDataByMas(strTabname,sd),odb.getColumnNamesByTabname(strTabname));
         				JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
						txtMsn.setText("");
						txtState.setText("");
					}
					else
					{
						JOptionPane.showMessageDialog(null,"查询条件不能为空","提示",JOptionPane.INFORMATION_MESSAGE);
					}	
				}
				else
				{
					if(strMsn.length()!=0)
					{
						tableShowByModel(sop.getDataByOneColname(strTabname,"品牌",strMsn),odb.getColumnNamesByTabname(strTabname));
         				JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
						txtMsn.setText("");
					}
					else
					{
						JOptionPane.showMessageDialog(null,"查询条件不能为空","提示",JOptionPane.INFORMATION_MESSAGE);
						txtMsn.requestFocus();
					}
				}
			}
		}
		else if(rbtSupp.isSelected())
		{
			if(strSupplierBrief.length()!=0)
			{
				tableShowByModel(sop.getDataByOneColname(strTabname,"供货商代码",strSupplierBrief),odb.getColumnNamesByTabname(strTabname));
         		JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
				txtSupplierBrief.setText("");
			}
			else
			{
				JOptionPane.showMessageDialog(null,"查询条件不能为空","提示",JOptionPane.INFORMATION_MESSAGE);
				txtSupplierBrief.requestFocus();
			}
		}
		else if(rbtCust.isSelected())
		{
			int customerCode=0;
			try
			{
				customerCode = Integer.parseInt(strCustomerCode);
				sd.setCustomerCode(customerCode);
				if(customerCode!=0)
				{
					tableShowByModel(sop.getDataByOneColname(strTabname,"顾客编号",customerCode),odb.getColumnNamesByTabname(strTabname));
	         		JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
					txtCustomerCode.setText("");
				}
				else
				{
					JOptionPane.showMessageDialog(null,"查询条件不能为空","提示",JOptionPane.INFORMATION_MESSAGE);
					txtCustomerCode.requestFocus();
				}
			}
			catch(NumberFormatException e)
			{
				JOptionPane.showMessageDialog(null,"请输入4位以内整数","提示",JOptionPane.INFORMATION_MESSAGE);
				txtCustomerCode.setText("");
				txtCustomerCode.requestFocus();	
			}
		}
		else if(rbtUsers.isSelected())
		{
			if(strUsersCode.length()!=0)
			{
				tableShowByModel(sop.getDataByOneColname(strTabname,"工号",strUsersCode),odb.getColumnNamesByTabname(strTabname));
         		JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
				txtUsersCode.setText("");
			}
			else
			{
				JOptionPane.showMessageDialog(null,"查询条件不能为空","提示",JOptionPane.INFORMATION_MESSAGE);
				txtUsersCode.requestFocus();
			}
		}
		else if(rbtPrice.isSelected())
		{
			double price=0;
			try
			{
				price=Double.parseDouble(strPrice);
				if(rbtBig.isSelected())
				{
					strMark=">=";
					if(price!=0)
					{
						tableShowByModel(sop.getDataByOneColname(strTabname,"单价",strMark,price),odb.getColumnNamesByTabname(strTabname));
	         			JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
						txtPrice.setText("");
					}
					else
					{
						JOptionPane.showMessageDialog(null,"查询条件不能为空","提示",JOptionPane.INFORMATION_MESSAGE);
						txtPrice.requestFocus();
					}
				}
				else if(rbtEqual.isSelected())
				{
					strMark="=";
					if(price!=0)
					{
						tableShowByModel(sop.getDataByOneColname(strTabname,"单价",strMark,price),odb.getColumnNamesByTabname(strTabname));
	         			JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
						txtPrice.setText("");
					}
					else
					{
						JOptionPane.showMessageDialog(null,"查询条件不能为空","提示",JOptionPane.INFORMATION_MESSAGE);
						txtPrice.requestFocus();
					}
				}
				else if(rbtSmall.isSelected())
				{
					strMark="<=";
					if(price!=0)
					{
						tableShowByModel(sop.getDataByOneColname(strTabname,"单价",strMark,price),odb.getColumnNamesByTabname(strTabname));
	         			JOptionPane.showMessageDialog(null,"查询完毕","提示",JOptionPane.INFORMATION_MESSAGE);
						txtPrice.setText("");
					}
					else
					{
						JOptionPane.showMessageDialog(null,"查询失败","提示",JOptionPane.INFORMATION_MESSAGE);
						txtPrice.requestFocus();
					}
				}
			}
			catch(NumberFormatException e)
			{
				JOptionPane.showMessageDialog(null,"请输入数字","提示",JOptionPane.INFORMATION_MESSAGE);
				txtPrice.setText("");
				txtPrice.requestFocus();	
			}
			
		}
	}
	public void tableShowByModel(Vector vData,Vector vColumnNames)
	{
		 DefaultTableModel dtm = new DefaultTableModel(vData,vColumnNames);
         tabShow.setModel(dtm);
         tabShow.setAutoResizeMode(tabShow.AUTO_RESIZE_OFF);
         tabShow.setRowHeight(20);
	}
}

⌨️ 快捷键说明

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