private void saveButton_Click(object sender, EventArgs e) { if (this.ValidateChildren(ValidationConstraints.Enabled)) { ReactionProgram newProgram = configureNewProgram(); if (File.Exists(path + Global.programFolderName + prgNameTextBox.Text + ".prg")) { DialogResult dialogResult = MessageBox.Show("O programa já existe, deseja sobrescrevê-lo?", "", MessageBoxButtons.OKCancel); if (dialogResult == DialogResult.Cancel) { throw new Exception("O programa não será salvo!"); } } if (newProgram.saveProgramFile(path + Global.programFolderName, instructionsBox.Text)) { MessageBox.Show("O programa foi salvo com sucesso"); } this.Parent.Controls.Remove(this); } else { MessageBox.Show("Algum campo não foi preenchido de forma correta."); } }
private void saveButton_Click(object sender, EventArgs e) { bool hasToSave = true; if (this.ValidateChildren(ValidationConstraints.Enabled)) { ReactionProgram newProgram = configureNewProgram(); if (File.Exists(path + Global.programFolderName + prgNameTextBox.Text + ".prg")) { DialogResult dialogResult = MessageBox.Show(LocRM.GetString("programExists", currentCulture), "", MessageBoxButtons.OKCancel); if (dialogResult == DialogResult.Cancel) { hasToSave = false; MessageBox.Show(LocRM.GetString("programNotSave", currentCulture)); } } if (hasToSave && newProgram.saveProgramFile(path + Global.programFolderName, instructionsBox.Text)) { MessageBox.Show(LocRM.GetString("programSave", currentCulture)); } this.Parent.Controls.Remove(this); } else { MessageBox.Show(LocRM.GetString("fieldNotRight", currentCulture)); } }