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

📄 outinvbillsysdeffilterui.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.OutInvBillStateEnum;
import com.cownew.PIS.inv.common.OutInventoryBillInfo;
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 OutInvBillSysDefFilterUI extends SysDefFilterPanel
{

	private static final String ALLBILL = "全部";

	private static final String BLUEBILL = "蓝单";

	private static final String REDBILL = "红单";

	private static final String IS_RED_BILL = "isRedBill";
	
	private static final String BILLSTATE = "billState";

	private static final String OPERATORID = "operatorid";

	private static final String OUT_DATE_TO = "outDateTo";

	private static final String OUT_DATE_FROM = "outDateFrom";

	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 JComboBox comboBillType;

	private JLabel jLabel4;

	private JTextField txtNumberTo;

	private PopupDatePicker pdpCreateDateFrom;

	private PopupDatePicker pdpCreateDateTo;

	private PopupDatePicker pdpOutDateFrom;

	private PopupDatePicker pdpOutDateTo;

	private PopupValueObjectPicker popOperator;

	private JLabel jLabel41;

	private JLabel jLabel42;

	private JLabel jLabel5;

	private JComboBox comboBillState;

	public OutInvBillSysDefFilterUI()
	{
		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 = pdpOutDateFrom.getSQLDate();
		if (bizDateFrom != null)
		{
			kvList.add(OUT_DATE_FROM, bizDateFrom);
		}

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

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

		String billType = (String) comboBillType.getSelectedItem();
		if (billType.equals(REDBILL))
		{
			kvList.add(IS_RED_BILL, Boolean.valueOf(true));
		} else if (billType.equals(BLUEBILL))
		{
			kvList.add(IS_RED_BILL, Boolean.valueOf(false));
		}
		
		Object objBillState = comboBillState.getSelectedItem();
		if(objBillState instanceof OutInvBillStateEnum)
		{
			String name = ((OutInvBillStateEnum)objBillState).getName();
			kvList.add(BILLSTATE, name);
		}

		return kvList;
	}

	public String getSQL()
	{
		StringBuffer sbSQL = new StringBuffer();
		sbSQL.append("from ").append(OutInventoryBillInfo.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 = pdpOutDateFrom.getSQLDate();
		if (bizDateFrom != null)
		{
			sbSQL.append(" and outDate>=:outDateFrom");
		}

		Date bizDateTo = pdpOutDateTo.getSQLDate();
		if (bizDateTo != null)
		{
			sbSQL.append(" and outDate<=:outDateTo");
		}

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

		String billType = (String) comboBillType.getSelectedItem();
		if (billType.equals(REDBILL) || billType.equals(BLUEBILL))
		{
			sbSQL.append(" and isRedBill=:isRedBill");
		}

		Object objBillState = comboBillState.getSelectedItem();
		if(objBillState instanceof OutInvBillStateEnum)
		{
			sbSQL.append(" and billState=:billState");
		}
		
		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(OUT_DATE_FROM);
		if (!StringUtils.isEmpty(strBizDateFrom))
		{
			pdpOutDateFrom.setDate(Date.valueOf(strBizDateFrom));
		} else
		{
			pdpOutDateFrom.setDate(null);
		}

		String strBizDateTo = prop.getProperty(OUT_DATE_TO);
		if (!StringUtils.isEmpty(strBizDateTo))
		{
			pdpOutDateTo.setDate(Date.valueOf(strBizDateTo));
		} else
		{
			pdpOutDateTo.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 billType = prop.getProperty(IS_RED_BILL);
		if (StringUtils.isEmpty(billType))
		{
			SwingUtils.setSelectedItem(comboBillType, ALLBILL);
		} else
		{
			boolean isRedBill = Boolean.valueOf(billType).booleanValue();
			SwingUtils.setSelectedItem(comboBillType, isRedBill ? REDBILL
					: BLUEBILL);
		}
		
		String billState = prop.getProperty(BILLSTATE);
		if (StringUtils.isEmpty(billState))
		{
			SwingUtils.setSelectedItem(comboBillState, ALLBILL);
		} else
		{
			OutInvBillStateEnum state = (OutInvBillStateEnum) EnumUtils.getEnum(
					OutInvBillStateEnum.class, billState);
			SwingUtils.setSelectedItem(comboBillState, state);
		}
	}

	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("至");
		jLabel41 = new JLabel();
		jLabel41.setBounds(new Rectangle(237, 46, 58, 16));
		jLabel41.setText("至");
		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, 75, 16));
		jLabel1.setText("出库日期从");
		jLabel = new JLabel();
		jLabel.setBounds(new Rectangle(11, 46, 80, 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(getComboBillType(), 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 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 comboBillType
	 * 
	 * @return javax.swing.JComboBox
	 */
	private JComboBox getComboBillType()
	{
		if (comboBillType == null)
		{
			comboBillType = new JComboBox();
			comboBillType.addItem(ALLBILL);
			comboBillType.addItem(BLUEBILL);
			comboBillType.addItem(REDBILL);
			comboBillType.setBounds(new Rectangle(82, 104, 132, 21));
		}
		return comboBillType;
	}

	/**
	 * 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 (pdpOutDateFrom == null)
		{
			pdpOutDateFrom = new PopupDatePicker();
			pdpOutDateFrom.setBounds(new Rectangle(82, 77, 135, 21));
		}
		return pdpOutDateFrom;
	}

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

	/**
	 * 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(83, 132, 132, 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,OutInvBillStateEnum.class);
			comboBillState.addItem(ALLBILL);
		}
		return comboBillState;
	}

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

⌨️ 快捷键说明

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