private void addNewContributionButton_Click(object sender, EventArgs e) { QueriesTableAdapter ta = new QueriesTableAdapter(); try { decimal percent = decimal.Parse(newContributionPercentTextBox.Text); bool? status = false; ta.УзнатьСтатусКлиента(id, ref status); if (status == true) { percent *= 2; } if (duration == 0) { ta.ОткрытьБессрочныйВклад(id, percent); MessageBox.Show("Открыт бессрочный вклад"); } else { ta.ОткрытьВклад(id, percent, duration); if (duration == 1) { MessageBox.Show("Открыт вклад на " + duration + " год"); } else { MessageBox.Show("Открыт вклад на " + duration + " лет"); } } if (status == true) { MessageBox.Show("Процент вклада удвоен, так как статус клиента - Премиум"); } of.updatePotentialClientsGrid(); cfif.updateClientStatus(); if (cfif != null) { cfif.updateClientContributions(); } Close(); } catch (Exception) { MessageBox.Show("Вклад не был открыт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void fillUpButton_Click(object sender, EventArgs e) { double sumToFillUp; bool isNum = double.TryParse(sumToFillUpTextBox.Text, out sumToFillUp); if (!isNum) { MessageBox.Show("Сумма должна быть числом", "Ошибка ввода", MessageBoxButtons.OK, MessageBoxIcon.Warning); sumToFillUpTextBox.Clear(); return; } if (fillUpTypeComboBox.SelectedItem == null) { MessageBox.Show("Выберите способ оплаты", "Способ оплаты не выбран", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (fillUpTypeComboBox.Text == "Наличные") { if (isCard == 1) { ta.ОсуществитьОперацию(4, null, isCard, cfif.getSelectedCard(), decimal.Parse(sumToFillUpTextBox.Text), cfif.of.operatorID); ta.НачислитьНаКарту(cfif.getSelectedCard(), decimal.Parse(sumToFillUpTextBox.Text)); } else { ta.ОсуществитьОперацию(4, null, isCard, cfif.getSelectedContribution(), decimal.Parse(sumToFillUpTextBox.Text), cfif.of.operatorID); ta.НачислитьНаВклад(cfif.getSelectedContribution(), decimal.Parse(sumToFillUpTextBox.Text)); } MessageBox.Show("Перевод осуществлен"); if (isCard == 1) { cfif.updateClientCards(); cfif.updateClientCardOperations(); } else { cfif.updateClientContributions(); cfif.updateClientContributionOperations(); } cfif.updateClientStatus(); cfif.of.updateClientsGrid(); this.Close(); } else if (fillUpTypeComboBox.Text == "С карты") { if (noAccountTextBox.Visible == true) { MessageBox.Show("Выберите другой способ оплаты", "Нет карт для оплаты", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (accountNumberComboBox.SelectedItem == null) { MessageBox.Show("Выберите карту", "Карта не выбрана", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } bool?availabilityToTransfer = false; ta.ПроверитьВозможностьПереводаСКарты(int.Parse(accountNumberComboBox.Text), decimal.Parse(sumToFillUpTextBox.Text), ref availabilityToTransfer); if (availabilityToTransfer == true) { if (isCard == 1) { ta.ОсуществитьОперацию(1, int.Parse(accountNumberComboBox.Text), isCard, cfif.getSelectedCard(), decimal.Parse(sumToFillUpTextBox.Text), cfif.of.operatorID); ta.НачислитьНаКарту(cfif.getSelectedCard(), decimal.Parse(sumToFillUpTextBox.Text)); } else { ta.ОсуществитьОперацию(1, int.Parse(accountNumberComboBox.Text), isCard, cfif.getSelectedContribution(), decimal.Parse(sumToFillUpTextBox.Text), cfif.of.operatorID); ta.НачислитьНаВклад(cfif.getSelectedContribution(), decimal.Parse(sumToFillUpTextBox.Text)); } ta.СнятьСКарты(int.Parse(accountNumberComboBox.Text), decimal.Parse(sumToFillUpTextBox.Text)); MessageBox.Show("Перевод осуществлен"); if (isCard == 1) { cfif.updateClientCards(); cfif.updateClientCardOperations(); } else { cfif.updateClientContributions(); cfif.updateClientCards(); cfif.updateClientContributionOperations(); } cfif.updateClientStatus(); cfif.of.updateClientsGrid(); this.Close(); } else { MessageBox.Show("Недостаточно средств на карте", "Перевод не осуществлен", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { if (noAccountTextBox.Visible == true) { MessageBox.Show("Выберите другой способ оплаты", "Нет вкладов для оплаты", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (accountNumberComboBox.SelectedItem == null) { MessageBox.Show("Выберите вклад", "Вклад не выбран", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } bool?availabilityToTransfer = false; ta.ПроверитьВозможностьПереводаСВклада(int.Parse(accountNumberComboBox.Text), decimal.Parse(sumToFillUpTextBox.Text), ref availabilityToTransfer); if (availabilityToTransfer == true) { if (isCard == 1) { ta.ОсуществитьОперацию(2, int.Parse(accountNumberComboBox.Text), isCard, cfif.getSelectedCard(), decimal.Parse(sumToFillUpTextBox.Text), cfif.of.operatorID); ta.НачислитьНаКарту(cfif.getSelectedCard(), decimal.Parse(sumToFillUpTextBox.Text)); } else { ta.ОсуществитьОперацию(2, int.Parse(accountNumberComboBox.Text), isCard, cfif.getSelectedContribution(), decimal.Parse(sumToFillUpTextBox.Text), cfif.of.operatorID); ta.НачислитьНаВклад(cfif.getSelectedContribution(), decimal.Parse(sumToFillUpTextBox.Text)); } ta.СнятьСВклада(int.Parse(accountNumberComboBox.Text), decimal.Parse(sumToFillUpTextBox.Text)); MessageBox.Show("Перевод осуществлен"); if (isCard == 1) { cfif.updateClientCards(); cfif.updateClientCardOperations(); cfif.updateClientContributions(); } else { cfif.updateClientContributions(); cfif.updateClientContributionOperations(); } cfif.updateClientStatus(); cfif.of.updateClientsGrid(); this.Close(); } else { MessageBox.Show("Недостаточно средств на вкладе", "Перевод не осуществлен", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void transferButton_Click(object sender, EventArgs e) { double transferSum; bool isNum = double.TryParse(transferSumTextBox.Text, out transferSum); if (!isNum) { MessageBox.Show("Сумма должна быть числом", "Ошибка ввода", MessageBoxButtons.OK, MessageBoxIcon.Warning); transferSumTextBox.Clear(); return; } int receiverAccountNumber; isNum = int.TryParse(receiverAccountNumberTextBox.Text, out receiverAccountNumber); if (!isNum) { MessageBox.Show("Номер счета получателя должен быть числом", "Ошибка ввода", MessageBoxButtons.OK, MessageBoxIcon.Warning); receiverAccountNumberTextBox.Clear(); return; } int?receiverAccountType = 0; ta.УзнатьТипАктивногоСчета(int.Parse(receiverAccountNumberTextBox.Text), ref receiverAccountType); if (receiverAccountType == 0) { MessageBox.Show("Не существует активной карты или вклада с таким номером", "Ошибка перевода", MessageBoxButtons.OK, MessageBoxIcon.Warning); receiverAccountNumberTextBox.Clear(); return; } if (isCard == 1) { bool?availabilityToTransfer = false; ta.ПроверитьВозможностьПереводаСКарты(cfif.getSelectedCard(), decimal.Parse(transferSumTextBox.Text), ref availabilityToTransfer); if (availabilityToTransfer == true) { ta.ОсуществитьОперацию(1, cfif.getSelectedCard(), receiverAccountType, int.Parse(receiverAccountNumberTextBox.Text), decimal.Parse(transferSumTextBox.Text), cfif.of.operatorID); if (receiverAccountType == 1) { ta.НачислитьНаКарту(int.Parse(receiverAccountNumberTextBox.Text), decimal.Parse(transferSumTextBox.Text)); } else { ta.НачислитьНаВклад(int.Parse(receiverAccountNumberTextBox.Text), decimal.Parse(transferSumTextBox.Text)); } ta.СнятьСКарты(cfif.getSelectedCard(), decimal.Parse(transferSumTextBox.Text)); MessageBox.Show("Перевод осуществлен"); cfif.updateClientCards(); cfif.updateClientCardOperations(); cfif.updateClientContributions(); cfif.updateClientStatus(); cfif.of.updateClientsGrid(); this.Close(); } else { MessageBox.Show("Недостаточно средств на карте", "Перевод не осуществлен", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { bool?availabilityToTransfer = false; ta.ПроверитьВозможностьПереводаСВклада(cfif.getSelectedContribution(), decimal.Parse(transferSumTextBox.Text), ref availabilityToTransfer); if (availabilityToTransfer == true) { ta.ОсуществитьОперацию(2, cfif.getSelectedContribution(), receiverAccountType, int.Parse(receiverAccountNumberTextBox.Text), decimal.Parse(transferSumTextBox.Text), cfif.of.operatorID); if (receiverAccountNumber == 1) { ta.НачислитьНаКарту(int.Parse(receiverAccountNumberTextBox.Text), decimal.Parse(transferSumTextBox.Text)); } else { ta.НачислитьНаВклад(int.Parse(receiverAccountNumberTextBox.Text), decimal.Parse(transferSumTextBox.Text)); } ta.СнятьСВклада(cfif.getSelectedContribution(), decimal.Parse(transferSumTextBox.Text)); MessageBox.Show("Перевод осуществлен"); cfif.updateClientCards(); cfif.updateClientContributionOperations(); cfif.updateClientContributions(); cfif.updateClientStatus(); cfif.of.updateClientsGrid(); this.Close(); } else { MessageBox.Show("Недостаточно средств на карте", "Перевод не осуществлен", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }