public void FillFactoryDetail(string factoryNumber, SqlDataReader dr) { const string METHOD_NAME = "FillFactoryDetail"; bool isFirstPass = true; TFactory factory = null; try { factory = this.FactoryList.GetFactoryByNumber(factoryNumber); factory.ClearRehaul(); factory.StationList.ClearRehaul(); while (dr.Read()) { if (isFirstPass) { factory.ChipsPercentTailings = dr.GetString((int)idx.iChipsPctTailings); factory.RehaulLoadAverageWeight = dr.GetString((int)idx.iRehaulLoadAvgWt); factory.YardLoadAverageWeight = dr.GetString((int)idx.iYardLoadAvgWt); factory.ChipsDiscardedTons = dr.GetString((int)idx.iChipsDiscardedTons); factory.BeetsSlidLoads = dr.GetString((int)idx.iBeetsSlidLoads); isFirstPass = false; } if (dr.GetString((int)idx.iStationName) != "") { // We have a station name because we have some rehaul. TStation station = factory.StationList.GetStationByNumber(dr.GetInt32((int)idx.iStationNumber).ToString()); if (station != null) { station.RehaulLoads = dr.GetString((int)idx.iRehaulLoads); } else { TStation stat = new TStation(dr.GetInt32((int)idx.iStationNumber).ToString(), dr.GetString((int)idx.iStationName)); stat.RehaulLoads = dr.GetString((int)idx.iRehaulLoads); factory.StationList.Stations.Add(stat); } } this.FactoryList.IsEmpty = isFirstPass; } } catch (Exception ex) { string errMsg = MOD_NAME + METHOD_NAME + "; factory number: " + (factoryNumber == null? "0": factoryNumber) + "; dr is Null: " + (dr == null? "Yes": "No") + "; factory is null: " + (factory == null? "Yes": "No"); WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(errMsg, ex); throw (wscEx); } }