Exemple #1
0
 // Update Movie Button (This button used for Update movie details)
 private void UpdateMovie_Click(object sender, EventArgs e)
 {
     con.Open();// Connection Open
     comm = new SqlCommand("update Movies set MoviesId= '" + MoviesID.Text + "', MTitle= '" + MovieTitle.Text + "', MRating='" + MovieRating.Text + "', Mcopies='" + MovieCopies.Text + "', Mgenre='" + MovieGenre.Text + "', Mplot='" + MoviePlot.Text + "', MCost='" + MovieCost.Text + "', MRelaseDate='" + MovieReleaseDate.Text + "' where MoviesId = '" + MoviesID.Text + "'", con);
     try
     {
         comm.ExecuteNonQuery();
         MessageBox.Show("Movie Updated");
         con.Close();// Connection Close
         ShowMoviesRecord();
         MoviesID.Clear();
         MovieTitle.Clear();
         MovieRating.Clear();
         MovieCopies.Clear();
         MovieGenre.Clear();
         MoviePlot.Clear();
         MovieCost.Clear();
         MovieReleaseDate.Clear();
     }
     catch (Exception)
     {
         MessageBox.Show("Movie Not Updated");
     }
     finally
     {
         con.Close();// Connection Close
     }
 }
Exemple #2
0
 //Button For Delete Movie (This button used for delete movie)
 private void DeleteMovie_Click(object sender, EventArgs e)
 {
     con.Open();// Connection Open
     comm = new SqlCommand("delete from Movies where MoviesId = " + MoviesID.Text + " ", con);
     try
     {
         comm.ExecuteNonQuery();
         MessageBox.Show("Movie Deleted");
         con.Close();// Connection Close
         ShowMoviesRecord();
         MoviesID.Clear();
         MovieTitle.Clear();
         MovieRating.Clear();
         MovieCopies.Clear();
         MovieGenre.Clear();
         MoviePlot.Clear();
         MovieCost.Clear();
         MovieReleaseDate.Clear();
     }
     catch (Exception x)
     {
         MessageBox.Show("Movie Not Deleted" + x.Message);
     }
     finally
     {
         con.Close();// Connection Close
     }
 }
Exemple #3
0
 // Insert Movie Button (This button use for insert movie)
 private void InsertMovie_Click(object sender, EventArgs e)
 {
     con.Open();// Connection Open
     comm = new SqlCommand("insert into Movies values('" + MoviesID.Text + "','" + MovieTitle.Text + "','" + MovieRating.Text + "','" + MovieCopies.Text + "','" + MovieGenre.Text + "', '" + MoviePlot.Text + "', '" + MovieCost.Text + "', '" + MovieReleaseDate.Text + "')", con);
     try
     {
         comm.ExecuteNonQuery();
         MessageBox.Show("Movie Saved");
         con.Close();// Connection Close
         ShowMoviesRecord();
         MoviesID.Clear();
         MovieTitle.Clear();
         MovieRating.Clear();
         MovieCopies.Clear();
         MovieGenre.Clear();
         MoviePlot.Clear();
         MovieCost.Clear();
         MovieReleaseDate.Clear();
     }
     catch (Exception)
     {
         MessageBox.Show("Movie Not Saved");
     }
     finally
     {
         con.Close();// Connection Close
     }
 }