private void applyFlatButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(nameFlatTextBox.Text) || string.IsNullOrWhiteSpace(nameFlatTextBox.Text)) { MessageBox.Show("Vous n'avez pas défini de nom pour la ressource !", "Merci de définir un nom de ressource"); return; } try { if (id == -1) { foreach (RPN_API_Json.RessourceTypeData ressourceTypeData in web.GetRessourceType()) { if (ressourceTypeData.Name.Equals(nameFlatTextBox.Text, StringComparison.InvariantCultureIgnoreCase)) { MessageBox.Show("Une ressource porte déjà ce nom !"); return; } } if (!web.CreateRessourceType(nameFlatTextBox.Text, (int)massNumericUpDown.Value, (int)priceNumericUpDown.Value, ressourcePictureBox.Image)) { throw new Exception("API ERROR"); } } else { if (!web.EditRessourceType(id, nameFlatTextBox.Text, (int)massNumericUpDown.Value, (int)priceNumericUpDown.Value, ressourcePictureBox.Image)) { throw new Exception("API ERROR"); } } } catch (Exception ex) { MessageBox.Show("Une erreur a eu lieu pendant l'envoie du type de ressource !\n" + ex.Message, "Erreur"); } Close(); }