public List_Of_Installed_Meters GetByID(int ID) { List_Of_Installed_Meters installed_meters = new List_Of_Installed_Meters(); using (var connection = new SqlConnection(_connectionString)) { var cmd = connection.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "GetInstalledMeterByID"; cmd.Parameters.AddWithValue(@"Record_Number", ID); connection.Open(); var reader = cmd.ExecuteReader(); while (reader.Read()) { installed_meters.Record_Number = (int)reader["Record_Number"]; installed_meters.ID_Meter = (int)reader["ID_Meter"]; installed_meters.Date = (DateTime)reader["Today_Date"]; installed_meters.Meter_Reading = (double)reader["Meter_Reading_For_Today_Date"]; } } return(installed_meters); }
// private string _connectionString = @"Data Source=1-vaio;Initial Catalog=UTILITIES3;Integrated Security=True"; public void Add(List_Of_Installed_Meters value) { using (var connection = new SqlConnection(_connectionString)) { var cmd = connection.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "AddInstalledMeter"; cmd.Parameters.AddWithValue(@"ID_Meter", value.ID_Meter); cmd.Parameters.AddWithValue(@"Date", value.Date); cmd.Parameters.AddWithValue(@"Meter_Reading", value.Meter_Reading); var id = new SqlParameter { DbType = DbType.Int32, ParameterName = "@Record_Number", Direction = ParameterDirection.Output }; //cmd.Parameters.Add(id); connection.Open(); cmd.ExecuteNonQuery(); } }
public void Add(List_Of_Installed_Meters value) { list_Of_Installed_MetersDao.Add(value); }