Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (richTextBox1.Text != "")
            {
                ProblemaController pc = new ProblemaController();

                Model.Problema problemaId = pc.search("id", comboBox1.SelectedItem.ToString())[0];
                Model.Solucao  solucaoId  = pc.listaSolucao(comboBox1.SelectedItem.ToString())[0];

                solucaoId.descricao = richTextBox1.Text;
                foreach (Model.Problema atraso in modelo.Keys)
                {
                    if (problemaId.nome == atraso.nome)
                    {
                        problemaId = atraso;
                    }
                }
                modelo[problemaId] = solucaoId;

                MessageBox.Show("Recomendação atualizada!");
                conteudoRelatorio(nome_paciente, Session.nome, this.consulta.datahora.ToShortDateString(), this.consulta.datahora.ToShortTimeString(), modelo);
            }
            else
            {
                MessageBox.Show("Preencha o campo requisitado!");
            }
        }
        private void btnAtualizar_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox2.Text != "")
            {
                try
                {
                    string id        = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[0].Value.ToString();
                    string nome      = textBox1.Text;
                    string descricao = textBox2.Text;

                    ProblemaController pc   = new ProblemaController();
                    Model.Problema     prob = pc.search("id", id)[0];
                    prob.nome      = nome;
                    prob.descricao = descricao;

                    try
                    {
                        if (pc.update(prob))
                        {
                            MessageBox.Show("Problema atualizado com sucesso!");
                            Limpar.limpar(this);

                            MySqlCommand sql = new MySqlCommand();
                            sql.CommandText = "select id as 'Id', stt as 'Status', nome as 'Nome', descricao as 'Descrição' from problema where id = @id or descricao like concat('%',@descricao,'%')";
                            sql.Parameters.AddWithValue("@id", id);
                            sql.Parameters.AddWithValue("@descricao", descricao);
                            Grid.grid(dataGridView1, sql);
                        }
                        else
                        {
                            MessageBox.Show("Problema não pôde ser atualizado!");
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Preencha tudo corretamente!");
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Selecione um problema para ser atualizado!");
                }
            }
            else
            {
                MessageBox.Show("Preencha todos os campos!");
            }
        }