package com.steering.pss.sale.price.server;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;

import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.EntityTool;
import com.steering.pss.sale.price.entity.SlmPriceBasesuitEntity;
import com.steering.pss.sale.price.entity.SlmPriceDocEntity;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import CoreFS.SC01.CoreConstantData;
public class CorePriceBaseSuit extends DBCommon {
	
	
	 public CoreReturnObject query(String SUIT_ID, String SUIT_NAME, String valid) {
	        String sql = CoreXmlSqlParsersFactory.getSql("CorePriceBaseSuit.query");
	        sql = sql.replaceAll("#SUIT_ID#", SUIT_ID);
	        sql = sql.replaceAll("#SUIT_NAME#", SUIT_NAME);
	        sql = sql.replaceAll("#VALIDFLAG#", valid);
	        return this.getData(sql);
	    }
	 public CoreReturnObject save(ArrayList<String> listJSON){
			ArrayList<String> sqllist = new ArrayList<String>();
			
			for(String strJSON : listJSON){
				SlmPriceBasesuitEntity PBFS = EntityTool.getEntityByJSONStr(strJSON, SlmPriceBasesuitEntity.class);
				if (PBFS.getValidflag().equals("")) {
					String sql_insert = CoreXmlSqlParsersFactory.getSql("CorePriceBaseSuit.insert");
					sql_insert = EntityTool.fillSqlByEntity(sql_insert, PBFS);
					sqllist.add(sql_insert);
				}
				else {
					String sql_update = CoreXmlSqlParsersFactory.getSql("CorePriceBaseSuit.update");
					sql_update = EntityTool.fillSqlByEntity(sql_update, PBFS);
					sqllist.add(sql_update);
				}				
			}
			return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
	}
	 public CoreReturnObject GetSUITCLASSIFY(String ver_type) {
		 Object[] obj = new Object[] { ver_type };
	        return this.getDataBySqlID("CorePriceBaseSuit.getSUITCLASSIFY", obj);
	    }
	 public CoreReturnObject GetSUITVALUE(String SUITCLASSIFY) {
		 Object[] obj = new Object[] { SUITCLASSIFY };
	        return this.getDataBySqlID("CorePriceBaseSuit.getSUITVALUE", obj);
	    }
	 public CoreReturnObject canResume(ArrayList<String> listJSON) throws SQLException {

			String strJSON = listJSON.get(0);
			SlmPriceBasesuitEntity PBFS = EntityTool.getEntityByJSONStr(
					strJSON, SlmPriceBasesuitEntity.class);

			String sql_canResume = CoreXmlSqlParsersFactory
					.getSql("CorePriceBaseSuit.canResume");
			sql_canResume = EntityTool.fillSqlByEntity(sql_canResume, PBFS);
				
			return this.getData(sql_canResume);
	    }
	public CoreReturnObject deleteOrResume(ArrayList<String> listJSON,Boolean flag){
		ArrayList<String> sqllist = new ArrayList<String>();
		
		for(String strJSON : listJSON){
			SlmPriceBasesuitEntity PBFS = EntityTool.getEntityByJSONStr(strJSON, SlmPriceBasesuitEntity.class);
			if (flag) {
				String sql_delete = CoreXmlSqlParsersFactory.getSql("CorePriceBaseSuit.Delete");
				sql_delete = EntityTool.fillSqlByEntity(sql_delete, PBFS);
				sqllist.add(sql_delete);
			}
			else {
				String sql_resume = CoreXmlSqlParsersFactory.getSql("CorePriceBaseSuit.Resume");
				sql_resume = EntityTool.fillSqlByEntity(sql_resume, PBFS);
				sqllist.add(sql_resume);
			}				
		}
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
}
	
	 public CoreReturnObject FactorBind(String TableName, String DataValue, String DataDesc,String sql_getSQL) {
	       String sql_getFactorBind="";
		 if (sql_getSQL == null || sql_getSQL.isEmpty() ) {
			 sql_getFactorBind = "select " + DataValue + "," + DataDesc + "  from   " + TableName;
		}
		 else
		 {
			 sql_getFactorBind = sql_getSQL ;
			
		 }	 
		 
		        
	        return this.getData(sql_getFactorBind);
	    }	
	 
	 public CoreReturnObject GetSuitInfo (String SuitId) {
		 Object[] obj = new Object[] { SuitId };
	        return this.getDataBySqlID("CorePriceBaseSuit.GetSuitInfo", obj);
	    }
	
	 
	 
	 
	
}
