public DataSet GetAffectedWPTiming(ITimingAndInterco timimgandInterco, DBGenericEntity dbGenericEntity) { DataSet ds = new DataSet(); ds = dbGenericEntity.GetCustomDataSet("GetAffectedWPTiming", timimgandInterco) as DataSet; return(ds); }
protected override void InitializeObject(IGenericEntity ent) { if (ent is ITimingAndInterco) { ITimingAndInterco timingAndInterco = (ITimingAndInterco)ent; DBStoredProcedure spGetPeriodAfectation = new DBStoredProcedure(); spGetPeriodAfectation.ProcedureName = "bgtGetAffectedWPTiming"; spGetPeriodAfectation.AddParameter(new DBParameter("@IdProject", DbType.Int32, ParameterDirection.Input, timingAndInterco.IdProject)); this.AddStoredProcedure("GetAffectedWPTiming", spGetPeriodAfectation); DBStoredProcedure spGetWPTiming = new DBStoredProcedure(); spGetWPTiming.ProcedureName = "bgtGetWPTiming"; spGetWPTiming.AddParameter(new DBParameter("@IdProject", DbType.Int32, ParameterDirection.Input, timingAndInterco.IdProject)); spGetWPTiming.AddParameter(new DBParameter("@IdPhase", DbType.Int32, ParameterDirection.Input, timingAndInterco.IdPhase)); spGetWPTiming.AddParameter(new DBParameter("@IdWP", DbType.Int32, ParameterDirection.Input, timingAndInterco.IdWP)); spGetWPTiming.AddParameter(new DBParameter("@IdAssociate", DbType.Int32, ParameterDirection.Input, timingAndInterco.IdAssociate)); this.AddStoredProcedure("GetWPTiming", spGetWPTiming); DBStoredProcedure spGetWPInterco = new DBStoredProcedure(); spGetWPInterco.ProcedureName = "bgtGetAffectedWPInterco"; spGetWPInterco.AddParameter(new DBParameter("@IdProject", DbType.Int32, ParameterDirection.Input, timingAndInterco.IdProject)); this.AddStoredProcedure("GetAffectedWPInterco", spGetWPInterco); DBStoredProcedure spGetUnaffectedWP = new DBStoredProcedure(); spGetUnaffectedWP.ProcedureName = "bgtGetUnaffectedWP"; spGetUnaffectedWP.AddParameter(new DBParameter("@IdProject", DbType.Int32, ParameterDirection.Input, timingAndInterco.IdProject)); this.AddStoredProcedure("GetUnaffectedWP", spGetUnaffectedWP); DBStoredProcedure spGetWPIntercoCountries = new DBStoredProcedure(); spGetWPIntercoCountries.ProcedureName = "bgtGetWPIntercoCountries"; spGetWPIntercoCountries.AddParameter(new DBParameter("@IdProject", DbType.Int32, ParameterDirection.Input, timingAndInterco.IdProject)); this.AddStoredProcedure("GetWPIntercoCountries", spGetWPIntercoCountries); DBStoredProcedure spUpdate = new DBStoredProcedure(); spUpdate.ProcedureName = "bgtUpdateWPTiming"; spUpdate.AddParameter(new DBParameter("@IdProject", DbType.Int32, ParameterDirection.Input, timingAndInterco.IdProject)); spUpdate.AddParameter(new DBParameter("@IdPhase", DbType.Int32, ParameterDirection.Input, timingAndInterco.IdPhase)); spUpdate.AddParameter(new DBParameter("@IdWP", DbType.Int32, ParameterDirection.Input, timingAndInterco.IdWP)); spUpdate.AddParameter(new DBParameter("@StartYearMonth", DbType.Int32, ParameterDirection.Input, timingAndInterco.StartYearMonth)); spUpdate.AddParameter(new DBParameter("@EndYearMonth", DbType.Int32, ParameterDirection.Input, timingAndInterco.EndYearMonth)); spUpdate.AddParameter(new DBParameter("@LastUserUpdate", DbType.Int32, ParameterDirection.Input, timingAndInterco.LastUserUpdate)); if (string.IsNullOrEmpty(timingAndInterco.WPCode)) { spUpdate.AddParameter(new DBParameter("@WPCode", DbType.String, ParameterDirection.Input, DBNull.Value)); } else { spUpdate.AddParameter(new DBParameter("@WPCode", DbType.String, ParameterDirection.Input, timingAndInterco.WPCode)); } this.AddStoredProcedure("UpdateObject", spUpdate); DBStoredProcedure sdDelete = new DBStoredProcedure(); sdDelete.ProcedureName = "bgtDeleteWPTimingAndInterco"; sdDelete.AddParameter(new DBParameter("@IdProject", DbType.Int32, ParameterDirection.Input, timingAndInterco.IdProject)); sdDelete.AddParameter(new DBParameter("@IdPhase", DbType.Int32, ParameterDirection.Input, timingAndInterco.IdPhase)); sdDelete.AddParameter(new DBParameter("@Id", DbType.Int32, ParameterDirection.Input, timingAndInterco.IdWP)); this.AddStoredProcedure("DeleteObject", sdDelete); } }
public void VerifyTimingAndInterco() { ITimingAndInterco timingAndInterco = BusinessObjectInitializer.CreateTimingAndInterco(); DBTimingAndInterco dbTimingAndInterco = new DBTimingAndInterco(connManager); timingAndInterco.IdProject = DATestUtils.DEFAULT_ENTITY_ID; timingAndInterco.IdPhase = DATestUtils.DEFAULT_ENTITY_ID; timingAndInterco.IdWP = DATestUtils.DEFAULT_ENTITY_ID; timingAndInterco.StartYearMonth = DATestUtils.DEFAULT_YEAR_MONTH; timingAndInterco.EndYearMonth = DATestUtils.DEFAULT_YEAR_MONTH; DataSet datasetGetWPPeriod = GetAffectedWPTiming(timingAndInterco, dbTimingAndInterco); //Verifies that the dataset is not null Assert.IsNotNull(datasetGetWPPeriod, "The table returned should not be null"); //Verifies that the dataset returns the correct columns DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[0], 0, "IdProject"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[0], 1, "IdPhase"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[0], 2, "PhaseCode"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[0], 3, "PhaseName"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[0], 4, "IdWP"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[0], 5, "WPCode"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[0], 6, "StartYearMonth"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[0], 7, "EndYearMonth"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[1], 0, "IdProject"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[1], 1, "IdPhase"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[1], 2, "PhaseCode"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[1], 3, "IdWP"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[1], 4, "WPCode"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[1], 5, "WPName"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[1], 6, "StartYearMonth"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[1], 7, "EndYearMonth"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[1], 8, "LastUserUpdate"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[1], 9, "LastUpdate"); DATestUtils.CheckColumn(datasetGetWPPeriod.Tables[1], 10, "HasBudget"); DataSet datasetGetWPIntercoCountries = GetAffectedWPInterco(timingAndInterco, dbTimingAndInterco); //Verifies that the dataset is not null Assert.IsNotNull(datasetGetWPIntercoCountries, "The table returned should not be null"); //Verifies that the dataset returns the correct columns DATestUtils.CheckColumn(datasetGetWPIntercoCountries.Tables[1], 0, "IdProject"); DATestUtils.CheckColumn(datasetGetWPIntercoCountries.Tables[1], 1, "IdPhase"); DATestUtils.CheckColumn(datasetGetWPIntercoCountries.Tables[1], 2, "IdWP"); DATestUtils.CheckColumn(datasetGetWPIntercoCountries.Tables[1], 3, "WPCode"); DATestUtils.CheckColumn(datasetGetWPIntercoCountries.Tables[1], 4, "WPName"); DATestUtils.CheckColumn(datasetGetWPIntercoCountries.Tables[1], 5, "PhaseCode"); DATestUtils.CheckColumn(datasetGetWPIntercoCountries.Tables[1], 6, "HasBudget"); }