package cn.hmsoft.ltc.model;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import javafx.beans.property.DoubleProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;

/**
 * 题型实体类
 * @author yfz
 *
 */
public class QuestionType {
	private IntegerProperty id;							//编号
	
	private StringProperty code;					//题型编码

	private IntegerProperty editeStatus;				//运行编辑状态-1  允许编辑,0- 不允许编辑
	
	private StringProperty name;					//题型名称
	
	private IntegerProperty correctOptionsNum;			//题型
	
	private IntegerProperty statusCode;					//选项状态 0停用 1启用
	
	private StringProperty statusName;					//选项状态 0停用 1启用
	
	private StringProperty remark;					//备注
	
	private StringProperty createTime;				//创建时间
	
	private IntegerProperty createBy;					//创建人
	
	private StringProperty updatedTime;				//最近更新时间
	
	private IntegerProperty updatedBy;				//最近更新人

	private IntegerProperty defaultScore;			//默认分值
	
	private StringProperty guideText;    //题型指导语
	
	private IntegerProperty order;//题型排序,试卷中根据这个字段显示题目先后
	
	protected StringProperty scoreStr;    //默认分值 字符串
	protected IntegerProperty subTotal;//题型小计
	protected IntegerProperty subTotalStr;//题型小计总和
	protected Button moveRightBtn = new Button();
	protected Button deleteBtn = new Button();
	protected TextField quesNumsTx = new TextField();
	protected TextField typeScoreTx = new TextField();
	protected StringProperty correctOptionsName;			//题型名称  0：主观题 1.单选题 2.多选题
	
	public QuestionType() {
		this.id = new SimpleIntegerProperty();
		this.code = new SimpleStringProperty();
		this.editeStatus = new SimpleIntegerProperty();
		this.name = new SimpleStringProperty();
		this.correctOptionsName = new SimpleStringProperty();
		this.correctOptionsNum = new SimpleIntegerProperty();
		this.statusCode = new SimpleIntegerProperty();
		this.statusName = new SimpleStringProperty();
		this.remark = new SimpleStringProperty();
		this.createTime = new SimpleStringProperty();
		this.createBy = new SimpleIntegerProperty();
		this.updatedTime = new SimpleStringProperty();
		this.updatedBy = new SimpleIntegerProperty();
		this.defaultScore = new SimpleIntegerProperty();
		this.guideText = new SimpleStringProperty();
		this.order = new SimpleIntegerProperty();
		this.subTotal = new SimpleIntegerProperty();
		this.scoreStr = new SimpleStringProperty();
		this.subTotalStr = new SimpleIntegerProperty();
	}
	
	public QuestionType(Integer id,String code,Integer editeStatus,String name,String correctOptionsName,
			Integer correctOptionsNum,Integer statusCode,String statusName,String remark,String createTime,Integer createBy,
			String updatedTime,Integer updatedBy,Integer defaultScore,String guideText) {
		this.id = new SimpleIntegerProperty(id);
		this.code = new SimpleStringProperty(code);
		this.editeStatus = new SimpleIntegerProperty(editeStatus);
		this.name = new SimpleStringProperty(name);
		this.correctOptionsName = new SimpleStringProperty(correctOptionsName);
		this.correctOptionsNum = new SimpleIntegerProperty(correctOptionsNum);
		this.statusCode = new SimpleIntegerProperty(statusCode);
		this.statusName = new SimpleStringProperty(statusName);
		this.remark = new SimpleStringProperty(remark);
		this.createTime = new SimpleStringProperty(createTime);
		this.createBy = new SimpleIntegerProperty(createBy);
		this.updatedTime = new SimpleStringProperty(updatedTime);
		this.updatedBy = new SimpleIntegerProperty(updatedBy);
		this.defaultScore = new SimpleIntegerProperty(defaultScore);
		this.guideText = new SimpleStringProperty(guideText);
	}

	public Integer getId() {
		return id.get();
	}

	public void setId(Integer id) {
		this.id.set(id);
	}

	public String getCode() {
		return code.get();
	}

	public void setCode(String code) {
		this.code.set(code);
	}

	public String getName() {
		return name.get();
	}

	public void setName(String name) {
		this.name.set(name);
	}

	public Integer getCorrectOptionsNum() {
		return correctOptionsNum.get();
	}

	public void setCorrectOptionsNum(Integer correctOptionsNum) {
		this.correctOptionsNum.set(correctOptionsNum);
	}

	public String getCorrectOptionsName() {
		return correctOptionsName.get();
	}

	public void setCorrectOptionsName(String correctOptionsName) {
		this.correctOptionsName.set(correctOptionsName);
	}

	public Integer getStatusCode() {
		return statusCode.get();
	}

	public void setStatusCode(Integer statusCode) {
		this.statusCode.set(statusCode);
	}

	public String getStatusName() {
		return statusName.get();
	}

	public void setStatusName(String statusName) {
		this.statusName.set(statusName);
	}

	public String getRemark() {
		return remark.get();
	}

	public void setRemark(String remark) {
		this.remark.set(remark);
	}

	public String getCreateTime() {
		return createTime.get();
	}

	public void setCreateTime(String createTime) {
		this.createTime.set(createTime);
	}

	public Integer getCreateBy() {
		return createBy.get();
	}

	public void setCreateBy(Integer createBy) {
		this.createBy.set(createBy);
	}

	public String getUpdatedTime() {
		return updatedTime.get();
	}

	public void setUpdatedTime(String updatedTime) {
		this.updatedTime.set(updatedTime);
	}

	public Integer getUpdatedBy() {
		return updatedBy.get();
	}

	public void setUpdatedBy(Integer updatedBy) {
		this.updatedBy.set(updatedBy);
	}

	public Integer getDefaultScore() {
		return defaultScore.get();
	}

	public void setDefaultScore(Integer defaultScore) {
		this.defaultScore.set(defaultScore);
	}

	public String getGuideText() {
		return guideText.get();
	}

	public void setGuideText(String guideText) {
		this.guideText.set(guideText);
	}
	
	public Integer getOrder() {
		return order.get();
	}

	public void setOrder(Integer order) {
		this.order.set(order);
	}

	public String toString() {
		return this.id.get() == -1 ? name.get() : code.get() + " | " + name.get();
	}
	
	public int hashCode() {
	     return new HashCodeBuilder(17, 37).
	       append(this.id.get()).
	       append(this.code.get()).
	       append(this.name.get()).
	       toHashCode();
	}
	
	public boolean equals(Object obj) {
		   if (obj == null) { return false; }
		   if (obj == this) { return true; }
		   if (obj.getClass() != getClass()) {
		     return false;
		   }
		   QuestionType oth = (QuestionType) obj;
		   return new EqualsBuilder()
		                 .append(this.id.get(), oth.id.get())
		                 .append(this.code.get(), oth.code.get())
		                 .append(this.name.get(), oth.name.get())
		                 .isEquals();
	}

	public Button getMoveRightBtn() {
		return moveRightBtn;
	}

	public Button getDeleteBtn() {
		return deleteBtn;
	}

	public void setMoveRightBtn(Button moveRightBtn) {
		this.moveRightBtn = moveRightBtn;
	}

	public void setDeleteBtn(Button deleteBtn) {
		this.deleteBtn = deleteBtn;
	}

	public Integer getSubTotal() {
		return subTotal.get();
	}

	public void setSubTotal(Integer subTotal) {
		this.subTotal.set(subTotal);
	}

	public TextField getQuesNumsTx() {
		return quesNumsTx;
	}

	public void setQuesNumsTx(TextField quesNumsTx) {
		this.quesNumsTx = quesNumsTx;
	}

	public TextField getTypeScoreTx() {
		return typeScoreTx;
	}

	public void setTypeScoreTx(TextField typeScoreTx) {
		this.typeScoreTx = typeScoreTx;
	}
	
	public Integer getEditeStatus() {
		return editeStatus.get();
	}

	public void setEditeStatus(Integer editeStatus) {
		this.editeStatus.set(editeStatus);
	}

	public String getScoreStr() {
		return scoreStr.get();
	}

	public void setScoreStr(String scoreStr) {
		this.scoreStr.set(scoreStr);
	}

	public Integer getSubTotalStr() {
		return subTotalStr.get();
	}

	public void setSubTotalStr(Integer subTotalStr) {
		this.subTotalStr.set(subTotalStr);
	}
}
