private void SQLupdate <T>(T client) { SQLDataBase dataBase = new SQLDataBase(); string sql = string.Empty; if (client is SimpleNaturalClient) { var temp = client as SimpleNaturalClient; sql = $@" UPDATE AllNaturalClients SET AmountOfMoney = {temp.AmountOfMoney} WHERE Id = {temp.ID} "; } else if (client is SimpleLegalEnity) { var temp = client as SimpleLegalEnity; sql = $@" UPDATE AllLegalClients SET AmountOfMoney = {temp.AmountOfMoney} WHERE Id = {temp.ID} "; } else if (client is VipNaturalClient) { var temp = client as VipNaturalClient; sql = $@" UPDATE AllVipNaturalClients SET AmountOfMoney = {temp.AmountOfMoney} WHERE Id = {temp.ID} "; } else if (client is VipLegalEnity) { var temp = client as VipLegalEnity; sql = $@" UPDATE AllVipLegalClients SET AmountOfMoney = {temp.AmountOfMoney} WHERE Id = {temp.ID} "; } dataBase.sql_upgade(sql); }
/// <summary> /// Редактировать клиента /// </summary> private void EditClient() { SQLDataBase dataBase = new SQLDataBase(); string sql = string.Empty; if (RadioNatural.IsChecked == true) { if (TextIsDate(BoxBirthday.Text)) { if (BoxFirstName.Text != string.Empty && BoxLastName.Text != string.Empty && BoxBirthday.Text != string.Empty) { if (item is SimpleNaturalClient) { var temp = item as NaturalClient; Bank.Edit(item as NaturalClient, BoxFirstName.Text, BoxLastName.Text, GetAge(BoxBirthday.Text)); sql = $@" UPDATE AllNaturalClients SET [FirstName] = N'{temp.FirstName}', [LastName] = N'{temp.LastName}', [DateOfBirth] = '{Convert.ToDateTime(temp.DateofBirth).ToString("yyyy-MM-dd")}' WHERE Id = {temp.ID} " + "\n"; dataBase.sql_upgade(sql); } else { var temp = item as VipNaturalClient; Bank.Edit(item as VipNaturalClient, BoxFirstName.Text, BoxLastName.Text, GetAge(BoxBirthday.Text)); sql = $@" UPDATE AllVipNaturalClients SET [FirstName] = N'{temp.FirstName}', [LastName] = N'{temp.LastName}', [DateOfBirth] = '{Convert.ToDateTime(temp.DateofBirth).ToString("yyyy-MM-dd")}' WHERE Id = {temp.ID} " + "\n"; dataBase.sql_upgade(sql); } Close(); } else { MessageBox.Show("Не все поля введены!", "WARNING", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("введите дату в формате dd.MM.yyyy", "WARNING", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { if (TextIsDate(BoxCreateDate.Text)) { if (BoxName.Text != string.Empty && BoxCreateDate.Text != string.Empty) { if (item is SimpleLegalEnity) { var temp = item as SimpleLegalEnity; Bank.Edit(item as SimpleLegalEnity, BoxName.Text, GetAge(BoxCreateDate.Text)); sql = $@" UPDATE AllLegalClients SET [Name] = N'{temp.Name}', [DateOfBirth] = '{Convert.ToDateTime(temp.DateofBirth).ToString("yyyy-MM-dd")}' WHERE Id = {temp.ID} " + "\n"; dataBase.sql_upgade(sql); } else { var temp = item as VipLegalEnity; Bank.Edit(item as VipLegalEnity, BoxName.Text, GetAge(BoxCreateDate.Text)); sql = $@" UPDATE AllVipLegalClients SET [Name] = N'{temp.Name}', [DateOfBirth] = '{Convert.ToDateTime(temp.DateofBirth).ToString("yyyy-MM-dd")}' WHERE Id = {temp.ID} " + "\n"; dataBase.sql_upgade(sql); } Close(); } else { MessageBox.Show("Не все поля введены!", "WARNING", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("введите дату в формате dd.MM.yyyy", "WARNING", MessageBoxButton.OK, MessageBoxImage.Warning); } } }