コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DataDirectory"></param>
        /// <param name="Filename"></param>
        public UnitData2(string DataDirectory, string Filename)
        {
            string errMessage = "";
            bool   isErr      = false;

            FDataDirectory = DataDirectory;
            FFilename      = Filename;
            UniDbConnection DbCon = new UniDbConnection(SQLServer.stText, "", FDataDirectory, "", "", "")
            {
                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;

            FCOUBasin_1 = new double[arraysize];
            FCOUBasin_2 = new double[arraysize];
            //int CodeI = 0;
            foreach (DataRow DR in TheData.Rows)
            {
                // Get name and code
                // Setup to use region or state codes
                string namestr = DR[FNameFieldStr].ToString();

                // Decided not to use code in DataTable
                // int codeint = Tools.ConvertToInt32(codestr,ref isErr,ref errMessage);


                if (!isErr)
                {
                    string rCOUB_1   = DR[FColoradoUBasinData1].ToString();
                    string rCOUB_2   = DR[FColoradoUBasinData2].ToString();
                    string ryearsstr = DR[FcurrentYearFieldStr].ToString();

                    double TempUB1 = Tools.ConvertToDouble(rCOUB_1, ref isErr, ref errMessage);
                    if (!isErr)
                    {
                        double TempUB2 = Tools.ConvertToDouble(rCOUB_2, 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
                                UBData UD = new UBData(TempUB1, TempUB2, TempYear);
                                FDataList.Add(UD);
                                //// add to dictionary
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        public double FastUB2(int year)
        {
            double temp    = InvalidRate;
            UBData TheData = FDataList.Find(delegate(UBData FD) {
                return((FD.TheYear == year));
            });

            temp = TheData.COUpperBasin_2;
            return(temp);
        }