Ejemplo n.º 1
0
        public override void Cadastrar()
        {
            this.txtPesquisa.Clear();
            //Direcionando para tela de cadastro Object sessao, int id, Boolean visualizar, object objFisioterapeuta
            FormSessaoCadastrar form = new FormSessaoCadastrar(nSessao, 0, false, null);

            form.ShowDialog();
            //Atualiza grid
            this.preencherGrid();
        }
Ejemplo n.º 2
0
        private void btnVisualizar_Click(object sender, EventArgs e)
        {
            this.txtPesquisa.Clear();
            //Verifica se o Data grid possui linha
            if (this.dgDados.Rows.Count > 0)
            {
                //Verifica de sé alguma linha selecionada
                if (this.dgDados.CurrentRow.Cells[4].Selected | this.dgDados.CurrentRow.Cells[5].Selected |
                    this.dgDados.CurrentRow.Cells[6].Selected | this.dgDados.CurrentRow.Cells[7].Selected)
                {
                    //Tratamento de exceções
                    try
                    {
                        //Inserindo dados da grid no objeto nSessoes.
                        this.nSessoes.id             = Convert.ToInt32(this.dgDados.CurrentRow.Cells[0].Value.ToString());
                        this.nClinica.id             = Convert.ToInt32(this.dgDados.CurrentRow.Cells[1].Value.ToString());
                        this.nSessoes.clinica        = this.nClinica;
                        this.nFisioterapeuta.id      = Convert.ToInt32(this.dgDados.CurrentRow.Cells[2].Value.ToString());
                        this.nSessoes.fisioterapeuta = this.nFisioterapeuta;
                        this.nPaciente.id            = Convert.ToInt32(this.dgDados.CurrentRow.Cells[3].Value.ToString());
                        this.nSessoes.paciente       = this.nPaciente;
                        this.nSessoes.situacao       = this.dgDados.CurrentRow.Cells[7].Value.ToString();
                        this.nSessoes.data           = Convert.ToDateTime(this.dgDados.CurrentRow.Cells[8].Value.ToString());
                        this.nSessoes.hora           = Convert.ToDateTime(this.dgDados.CurrentRow.Cells[9].Value.ToString());
                        this.nSessoes.observacao     = this.dgDados.CurrentRow.Cells[10].Value.ToString();

                        FormSessaoCadastrar form = new FormSessaoCadastrar(this.nSessao, this.nSessoes.id,
                                                                           true, this.nSessoes);
                        form.ShowDialog();

                        //Atualiza a grid
                        this.preencherGrid();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Nenhuma sessão selecionada.", "Aviso!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Não há sessões cadastradas!", "Aviso!",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Este método recebe os dados do Data Grid para um objeto
        /// do tipo Sessoes para o Formulário que será aberto.
        /// </summary>
        public override void Alterar()
        {
            this.txtPesquisa.Clear();
            //Verifica se o Data grid possui linha
            if (this.dgDados.Rows.Count > 0)
            {
                //Verifica de sé alguma linha selecionada
                if (this.dgDados.CurrentRow.Cells[4].Selected | this.dgDados.CurrentRow.Cells[5].Selected |
                    this.dgDados.CurrentRow.Cells[6].Selected | this.dgDados.CurrentRow.Cells[7].Selected)
                {
                    //Tratamento de exceções
                    try
                    {
                        this.nSessoes.id             = Convert.ToInt32(this.dgDados.CurrentRow.Cells[0].Value.ToString());
                        this.nClinica.id             = Convert.ToInt32(this.dgDados.CurrentRow.Cells[1].Value.ToString());
                        this.nSessoes.clinica        = this.nClinica;
                        this.nFisioterapeuta.id      = Convert.ToInt32(this.dgDados.CurrentRow.Cells[2].Value.ToString());
                        this.nSessoes.fisioterapeuta = this.nFisioterapeuta;
                        this.nPaciente.id            = Convert.ToInt32(this.dgDados.CurrentRow.Cells[3].Value.ToString());
                        this.nSessoes.paciente       = this.nPaciente;
                        this.nSessoes.situacao       = this.dgDados.CurrentRow.Cells[7].Value.ToString();
                        this.nSessoes.data           = Convert.ToDateTime(this.dgDados.CurrentRow.Cells[8].Value.ToString());
                        this.nSessoes.hora           = Convert.ToDateTime(this.dgDados.CurrentRow.Cells[9].Value.ToString());
                        this.nSessoes.observacao     = this.dgDados.CurrentRow.Cells[10].Value.ToString();

                        //Verifica se o usuário quer alterar uma sessão concluída
                        if (this.dgDados.CurrentRow.Cells[7].Value.ToString() == "Concluída")
                        {
                            //Pergunta se deseja visualizar a sessão, pois, não é possível alterar
                            DialogResult ds = MessageBox.Show("Não é possível alterar uma sessão concluída. \n " +
                                                              "Deseja visualizá-la?", "Aviso!", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                            if (ds == DialogResult.Yes)
                            {
                                FormSessaoCadastrar form = new FormSessaoCadastrar(this.nSessao, this.nSessoes.id,
                                                                                   true, this.nSessoes);
                                form.ShowDialog();
                            }
                        }//Se não ele pode alterar normalmente.
                        else
                        {
                            //Inserindo dados da grid no objeto nSessoes.
                            FormSessaoCadastrar form = new FormSessaoCadastrar(this.nSessao, this.nSessoes.id,
                                                                               false, this.nSessoes);
                            form.ShowDialog();
                        }
                        //Atualiza a grid
                        this.preencherGrid();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Nenhuma sessão selecionada.", "Aviso!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Não há sessões cadastradas!", "Aviso!",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }