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

📄 petinfoform.java

📁 爱心”宠物诊所的职员需要使用系统提供的如下功能: 浏览诊所的兽医以及他们的专业特长; 浏览宠物的主人(即诊所的客户)的相关信息; 更新宠物的主人的相关信息; 向系统中增加一个新客户; 浏览宠
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.wzxy.web.struts.form;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.LabelValueBean;
import org.apache.struts.validator.ValidatorForm;

import com.wzxy.business.IPetMgr;
import com.wzxy.business.PetMgrFactory;
import com.wzxy.exception.DBException;
import com.wzxy.pojos.PetDTO;
import com.wzxy.pojos.PetOwnerDTO;

/**
 * MyEclipse Struts Creation date: 11-10-2007
 * 
 * XDoclet definition:
 * 
 * @struts.form name="petInfoForm"
 */
public class PetInfoForm extends ValidatorForm {
	/*
	 * Generated fields
	 */

	private int petID;

	private String petName;

	private Date petBirthDate;

	private String strYear;

	private String strMonth;

	private String strDay;

	private int petTypeID;

	private int petOwnerID;

	private String petOwnerName;

	private String petTypeName;

	private static final String DATE_PATTERN = "yyyy-MM-dd";

	/*
	 * Generated Methods
	 */

	/**
	 * Method validate
	 * 
	 * @param mapping
	 * @param request
	 * @return ActionErrors
	 */
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * Method reset
	 * 
	 * @param mapping
	 * @param request
	 */
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		IPetMgr service=PetMgrFactory.getInstance();
		try {
			ArrayList petTypes= (ArrayList) service.selectPetTypes();
			ArrayList owners=(ArrayList) service.selectPetOwners();
			request.setAttribute("petTypes",petTypes);
			request.setAttribute("owners",owners);
		} catch (DBException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		ArrayList yearOptions = new ArrayList();
		ArrayList monthOptions = new ArrayList();
		ArrayList dateOptions = new ArrayList();
		for (int i = 1970; i <= new java.util.Date().getYear() + 1900; i++) {
			LabelValueBean option = new LabelValueBean(String.valueOf(i),
					String.valueOf(i));
			yearOptions.add(option);
		}

		for (int i = 1; i <= 12; i++) {
			LabelValueBean option = new LabelValueBean(String.valueOf(i),
					String.valueOf(i));
			monthOptions.add(option);
		}

		for (int i = 1; i <= 31; i++) {
			LabelValueBean option = new LabelValueBean(String.valueOf(i),
					String.valueOf(i));
			dateOptions.add(option);
		}

		request.setAttribute("yearOptions", yearOptions);
		request.setAttribute("monthOptions", monthOptions);
		request.setAttribute("dateOptions", dateOptions);
		
		
	}

	public String getStrYear() {
		return strYear;
	}

	public void setStrYear(String strYear) {
		this.strYear = strYear;
		System.out.println(strYear);
	}

	public String getStrMonth() {
		return strMonth;
	}

	public void setStrMonth(String strMonth) {
		this.strMonth = strMonth;

		String strBirth = this.getStrYear() + "-" + this.getStrMonth() + "-"
				+ this.strDay;

		SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN);
		dateFormat.setLenient(false);
	
		try {
			this.petBirthDate = dateFormat.parse(strBirth);
		} catch (ParseException e) {
			e.printStackTrace();
			System.out.println("error birthday!");
		}
	
		System.out.println("petBirthDate :" +new java.sql.Date(petBirthDate.getTime()) );
	}

	public String getStrDay() {
		return strDay;
	}

	public void setStrDay(String strDay) {
		this.strDay = strDay;
    }

	
	public int getPetTypeID() {
		return petTypeID;
	}

	/**
	 * Set the petTypeId.
	 * 
	 * @param petTypeId
	 *            The petTypeId to set
	 */
	public void setPetTypeId(int petTypeID) {
		this.petTypeID = petTypeID;
	}

	/**
	 * Returns the petTypeName.
	 * 
	 * @return String
	 */
	public String getPetTypeName() {
		return petTypeName;
	}

	/**
	 * Set the petTypeName.
	 * 
	 * @param petTypeName
	 *            The petTypeName to set
	 */
	public void setPetTypeName(String petTypeName) {
		this.petTypeName = petTypeName;
	}

	public int getPetOwnerID() {
		return petOwnerID;
	}

	/**
	 * Set the petOwnerId.
	 * 
	 * @param petOwnerId
	 *            The petOwnerId to set
	 */
	public void setPetOwnerID(int petOwnerID) {
		this.petOwnerID = petOwnerID;
	}

	/**
	 * Returns the petName.
	 * 
	 * @return String
	 */
	public String getPetName() {
		return petName;
	}

	/**
	 * Set the petName.
	 * 
	 * @param petName
	 *            The petName to set
	 */
	public void setPetName(String petName) {
		this.petName = petName;
	}

	/**
	 * Returns the strMonth.
	 * 
	 * @return String
	 */

	/**
	 * Returns the petOwnerName.
	 * 
	 * @return String
	 */
	public String getPetOwnerName() {
		return petOwnerName;
	}

	/**
	 * Set the petOwnerName.
	 * 
	 * @param petOwnerName
	 *            The petOwnerName to set
	 */
	public void setPetOwnerName(String petOwnerName) {
		this.petOwnerName = petOwnerName;
	}

	/**
	 * Returns the petBirthDate.
	 * 
	 * @return Date
	 */
	public Date getPetBirthDate() {
		return petBirthDate;
	}

	/**
	 * Set the petBirthDate.
	 * 
	 * @param petBirthDate
	 *            The petBirthDate to set
	 */
	public void setPetBirthDate(Date petBirthDate) {
		this.petBirthDate = petBirthDate;
		
		
	}

	/**
	 * Returns the petId.
	 * 
	 * @return TexturePaintContext$Int
	 */
	public int getPetID() {
		return petID;
	}

	/**
	 * Set the petId.
	 * 
	 * @param petId
	 *            The petId to set
	 */
	public void setPetID(int petID) {
		this.petID = petID;
	}
}

⌨️ 快捷键说明

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