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.SlmPriceBasepriceEntity;
import com.steering.pss.sale.price.entity.SlmPriceBasepriceExpEntity;
import com.steering.pss.sale.price.entity.SlmPriceBasepriceLineEntity;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import CoreFS.SC01.CoreConstantData;
public class CorePriceFramePriceExp extends DBCommon {

	 /**
     * @param valid
     * @return
     */
    public CoreReturnObject queryById(String PRICE_HEAD_ID, String isValid) {
     
        String sql = CoreXmlSqlParsersFactory.getSql("CorePriceFramePriceExp.getPriceExpByVerId");
        sql = sql.replaceAll("#PRICE_HEAD_ID#", PRICE_HEAD_ID);
        sql = sql.replaceAll("#VALIDFLAG#", isValid);
        return this.getData(sql);
        
        
    }
    
    public CoreReturnObject save(ArrayList<String> listJSON){
		ArrayList<String> sqllist = new ArrayList<String>();
		
		for(String strJSON : listJSON){
			SlmPriceBasepriceExpEntity PBFS = EntityTool.getEntityByJSONStr(strJSON, SlmPriceBasepriceExpEntity.class);
			if (PBFS.getValidflag().equals("")) {
				String sql_insert = CoreXmlSqlParsersFactory.getSql("CorePriceFramePriceExp.insert");
				sql_insert = EntityTool.fillSqlByEntity(sql_insert, PBFS);
				sqllist.add(sql_insert);
			}
			else {
				String sql_update = CoreXmlSqlParsersFactory.getSql("CorePriceFramePriceExp.update");
				sql_update = EntityTool.fillSqlByEntity(sql_update, PBFS);
				sqllist.add(sql_update);
			}				
		}
		
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
}
    
    public CoreReturnObject deleteOrResume(ArrayList<String> listJSON,Boolean flag){
		ArrayList<String> sqllist = new ArrayList<String>();
		
		for(String strJSON : listJSON){
			SlmPriceBasepriceExpEntity PBFS = EntityTool.getEntityByJSONStr(strJSON, SlmPriceBasepriceExpEntity.class);
			if (flag) {
				String sql_delete = CoreXmlSqlParsersFactory.getSql("CorePriceFramePriceExp.Delete");
				sql_delete = EntityTool.fillSqlByEntity(sql_delete, PBFS);
				sqllist.add(sql_delete);
			}
			else {
				String sql_resume = CoreXmlSqlParsersFactory.getSql("CorePriceFramePriceExp.Resume");
				sql_resume = EntityTool.fillSqlByEntity(sql_resume, PBFS);
				sqllist.add(sql_resume);
			}				
		}
		
		
		
		
		return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
} 
	
	
	
}
