using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace KursachMukha692gr { /// /// Логика взаимодействия для DeleteRaspisaniye.xaml /// public partial class DeleteRaspisaniye : Window { public DeleteRaspisaniye() { InitializeComponent(); } private void Button_Click_Delete(object sender, RoutedEventArgs e) { if (MessageBox.Show("Вы действительно хотите удалить данные ", "Удаление", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { for(int i = 0; i< id_raspisaniye.Text.Length;i++) { if (id_raspisaniye.Text.Length > 0 && id_raspisaniye.Text[i] >= '0' && id_raspisaniye.Text[i] <='9') { DataTable dt_raspisaniye = Delete("delete from [dbo].[raspisaniye] where [id] = " + id_raspisaniye.Text); Raspisaniye a = new Raspisaniye(); a.Show(); Close(); } else { MessageBox.Show("Поле id не заполнено или введено не корректно"); } } } } public DataTable Delete(string selectSQL) { DataTable dataTable = new DataTable("dataBase"); SqlConnection sqlConnection = new SqlConnection("server=WIN-2CL665KE0ED; Trusted_Connection=YES;DataBase=KURSACH1;"); sqlConnection.Open(); SqlCommand sqlCommand = sqlConnection.CreateCommand(); sqlCommand.CommandText = selectSQL; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand); sqlDataAdapter.Fill(dataTable); sqlConnection.Close(); return dataTable; } private void Button_Click_Back(object sender, RoutedEventArgs e) { Raspisaniye ras = new Raspisaniye(); ras.Show(); Close(); } } }