public static List <StoreCallCycle> GetStoreCallCycleByRepresentativeStoreId(int repStoreId) { List <StoreCallCycle> list = new List <StoreCallCycle>(); Database db = DatabaseFactory.CreateDatabase("Spar-StoreRep"); string sqlCommand = "GetStoreCallCycleByRepresentativeStoreId"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "@RepresentativeStoreId", DbType.Int32, repStoreId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { StoreCallCycle storeCallCycle = new StoreCallCycle(); storeCallCycle.StoreCallCycleId = Convert.ToInt32(dataReader["StoreCallCycleId"]); storeCallCycle.RepStoreId = Convert.ToInt32(dataReader["RepresentativeStoreId"]); storeCallCycle.CallCycleId = Convert.ToInt32(dataReader["CallCycleId"]); storeCallCycle.WeekNumber = Convert.ToInt32(dataReader["WeekNumber"]); storeCallCycle.WeekDescription = dataReader["WeekDescription"].ToString(); storeCallCycle.Day1 = Convert.ToInt32(dataReader["Day1"]); storeCallCycle.Day2 = Convert.ToInt32(dataReader["Day2"]); storeCallCycle.Day3 = Convert.ToInt32(dataReader["Day3"]); storeCallCycle.Day4 = Convert.ToInt32(dataReader["Day4"]); storeCallCycle.Day5 = Convert.ToInt32(dataReader["Day5"]); storeCallCycle.Day6 = Convert.ToInt32(dataReader["Day6"]); storeCallCycle.Day7 = Convert.ToInt32(dataReader["Day7"]); list.Add(storeCallCycle); } } return(list); }
public static StoreCallCycle GetStoreCallCycleByStoreCallCycleId(int storeCallCycleId) { Database db = DatabaseFactory.CreateDatabase("Spar-StoreRep"); string sqlCommand = "GetStoreCallCycleByStoreCallCycleId"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "@StoreCallCycleId", DbType.Int32, storeCallCycleId); db.AddOutParameter(dbCommand, "@CallCycleId", DbType.Int32, 4); db.ExecuteNonQuery(dbCommand); StoreCallCycle storeCallCycle = new StoreCallCycle(); storeCallCycle.StoreCallCycleId = storeCallCycleId; storeCallCycle.CallCycleId = Convert.ToInt32(db.GetParameterValue(dbCommand, "CallCycleId")); return(storeCallCycle); }