private void cmdPay_Click(object sender, EventArgs e) { if (cboPayList.SelectedIndex == 0 || cboPayList.SelectedIndex == -1) { if (userInformations.Money >= Convert.ToDouble(updPayAmount.Value)) { DatabaseManagement database = new DatabaseManagement(); database.OpenConnection(); bool success = database.Transact(Convert.ToDouble(updPayAmount.Value), txtPayReason.Text, userInformations.Iban, txtPayIban.Text); if (success) { userInformations = (PublicUser)database.GetUser(userInformations.Email); } database.CloseConnection(); updateInfos(); txtPayIban.Text = ""; updPayAmount.Value = 1; txtPayReason.Text = ""; } else { MessageBox.Show("Vous n'avez pas assez d'argent pour effectuer cette transaction", "Erreur"); } } else { if (userInformations.Money >= Convert.ToDouble(((UsersList)cboPayList.SelectedItem).Users.Count() * updPayAmount.Value)) { foreach (User user in ((UsersList)cboPayList.SelectedItem).Users) { DatabaseManagement database = new DatabaseManagement(); database.OpenConnection(); bool success = database.Transact(Convert.ToDouble(updPayAmount.Value), txtPayReason.Text, userInformations.Iban, user.Iban); if (success) { userInformations = (PublicUser)database.GetUser(userInformations.Email); } database.CloseConnection(); updateInfos(); } updPayAmount.Value = 1; txtPayReason.Text = ""; cboPayList.SelectedIndex = 0; txtPayIban.Text = ""; } else { MessageBox.Show("Vous n'avez pas assez d'argent pour effectuer cette transaction", "Erreur"); } } }