示例#1
0
 private void BtnCadastrar_Click(object sender, EventArgs e)
 {
     if (TextNome.Text.Length == 0 || TextCnpj.Text.Length == 0 || TextQuantidadeFuncionario.Text.Length == 0 ||
         TextEndereco.Text.Length == 0 || TextTelefone.Text.Length == 0)
     {
         MetroMessageBox.Show(this, "Favor preencher todos os campos!", "Atenção !",
                              MessageBoxButtons.OK,
                              MessageBoxIcon.Warning);
     }
     if (LabelCnae.Text.Equals("CNAE"))
     {
         MetroMessageBox.Show(this, "Favor selecionar um CNAE!", "Atenção !",
                              MessageBoxButtons.OK,
                              MessageBoxIcon.Warning);
     }
     else
     {
         var Servicos = "";
         for (var i = 0; i < GridServicosPrestados.RowCount; i++)
         {
             if (Convert.ToBoolean(GridServicosPrestados.Rows[i].Cells[0].Value))
             {
                 Servicos = Servicos + ";" + GridServicosPrestados.Rows[i].Cells[1].Value;
             }
         }
         var Cnae = LabelCnae.Text.Split('|');
         Cadastro.CadastraEmpresa(TextNome.Text, TextEndereco.Text, TextCnpj.Text,
                                  Convert.ToInt32(TextQuantidadeFuncionario.Text), TextTelefone.Text, TextEmail.Text,
                                  Cnae[1] + " | " + Cnae[2], Servicos, TextMedicoExaminador.Text, TextCrmMedico.Text);
         MetroMessageBox.Show(this, "Empresa cadastrada com sucesso!", "Sucesso !", MessageBoxButtons.OK,
                              MessageBoxIcon.Information);
         TextNome.Text = "";
         TextCnpj.Text = "";
         TextQuantidadeFuncionario.Text = "";
         TextEndereco.Text                = "";
         TextTelefone.Text                = "";
         TextEmail.Text                   = "";
         TextMedicoExaminador.Text        = "";
         TextCrmMedico.Text               = "";
         LabelCnae.Text                   = "CNAE:";
         GridServicosPrestados.DataSource = null;
         var TabelaServicos = Cadastro.RetornaServicosPrestados();
         GridServicosPrestados.DataSource = TabelaServicos;
     }
 }