Esempio n. 1
0
        public List<DataObject.LinkedRuleUnitDevice> List(int Id_Rule)
        {
            List<DataObject.LinkedRuleUnitDevice> list = null;

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                connection.Open();

                string query = "Exec [BusinessRule].[ListRuleUnitAndDevice] {0}";

                using (SqlCommand command = new SqlCommand(string.Format(query, Id_Rule), connection))
                {
                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            DataObject.LinkedRuleUnitDevice dataObject = new DataObject.LinkedRuleUnitDevice();
                            dataObject.UnitId = int.Parse(reader.GetValue(1).ToString());
                            dataObject.UnitAddress = reader.GetValue(2).ToString();
                            dataObject.DeviceId = int.Parse(reader.GetValue(4).ToString());

                            list.Add(dataObject);
                        }
                    }
                }
            }

            return list;
        }
Esempio n. 2
0
        public List <DataObject.LinkedRuleUnitDevice> List(int Id_Rule)
        {
            List <DataObject.LinkedRuleUnitDevice> list = null;

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                connection.Open();

                string query = "Exec [BusinessRule].[ListRuleUnitAndDevice] {0}";

                using (SqlCommand command = new SqlCommand(string.Format(query, Id_Rule), connection))
                {
                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            DataObject.LinkedRuleUnitDevice dataObject = new DataObject.LinkedRuleUnitDevice();
                            dataObject.UnitId      = int.Parse(reader.GetValue(1).ToString());
                            dataObject.UnitAddress = reader.GetValue(2).ToString();
                            dataObject.DeviceId    = int.Parse(reader.GetValue(4).ToString());

                            list.Add(dataObject);
                        }
                    }
                }
            }

            return(list);
        }