Exemple #1
0
        public DataObject.Unit Get(int Id)
        {
            DataObject.Unit dataObjectUnit = null;

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

                string query = "Exec [Configuration].[GetActiveUnit] {0}";

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

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            dataObjectUnit           = new DataObject.Unit();
                            dataObjectUnit.Id        = int.Parse(reader.GetValue(0).ToString());
                            dataObjectUnit.Id_Zone   = 0;
                            dataObjectUnit.Name      = reader.GetValue(1).ToString();
                            dataObjectUnit.Address   = reader.GetValue(3).ToString();
                            dataObjectUnit.DateAdded = Convert.ToDateTime(reader.GetValue(2).ToString());
                            dataObjectUnit.IsActive  = true;
                        }
                    }
                }
            }

            return(dataObjectUnit);
        }
Exemple #2
0
        public DataObject.Unit Get(int Id)
        {
            DataObject.Unit dataObjectUnit = null;

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

                string query = "Exec [Configuration].[GetActiveUnit] {0}";

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

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            dataObjectUnit = new DataObject.Unit();
                            dataObjectUnit.Id = int.Parse(reader.GetValue(0).ToString());
                            dataObjectUnit.Id_Zone = 0;
                            dataObjectUnit.Name = reader.GetValue(1).ToString();
                            dataObjectUnit.Address = reader.GetValue(3).ToString();
                            dataObjectUnit.DateAdded = Convert.ToDateTime(reader.GetValue(2).ToString());
                            dataObjectUnit.IsActive = true;
                        }
                    }
                }
            }

            return dataObjectUnit;
        }
Exemple #3
0
        public List <DataObject.Unit> List(int Id_Zone)
        {
            List <DataObject.Unit> unitList = new List <DataObject.Unit>();

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

                string query = "Exec [Configuration].[ListActiveUnit] {0}";

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

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            DataObject.Unit dataObjectUnit = new DataObject.Unit();
                            dataObjectUnit.Id        = int.Parse(reader.GetValue(0).ToString());
                            dataObjectUnit.Id_Zone   = Id_Zone;
                            dataObjectUnit.Name      = reader.GetValue(1).ToString();
                            dataObjectUnit.Address   = reader.GetValue(3).ToString();
                            dataObjectUnit.DateAdded = Convert.ToDateTime(reader.GetValue(2).ToString());
                            dataObjectUnit.IsActive  = Convert.ToBoolean(reader.GetValue(4).ToString());

                            unitList.Add(dataObjectUnit);
                        }
                    }
                }
            }

            return(unitList);
        }
Exemple #4
0
        private string GetUnitIpAddress(int unitId)
        {
            lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new pmgmt.data.DAO.Configuration.Unit();
            unitDAO.ConnectionString = _connectionString;
            lfa.pmgmt.data.DTO.Configuration.Unit unitDTO = unitDAO.Get(unitId);

            return(unitDTO.Address);
        }
Exemple #5
0
        public List<DataObject.Unit> List(int Id_Zone)
        {
            List<DataObject.Unit> unitList = new List<DataObject.Unit>();

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

                string query = "Exec [Configuration].[ListActiveUnit] {0}";

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

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            DataObject.Unit dataObjectUnit = new DataObject.Unit();
                            dataObjectUnit.Id = int.Parse(reader.GetValue(0).ToString());
                            dataObjectUnit.Id_Zone = Id_Zone;
                            dataObjectUnit.Name = reader.GetValue(1).ToString();
                            dataObjectUnit.Address = reader.GetValue(3).ToString();
                            dataObjectUnit.DateAdded = Convert.ToDateTime(reader.GetValue(2).ToString());
                            dataObjectUnit.IsActive = Convert.ToBoolean(reader.GetValue(4).ToString());

                            unitList.Add(dataObjectUnit);
                        }
                    }
                }
            }

            return unitList;
        }