public List <DataObject.Schedule> List() { List <DataObject.Schedule> scheduleList = new List <DataObject.Schedule>(); using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); string query = "Exec [Schedule].[ListActiveSchedule]"; using (SqlCommand command = new SqlCommand(query, connection)) { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { DataObject.Schedule dataObjectSchedule = new DataObject.Schedule(); dataObjectSchedule.Id = int.Parse(reader.GetValue(0).ToString()); dataObjectSchedule.Name = reader.GetValue(1).ToString(); dataObjectSchedule.StartTime = reader.GetValue(2).ToString().Substring(0, 5); dataObjectSchedule.EndTime = reader.GetValue(3).ToString().Substring(0, 5); dataObjectSchedule.ElapsedTime = int.Parse(reader.GetValue(4).ToString()); dataObjectSchedule.DateAdded = Convert.ToDateTime(reader.GetValue(5).ToString()); dataObjectSchedule.IsActive = Convert.ToBoolean(reader.GetValue(6).ToString()); scheduleList.Add(dataObjectSchedule); } } } } return(scheduleList); }
public DataObject.Schedule Get(int Id) { DataObject.Schedule dataObjectSchedule = null; using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); string query = "Exec [Schedule].[GetActiveSchedule] {0}"; using (SqlCommand command = new SqlCommand(string.Format(query, Id), connection)) { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { dataObjectSchedule = new DataObject.Schedule(); dataObjectSchedule.Id = int.Parse(reader.GetValue(0).ToString()); dataObjectSchedule.Name = reader.GetValue(1).ToString(); dataObjectSchedule.StartTime = reader.GetValue(2).ToString(); dataObjectSchedule.EndTime = reader.GetValue(3).ToString(); dataObjectSchedule.ElapsedTime = int.Parse(reader.GetValue(4).ToString()); dataObjectSchedule.DateAdded = Convert.ToDateTime(reader.GetValue(5).ToString()); dataObjectSchedule.IsActive = true; } } } } return(dataObjectSchedule); }
public DataObject.Schedule Get(int Id) { DataObject.Schedule dataObjectSchedule = null; using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); string query = "Exec [Schedule].[GetActiveSchedule] {0}"; using (SqlCommand command = new SqlCommand(string.Format(query, Id), connection)) { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { dataObjectSchedule = new DataObject.Schedule(); dataObjectSchedule.Id = int.Parse(reader.GetValue(0).ToString()); dataObjectSchedule.Name = reader.GetValue(1).ToString(); dataObjectSchedule.StartTime = reader.GetValue(2).ToString(); dataObjectSchedule.EndTime = reader.GetValue(3).ToString(); dataObjectSchedule.ElapsedTime = int.Parse(reader.GetValue(4).ToString()); dataObjectSchedule.DateAdded = Convert.ToDateTime(reader.GetValue(5).ToString()); dataObjectSchedule.IsActive = true; } } } } return dataObjectSchedule; }
public List<DataObject.Schedule> List() { List<DataObject.Schedule> scheduleList = new List<DataObject.Schedule>(); using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); string query = "Exec [Schedule].[ListActiveSchedule]"; using (SqlCommand command = new SqlCommand(query, connection)) { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { DataObject.Schedule dataObjectSchedule = new DataObject.Schedule(); dataObjectSchedule.Id = int.Parse(reader.GetValue(0).ToString()); dataObjectSchedule.Name = reader.GetValue(1).ToString(); dataObjectSchedule.StartTime = reader.GetValue(2).ToString().Substring(0, 5); dataObjectSchedule.EndTime = reader.GetValue(3).ToString().Substring(0, 5); dataObjectSchedule.ElapsedTime = int.Parse(reader.GetValue(4).ToString()); dataObjectSchedule.DateAdded = Convert.ToDateTime(reader.GetValue(5).ToString()); dataObjectSchedule.IsActive = Convert.ToBoolean(reader.GetValue(6).ToString()); scheduleList.Add(dataObjectSchedule); } } } } return scheduleList; }