package com.steering.pss.qcm;

import java.sql.Connection;
import java.util.ArrayList;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import CoreFS.SC01.CoreConstantData;

import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.EntityTool;
import com.steering.pss.qcm.model.ComMscGradeEntity;

public class TestComMscGradeDAL extends DBCommon{
	public String getInsertSql(ComMscGradeEntity mscGradeEntity){
		String sql = CoreXmlSqlParsersFactory.getSql("TestComMscGrade.insert");
		sql = EntityTool.fillSqlByEntity(sql, mscGradeEntity);
		return sql;
	}
	
	public String getUpdateSql(ComMscGradeEntity mscGradeEntity){
		String sql = CoreXmlSqlParsersFactory.getSql("");
		sql = EntityTool.fillSqlByEntity(sql, mscGradeEntity);
		return sql;
	}
	
	public ComMscGradeEntity getComMscGradeEntityByPk(ComMscGradeEntity mscGradeEntity){
		String sql = CoreXmlSqlParsersFactory.getSql("");
		sql = EntityTool.fillSqlByEntity(sql, mscGradeEntity);
		Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		ArrayList<ComMscGradeEntity> listMscGrade = EntityTool.getEntitysBySql(sql, con, ComMscGradeEntity.class);
		if(listMscGrade.size() > 0){
			return listMscGrade.get(0);
		}else{
			return null;
		}
	}
	
	public ArrayList<ComMscGradeEntity> getComMscGradeEntity(ComMscGradeEntity mscGradeEntity){
		String sql = CoreXmlSqlParsersFactory.getSql("TestComMscGrade.getComMscGradeEntity");
		sql = EntityTool.fillSqlByEntity(sql, mscGradeEntity);
		Connection con = this.getDao(CoreConstantData.sysbeanstr).getConnection();
		ArrayList<ComMscGradeEntity> listMscGrade = EntityTool.getEntitysBySql(sql, con, ComMscGradeEntity.class);
		return listMscGrade;
	}
	
	public CoreReturnObject getComMscGradeEntityCroByPk(ComMscGradeEntity mscGradeEntity){
		CoreReturnObject cro = new CoreReturnObject();
		cro.setResult(getComMscGradeEntityByPk(mscGradeEntity));
		return cro;
	}
	
	public CoreReturnObject getComMscGradeEntityCro(ComMscGradeEntity mscGradeEntity){
		CoreReturnObject cro = new CoreReturnObject();
		cro.setResult(getComMscGradeEntity(mscGradeEntity));
		return cro;
	}
	
	public CoreReturnObject insert(ComMscGradeEntity mscGradeEntity){
		String sql = this.getInsertSql(mscGradeEntity);
		return this.setData(sql);
	}
	
	public CoreReturnObject update(ComMscGradeEntity mscGradeEntity){
		String sql = this.getUpdateSql(mscGradeEntity);
		return this.setData(sql);
	}
}
