コード例 #1
0
ファイル: Movie.cs プロジェクト: mark06/WebApplication1
 public static Movie ReadMovie(IDataReader reader)
 {
     Movie movie = new Movie();
     movie.ID = reader.GetInt32(0);
     movie.Title = reader.GetString(1);
     movie.ReleaseDate = reader.GetDateTime(2).Date;
     movie.Genre = reader.GetString(3);
     movie.Price = reader.GetDecimal(4);
     return movie;
 }
コード例 #2
0
        public ActionResult Edit(Movie movie)
        {
            movie.Genre = Request.Form["genre_reselect"];

            moviesOps.AddMovie(movie);
            if (ModelState.IsValid)
            {
                return RedirectToAction("Index");
            }
            return View();
        }
コード例 #3
0
 public void AddMovie(Movie newMovie)
 {
     using (SqlCommand command = new SqlCommand("Movie_Post", Connection) { CommandType = CommandType.StoredProcedure })
     {
         command.Parameters.AddWithValue("ID", newMovie.ID);
         command.Parameters.AddWithValue("Title", newMovie.Title);
         command.Parameters.AddWithValue("ReleaseDate", newMovie.ReleaseDate);
         command.Parameters.AddWithValue("Genre", newMovie.Genre);
         command.Parameters.AddWithValue("Price", newMovie.Price);
         command.ExecuteNonQuery();
     }
 }