private void Replace_Click(object sender, EventArgs e) {// Удаление записи о выдаче диска в БД string sql = "DELETE DVD WHERE ID_Name = (" + SELECT.WhereValue("Name", Result.CurrentRow.Cells[0].Value.ToString()) + ") AND ID_Contact = (" + SELECT.WhereValue("Contact", Title.Text) + ")"; SqlCommand command = new SqlCommand(sql, connection); command.ExecuteNonQuery(); }
private void ButtonSearch_Click(object sender, EventArgs e) {// Поиск по названию в БД string sql = SELECT.WhereValue("NameField", TextBoxSearch.Text); SqlDataAdapter adapter = new SqlDataAdapter(sql, connection); DataSet ds = new DataSet(); adapter.Fill(ds); Result.DataSource = ds.Tables[0]; }
public Main() { InitializeComponent(); string connectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=laba5;Integrated Security=True"; connection = new SqlConnection(connectionString); connection.Open(); string sql = SELECT.All("Name"); SqlDataAdapter adapter = new SqlDataAdapter(sql, connection); DataSet ds = new DataSet(); adapter.Fill(ds); Result.DataSource = ds.Tables[0]; }
private void NewFilm_Click(object sender, EventArgs e) {// Добавление фильма в БД NewFilm film = new NewFilm(connection); EventHandler submit = (s, ev) => { string sql = SELECT.All("Name"); SqlDataAdapter adapter = new SqlDataAdapter(sql, connection); DataSet ds = new DataSet(); adapter.Fill(ds); Result.DataSource = ds.Tables[0]; }; film.AddSubmit(submit); film.Show(); }
private void ButtonGenre_Click(object sender, EventArgs e) {// Поиск по жанрам в БД string sql = SELECT.All("Genre"); SqlDataAdapter adapter = new SqlDataAdapter(sql, connection); DataSet ds = new DataSet(); adapter.Fill(ds); DataTable table = ds.Tables[0]; int n = table.Rows.Count; List <string> Name = new List <string>(n); foreach (DataRow row in table.Rows) { string s = row[0].ToString(); Name.Add(row[0].ToString()); } Genre genre = new Genre(n, Name); EventHandler submit = (s, ev) => { int vs = genre.GetChecked(); sql = "SELECT n.Price AS Цена, n.Title AS Название, n.Date AS Дата FROM Name n, " + "Genre g, Relation r WHERE n.ID_Name = r.ID_Name AND g.ID_Genre = r.ID_Genre AND " + "g.ID_Genre = " + vs.ToString(); adapter = new SqlDataAdapter(sql, connection); ds = new DataSet(); adapter.Fill(ds); Result.DataSource = ds.Tables[0]; genre.Close(); }; genre.AddSubmit(submit); genre.Show(); }