Esempio n. 1
0
        public double FastTotalArea(string UnitName, int year)
        {
            double             temp    = InvalidRate;
            DataStructLcluArea TheData = FLcluClassesDataList.Find(delegate(DataStructLcluArea AD)
            {
                return((AD.TheYear == year) && (AD.UnitName == UnitName));
            });

            if (TheData.UnitName == UnitName)
            {
                temp = TheData.TotalArea;
            }
            return(temp);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DataDirectory"></param>
        /// <param name="Filename"></param>
        public DataClassLcluArea(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;

            //
            FTurfArray    = new double[arraysize];
            FWoodsArray   = new double[arraysize];
            FWaterArray   = new double[arraysize];
            FPastureArray = new double[arraysize];
            FCropsArray   = new double[arraysize];
            FFallowarray  = new double[arraysize];
            FIndArray     = new double[arraysize];
            FCommArray    = new double[arraysize];
            FPaved        = new double[arraysize];
            FEightArray   = new double[arraysize];
            FQuarterArray = new double[arraysize];
            FThirdArray   = new double[arraysize];
            FHalfArray    = new double[arraysize];
            FAcreArray    = new double[arraysize];
            FTotalArray   = 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 turffStr   = DR[FAreaTurfFieldStr].ToString();
                    string woodsStr   = DR[FAreaWoodsFieldStr].ToString();
                    string waterStr   = DR[FAreaWaterFieldStr].ToString();
                    string pastureStr = DR[FAreaPastureFieldStr].ToString();
                    string cropsStr   = DR[FAreaRowCropsFieldStr].ToString();
                    string fallowStr  = DR[FAreaFallowFieldStr].ToString();
                    string indStr     = DR[FAreaIndFieldStr].ToString();
                    string commStr    = DR[FAreaCommFieldStr].ToString();
                    string pavedStr   = DR[FAreaPavedFieldStr].ToString();
                    string eigthStr   = DR[FAreaEigthAcreFieldStr].ToString();
                    string quarterStr = DR[FAreaQuarterAcreFieldStr].ToString();
                    string thirdStr   = DR[FAreaThirdAcreFieldStr].ToString();
                    string halfStr    = DR[FAreaHalfAcreFieldStr].ToString();
                    string acreStr    = DR[FAreaAcreFieldStr].ToString();
                    string totalStr   = DR[FAreaTotalFieldStr].ToString();
                    //
                    //string rindacresstr = DR[FAcerageIndFieldStr].ToString();
                    string ryearsstr = DR[FcurrentYearFieldStr].ToString();

                    double tempTurf = Tools.ConvertToDouble(turffStr, ref isErr, ref errMessage);
                    if (!isErr)
                    {
                        double tempWoods = Tools.ConvertToDouble(woodsStr, ref isErr, ref errMessage);
                        if (!isErr)
                        {
                            double tempWater = Tools.ConvertToDouble(waterStr, ref isErr, ref errMessage);
                            if (!isErr)
                            {
                                double tempPasture = Tools.ConvertToDouble(pastureStr, ref isErr, ref errMessage);
                                if (!isErr)
                                {
                                    double tempCrops = Tools.ConvertToDouble(cropsStr, ref isErr, ref errMessage);
                                    if (!isErr)
                                    {
                                        double tempFallow = Tools.ConvertToDouble(fallowStr, ref isErr, ref errMessage);
                                        if (!isErr)
                                        {
                                            double tempInd = Tools.ConvertToDouble(indStr, ref isErr, ref errMessage);
                                            if (!isErr)
                                            {
                                                double tempComm = Tools.ConvertToDouble(commStr, ref isErr, ref errMessage);
                                                if (!isErr)
                                                {
                                                    double tempPaved = Tools.ConvertToDouble(pavedStr, ref isErr, ref errMessage);
                                                    if (!isErr)
                                                    {
                                                        double tempEigth = Tools.ConvertToDouble(eigthStr, ref isErr, ref errMessage);
                                                        if (!isErr)
                                                        {
                                                            double tempQuarter = Tools.ConvertToDouble(quarterStr, ref isErr, ref errMessage);
                                                            if (!isErr)
                                                            {
                                                                double tempThird = Tools.ConvertToDouble(thirdStr, ref isErr, ref errMessage);
                                                                if (!isErr)
                                                                {
                                                                    double tempHalf = Tools.ConvertToDouble(halfStr, ref isErr, ref errMessage);
                                                                    if (!isErr)
                                                                    {
                                                                        double tempAcre = Tools.ConvertToDouble(acreStr, ref isErr, ref errMessage);
                                                                        if (!isErr)
                                                                        {
                                                                            int tempYear = Tools.ConvertToInt32(ryearsstr, ref isErr, ref errMessage);
                                                                            if (!isErr)
                                                                            {
                                                                                double tempTot = Tools.ConvertToInt32(totalStr, ref isErr, ref errMessage);
                                                                                if (!isErr)
                                                                                {
                                                                                    // OK
                                                                                    DataStructLcluArea AD = new DataStructLcluArea(codestr, tempYear, tempTurf, tempWoods, tempWater,
                                                                                                                                   tempPasture, tempCrops, tempFallow, tempInd, tempComm, tempPaved, tempEigth, tempQuarter,
                                                                                                                                   tempThird, tempHalf, tempAcre, tempTot, namestr);
                                                                                    FLcluClassesDataList.Add(AD);
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }