示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool   IsError      = false;
            string ErrorMessage = "";

            //MyUniDbConnection = new UniDbConnection(SQLServer.stAccess, "Database=TestuniDb2.mdb");
//            MyUniDbConnection = new UniDbConnection(SQLServer.stAccess, "", "G:\\DCDC\\Visual Studio Projects\\Db Stuff\\UniDb2\\Projects\\UniDb2\\bin\\Debug\\TestUniDb2.mdb", "", "", "");
//            MyUniDbConnection = new UniDbConnection(SQLServer.stText, "", "G:\\DCDC\\Visual Studio Projects\\Db Stuff\\UniDb2\\Projects\\UniDb2\\bin\\Debug", "", "", "");
            MyUniDbConnection = new UniDbConnection(SQLServer.stText, "", "G:\\DCDC\\Visual Studio Projects\\Db Stuff\\UniDb2\\Source", "", "", "");
            //            MyUniDbConnection = new UniDbConnection(SQLServer.stText, "", "I:\\Visual Studio Projects\\Db Stuff\\UniDb2\\Projects\\UniDb2\\bin\\Debug", "", "", "");
            MyUniDbConnection.Open();
//            DataTable DT = Tools.LoadTable(MyUniDbConnection, "TestTable", ref IsError, ref ErrorMessage);
            DataTable DT = Tools.LoadTable(MyUniDbConnection, "TxtDbTestFile1.cdf.txt", ref IsError, ref ErrorMessage);

            listBox1.Items.Clear();
            foreach (DataRow DR in DT.Rows)
            {
                string line = "";
                foreach (DataColumn DC in DT.Columns)
                {
                    string colval = DR[DC].ToString();
                    line += colval + " ";
                }
                listBox1.Items.Add(line);
            }
            MyUniDbConnection.Close();
        }
示例#2
0
        public void CheckConnectionTest()
        {
            ProviderSetting.CurrentDBProvider = DbProviderType.OracleOdpNetManaged;
            UniDbConnection connect = new UniDbConnection("knvtest", "3");

            connect.Open();
            Assert.AreEqual(connect.State, ConnectionState.Open);

            UniDbCommand cmd = new UniDbCommand("select * from apstaff.emp where emp_birth_date=:p_date and per_num=:p_per_num and perco_sync_id=:p_perco_sync_id  order by per_num", connect);

            cmd.Parameters.Add("p_per_num", UniDbType.String, "14534");
            cmd.Parameters.Add("p_date", UniDbType.DateTime, new DateTime(1989, 7, 8));
            cmd.Parameters.Add("p_perco_sync_id", UniDbType.Decimal, 9479);
            UniDbDataReader dr = cmd.ExecuteReader();
            List <string>   ls = new List <string>();

            while (dr.Read())
            {
                ls.Add(dr["PER_NUM"].ToString());
            }
            Assert.AreEqual(ls.Count, 1);
            Assert.AreEqual(ls[ls.Count - 1], "14534");
            connect.Close();
            connect.Dispose();
        }
示例#3
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
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        private void TestConnect_Click(object sender, RoutedEventArgs e)
        {
            UniDbConnection connect = new UniDbConnection("knvtest", "3");

            connect.Open();
            MessageBox.Show("Успешное соединение");

            /* UniDbCommand cmd = new UniDbCommand("select * from apstaff.emp where emp_birth_date=:p_date and per_num=:p_per_num and perco_sync_id=:p_perco_sync_id  order by per_num", connect);
             * cmd.Parameters.Add("p_per_num", UniDbType.String, "14534");
             * cmd.Parameters.Add("p_date", UniDbType.DateTime, new DateTime(1989, 7, 8));
             * cmd.Parameters.Add("p_perco_sync_id", UniDbType.Decimal, 9479);
             * /*var p = cmd.ExecuteScalar();
             * MessageBox.Show($"значение={p}");
             *
             * UniDbDataReader dr = cmd.ExecuteReader();
             * List<string> ls = new List<string>();
             * while (dr.Read())
             * {
             *   ls.Add(dr["PER_NUM"].ToString());
             * }
             * MessageBox.Show($"Загружен список Reader ом, кол-во равно = {ls.Count}; last per_num={ls[ls.Count-1]}");*/
            AppConstants.Schema_Name_Handbook = "APSTAFF";
            AppConstants.App_Name_ID          = 11;
            TableEditorWindow f = new TableEditorWindow("SALARY.TAX_COMPANY");

            f.Model.EditCommand = "AddEmpPaySalary";
            f.Owner             = Window.GetWindow(this);
            f.ShowDialog();
        }
示例#5
0
        //FDataList = new List<ICSDataStruct>();
        /// <summary>
        ///
        /// </summary>
        /// <param name="DataDirectory"></param>
        /// <param name="Filename"></param>
        public UnitData_ICS(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;

            //
            FRC_ICS = new double[arraysize];

            foreach (DataRow DR in TheData.Rows)
            {
                // Get name and code
                // Setup to use region or state codes
                string statestr = DR[FSCFieldStr].ToString();
                string namestr  = DR[FNameFieldStr].ToString();
                string codestr  = DR[FCodeFieldStr].ToString();
                // Decided not to use code in DataTable
                // int codeint = Tools.ConvertToInt32(codestr,ref isErr,ref errMessage);

                if (!isErr)
                {
                    string rICS      = DR[FICSFieldStr].ToString();
                    string ryearsstr = DR[FcurrentYearFieldStr].ToString();
                    string rstatestr = DR[FScodeFieldStr].ToString();
                    //
                    int TempSC = Tools.ConvertToInt32(rstatestr, ref isErr, ref errMessage);
                    if (!isErr)
                    {
                        double TempICS = Tools.ConvertToDouble(rICS, ref isErr, ref errMessage);
                        if (!isErr)
                        {
                            int TempYear = Tools.ConvertToInt32(ryearsstr, ref isErr, ref errMessage);
                            if (!isErr)
                            {
                                // OK
                                ICSDataStruct ICS = new ICSDataStruct(TempSC, namestr, codestr, TempYear, TempICS);
                                FDataList.Add(ICS);
                                //// add to dictionary
                            }
                        }
                    }
                }
            }
        }
示例#6
0
 private void toolStripMenuItemOpenDB_Click(object sender, EventArgs e)
 {
     if (ServerDlg.ShowDialog() == DialogResult.OK)
     {
         MyUniDbConnection = new UniDbConnection(ServerDlg.ServerType, ServerDlg.ServerLocation, ServerDlg.Datbasename, ServerDlg.User, ServerDlg.Password, ServerDlg.Options);
         MyUniDbConnection.Open();
     }
 }
示例#7
0
        public void CheckUniAdapterTest()
        {
            ProviderSetting.CurrentDBProvider = DbProviderType.OracleOdpNetManaged;
            UniDbConnection connect = new UniDbConnection("knvtest", "3");

            connect.Open();
            Assert.AreEqual(connect.State, ConnectionState.Open);

            UniDbAdapter a = new UniDbAdapter("select * from test_apstaff.temp_rep where per_num=:p_per_num", connect);

            a.TableMappings.Add("Table", "temp_rep");
            a.SelectCommand.Parameters.Add("p_per_num", UniDbType.String, "14534");
            DataSet ds = new DataSet();

            a.Fill(ds);
            a.Dispose();

            UniDbAdapter a1 = new UniDbAdapter("declare begin open :c for select * from test_apstaff.temp_rep where per_num=:p_per_num; end;", connect);

            a1.TableMappings.Add("Table", "temp_rep1");
            a1.SelectCommand.Parameters.Add("p_per_num", UniDbType.String, "14534");
            a1.SelectCommand.Parameters.Add("c", UniDbType.RefCursor);

            a1.Fill(ds);

            Assert.AreEqual(ds.Tables["temp_rep1"].Rows.Count, 2);

            UniDbAdapter a2 = new UniDbAdapter();
            UniDbCommand cm = new UniDbCommand("declare begin open :c for select * from test_apstaff.temp_rep where per_num=:p_per_num; end;", connect);

            a2.SelectCommand = cm;
            a2.TableMappings.Add("Table", "temp_rep2");
            a2.SelectCommand.Parameters.Add("p_per_num", UniDbType.String);
            a2.SelectCommand.Parameters.Add("c", UniDbType.RefCursor);
            a2.SelectCommand.SetParameters(new TestFilter());

            DataTable t = new DataTable();

            a2.Fill(ds);
            Assert.AreEqual(ds.Tables["temp_rep2"].Rows.Count, 2);
            Assert.IsTrue(ds.Tables["temp_rep2"].Rows.Cast <DataRow>().All(r => r["PER_NUM"].ToString() == "12714"));

            a2.SelectCommand.Parameters["p_per_num"].Value = "13772";
            a2.Fill(t);
            Assert.AreEqual(t.Rows.Count, 2);
            Assert.IsTrue(t.Rows.Cast <DataRow>().All(r => r["PER_NUM"].ToString() == "13772"));



            connect.Close();
            connect.Dispose();
        }
        public RateDataClass(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);
            }
        }
示例#9
0
        //-----------------------------------------------------------------

        ///-------------------------------------------------------------------------------------------------
        /// <summary> Shows the dialog in dialog mode. </summary>
        ///
        /// <remarks>  </remarks>
        ///
        /// <param name="Connection">    The OlDbConnection. </param>
        /// <param name="RequireUnique"> true to require unique tablename. </param>
        /// <param name="MustExist">     true if tablename must exist. </param>
        ///
        /// <returns> . </returns>
        ///-------------------------------------------------------------------------------------------------

        public DialogResult ShowDialog(UniDbConnection Connection, bool RequireUnique, bool MustExist)
        {
            bool   iserror    = true;
            string ErrMessage = "";

            _dbConnect             = Connection;
            orgOpen                = (_dbConnect.State == System.Data.ConnectionState.Open);
            RequireUniqueTablename = RequireUnique;
            TablenameMustExist     = MustExist;
            try
            {
                if (!orgOpen)
                {
                    _dbConnect.Open();
                }
                TablenameComboBox.Items.Clear();
                _tablenames.Clear();
                DataSetInfoLabel.Text = _dbConnect.DataSource.ToString();
                _tablenames           = _dbConnect.GetTableNames(ref iserror, ref ErrMessage);
                foreach (string str in _tablenames)
                {
                    TablenameComboBox.Items.Add(str);
                }
                //DataTable dbSchema = new DataTable();
                //dbSchema = _dbConnect.GetSchema("TABLES");
                //for (int i = 0; i < dbSchema.Rows.Count; i++)
                //{
                //    if (dbSchema.Rows[i]["TABLE_TYPE"].ToString() == "TABLE")
                //    {
                //        temp = dbSchema.Rows[i]["TABLE_NAME"].ToString();
                //         TablenameComboBox.Items.Add(temp);
                //         _tablenames.Add(temp);
                //    }
                //}
                return(ShowDialog());
            }
            catch (Exception)
            {
                return(DialogResult.Abort);
            }
        }
示例#10
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>   Constructor. </summary>
        ///
        /// <param name="Filename"> Filename of the file. </param>
        ///-------------------------------------------------------------------------------------------------

        public StateData(string Filename)
        {
            bool            isErr     = false;
            string          Database  = Path.GetDirectoryName(Filename);
            string          TableName = Path.GetFileName(Filename);
            UniDbConnection DbConnect = new UniDbConnection(SQLServer.stText, "", Database, "", "", "");

            DbConnect.Open();
            DbConnect.UseFieldHeaders = true;
            FStateDataTable           = Tools.LoadTable(DbConnect, TableName, ref isErr, ref errMessage);
            if (isErr)
            {
                FStateDataTable = null;
                FDataLoaded     = false;
            }
            else
            {
                FDataLoaded = true;
                FFluxes     = ConstructFluxList();
            }
        }
示例#11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DataDirectory"></param>
        /// <param name="Filename"></param>
        public DataClassLcluClasses(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];
            //
            //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 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)
                                                                            {
                                                                                // OK
                                                                                DataLcluClasses AD = new DataLcluClasses(codestr, tempYear, tempTurf, tempWoods, tempWater,
                                                                                                                         tempPasture, tempCrops, tempFallow, tempInd, tempComm, tempPaved, tempEigth, tempQuarter,
                                                                                                                         tempThird, tempHalf, tempAcre, namestr);
                                                                                FLcluClassesDataList.Add(AD);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DataDirectory"></param>
        /// <param name="Filename"></param>
        public DataClassRainFall(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;

            FRainFallArray = new double[arraysize];
            FYearArray     = new double[arraysize];
            //

            int i = 0;

            //
            //int CodeI = 0;
            foreach (DataRow DR in TheData.Rows)
            {
                i += 1;

                // Get name and code
                // EDIT QUAY 2/19/18
                // Setup to use region or state codes
                string namestr  = DR[FNameFieldStr].ToString();
                string codestr  = DR[FScodeFieldStr].ToString();
                string Rcodestr = DR[FRcodeFieldStr].ToString();
                // END EDIT

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

                if (!isErr)
                {
                    string rrainfallstr = DR[FRainFallFieldStr].ToString();
                    string ryearsstr    = DR[FcurrentYearFieldStr].ToString();

                    int StateC = Tools.ConvertToInt32(codestr, ref isErr, ref errMessage);
                    if (!isErr)
                    {
                        int RegionC = Tools.ConvertToInt32(Rcodestr, ref isErr, ref errMessage);
                        if (!isErr)
                        {
                            int TempYear = Tools.ConvertToInt32(ryearsstr, ref isErr, ref errMessage);
                            if (!isErr)
                            {
                                if (i == 1)
                                {
                                    FirstYear = TempYear;
                                }
                                Tyear = TempYear;
                                double TempRain = Tools.ConvertToInt32(rrainfallstr, ref isErr, ref errMessage);
                                if (!isErr)
                                {
                                    // OK
                                    DataStructRainWater RW = new DataStructRainWater(StateC, RegionC, namestr, TempYear, TempRain);
                                    FRainFallDataList.Add(RW);
                                }
                            }
                        }
                    }
                }

                DataTableRows = i;
            }
            LastYear = Tyear;
        }
示例#13
0
        /// <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
                                }
                            }
                        }
                    }
                }
            }
        }
示例#14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DataDirectory"></param>
        /// <param name="Filename"></param>
        public DataClassTemperature(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;

            FTavArray          = new double[arraysize];
            FContemporaryArray = 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 maximumtempstr      = DR[FMaximumTempFieldStr].ToString();
                    string contemporarytempstr = DR[FContemporaryTempFieldStr].ToString();
                    string ryearsstr           = DR[FcurrentYearFieldStr].ToString();

                    double TempTav = Tools.ConvertToDouble(maximumtempstr, ref isErr, ref errMessage);
                    if (!isErr)
                    {
                        double TempTC = Tools.ConvertToDouble(contemporarytempstr, ref isErr, ref errMessage);
                        if (!isErr)
                        {
                            int TempYear = Tools.ConvertToInt32(ryearsstr, ref isErr, ref errMessage);
                            if (!isErr)
                            {
                                // OK
                                DataTemperature DT = new DataTemperature(namestr, codestr, TempTav, TempTC, TempYear);
                                FTemperatureDataList.Add(DT);
                                //// add to dictionary
                            }
                        }
                    }
                }
            }
        }
示例#15
0
        //
        public DataClassRCN(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 Runoff Curve Number Data- file RCNbyLCLU" + errMessage);
            }
            // build data arrays
            int arraysize = TheData.Rows.Count;

            //
            FOrderArray = new string[arraysize];
            FSandArray  = new string[arraysize];
            FLoamArray  = new string[arraysize];
            FSCLArray   = new string[arraysize];
            FClayArray  = new string[arraysize];
            FLCLUArray  = new string[arraysize];
            //
            foreach (DataRow DR in TheData.Rows)
            {
                string codestr = DR[FRCNlcluFieldStr].ToString();
                // END EDIT

                // Decided not to use code in DataTable
                int codeint = Tools.ConvertToInt32(codestr, ref isErr, ref errMessage);
                if (!isErr)
                {
                    string orderStr = DR[FRCNOrderFieldStr].ToString();
                    string sandStr  = DR[FRCNSandFieldStr].ToString();
                    string loamStr  = DR[FRCNLOAMFieldStr].ToString();
                    string sclStr   = DR[FRCNSCLFieldStr].ToString();
                    string clayStr  = DR[FRCNClayFieldStr].ToString();
                    string lcluStr  = DR[FRCNlcluFieldStr].ToString();
                    //
                    int tempOrder = Tools.ConvertToInt32(orderStr, ref isErr, ref errMessage);
                    if (!isErr)
                    {
                        double tempSand = Tools.ConvertToDouble(sandStr, ref isErr, ref errMessage);
                        if (!isErr)
                        {
                            double tempLoam = Tools.ConvertToDouble(loamStr, ref isErr, ref errMessage);
                            if (!isErr)
                            {
                                double tempSCL = Tools.ConvertToDouble(sclStr, ref isErr, ref errMessage);
                                if (!isErr)
                                {
                                    double tempClay = Tools.ConvertToDouble(clayStr, ref isErr, ref errMessage);
                                    if (!isErr)
                                    {
                                        string tempLCLU = clayStr;//, ref isErr, ref errMessage);
                                        if (!isErr)
                                        {
                                            DataStructRCN AD = new DataStructRCN(tempOrder, tempSand, tempLoam, tempSCL, tempClay, tempLCLU);
                                            FRCNDataList.Add(AD);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DataDirectory"></param>
        /// <param name="Filename"></param>
        public UnitData_ICS(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;

            //
            FAZ_ICS      = new double[arraysize];
            FCA_ICS      = new double[arraysize];
            FIID_ICS     = new double[arraysize];
            FNV_ICS      = new double[arraysize];
            FSNWA_ICS    = new double[arraysize];
            FNVother_ICS = new double[arraysize];
            FTON_ICS     = new double[arraysize];
            FGILA_ICS    = new double[arraysize];

            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 rICS_AZ      = DR[FICS_AZ].ToString();
                    string rICS_CA      = DR[FICS_CA].ToString();
                    string rICS_IID     = DR[FICS_IID].ToString();
                    string rICS_NV      = DR[FICS_NV].ToString();
                    string rICS_SNWA    = DR[FICS_SNWA].ToString();
                    string rICS_NVother = DR[FICS_NVOther].ToString();
                    string rICS_TON     = DR[FICS_TON].ToString();
                    string rICS_GILA    = DR[FICS_GILA].ToString();
                    //
                    string ryearsstr = DR[FcurrentYearFieldStr].ToString();

                    double TempAZ = Tools.ConvertToDouble(rICS_AZ, ref isErr, ref errMessage);
                    if (!isErr)
                    {
                        double TempCA = Tools.ConvertToDouble(rICS_CA, ref isErr, ref errMessage);
                        if (!isErr)
                        {
                            double TempIID = Tools.ConvertToDouble(rICS_IID, ref isErr, ref errMessage);
                            if (!isErr)
                            {
                                double TempNV = Tools.ConvertToDouble(rICS_NV, ref isErr, ref errMessage);
                                if (!isErr)
                                {
                                    double TempSNWA = Tools.ConvertToDouble(rICS_SNWA, ref isErr, ref errMessage);
                                    if (!isErr)
                                    {
                                        double TempNVother = Tools.ConvertToDouble(rICS_NVother, ref isErr, ref errMessage);
                                        if (!isErr)
                                        {
                                            double TempTON = Tools.ConvertToDouble(rICS_TON, ref isErr, ref errMessage);
                                            if (!isErr)
                                            {
                                                double TempGILA = Tools.ConvertToDouble(rICS_GILA, ref isErr, ref errMessage);
                                                if (!isErr)
                                                {
                                                    int TempYear = Tools.ConvertToInt32(ryearsstr, ref isErr, ref errMessage);
                                                    if (!isErr)
                                                    {
                                                        // OK
                                                        ICSData ICS = new ICSData(TempAZ, TempCA, TempIID, TempNV, TempSNWA, TempNVother, TempTON, TempGILA, TempYear);
                                                        FDataList.Add(ICS);
                                                        //// add to dictionary
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#17
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="DataDirectory"></param>
            /// <param name="Filename"></param>
            public USGSdataClass(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;

                FString   = new string[arraysize];
                FRegion   = new int[arraysize];
                FCORuse_1 = new double[arraysize];
                FCORuse_2 = new double[arraysize];
                FCORuse_3 = new double[arraysize];
                FCORuse_4 = new double[arraysize];
                FCORuse_5 = new double[arraysize];
                FCORuse_6 = new double[arraysize];


                //int CodeI = 0;
                foreach (DataRow DR in TheData.Rows)
                {
                    // Decided not to use code in DataTable
                    // int codeint = Tools.ConvertToInt32(codestr,ref isErr,ref errMessage);


                    if (!isErr)
                    {
                        string FRegion   = DR[FRnameFieldStr1].ToString();
                        string rCORuse_1 = DR[FColoradoRiverUse_1].ToString();
                        string rCORuse_2 = DR[FColoradoRiverUse_2].ToString();
                        string rCORuse_3 = DR[FColoradoRiverUse_3].ToString();
                        string rCORuse_4 = DR[FColoradoRiverUse_4].ToString();
                        string rCORuse_5 = DR[FColoradoRiverUse_5].ToString();
                        string rCORuse_6 = DR[FColoradoRiverUse_6].ToString();
                        string FString   = DR[FRnameFieldStr2].ToString();
                        //

                        int Temp1 = Tools.ConvertToInt32(FRegion, ref isErr, ref errMessage);
                        if (!isErr)
                        {
                            double Temp2 = Tools.ConvertToDouble(rCORuse_1, ref isErr, ref errMessage);
                            if (!isErr)
                            {
                                double Temp3 = Tools.ConvertToDouble(rCORuse_2, ref isErr, ref errMessage);
                                if (!isErr)
                                {
                                    double Temp4 = Tools.ConvertToDouble(rCORuse_3, ref isErr, ref errMessage);
                                    if (!isErr)
                                    {
                                        double Temp5 = Tools.ConvertToDouble(rCORuse_4, ref isErr, ref errMessage);
                                        if (!isErr)
                                        {
                                            double Temp6 = Tools.ConvertToDouble(rCORuse_5, ref isErr, ref errMessage);
                                            if (!isErr)
                                            {
                                                double Temp7 = Tools.ConvertToDouble(rCORuse_6, ref isErr, ref errMessage);
                                                if (!isErr)
                                                {
                                                    string Temp8 = Tools.ConvertToString(FString, ref isErr, ref errMessage);
                                                    if (!isErr)
                                                    {
                                                        // OK
                                                        //string aUnitName, string aUnitCode, double anAcerageUrban, double anAcerageAg, double anAcerageInd, int aYear
                                                        USGSData USGSD = new USGSData(Temp1, Temp2, Temp3, Temp4, Temp5, Temp6, Temp7, Temp8);
                                                        FDataList.Add(USGSD);
                                                        //// add to dictionary
                                                        ///
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }