private void btnSaveOption_Click(object sender, EventArgs e) { double duration = 0; if (String.IsNullOrEmpty(txtName.Text)) MessageBox.Show("Please enter a valid Assembly Name."); else if (String.IsNullOrEmpty(txtCode.Text)) MessageBox.Show("Please enter a valid Assembly Code."); else if (String.IsNullOrEmpty(txtDuration.Text) || !Double.TryParse(txtDuration.Text, out duration)) MessageBox.Show("Please enter a valid duration."); else if (CreatedOption.Materials.Count() <= 0) MessageBox.Show("Assembly must contain at least one material."); else { CreatedOption.AssemblyName = txtName.Text; CreatedOption.AssemblyCode = txtCode.Text; CreatedOption.Description = txtDesc.Text; CreatedOption.Cost = Double.Parse(txtCost.Text); CreatedOption.CO2 = Double.Parse(txtEI.Text); CreatedOption.Duration = Double.Parse(txtDuration.Text); CreatedOption.Category = this.AssemCategory; DBManager manager = new DBManager(RevitDocument); if (!manager.saveAssembly(CreatedOption)) MessageBox.Show("Failed to save Option."); } }