public double FastAgAcres(string UnitName, int year) { double temp = InvalidRate; DataLCLU TheData = FRuralDataList.Find(delegate(DataLCLU AD) { return((AD.TheYear == year) && (AD.UnitName == UnitName)); }); if (TheData.UnitName == UnitName) { temp = TheData.AcerageAg; } return(temp); }
/// <summary> /// /// </summary> /// <param name="DataDirectory"></param> /// <param name="Filename"></param> public DataClassLCLU(string DataDirectory, string Filename) { string errMessage = ""; bool isErr = false; FDataDirectory = DataDirectory; FFilename = Filename; UniDbConnection DbCon = new UniDbConnection(SQLServer.stText, "", FDataDirectory, "", "", ""); DbCon.UseFieldHeaders = true; DbCon.Open(); TheData = Tools.LoadTable(DbCon, FFilename, ref isErr, ref errMessage); if (isErr) { throw new Exception("Error loading Rate Data. " + errMessage); } // build data arrays int arraysize = TheData.Rows.Count; FAcresUrbanArray = new double[arraysize]; FAcresAgArray = new double[arraysize]; FAcresIndArray = new double[arraysize]; FYearArray = new double[arraysize]; //int CodeI = 0; foreach (DataRow DR in TheData.Rows) { // Get name and code // EDIT QUAY 2/19/18 // Setup to use region or state codes string namestr = DR[FNameFieldStr].ToString(); string codestr = DR[FCodeFieldStr].ToString(); // END EDIT // Decided not to use code in DataTable // int codeint = Tools.ConvertToInt32(codestr,ref isErr,ref errMessage); if (!isErr) { string ragacresstr = DR[FAcerageAgFieldStr].ToString(); string rurbanacresstr = DR[FAcerageUrbanFieldStr].ToString(); string rindacresstr = DR[FAcerageIndFieldStr].ToString(); string ryearsstr = DR[FcurrentYearFieldStr].ToString(); double TempAg = Tools.ConvertToDouble(ragacresstr, ref isErr, ref errMessage); if (!isErr) { double TempUrban = Tools.ConvertToDouble(rurbanacresstr, ref isErr, ref errMessage); if (!isErr) { double TempInd = Tools.ConvertToDouble(rindacresstr, ref isErr, ref errMessage); if (!isErr) { int TempYear = Tools.ConvertToInt32(ryearsstr, ref isErr, ref errMessage); if (!isErr) { // OK //string aUnitName, string aUnitCode, double anAcerageUrban, double anAcerageAg, double anAcerageInd, int aYear DataLCLU AD = new DataLCLU(namestr, codestr, TempAg, TempUrban, TempInd, TempYear); FRuralDataList.Add(AD); //// add to dictionary } } } } } } }