package com.steering.mes.zgmil.coup;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;

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

import com.steering.comm.db.DBCommon;
import com.steering.common.EntityTool;
import com.steering.mes.zgmil.entity.MilPerToolEntity;
import com.steering.mes.zgmil.entity.MilPlanEntity;
import com.steering.mes.zgmil.entity.MilFeedPlanEntity;
import com.steering.mes.zgmil.entity.MilRollingToolEntity;
import com.steering.mes.zgmil.entity.MilSizingToolEntity;

public class FrmToolChange extends DBCommon {
	   public CoreReturnObject ToolResultAdd(MilPerToolEntity MilPerToolEntity,MilRollingToolEntity MilRollingToolEntity,MilSizingToolEntity MilSizingToolEntity,Integer Flag
			   ){
		   String sql = "";
		   ArrayList<String> sqllist = new ArrayList<String>();
		   if(Flag.equals(1))
		   {
			   sql = CoreXmlSqlParsersFactory.getSql("ToolChange.AddPerResultNode");	
			    sql = EntityTool.fillSqlByEntity(sql, MilPerToolEntity);
		   }
		   if(Flag.equals(2))
		   {
			   sql = CoreXmlSqlParsersFactory.getSql("ToolChange.AddRollingResultNode");	
			    sql = EntityTool.fillSqlByEntity(sql, MilRollingToolEntity);
		   }
		   if(Flag.equals(3))
		   {
			   sql = CoreXmlSqlParsersFactory.getSql("ToolChange.AddSizingResultNode");	
			    sql = EntityTool.fillSqlByEntity(sql, MilSizingToolEntity);
		   }
	   
	      
	       sqllist.add(sql);
	
	       return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);	
	       
	   }
	   
	   
	   public CoreReturnObject ToolResultUpdate(MilPerToolEntity MilPerToolEntity,MilRollingToolEntity MilRollingToolEntity,MilSizingToolEntity MilSizingToolEntity,Integer Flag
			   ){
		   String sql = "";
		   ArrayList<String> sqllist = new ArrayList<String>();
		   if(Flag.equals(1))
		   {
			   sql = CoreXmlSqlParsersFactory.getSql("ToolChange.UpdatePerResultNode");	
			    sql = EntityTool.fillSqlByEntity(sql, MilPerToolEntity);
		   }
		   if(Flag.equals(2))
		   {
			   sql = CoreXmlSqlParsersFactory.getSql("ToolChange.UpdateRollingResultNode");	
			    sql = EntityTool.fillSqlByEntity(sql, MilRollingToolEntity);
		   }
		   if(Flag.equals(3))
		   {
			   sql = CoreXmlSqlParsersFactory.getSql("ToolChange.UpdateSizingResultNode");	
			    sql = EntityTool.fillSqlByEntity(sql, MilSizingToolEntity);
		   }
	   
	      
	       sqllist.add(sql);
	
	       return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);	
	       
	   }
	   
	   public CoreReturnObject ToolResultDelete(MilPerToolEntity MilPerToolEntity,MilRollingToolEntity MilRollingToolEntity,MilSizingToolEntity MilSizingToolEntity,Integer Flag
			   ){
		   String sql = "";
		   ArrayList<String> sqllist = new ArrayList<String>();
		   if(Flag.equals(1))
		   {
			   sql = CoreXmlSqlParsersFactory.getSql("ToolChange.DeletePerResultNode");	
			    sql = EntityTool.fillSqlByEntity(sql, MilPerToolEntity);
		   }
		   if(Flag.equals(2))
		   {
			   sql = CoreXmlSqlParsersFactory.getSql("ToolChange.DeleteRollingResultNode");	
			    sql = EntityTool.fillSqlByEntity(sql, MilRollingToolEntity);
		   }
		   if(Flag.equals(3))
		   {
			   sql = CoreXmlSqlParsersFactory.getSql("ToolChange.DeleteSizingResultNode");	
			    sql = EntityTool.fillSqlByEntity(sql, MilSizingToolEntity);
		   }
	   
	      
	       sqllist.add(sql);
	
	       return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);	
	       
	   }
	
}
