public List <MODEL.risk_resource> findResByTaskAutoId(int taskAutoId) { List <MODEL.risk_resource> resourcesList = new List <MODEL.risk_resource>(); string sql = "select * from risk_resource where AUTO_ID in (select RESOURCE_ID from risk_task_resource_assignment where TASK_AUTO_ID=:taskAutoId)"; OracleParameter[] parameters = new OracleParameter[] { new OracleParameter(":taskAutoId", OracleDbType.Int32, 11) }; parameters[0].Value = taskAutoId; try { using (OracleDataReader reader = SqlHelper.ExecuteQuery(sql, parameters)) { while (reader.Read()) { MODEL.risk_resource res = new MODEL.risk_resource(); res.Auto_id = Convert.ToInt32(reader["auto_id"]); res.Resource_amount = Convert.ToInt32(reader["resource_amount"]); res.Resource_description = reader["resource_description"].ToString(); res.Resource_name = reader["resource_name"].ToString(); res.Resource_remains = Convert.ToInt32(reader["resource_remains"]); int resourceTypeId = Convert.ToInt32(reader["resource_type"]); res.Resource_type = DALresources.findresourceTypeNameById(resourceTypeId); res.Resource_unit_price = Convert.ToDouble(reader["resource_unit_price"]); resourcesList.Add(res); } } return(resourcesList); } catch (Exception ex) { throw ex; } }
public List <MODEL.risk_resource> showResources(int projectId) { string sql = "select * from risk_project_res_assignment where pri_id =:projectId"; OracleParameter[] parameters = new OracleParameter[] { new OracleParameter(":projectId", OracleDbType.Int32, 11) }; parameters[0].Value = projectId; try { using (OracleDataReader myReader = SqlHelper.ExecuteQuery(sql, parameters)) { List <MODEL.risk_resource> ResList = new List <MODEL.risk_resource>(); while (myReader.Read()) { DALresources get_Resource = new DALresources(); MODEL.risk_resource Res = new MODEL.risk_resource(); Res = get_Resource.findResById(Int32.Parse(myReader["RESOURCE_ID"].ToString())); Res.Resource_amount = Int32.Parse(myReader["assignment_amount"].ToString()); ResList.Add(Res); } return(ResList); } } catch (System.Exception ex) { throw ex; } }
public void insertRes(int taskAutoId, MODEL.risk_resource res) { string sql = "insert into risk_task_resource_assignment(auto_id,task_auto_id,resource_id,assignment_amount,assignment_own)values(RISK_TASK_RES_ASSIGN_AUTOID.NEXTVAL,:taskAutoId,:resourceId,:assignmentAmount,:assignmentOwn)"; OracleParameter[] parameters = new OracleParameter[] { new OracleParameter(":taskAutoId", OracleDbType.Int32, 11), new OracleParameter(":resourceId", OracleDbType.Int32, 11), new OracleParameter(":assignmentAmount", OracleDbType.Int32, 11), new OracleParameter(":assignmentOwn", OracleDbType.Int32, 11) }; DAL.DALresources resource_operation = new DALresources(); parameters[0].Value = taskAutoId; parameters[1].Value = resource_operation.findResByName(res.Resource_name).Auto_id; parameters[2].Value = res.Resource_amount; parameters[3].Value = 0; try { SqlHelper.ExecuteNonQuery(sql, parameters); } catch (System.Exception ex) { throw ex; } }