public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { ModelProcessVo inVo = (ModelProcessVo)vo; StringBuilder sql = new StringBuilder(); sql.Append("insert into public.m_ncvp_model_process(model_id,process_id,registration_user_cd,registration_date_time,factory_cd) "); sql.Append("values(:model_id,:process_id,:registration_user_cd,now(),:factory_cd)"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); // DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("model_id", inVo.ModelID); sqlParameter.AddParameterInteger("process_id", inVo.ProcessID); sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode); sqlParameter.AddParameterString("registration_user_cd", inVo.RegistrationUserCode); //execute SQL ModelProcessVo outVo = new ModelProcessVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { ModelProcessVo inVo = (ModelProcessVo)vo; StringBuilder sql = new StringBuilder(); ValueObjectList <ModelProcessVo> voList = new ValueObjectList <ModelProcessVo>(); DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, string.Empty); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append("select model_process_id, model_id, process_id, registration_user_cd,registration_date_time,factory_cd from public.m_model_process"); sql.Append(" Where 1=1 "); // if (!String.IsNullOrEmpty(inVo.FactoryCode)) { sql.Append(" and factory_cd = :factory_cd "); sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode); } if (inVo.ModelID > 0) { sql.Append(" and model_id = :model_id "); sqlParameter.AddParameterInteger("model_id", inVo.ModelID); } if (inVo.ProcessID > 0) { sql.Append(" and process_id = :process_id "); sqlParameter.AddParameterInteger("process_id", inVo.ProcessID); } if (inVo.ModelProcessID > 0) { sql.Append(" and model_process_id = :model_process_id "); sqlParameter.AddParameterInteger("model_process_id", inVo.ModelProcessID); } //create command //DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { ModelProcessVo outVo = new ModelProcessVo { //convert ModelProcessID = int.Parse(dataReader["model_process_id"].ToString()), ModelID = int.Parse(dataReader["model_id"].ToString()), ProcessID = int.Parse(dataReader["process_id"].ToString()), RegistrationUserCode = dataReader["registration_user_cd"].ToString(), RegistrationDateTime = DateTime.Parse(dataReader["registration_date_time"].ToString()), FactoryCode = dataReader["factory_cd"].ToString() }; voList.add(outVo); } dataReader.Close(); return(voList); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { ModelProcessVo inVo = (ModelProcessVo)vo; StringBuilder sql = new StringBuilder(); DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, string.Empty); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append("delete from public.m_model_process Where 1=1 "); if (!String.IsNullOrEmpty(inVo.FactoryCode)) { sql.Append(" and factory_cd = :factory_cd "); sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode); } if (inVo.ModelID > 0) { sql.Append(" and model_id = :model_id "); sqlParameter.AddParameterInteger("model_id", inVo.ModelID); } if (inVo.ProcessID > 0) { sql.Append(" and process_id = :process_id "); sqlParameter.AddParameterInteger("process_id", inVo.ProcessID); } if (inVo.ModelProcessID > 0) { sql.Append(" and model_process_id = :model_process_id "); sqlParameter.AddParameterInteger("model_process_id", inVo.ModelProcessID); } //create command sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL ModelVo outVo = new ModelVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }