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

📄 countinvbillsysdeffilterui.java

📁 《j2ee开发全程实录》随书源码
💻 JAVA
字号:
package com.cownew.PIS.inv.client;

import java.awt.Rectangle;
import java.sql.Date;
import java.util.Properties;

import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;

import org.apache.commons.lang.enums.EnumUtils;

import com.cownew.PIS.basedata.common.IPersonDAO;
import com.cownew.PIS.basedata.common.PersonInfo;
import com.cownew.PIS.framework.client.RemoteServiceLocator;
import com.cownew.PIS.framework.common.utils.KeyValueList;
import com.cownew.PIS.inv.common.CountInvBillStateEnum;
import com.cownew.PIS.inv.common.CountInvTypeEnum;
import com.cownew.PIS.inv.common.CountInventoryBillInfo;
import com.cownew.PIS.ui.commonUI.filterUI.SysDefFilterPanel;
import com.cownew.PIS.ui.ctrl.prompt.PopupDatePicker;
import com.cownew.PIS.ui.ctrl.prompt.OVPicker.PopupValueObjectPicker;
import com.cownew.ctk.common.StringUtils;
import com.cownew.ctk.ui.swing.SwingUtils;

public class CountInvBillSysDefFilterUI extends SysDefFilterPanel
{
	private static final String ALLBILL = "全部";
	
	private static final String BILLSTATE = "billState";
	
	private static final String COUNTTYPE = "countType";

	private static final String OPERATORID = "operatorid";

	private static final String COUNT_DATE_TO = "countDateTo";

	private static final String COUNT_DATE_FROM = "countDateFrom";

	private static final String CREATE_DATE_TO = "createDateTo";

	private static final String CREATE_DATE_FROM = "createDateFrom";

	private static final String NUM_TO = "numTo";

	private static final String NUM_FROM = "numFrom";

	private static final long serialVersionUID = 1L;

	private JLabel labelNumber;

	private JTextField txtNumberFrom;

	private JLabel jLabel;

	private JLabel jLabel1;

	private JLabel jLabel2;

	private JLabel jLabel3;

	private JLabel jLabel4;

	private JTextField txtNumberTo;

	private PopupDatePicker pdpCreateDateFrom;

	private PopupDatePicker pdpCreateDateTo;

	private PopupDatePicker pdpCountDateFrom;

	private PopupDatePicker pdpCountDateTo;

	private PopupValueObjectPicker popOperator;

	private JLabel jLabel41;

	private JLabel jLabel42;

	private JLabel jLabel5;

	private JComboBox comboBillState;

	private JComboBox comboCountType;

	public CountInvBillSysDefFilterUI()
	{
		super();
		initialize();
	}

	public KeyValueList getParams()
	{
		KeyValueList kvList = new KeyValueList();

		String numFrom = txtNumberFrom.getText();
		if (!StringUtils.isEmpty(numFrom))
		{
			kvList.add(NUM_FROM, numFrom);
		}

		String numTo = txtNumberTo.getText();
		if (!StringUtils.isEmpty(numTo))
		{
			kvList.add(NUM_TO, numTo);
		}

		Date createDateFrom = pdpCreateDateFrom.getSQLDate();
		if (createDateFrom != null)
		{
			kvList.add(CREATE_DATE_FROM, createDateFrom);
		}

		Date createDateTo = pdpCreateDateTo.getSQLDate();
		if (createDateTo != null)
		{
			kvList.add(CREATE_DATE_TO, createDateTo);
		}

		Date bizDateFrom = pdpCountDateFrom.getSQLDate();
		if (bizDateFrom != null)
		{
			kvList.add(COUNT_DATE_FROM, bizDateFrom);
		}

		Date bizDateTo = pdpCountDateTo.getSQLDate();
		if (bizDateTo != null)
		{
			kvList.add(COUNT_DATE_TO, bizDateTo);
		}

		PersonInfo operator = (PersonInfo) popOperator.getValueObject();
		if (operator != null)
		{
			kvList.add(OPERATORID, operator.getId());
		}

		
		Object objBillState = comboBillState.getSelectedItem();
		if(objBillState instanceof CountInvBillStateEnum)
		{
			String name = ((CountInvBillStateEnum)objBillState).getName();
			kvList.add(BILLSTATE, name);
		}
		
		Object objCountType = comboCountType.getSelectedItem();
		if(objCountType instanceof CountInvTypeEnum)
		{
			String name = ((CountInvTypeEnum)objCountType).getName();
			kvList.add(COUNTTYPE, name);
		}

		return kvList;
	}

	public String getSQL()
	{
		StringBuffer sbSQL = new StringBuffer();
		sbSQL.append("from ").append(CountInventoryBillInfo.class.getName()).append("\n");
		sbSQL.append("where 1=1");

		String numFrom = txtNumberFrom.getText();
		if (!StringUtils.isEmpty(numFrom))
		{
			sbSQL.append(" and number>=:numFrom");
		}

		String numTo = txtNumberTo.getText();
		if (!StringUtils.isEmpty(numTo))
		{
			sbSQL.append(" and number<=:numTo");
		}

		Date createDateFrom = pdpCreateDateFrom.getSQLDate();
		if (createDateFrom != null)
		{
			sbSQL.append(" and createDate>=:createDateFrom");
		}

		Date createDateTo = pdpCreateDateTo.getSQLDate();
		if (createDateTo != null)
		{
			sbSQL.append(" and createDate<=:createDateTo");
		}

		Date bizDateFrom = pdpCountDateFrom.getSQLDate();
		if (bizDateFrom != null)
		{
			sbSQL.append(" and countDate>=:countDateFrom");
		}

		Date bizDateTo = pdpCountDateTo.getSQLDate();
		if (bizDateTo != null)
		{
			sbSQL.append(" and countDate<=:countDateTo");
		}

		PersonInfo creator = (PersonInfo) popOperator.getValueObject();
		if (creator != null)
		{
			sbSQL.append(" and operator.id=:operatorid");
		}

		Object objBillState = comboBillState.getSelectedItem();
		if(objBillState instanceof CountInvBillStateEnum)
		{
			sbSQL.append(" and billState=:billState");
		}
		
		Object objCountType = comboCountType.getSelectedItem();
		if(objCountType instanceof CountInvTypeEnum)
		{
			sbSQL.append(" and countType=:countType");
		}
		
		return sbSQL.toString();
	}

	public void setParamsFromSolution(String params) throws Exception
	{
		Properties prop = null;
		prop = StringUtils.stringToProperties(params);

		txtNumberFrom.setText(prop.getProperty(NUM_FROM));
		txtNumberTo.setText(prop.getProperty(NUM_TO));

		String strCreateDateFrom = prop.getProperty(CREATE_DATE_FROM);
		if (!StringUtils.isEmpty(strCreateDateFrom))
		{
			pdpCreateDateFrom.setDate(Date.valueOf(strCreateDateFrom));
		} else
		{
			pdpCreateDateFrom.setDate(null);
		}

		String strCreateDateTo = prop.getProperty(CREATE_DATE_TO);
		if (!StringUtils.isEmpty(strCreateDateTo))
		{
			pdpCreateDateTo.setDate(Date.valueOf(strCreateDateTo));
		} else
		{
			pdpCreateDateTo.setDate(null);
		}

		String strBizDateFrom = prop.getProperty(COUNT_DATE_FROM);
		if (!StringUtils.isEmpty(strBizDateFrom))
		{
			pdpCountDateFrom.setDate(Date.valueOf(strBizDateFrom));
		} else
		{
			pdpCountDateFrom.setDate(null);
		}

		String strBizDateTo = prop.getProperty(COUNT_DATE_TO);
		if (!StringUtils.isEmpty(strBizDateTo))
		{
			pdpCountDateTo.setDate(Date.valueOf(strBizDateTo));
		} else
		{
			pdpCountDateTo.setDate(null);
		}

		String creatorId = prop.getProperty(OPERATORID);
		if (!StringUtils.isEmpty(creatorId))
		{
			IPersonDAO pDAO = (IPersonDAO) RemoteServiceLocator
					.getRemoteService(IPersonDAO.class);
			popOperator.setValueObject(pDAO.loadByPK(creatorId));
		} else
		{
			popOperator.setValueObject(null);
		}
		
		String billState = prop.getProperty(BILLSTATE);
		if (StringUtils.isEmpty(billState))
		{
			SwingUtils.setSelectedItem(comboBillState, ALLBILL);
		} else
		{
			CountInvBillStateEnum state = (CountInvBillStateEnum) EnumUtils.getEnum(
					CountInvBillStateEnum.class, billState);
			SwingUtils.setSelectedItem(comboBillState, state);
		}
		
		String countType = prop.getProperty(COUNTTYPE);
		if (StringUtils.isEmpty(countType))
		{
			SwingUtils.setSelectedItem(comboCountType, ALLBILL);
		} else
		{
			CountInvTypeEnum type = (CountInvTypeEnum) EnumUtils.getEnum(
					CountInvTypeEnum.class, countType);
			SwingUtils.setSelectedItem(comboCountType, type);
		}
	}

	protected void initialize()
	{
		jLabel5 = new JLabel();
		jLabel5.setBounds(new Rectangle(234, 104, 51, 16));
		jLabel5.setText("单据状态");
		jLabel42 = new JLabel();
		jLabel42.setBounds(new Rectangle(237, 77, 58, 16));
		jLabel42.setText("\u81f3");
		jLabel41 = new JLabel();
		jLabel41.setBounds(new Rectangle(237, 46, 58, 16));
		jLabel41.setText("\u81f3");
		jLabel4 = new JLabel();
		jLabel4.setBounds(new Rectangle(237, 15, 58, 16));
		jLabel4.setText("至");
		jLabel3 = new JLabel();
		jLabel3.setBounds(new Rectangle(11, 104, 58, 16));
		jLabel3.setText("盘点类型");
		jLabel2 = new JLabel();
		jLabel2.setBounds(new Rectangle(11, 132, 58, 16));
		jLabel2.setText("操作员");
		jLabel1 = new JLabel();
		jLabel1.setBounds(new Rectangle(11, 77, 62, 16));
		jLabel1.setText("盘点日期从");
		jLabel = new JLabel();
		jLabel.setBounds(new Rectangle(11, 46, 62, 16));
		jLabel.setText("制单日期从");
		labelNumber = new JLabel();
		labelNumber.setBounds(new Rectangle(11, 15, 62, 16));
		labelNumber.setText("编号从");
		this.setSize(467, 203);

		// 只有设置了PreferredSize才会出现滚动条
		this.setPreferredSize(getSize());
		this.setLayout(null);
		this.add(labelNumber, null);
		this.add(getTxtNumberFrom(), null);
		this.add(jLabel, null);
		this.add(jLabel1, null);
		this.add(jLabel2, null);
		this.add(jLabel3, null);
		this.add(jLabel4, null);
		this.add(getTxtNumberTo(), null);
		this.add(getPdpCreateDateFrom(), null);
		this.add(getPdpCreateDateTo(), null);
		this.add(getPdpOutDateFrom(), null);
		this.add(getPdpOutDateTo(), null);
		this.add(getPopOperator(), null);
		this.add(jLabel41, null);
		this.add(jLabel42, null);
		this.add(jLabel5, null);
		this.add(getComboBillState(), null);
		this.add(getComboCountType(), null);
	}

	/**
	 * This method initializes txtNumberFrom
	 * 
	 * @return javax.swing.JTextField
	 */
	private JTextField getTxtNumberFrom()
	{
		if (txtNumberFrom == null)
		{
			txtNumberFrom = new JTextField();
			txtNumberFrom.setBounds(new Rectangle(82, 15, 135, 21));
		}
		return txtNumberFrom;
	}


	/**
	 * This method initializes txtNumberTo
	 * 
	 * @return javax.swing.JTextField
	 */
	private JTextField getTxtNumberTo()
	{
		if (txtNumberTo == null)
		{
			txtNumberTo = new JTextField();
			txtNumberTo.setBounds(new Rectangle(300, 15, 149, 21));
		}
		return txtNumberTo;
	}

	/**
	 * This method initializes pdpCreateDateFrom
	 * 
	 * @return com.cownew.PIS.ui.ctrl.prompt.PopupDatePicker
	 */
	private PopupDatePicker getPdpCreateDateFrom()
	{
		if (pdpCreateDateFrom == null)
		{
			pdpCreateDateFrom = new PopupDatePicker();
			pdpCreateDateFrom.setBounds(new Rectangle(82, 46, 135, 21));
		}
		return pdpCreateDateFrom;
	}

	/**
	 * This method initializes pdpCreateDateTo
	 * 
	 * @return com.cownew.PIS.ui.ctrl.prompt.PopupDatePicker
	 */
	private PopupDatePicker getPdpCreateDateTo()
	{
		if (pdpCreateDateTo == null)
		{
			pdpCreateDateTo = new PopupDatePicker();
			pdpCreateDateTo.setBounds(new Rectangle(300, 46, 149, 21));
		}
		return pdpCreateDateTo;
	}

	/**
	 * This method initializes pdpInDateFrom
	 * 
	 * @return com.cownew.PIS.ui.ctrl.prompt.PopupDatePicker
	 */
	private PopupDatePicker getPdpOutDateFrom()
	{
		if (pdpCountDateFrom == null)
		{
			pdpCountDateFrom = new PopupDatePicker();
			pdpCountDateFrom.setBounds(new Rectangle(82, 77, 135, 21));
		}
		return pdpCountDateFrom;
	}

	/**
	 * This method initializes pdpInDateTo
	 * 
	 * @return com.cownew.PIS.ui.ctrl.prompt.PopupDatePicker
	 */
	private PopupDatePicker getPdpOutDateTo()
	{
		if (pdpCountDateTo == null)
		{
			pdpCountDateTo = new PopupDatePicker();
			pdpCountDateTo.setBounds(new Rectangle(300, 77, 149, 21));
		}
		return pdpCountDateTo;
	}

	/**
	 * This method initializes popOperator
	 * 
	 * @return com.cownew.PIS.ui.ctrl.prompt.OVPicker.PopupValueObjectPicker
	 */
	private PopupValueObjectPicker getPopOperator()
	{
		if (popOperator == null)
		{
			popOperator = new PopupValueObjectPicker(IPersonDAO.class);
			popOperator.setDisplayProperty("name");
			popOperator.setBounds(new Rectangle(82, 132, 135, 21));
		}
		return popOperator;
	}

	/**
	 * This method initializes comboBillState	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getComboBillState()
	{
		if (comboBillState == null)
		{
			comboBillState = new JComboBox();
			comboBillState.setBounds(new Rectangle(300, 104, 149, 20));
			SwingUtils.fillWithEnum(comboBillState,CountInvBillStateEnum.class);
			comboBillState.addItem(ALLBILL);
		}
		return comboBillState;
	}

	/**
	 * This method initializes comboCountType	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getComboCountType()
	{
		if (comboCountType == null)
		{
			comboCountType = new JComboBox();
			comboCountType.setBounds(new Rectangle(82, 106, 135, 20));
			SwingUtils.fillWithEnum(comboCountType,CountInvTypeEnum.class);
			comboCountType.addItem(ALLBILL);
		}
		return comboCountType;
	}

} // @jve:decl-index=0:visual-constraint="10,10"

⌨️ 快捷键说明

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