/// <summary> /// Отправка запроса в базу данных /// </summary> /// <param name="sql"></param> public void GoToDataBase(string sql) { try { SQLDataBase dataBase = new SQLDataBase(); dataBase.sql_upgade(sql); } catch (Exception exception) { MessageBox.Show(exception.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Сохранить /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButSerializ_Click(object sender, RoutedEventArgs e) { string[] sql = new string[Bank.naturals_clients.Count]; int number = 0; foreach (var item in Bank.naturals_clients) { sql[number] = $@" UPDATE AllNaturalClients SET [FirstName] = N'{item.FirstName}', [LastName] = N'{item.LastName}', [DateOfBirth] = '{Convert.ToDateTime(item.DateofBirth).ToString("yyyy-MM-dd")}', [reputation] = N'{(item as SimpleNaturalClient).reputation}',[Department] = N'{item.Department}', [AccountNumber] = {item.AccountNumber}, [AmountOfMoney] = {item.AmountOfMoney}, [CheckContribution] = {(item as SimpleNaturalClient).CheckContribution}, [CheckDebt] = {(item as SimpleNaturalClient).CheckDebt} WHERE Id = {item.ID} " + "\n"; number++; } try { SQLDataBase dataBase = new SQLDataBase(); dataBase.sql_upgade(sql); MessageBox.Show("Готово", "Complite", MessageBoxButton.OK, MessageBoxImage.Asterisk); } catch (Exception exception) { MessageBox.Show(exception.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } //Юр лица sql = new string[Bank.legals_clients.Count]; number = 0; foreach (var item in Bank.legals_clients) { sql[number] = $@" UPDATE AllLegalClients SET [Name] = N'{item.Name}', [DateOfBirth] = '{Convert.ToDateTime(item.DateofBirth).ToString("yyyy-MM-dd")}', [reputation] = N'{(item as SimpleLegalEnity).reputation}',[Department] = N'{item.Department}', [AccountNumber] = {item.AccountNumber}, [AmountOfMoney] = {item.AmountOfMoney}, [CheckContribution] = {(item as SimpleLegalEnity).CheckContribution}, [CheckDebt] = {(item as SimpleLegalEnity).CheckDebt} WHERE Id = {item.ID} " + "\n"; number++; } try { SQLDataBase dataBase = new SQLDataBase(); dataBase.sql_upgade(sql); MessageBox.Show("Готово", "Complite", MessageBoxButton.OK, MessageBoxImage.Asterisk); } catch (Exception exception) { MessageBox.Show(exception.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } //VIP sql = new string[Bank.vip_clients.Count]; number = 0; foreach (var item in Bank.vip_clients) { if (item is VipNaturalClient) { sql[number] = $@" UPDATE AllVipNaturalClients SET [FirstName] = N'{(item as VipNaturalClient).FirstName}', [LastName] = N'{(item as VipNaturalClient).LastName}', [DateOfBirth] = '{Convert.ToDateTime(item.DateofBirth).ToString("yyyy-MM-dd")}', [Department] = N'{item.Department}', [AccountNumber] = {item.AccountNumber}, [AmountOfMoney] = {item.AmountOfMoney}, [CheckContribution] = {item.CheckContribution}, [CheckDebt] = {item.CheckDebt} WHERE Id = {item.ID} " + "\n"; number++; } else { sql[number] = $@" UPDATE AllVipLegalClients SET [Name] = N'{(item as VipLegalEnity).Name}', [DateOfBirth] = '{Convert.ToDateTime(item.DateofBirth).ToString("yyyy-MM-dd")}', [Department] = N'{item.Department}', [AccountNumber] = {item.AccountNumber}, [AmountOfMoney] = {item.AmountOfMoney}, [CheckContribution] = {item.CheckContribution}, [CheckDebt] = {item.CheckDebt} WHERE Id = {item.ID} " + "\n"; number++; } } try { SQLDataBase dataBase = new SQLDataBase(); dataBase.sql_upgade(sql); MessageBox.Show("Готово", "Complite", MessageBoxButton.OK, MessageBoxImage.Asterisk); } catch (Exception exception) { MessageBox.Show(exception.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } }