Beispiel #1
0
        public Rate_Archive GetByID(int ID)
        {
            Rate_Archive rates = new Rate_Archive();

            using (var connection = new SqlConnection(_connectionString))
            {
                var cmd = connection.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "GetRatesByID";
                cmd.Parameters.AddWithValue(@"ID_Rate", ID);
                connection.Open();
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    rates.ID_Rate         = (int)reader["ID_Rate"];
                    rates.Start_Rate_Date = (DateTime)reader["Start_Rate_Date"];
                    rates.Price           = (double)reader["Price"];
                }
            }
            return(rates);
        }
Beispiel #2
0
        // private string _connectionString = @"Data Source=1-vaio;Initial Catalog=UTILITIES3;Integrated Security=True";

        public void Add(Rate_Archive value)
        {
            using (var connection = new SqlConnection(_connectionString))
            {
                var cmd = connection.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "AddRate";
                cmd.Parameters.AddWithValue(@"Rate_Start_Date", value.Start_Rate_Date);
                cmd.Parameters.AddWithValue(@"Price", value.Price);

                var id = new SqlParameter
                {
                    DbType        = DbType.Int32,
                    ParameterName = "@ID_Rate",
                    Direction     = ParameterDirection.Output
                };

                //cmd.Parameters.Add(id);
                connection.Open();
                cmd.ExecuteNonQuery();
            }
        }
 public void Add(Rate_Archive value)
 {
     rate_ArchiveDao.Add(value);
 }