Пример #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (VerificarCampo())
            {
                try
                {
                    List <Dentistas> salvarDentista = new List <Dentistas>();
                    string           arquivo        = @"C:\\aula arquivo texto\Cadastro dentista.txt";
                    StreamWriter     sw             = new StreamWriter(arquivo, true);
                    Dentistas        dentista       = new Dentistas();
                    dentista.Nome       = txtNome.Text;
                    dentista.Nascimento = Convert.ToDateTime(dtpNascimento.Text);
                    dentista.Estado     = cbxEstado.SelectedItem.ToString();
                    dentista.Endereco   = txtEndereco.Text;
                    dentista.Cpf        = txtCpf.Text;
                    dentista.Celular    = txtCelular.Text;
                    dentista.Sexo       = rbF.Checked ? 'f' : 'm';

                    sw.WriteLine("Nome: " + dentista.Nome + "/ Cpf: " + dentista.Cpf + "/ Data Nascimento: " +
                                 dentista.Nascimento + "/ Sexo: " + dentista.Sexo + "/ Estado: " + dentista.Estado);
                    sw.WriteLine("");
                    sw.Dispose();
                    MessageBox.Show("Cadastrado!", "SUCESSO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Dentistas.cadastrarDentistas(salvarDentista, dentista);
                    Limpartela();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Пример #2
0
 public static void cadastrarDentistas(List <Dentistas> cadastro, Dentistas dentista)
 {
     cadastro.Add(dentista);
 }