public void BtCadastrarMedico_Click_1(object sender, EventArgs e)
        {
            label1.Hide();
            textBox1.Hide();
            string telefoneMedicoFormatado = TextNoFormatting(telefoneMedico);

            if (nomeMedico.Text != "" && especialidadeMedico.Text != "" && telefoneMedicoFormatado != "")
            {
                MedicosClass med = new MedicosClass();
                textBox1.Text = med.CadastrarMedico(nomeMedico.Text, especialidadeMedico.Text, telefoneMedico.Text);
                string nome = nomeMedico.Text;
                nomeMedico.Text          = "";
                especialidadeMedico.Text = "";
                telefoneMedico.Text      = "";
                resultadoPesquisa1.Show();
                btNovaPesquisa.Show();
                btNovaPesquisa.BringToFront();
                btNovaPesquisa.Focus();
                label1.Show();
                label1.BringToFront();
                textBox1.Show();
                textBox1.BringToFront();
            }

            else
            {
                MessageBox.Show("Preencha todos os campos");
            }
        }
        private void BtPesquisar_Click(object sender, EventArgs e)
        {
            if (nomeMedico.Text != "")
            {
                listView1.Items.Clear();
                MedicosClass pesquisa  = new MedicosClass();
                string       resultado = pesquisa.PesquisarMedico(nomeMedico.Text.ToUpper());
                btexcluirMed.Show();
                btNovaPesquisaMed.Show();

                string[] texto = resultado.Split('*');

                for (int i = 0; i < texto.Length; i++)
                {
                    string[] aux = texto[i].Split('+');

                    ListViewItem lista = new ListViewItem(aux);

                    listView1.Items.Add(lista);
                }

                listView1.Show();
                btexcluirMed.Show();
                btNovaPesquisaMed.Show();
                btHistorico.Show();
                listView1.BringToFront();
            }
            else
            {
                MessageBox.Show("Digite uma pesquisa");
            }
        }
        public string CadastrarPaciente(string nome, string data, string endereco, string telefone)  // Função para cadastrar o paciente
        {
            string         cod        = IdAleatrio().ToString();
            MedicosClass   aux        = new MedicosClass();
            FileStream     arqpac     = new FileStream("cadastropaciente.txt", FileMode.Append);
            StreamWriter   escrevepac = new StreamWriter(arqpac);
            PacientesClass cadpac     = new PacientesClass(nome, data, endereco, telefone);


            escrevepac.WriteLine($"{cod}*{nome.ToUpper()}*{data}*{endereco.ToUpper()}*{telefone}");
            escrevepac.Close();
            arqpac.Close();
            return(cod);
        }
示例#4
0
        //Cadastra o médico
        public string CadastrarMedico(string nome, string espec, string tel)
        {
            string cod;

            cod = IdAleatrio().ToString();
            FileStream   arqmed     = new FileStream("cadastromedico.txt", FileMode.Append);
            StreamWriter escrevemed = new StreamWriter(arqmed);
            MedicosClass cadmed     = new MedicosClass(nome, espec, tel);

            escrevemed.WriteLine($"{cod}*{nome.ToUpper()}*{espec.ToUpper()}*{tel}");
            escrevemed.Close();
            arqmed.Close();
            return(cod);
        }
 private void BtexcluirMed_Click(object sender, EventArgs e)
 {
     if (listView1.Items.Count > 0)
     {
         if ((MessageBox.Show("Tem certeza que deseja excluir este cadastro?", "Excluir cadastro", MessageBoxButtons.YesNo) == DialogResult.Yes))
         {
             string excluir = listView1.SelectedItems[0].Text;
             listView1.Items.Remove(listView1.SelectedItems[0]);
             MedicosClass excluircadastro = new MedicosClass();
             excluircadastro.ExcluirMedico(excluir);
             listView1.Refresh();
         }
     }
     else
     {
         MessageBox.Show("Selecione um cadastro");
     }
 }
        private void BtHistorico_Click(object sender, EventArgs e)
        {
            if (listView1.Items.Count > 0)
            {
                try {
                    string       historico  = listView1.SelectedItems[0].Text;
                    MedicosClass historico2 = new MedicosClass();
                    string       resultado  = historico2.HistoricoMedico(historico);
                    string[]     texto      = resultado.Split('*');

                    for (int i = 0; i < texto.Length - 1; i++)
                    {
                        string[] aux = texto[i].Split('+');


                        ListViewItem lista = new ListViewItem(aux);

                        listView2.Items.Add(lista);
                    }

                    listView2.Show();
                    listView2.BringToFront();
                    listView2.Refresh();
                    btexcluirMed.Hide();
                    back.Show();
                    back.BringToFront();
                }
                catch (Exception) {
                    MessageBox.Show("Selecione um Médico");
                }
            }
            else
            {
                MessageBox.Show("Lista Vazia");
            }
        }