public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { ResponseMachineVo inVo = (ResponseMachineVo)vo; StringBuilder sql = new StringBuilder(); sql.Append("insert into public.m_response_machine(machine_id,prodution_work_content_id,registration_user_cd,registration_date_time,factory_cd) "); sql.Append("values(:machine_id,:prodution_work_content_id,:registration_user_cd,now(),:factory_cd)"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); // DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("machine_id", inVo.MachineId); sqlParameter.AddParameterInteger("prodution_work_content_id", inVo.ProdutionWorkContentId); sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode); sqlParameter.AddParameterString("registration_user_cd", inVo.RegistrationUserCode); //execute SQL ResponseMachineVo outVo = new ResponseMachineVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { ResponseMachineVo inVo = (ResponseMachineVo)vo; StringBuilder sql = new StringBuilder(); ValueObjectList <ResponseMachineVo> voList = new ValueObjectList <ResponseMachineVo>(); DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, string.Empty); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append("select response_machine_id, machine_id, prodution_work_content_id, registration_user_cd,registration_date_time,factory_cd from public.m_response_machine"); 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.MachineId > 0) { sql.Append(" and machine_id = :machine_id "); sqlParameter.AddParameterInteger("machine_id", inVo.MachineId); } if (inVo.ProdutionWorkContentId > 0) { sql.Append(" and prodution_work_content_id = :prodution_work_content_id "); sqlParameter.AddParameterInteger("prodution_work_content_id", inVo.ProdutionWorkContentId); } if (inVo.ResponseMachineId > 0) { sql.Append(" and response_machine_id = :response_machine_id "); sqlParameter.AddParameterInteger("response_machine_id", inVo.ResponseMachineId); } //create command //DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { ResponseMachineVo outVo = new ResponseMachineVo { //convert ResponseMachineId = int.Parse(dataReader["response_machine_id"].ToString()), ProdutionWorkContentId = int.Parse(dataReader["prodution_work_content_id"].ToString()), MachineId = int.Parse(dataReader["machine_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) { ResponseMachineVo inVo = (ResponseMachineVo)vo; StringBuilder sql = new StringBuilder(); DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, string.Empty); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append("delete from public.m_response_machine Where 1=1 "); if (!String.IsNullOrEmpty(inVo.FactoryCode)) { sql.Append(" and factory_cd = :factory_cd "); sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode); } if (inVo.MachineId > 0) { sql.Append(" and machine_id = :machine_id "); sqlParameter.AddParameterInteger("machine_id", inVo.MachineId); } if (inVo.ProdutionWorkContentId > 0) { sql.Append(" and prodution_work_content_id = :prodution_work_content_id "); sqlParameter.AddParameterInteger("prodution_work_content_id", inVo.ProdutionWorkContentId); } if (inVo.ResponseMachineId > 0) { sql.Append(" and response_machine_id = :response_machine_id "); sqlParameter.AddParameterInteger("response_machine_id", inVo.ResponseMachineId); } //create command sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL MachineVo outVo = new MachineVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }