Пример #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!");
            }
        }
Пример #2
0
 private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
 {
     try
     {
         ProblemaController pc = new ProblemaController();
         foreach (Model.Problema atraso in modelo.Keys)
         {
             if (comboBox1.SelectedItem.ToString() == atraso.id)
             {
                 Model.Solucao solu = modelo[atraso];
                 richTextBox1.Text = solu.descricao;
             }
         }
     }
     catch (Exception) { }
 }
        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;

                    SolucaoController pc  = new SolucaoController();
                    Model.Solucao     sol = pc.search("id", id)[0];
                    sol.nome      = nome;
                    sol.descricao = descricao;

                    try
                    {
                        if (pc.update(sol))
                        {
                            MessageBox.Show("Solução atualizada com sucesso!");
                            Limpar.limpar(this);

                            MySqlCommand sql = new MySqlCommand();
                            sql.CommandText = "select id as 'Id', nome as 'Nome', descricao as 'Descrição' from solucao where id = @id";
                            sql.Parameters.AddWithValue("@id", id);
                            Grid.grid(dataGridView1, sql);
                        }
                        else
                        {
                            MessageBox.Show("Solução não pôde ser atualizada!");
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Preencha tudo corretamente!");
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Selecione uma solução para ser atualizada!");
                }
            }
            else
            {
                MessageBox.Show("Preencha todos os campos!");
            }
        }
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                if (!(textBox1.Text == "" || textBox2.Text == "" || comboBox1.Text == ""))
                {
                    string nome      = textBox1.Text;
                    string descricao = textBox2.Text;
                    string problema  = Hash.md5(comboBox1.Text);
                    string id        = Hash.md5(nome);

                    SolucaoController solC = new SolucaoController();
                    Model.Solucao     sol  = new Model.Solucao(id, nome, descricao);
                    string            msg  = "";
                    if (solC.add(sol))
                    {
                        msg += "Solução cadastrada com sucesso";
                        Limpar.limpar(this);
                        dataGridView1.DataSource = null;
                        Grid.grid(dataGridView1, "select id as 'Id', nome as 'Nome', descricao as 'Descrição' from solucao where id = '" + id + "'");
                        if (solC.problemaSolucao(problema, id))
                        {
                            MessageBox.Show(msg + " e devidamente associada ao problema!");
                        }
                        else
                        {
                            MessageBox.Show(msg + ", mas não devidamente associada ao problema!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Solução não pôde ser cadastrada!");
                    }
                }
                else
                {
                    MessageBox.Show("Informe tudo que for necessário!");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Solução não pôde ser cadastrada!");
            }
        }