private void btnEdit_Click(object sender, EventArgs e) { Film f = new Film(); f.FilmTitle = txtTitle2.Text; f.FilmGenre = txtGenre2.Text; f.FilmCountry = txtCountry2.Text; f.FilmProducer = txtProducer2.Text; f.FilmYear = txtYear2.Text; f.InfoRent = cmbInfoRent2.Text; f.InRent = txtInRent2.Text; f.OverRent = txtOverRent2.Text; f.ID = selectedFilmID; c.Update(f); }
public void Insert(Film f) { try { command.CommandText = "INSERT INTO TFilms (FilmTitle, FilmGenre, FilmCountry, FilmProducer, FilmYear, InfoRent, InRent, OverRent) VALUES('" + f.FilmTitle + "', '" + f.FilmGenre + "', '" + f.FilmCountry + "', '" + f.FilmProducer + "', '" + f.FilmYear + "', '" + f.InfoRent + "', '" + f.InRent + "', '" + f.OverRent + "')"; command.CommandType = System.Data.CommandType.Text; connection.Open(); command.ExecuteNonQuery(); } catch (Exception) { throw; } finally { if(connection != null) { connection.Close(); } } }
public void Update(Film f) { try { command.CommandText = "UPDATE [TFilms] SET [TFilms].FilmTitle= '" +f.FilmTitle+ "', [TFilms].FilmGenre= '" +f.FilmGenre+ "', [TFilms].FilmCountry= '" +f.FilmCountry+ "', [TFilms].FilmProducer= '" +f.FilmProducer+ "', [TFilms].FilmYear= '" +f.FilmYear+ "', [TFilms].InfoRent= '" +f.InfoRent+ "', [TFilms].InRent= '" +f.InRent+"', [TFilms].OverRent= '" +f.OverRent+"' WHERE [TFilms].ID = " +f.ID+ ""; command.Parameters.Add(new OleDbParameter("ID", f.ID)); command.CommandType = System.Data.CommandType.Text; connection.Open(); command.ExecuteNonQuery(); } catch (Exception) { throw; } finally { if (connection != null) { connection.Close(); } } }
public void Delete(Film f) { try { command.CommandText = "DELETE FROM TFilms WHERE ID= " + f.ID; command.Parameters.Add(new OleDbParameter("ID", f.ID)); command.CommandType = System.Data.CommandType.Text; connection.Open(); command.ExecuteNonQuery(); } catch (Exception) { throw; } finally { if (connection != null) { connection.Close(); } } }
private void btnInsert_Click(object sender, EventArgs e) { Film f = new Film(); f.FilmTitle = txtTitle.Text; f.FilmGenre = txtGenre.Text; f.FilmCountry = txtCountry.Text; f.FilmProducer = txtProducer.Text; f.FilmYear = txtYear.Text; f.InfoRent = cmbInfoRent.Text; f.InRent = txtInRent.Text; f.OverRent = txtOverRent.Text; c.Insert(f); }
private void btnDelete_Click(object sender, EventArgs e) { Film f = new Film(); f.ID = selectedFilmID; c.Delete(f); }