1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace proba
- {
- public partial class Genre_update : Form
- {
- string id_genre;
- public int razmer = 0;
- public static string[] update_genre = new string[1];
- DataBase dataBase = new DataBase();
- public Genre_update(string id_genre, string genre)
- {
- InitializeComponent();
- textBox1.Text = genre;
- this.id_genre = id_genre;
- }
- public void global_FormClosed(object sender, EventArgs e)
- {
- Application.Exit();
- }
- private void button_back_Click(object sender, EventArgs e)
- {
- this.Hide();
- Genre genre = new Genre();
- genre.ShowDialog();
- }
- private void button_save_Click(object sender, EventArgs e)
- {
- if (textBox1.Text.Replace(" ", "") == "") MessageBox.Show("Поле жанр-музыки не может быть пустым");
- else
- {
- dataBase.openConnection();
- var addQuery = $"update Genre set genre = '{textBox1.Text}' where id_genre = '{id_genre}'";
- var command = new SqlCommand(addQuery, dataBase.GetConnection());
- command.ExecuteNonQuery();
- MessageBox.Show("Запись успешно изменена");
- update_genre[razmer] = textBox1.Text;
- Array.Resize(ref update_genre, update_genre.Length + 1);
- razmer++;
- dataBase.closeConnection();
- this.Hide();
- Genre genre = new Genre();
- genre.ShowDialog();
- }
- }
- }
- }
|