示例#1
0
        public List <DataObject.LoadShedDevice> ListLoadShed(int Id_Unit)
        {
            List <DataObject.LoadShedDevice> deviceList = new List <DataObject.LoadShedDevice>();

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

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

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

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

                            if (reader.GetValue(4).ToString().Trim() == "2")
                            {
                                dataObjectDevice.Status = "Off";
                            }
                            else
                            {
                                dataObjectDevice.Status = "On";
                            }

                            deviceList.Add(dataObjectDevice);
                        }
                    }
                }
            }

            return(deviceList);
        }
示例#2
0
        public List<DataObject.LoadShedDevice> ListLoadShed(int Id_Unit)
        {
            List<DataObject.LoadShedDevice> deviceList = new List<DataObject.LoadShedDevice>();

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

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

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

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

                            if (reader.GetValue(4).ToString().Trim() == "2")
                            {
                                dataObjectDevice.Status = "Off";
                            }
                            else
                            {
                                dataObjectDevice.Status = "On";
                            }

                            deviceList.Add(dataObjectDevice);
                        }
                    }
                }
            }

            return deviceList;
        }