public Safe(DataSet ds) { const int TBL_DETAILS = 2; const int TBL_HEARING = 3; DataTable dtCitationDetail = null; DataTable dtCitationHearing = null; try { dtCitationDetail = ds.Tables[TBL_DETAILS]; dtCitationHearing = ds.Tables[TBL_HEARING]; if (dtCitationDetail != null) { foreach (DataRow dr in dtCitationDetail.Rows) { this.CitationNumber = dr["CitationNumber"].ToString(); this.BadgeNumberCurrent = dr["BadgeNumber"].ToString(); this.CitationDate = Convert.ToDateTime(dr["WhenCreated"].ToString()); this.Violation = DictionaryHelper.FromTable(ds.Tables["Violation"]); this.ViolationCurrent = Convert.ToInt32(dr["ViolationID"].ToString()); this.LocationCurrent = dr["ViolationLocation"].ToString(); this.ConditionsCurrent = dr["Conditions"].ToString(); this.CompanyCurrent = dr["CorporationName"].ToString(); this.DivisionCurrent = dr["DivisionName"].ToString(); this.VehicleManufacturer = dr["VehicleMakeAbbreviation"].ToString(); this.VehicleModel = dr["VehicleBodyAbbreviation"].ToString(); this.LicenseNumber = dr["LicensePlate"].ToString(); this.PointValue = Convert.ToInt32(dr["ViolationPoints"].ToString()); this.CitingOfficerName = dr["CitingOfficerName"].ToString(); this.CitingOfficerBadgeNumber = dr["CitingOfficerBadgeNumber"].ToString(); this.LicenseCountry = DictionaryHelper.FromTable(ds.Tables["Countries"]); this.LicenseCountryCurrent = dr["CountryCode_LicensePlate"].ToString(); // states------------- String stateCode; if (!String.IsNullOrEmpty(this.LicenseCountryCurrent)) { stateCode = "ALLSTATES" + this.LicenseCountryCurrent; } else { stateCode = "ALLSTATESUSACAN"; } //this.LicenseState = DictionaryHelper.FromTable(ds.Tables[stateCode]); this.LicenseState = DictionaryHelper.FromTable(ds.Tables["ALLSTATESUSACAN"]); this.LicenseStateCurrent = dr["CountrySubdivisionCode_LicensePlate"].ToString(); //this.Group = o.FillLookup("Description", "Code", "SafeViolationTypes"); Group = DictionaryHelper.FromTable(ds.Tables["SafeViolationTypes"]); this.GroupCurrent = dr["ViolationTypeID"].ToString(); //this.BadgeDisplayed = o.YesNoLookup(); BadgeDisplayed = new Dictionary <string, object> { { "Yes", "Yes" }, { "No", "No" } }; // ======= Boolean lc = false; String ls = ""; ls = dr["BadgeDisplayed"].ToString(); if (!String.IsNullOrEmpty(ls)) { lc = Convert.ToBoolean(ls); } this.BadgeDisplayedCurrent = lc ? "Yes" : "No"; lc = false; ls = dr["Cancelled"].ToString(); if (!String.IsNullOrEmpty(ls)) { lc = Convert.ToBoolean(ls); } this.IsCancelled = lc; lc = false; ls = dr["IsDeleted"].ToString(); if (!String.IsNullOrEmpty(ls)) { lc = Convert.ToBoolean(ls); } this.IsDeleted = lc; lc = false; ls = dr["LicenseValid"].ToString(); if (!String.IsNullOrEmpty(ls)) { lc = Convert.ToBoolean(ls); } this.LicenseValid = lc; lc = false; ls = dr["DriverIcon"].ToString(); if (!String.IsNullOrEmpty(ls)) { lc = Convert.ToBoolean(ls); } this.DriverIcon = lc; // ======= // administration this.DateCreated = Convert.ToDateTime(dr["WhenCreated"].ToString()); this.ReturnToSAFEBy = Convert.ToDateTime(dr["WhenDue"].ToString()); this.DateResolved = Convert.ToDateTime(dr["WhenResolved"].ToString()); // hearing List <HearingSummary> dtCitationHearingList = new List <HearingSummary>(); if (dtCitationHearingList != null) { foreach (DataRow drr in dtCitationHearing.Rows) { dtCitationHearingList.Add( new HearingSummary ( Convert.ToInt32(drr["SafeHearingID"]), Convert.ToInt32(drr["SafeCitationID"]), Convert.ToDateTime(drr["SafeHearingDate"].ToString()), drr["SafeHearingNotes"].ToString() ) ); } this.HearingSummaries = dtCitationHearingList; } break; } } } finally { if (dtCitationDetail != null) { dtCitationDetail.Dispose(); } if (dtCitationHearing != null) { dtCitationHearing.Dispose(); } } }