コード例 #1
0
        public WaterParameterCode GetParameterCodeInfoFromDataType(long dataTypeID)
        {
            WaterParameterCode record = new WaterParameterCode();
            long codeID = 1;

            using (SqlConnection conn = new SqlConnection(_connectionString))
            {
                conn.Open();
                using (SqlCommand dataTypeLookup = new SqlCommand(string.Format("select * from AvailableWaterDataTypes where ID={0}", dataTypeID), conn))
                    using (SqlDataReader reader1 = dataTypeLookup.ExecuteReader())
                    {
                        if (reader1.Read())
                        {
                            codeID = reader1.GetInt64(2);
                        }
                        reader1.Close();
                    }

                using (SqlCommand parameterLookup = new SqlCommand(string.Format("select * from WaterDataParameters where ID={0}", codeID), conn))
                    using (SqlDataReader reader2 = parameterLookup.ExecuteReader())
                    {
                        if (reader2.Read())
                        {
                            record.ParameterID       = reader2.GetInt64(0);
                            record.ParameterCode     = reader2.GetString(1).TrimEnd();
                            record.ParameterDesc     = reader2.GetString(2);
                            record.StatisticCode     = reader2.GetString(3).TrimEnd();
                            record.StatisticDesc     = reader2.GetString(4);
                            record.UnitOfMeasureDesc = reader2.GetString(5);
                        }
                        reader2.Close();
                    }//End Using SQL Command
            } //End Using SQL Conection
            return(record);
        }
コード例 #2
0
        public ICollection <WaterParameterCode> FetchParameterCodes()
        {
            List <WaterParameterCode> codes = new List <WaterParameterCode>();

            using (SqlConnection conn = new SqlConnection(_connectionString))
            {
                conn.Open();
                using (SqlCommand parameterLookup = new SqlCommand(string.Format("select * from WaterDataParameters"), conn))
                    using (SqlDataReader reader = parameterLookup.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            WaterParameterCode record = new WaterParameterCode();
                            record.ParameterID       = reader.GetInt64(0);
                            record.ParameterCode     = reader.GetString(1).TrimEnd();
                            record.ParameterDesc     = reader.GetString(2);
                            record.StatisticCode     = reader.GetString(3).TrimEnd();
                            record.StatisticDesc     = reader.GetString(4);
                            record.UnitOfMeasureDesc = reader.GetString(5);
                            codes.Add(record);
                        }
                        reader.Close();
                    }//End Using SQL Command
            } //End Using SQL Conection
            return(codes);
        }