コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: Aynur11/Bank
        /// <summary>
        /// Перевод денег выбранного клиента другому клиенту.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TransferMoneyButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            if (PhysicalTabItem.IsSelected && PhysicalPersonsDataGrid.CurrentItem != null)
            {
                row = (DataRowView)PhysicalPersonsDataGrid.SelectedItem;
            }
            else if (LegalTabItem.IsSelected && LegalPersonsDataGrid.CurrentItem != null)
            {
                row = (DataRowView)LegalPersonsDataGrid.SelectedItem;
            }
            else
            {
                MessageBox.Show("Выберите нужного клиента!");
                return;
            }

            ClientNameWindow clientNameWindow = new ClientNameWindow
            {
                ClientNamesComboBox = { ItemsSource = bankManager.GetAllClientNamesWithId() },
                NameTextBox         = { IsEnabled = false }
            };

            if (clientNameWindow.ShowDialog() == true)
            {
                Int32.TryParse(row[0].ToString(), out int currentClientId);
                int purposeClientId = ((KeyValuePair <int, string>)clientNameWindow.ClientNamesComboBox.SelectedValue).Key;
                bankManager.TransferMoney(currentClientId, purposeClientId, clientNameWindow.Sum);
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: Aynur11/Bank
        /// <summary>
        /// Добавляет нового клиента.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddNewClientButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            ClientNameWindow clientNameWindow = new ClientNameWindow();

            clientNameWindow.IsVipClientCheckBox.IsEnabled   = true;
            clientNameWindow.IsLegalClientCheckBox.IsEnabled = true;
            clientNameWindow.ClientNamesComboBox.IsEnabled   = false;
            if (clientNameWindow.ShowDialog() == true)
            {
                DataRow dataRow = Convert.ToBoolean(clientNameWindow.IsLegalClientCheckBox.IsChecked) ?
                                  bankManager.LegalDataTable.NewRow() :
                                  bankManager.PhysDataTable.NewRow();
                dataRow["Name"] = clientNameWindow.NameTextBox.Text;
                dataRow["Sum"]  = clientNameWindow.Sum;
                dataRow["Vip"]  = Convert.ToBoolean(clientNameWindow.IsVipClientCheckBox.IsChecked);
                dataRow["PhysicalPersonsDepartment"] = !Convert.ToBoolean(clientNameWindow.IsLegalClientCheckBox.IsChecked);
                if (Convert.ToBoolean(clientNameWindow.IsLegalClientCheckBox.IsChecked))
                {
                    bankManager.LegalDataTable.Rows.Add(dataRow);
                    bankManager.ClientsSqlDataAdapter.SafelyUpdate(bankManager.LegalDataTable);
                }
                else
                {
                    bankManager.PhysDataTable.Rows.Add(dataRow);
                    bankManager.ClientsSqlDataAdapter.SafelyUpdate(bankManager.PhysDataTable);
                }
            }
        }