Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- amountForUser = decimal.Parse(sendingAmount.Text);
- amountForRecipient = amountForUser;
- amountForUser = calculateMoney(amountForUser, percent);
- LoadingForm loading = new LoadingForm();
- loading.ShowDialog();
- this.Visible = false;
- if (userBalance >= amountForUser)
- {
- this.Visible = true;
- try
- {
- int operationSuccsessful = 0;
- recipientCard = long.Parse(recipient_textBox.Text);
- string query = "Select [UserName], [UserSurname], [UserPatronymic], [Balance] from UsersInfo where CardNumber = '" + recipientCard + "'";
- using (SqlConnection Connection = new SqlConnection(connectionString))
- {
- SqlCommand Command = new SqlCommand(query, Connection);
- SqlDataReader Reader;
- Connection.Open();
- Reader = Command.ExecuteReader();
- while (Reader.Read())
- {
- operationSuccsessful++;
- recipientName = Reader["UserName"].ToString();
- recipientSurname = Reader["UserSurname"].ToString();
- recipientPatronymic = Reader["UserPatronymic"].ToString();
- recipientBalance = Convert.ToDecimal(Reader["Balance"]);
- }
- }
- if (operationSuccsessful == 0 || recipientCard == userCard)
- {
- recipient_textBox.Focus();
- MessageBox.Show("Вы не можете перевести деньги на этот счет.\nПроверьте введенные данные", "Ошибка перевеода", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- else if (operationSuccsessful != 0 && recipientCard != userCard)
- {
- userBalance -= amountForUser;
- recipientBalance += amountForRecipient;
- this.Opacity = 0.2;
- ConfirmationForm confirmation = new ConfirmationForm();
- confirmation.userName = userName;
- confirmation.userPassword = userPassword;
- confirmation.amount = amountForUser;
- confirmation.ShowDialog();
- bool succsess = confirmation.ok;
- if (succsess != true)
- {
- this.Opacity = 1;
- try
- {
- using(SqlConnection connection = new SqlConnection(connectionString))
- {
- string recipQuery = "Update UsersInfo set Balance = '" + recipientBalance + "' where CardNumber = '" + recipientCard + "'";
- string userQuery = "Update UsersInfo set Balance = '" + userBalance + "' where Phone = '" + login + "'";
- connection.Open();
- SqlCommand recipCommand = new SqlCommand(recipQuery, connection);
- SqlCommand userCommand = new SqlCommand(userQuery, connection);
- recipCommand.ExecuteNonQuery();
- userCommand.ExecuteNonQuery();
- }
- this.Close();
- LoadingForm loadingForm = new LoadingForm();
- loadingForm.Show();
- notifyIconConfirmed.Icon = SystemIcons.Application;
- notifyIconConfirmed.Visible = true;
- notifyIconConfirmed.ShowBalloonTip(3000, "Перевод средств", $"Сумма в размере {amountForRecipient} были успешно переведены {recipientSurname} {recipientName} {recipientPatronymic}\nВаш поточный баланс: {userBalance}", ToolTipIcon.Info);
- mainMenu.login = login;
- mainMenu.Show();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- return;
- }
- }
- else if(confirmation.ok != true)
- {
- this.Opacity = 1;
- MessageBox.Show($"Извините, {userName}, Вы не можете отправить деньги без подтверждения.", "Ошибка перевода", MessageBoxButtons.OK, MessageBoxIcon.Error);
- sendMoney.Focus();
- return;
- }
- else
- {
- this.Opacity = 1;
- }
- }
- }
- catch (FormatException fe)
- {
- MessageBox.Show(fe.Message);
- }
- }
- else
- {
- this.Visible = true;
- MessageBox.Show($"У вас не достаточно сресдтв для перевода\nВведите сумму меньше или равную {amountForUser}", "Ошибка перевеода", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment