private void IncluirlayoutButton_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(nomelayoutTextBox.Text)) { throw new Exception("Favor preencher o nome do layout."); } Layout ObjLayout = new Layout() { Nome = nomelayoutTextBox.Text }; for (int i = 0; i < ConteudoComboBoxes.Count(); i++) { switch (ConteudoComboBoxes.ElementAt(i).SelectedIndex) { case 1: //Código Empresa if (!string.IsNullOrEmpty(InicioComboBoxes.ElementAt(i).Text)) { ObjLayout.InicioEmpresa = int.Parse(InicioComboBoxes.ElementAt(i).Text); } if (!string.IsNullOrEmpty(TamanhoComboBoxes.ElementAt(i).Text)) { ObjLayout.TamanhoEmpresa = int.Parse(TamanhoComboBoxes.ElementAt(i).Text); } break; case 2: //Código Funcionário if (!string.IsNullOrEmpty(InicioComboBoxes.ElementAt(i).Text)) { ObjLayout.InicioFuncionario = int.Parse(InicioComboBoxes.ElementAt(i).Text); } if (!string.IsNullOrEmpty(TamanhoComboBoxes.ElementAt(i).Text)) { ObjLayout.TamanhoFuncionario = int.Parse(TamanhoComboBoxes.ElementAt(i).Text); } break; case 3: //Código Evento if (!string.IsNullOrEmpty(InicioComboBoxes.ElementAt(i).Text)) { ObjLayout.InicioEvento = int.Parse(InicioComboBoxes.ElementAt(i).Text); } if (!string.IsNullOrEmpty(TamanhoComboBoxes.ElementAt(i).Text)) { ObjLayout.TamanhoEvento = int.Parse(TamanhoComboBoxes.ElementAt(i).Text); } break; case 4: //Horas if (!string.IsNullOrEmpty(InicioComboBoxes.ElementAt(i).Text)) { ObjLayout.InicioHoras = int.Parse(InicioComboBoxes.ElementAt(i).Text); } if (!string.IsNullOrEmpty(TamanhoComboBoxes.ElementAt(i).Text)) { ObjLayout.TamanhoHoras = int.Parse(TamanhoComboBoxes.ElementAt(i).Text); } break; } } VerificarLayoutVazio(ObjLayout); DataBaseBLL.GravarLayout(ObjLayout); MessageBox.Show("Layout cadastrado com sucesso!", ParametroInfo.SistemaVersao, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Utilities.ResetarControles(cadastrolayoutGroupBox); nomelayoutTextBox.Focus(); } catch (Exception ex) { if (ex.Message == "23505") { MessageBox.Show("Layout já cadastrado.", ParametroInfo.SistemaVersao, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show(ex.Message, ParametroInfo.SistemaVersao, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }