Esempio n. 1
0
        private void PreencherComboPacientes()
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            DataTable    tblResultado;
            DataRow      objLinha;

            try
            {
                cboPaciente.DisplayMember = "NMPACIENTE";
                cboPaciente.ValueMember   = "CDPACIENTE";

                tblResultado = objConexao.ExecutarComandoSqlDataSet("SELECT CDPACIENTE, UCASE(NMPACIENTE) AS NMPACIENTE FROM TBPACIENTES WHERE STATUSINATIVO = FALSE ORDER BY NMPACIENTE").Tables[0];
                objLinha     = tblResultado.NewRow();
                tblResultado.Rows.InsertAt(objLinha, 0);

                cboPaciente.DataSource = tblResultado;
            }
            catch (Exception objErro)
            {
                MessageBox.Show(objErro.Message);
            }
            finally
            {
                objConexao   = null;
                tblResultado = null;
                objLinha     = null;
            }
        }
Esempio n. 2
0
        private void PreencherGrid()
        {
            clsConexaoBD objConexao = new clsConexaoBD();

            try
            {
                dtgPacientes.DataSource = objConexao.ExecutarComandoSqlDataSet("SELECT CDPACIENTE, CODPACIENTEUNIMED, UCASE(NMPACIENTE) AS NMPACIENTE," +
                                                                               " TELPACIENTE2, TELPACIENTE,  IIF( STATUSINATIVO = FALSE, 'ATIVO', 'INATIVO' ) AS STATUS FROM TBPACIENTES " +
                                                                               " WHERE UCASE(NMPACIENTE) LIKE '%" + txtNome.Text.Trim().ToUpper() + "%'" +
                                                                               "ORDER BY NMPACIENTE").Tables[0];
                dtgPacientes.Columns["CDPACIENTE"].Visible           = false;
                dtgPacientes.Columns["NMPACIENTE"].HeaderText        = "Nome do Paciente";
                dtgPacientes.Columns["TELPACIENTE"].HeaderText       = "Celular";
                dtgPacientes.Columns["TELPACIENTE2"].HeaderText      = "Telefone Residencial";
                dtgPacientes.Columns["CODPACIENTEUNIMED"].HeaderText = "Código Paciente";
                dtgPacientes.Columns["STATUS"].HeaderText            = "Status";
                if (dtgPacientes.SelectedRows.Count > 0)
                {
                    dtgPacientes.SelectedRows[0].Selected = false;
                }
            }
            catch (Exception objErro)
            {
                MessageBox.Show(objErro.Message);
            }
            finally
            {
                objConexao = null;
            }
        }
Esempio n. 3
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            clsConexaoBD objConexao = new clsConexaoBD();

            try
            {
                if (objAgendamento.cdAgendamento != "")
                {
                    if (MessageBox.Show("Deseja realmenre excluir esse agendamento?", "Excluir Agendamento", MessageBoxButtons.YesNo)
                        == System.Windows.Forms.DialogResult.Yes)
                    {
                        objConexao.ExecutarComandoSql("DELETE FROM TBPROCEDIMENTOSAGENDAMENTO WHERE CDAGENDAMENTO = " + objAgendamento.cdAgendamento);
                        objConexao.ExecutarComandoSql("DELETE FROM TBAGENDAMENTO WHERE CDAGENDAMENTO = " + objAgendamento.cdAgendamento);

                        MessageBox.Show("Exclusão do agendamento realizada!", "Exclusão de Agendamento ", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Código do Agendamento não informado, por favor, tentar novamente!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Erro na exclusão do agendamento. ERRO: " + objErro.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
            }
        }
        private void PreencherComboStatus()
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            DataTable    tblResultado;
            DataRow      objLinha;

            try
            {
                cboStatus.DisplayMember = "DESSTATUS";
                cboStatus.ValueMember   = "CDSTATUS";

                tblResultado = objConexao.ExecutarComandoSqlDataSet("SELECT CDSTATUS, UCASE(DESSTATUS) AS DESSTATUS FROM TBSTATUS ORDER BY DESSTATUS").Tables[0];
                objLinha     = tblResultado.NewRow();
                tblResultado.Rows.InsertAt(objLinha, 0);

                cboStatus.DataSource = tblResultado;
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Agendamento/Método PreencherComboStatus/ERRO: " + objErro.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao   = null;
                tblResultado = null;
                objLinha     = null;
            }
        }
        private void CarregarGrid()
        {
            clsConexaoBD objConexao = new clsConexaoBD();

            try
            {
                dtgProcedimentos.DataSource =
                    objConexao.ExecutarComandoSqlDataSet("SELECT CDPROCEDIMENTO, CDPROCEDIMENTOUNIMED, UCASE(NMPROCEDIMENTO) AS NMPROCEDIMENTO, VLPROCEDIMENTO, CORPROCEDIMENTO FROM TBPROCEDIMENTOS ORDER BY 2").Tables[0];

                dtgProcedimentos.Columns["CDPROCEDIMENTO"].Visible                 = false;
                dtgProcedimentos.Columns["CDPROCEDIMENTOUNIMED"].HeaderText        = "Código Procedimento.";
                dtgProcedimentos.Columns["NMPROCEDIMENTO"].HeaderText              = "Descrição";
                dtgProcedimentos.Columns["VLPROCEDIMENTO"].HeaderText              = "Valor";
                dtgProcedimentos.Columns["VLPROCEDIMENTO"].DefaultCellStyle.Format = "c";
                dtgProcedimentos.Columns["CORPROCEDIMENTO"].Visible                = false;
            }
            catch (Exception objErro)
            {
                MessageBox.Show(objErro.Message);
            }
            finally
            {
                objConexao = null;
            }
        }
        private void VerificarNotificacoes()
        {
            clsConexaoBD  objConexao = new clsConexaoBD();
            StringBuilder strSQL     = new StringBuilder();

            try
            {
                strSQL.Append(" SELECT COUNT(*) FROM TBLEMBRETES WHERE ");
                strSQL.Append(" YEAR(DTLEMBRETE) = " + dtAgenda.Value.Year);
                strSQL.Append(" AND MONTH(DTLEMBRETE) = " + dtAgenda.Value.Month);
                strSQL.Append(" AND DAY(DTLEMBRETE) = " + dtAgenda.Value.Day);

                if (int.Parse(objConexao.ExecutarComandoSqlDataSet(strSQL.ToString()).Tables[0].Rows[0][0].ToString()) > 0)
                {
                    imgNotificacao.Visible = lblLembrete.Visible = true;
                    lblLembrete.Text       = "Você possui " +
                                             objConexao.ExecutarComandoSqlDataSet(strSQL.ToString()).Tables[0].Rows[0][0].ToString()
                                             + " lembrete(s).";
                }
                else
                {
                    imgNotificacao.Visible = lblLembrete.Visible = false;
                }
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Agendamento/Método VerificarNotificacoes/ERRO: " + objErro.Message, "ERRO",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
                strSQL     = null;
            }
        }
        private void PreencherComboFisioterapeutas()
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            DataTable    tblResultado;
            DataRow      objLinha;

            try
            {
                cboFisioterapeutas.DisplayMember = "NMFUNCIONARIO";
                cboFisioterapeutas.ValueMember   = "CDFUNCIONARIO";

                tblResultado = objConexao.ExecutarComandoSqlDataSet("SELECT CDFUNCIONARIO, UCASE(NMFUNCIONARIO) AS NMFUNCIONARIO FROM TBFUNCIONARIOS ORDER BY NMFUNCIONARIO").Tables[0];
                objLinha     = tblResultado.NewRow();
                tblResultado.Rows.InsertAt(objLinha, 0);

                cboFisioterapeutas.DataSource = tblResultado;
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Agendamento/Método PreencherComboFisioterapeuta/ERRO: " + objErro.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao   = null;
                tblResultado = null;
                objLinha     = null;
            }
        }
Esempio n. 8
0
        private void CarregarGridProcedimentos()
        {
            clsConexaoBD  objConexao = new clsConexaoBD();
            DataTable     tblResultado;
            StringBuilder strSQL = new StringBuilder();

            string[] strCor;
            try
            {
                strSQL.Append("SELECT ");
                strSQL.Append("A.CDPROCEDIMENTO,  ");
                strSQL.Append("UCASE(B.CDPROCEDIMENTOUNIMED & ' - ' & B.NMPROCEDIMENTO) AS NMPROCEDIMENTO,  ");
                strSQL.Append("A.QTDPROCEDIMENTO,  ");
                strSQL.Append("B.CORPROCEDIMENTO  ");
                strSQL.Append("FROM  ");
                strSQL.Append("TBPROCEDIMENTOSAGENDAMENTO A INNER JOIN TBPROCEDIMENTOS B ON  A.CDPROCEDIMENTO = B.CDPROCEDIMENTO ");
                strSQL.Append("WHERE ");
                strSQL.Append("A.CDAGENDAMENTO =  " + objAgendamento.cdAgendamento);

                tblResultado = objConexao.ExecutarComandoSqlDataSet(strSQL.ToString()).Tables[0];

                foreach (DataRow objLinha in tblResultado.Rows)
                {
                    dtgProcedimentos.Rows.Add(objLinha[0].ToString(), objLinha[1].ToString(), objLinha[2].ToString());

                    if (objLinha[3].ToString() != "")
                    {
                        strCor = objLinha[3].ToString().Split('/');
                        dtgProcedimentos.Rows[dtgProcedimentos.Rows.Count - 1].DefaultCellStyle.BackColor =
                            Color.FromArgb(int.Parse(strCor[0]), int.Parse(strCor[1]), int.Parse(strCor[2]), int.Parse(strCor[3]));
                    }
                }
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Incluir Agendamento/ Método CarregarGridProcedimento/ERRO: " + objErro.Message, "ERRO",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao   = null;
                tblResultado = null;
                strSQL       = null;
            }
        }
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            if (strCodigoAgendamento == "")
            {
                MessageBox.Show("Selecione um lembrete para excluir.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                clsConexaoBD objConexao = new clsConexaoBD();

                try
                {
                    if (MessageBox.Show("Deseja realmente excluir o lembrete?", "Exclusão de Lembrete", MessageBoxButtons.YesNo) ==
                        System.Windows.Forms.DialogResult.Yes)
                    {
                        objConexao.ExecutarComandoSql(" DELETE FROM TBLEMBRETES WHERE CDLEMBRETE = " + strCodigoAgendamento);

                        btnExcluir.Enabled      = false;
                        btnNovoLembrete.Enabled = false;
                        strCodigoAgendamento    = "";
                        chkNotificacao.Checked  = false;
                        txtLembrete.Text        = "";

                        if (dtgLembrete.SelectedRows.Count > 0)
                        {
                            dtgLembrete.SelectedRows[0].Selected = false;
                        }

                        MessageBox.Show("Lembrete excluído.", "Exclusão", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        PreencherGridLembretes();
                    }
                }
                catch (Exception objErro)
                {
                    MessageBox.Show("tela de Lembrete/Método Excluir/ERRO: " + objErro.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    objConexao = null;
                }
            }
        }
Esempio n. 10
0
        private void frmNotas_Load(object sender, EventArgs e)
        {
            clsConexaoBD objConexao = new clsConexaoBD();

            try
            {
                txtNotas.Text = objConexao.ExecutarComandoSqlDataSet("SELECT DESCLEMBRETE FROM TBLEMBRETES WHERE DTLEMBRETE IS NULL").Tables[0].Rows[0][0].ToString();
                this.ShowIcon = true;
                this.Icon = Resource.notepad1;
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela Anotações/Método OnLoad/ERRO: " + objErro.Message , "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
            }
        }
Esempio n. 11
0
        private void frmNotas_Load(object sender, EventArgs e)
        {
            clsConexaoBD objConexao = new clsConexaoBD();

            try
            {
                txtNotas.Text = objConexao.ExecutarComandoSqlDataSet("SELECT DESCLEMBRETE FROM TBLEMBRETES WHERE DTLEMBRETE IS NULL").Tables[0].Rows[0][0].ToString();
                this.ShowIcon = true;
                this.Icon     = Resource.notepad1;
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela Anotações/Método OnLoad/ERRO: " + objErro.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
            }
        }
Esempio n. 12
0
        private void btnConfirmar_Click(object sender, EventArgs e)
        {
            clsConexaoBD objConexao = new clsConexaoBD();

            try
            {
                if(objConexao.ExecutarComandoSqlDataSet("SELECT COUNT(*) FROM TBLEMBRETES WHERE DTLEMBRETE IS NULL").Tables[0].Rows.Count <= 0 )
                    objConexao.ExecutarComandoSql("INSERT INTO TBLEMBRETES(DESCLEMBRETE) VALUES('" + txtNotas.Text + "')");
                else
                    objConexao.ExecutarComandoSql("UPDATE TBLEMBRETES SET  DESCLEMBRETE = '" + txtNotas.Text + "' WHERE DTLEMBRETE IS NULL");
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Anotações/Método Salvar/ERRO: " + objErro.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
            }
        }
Esempio n. 13
0
        private void InserirProcedimentos()
        {
            clsConexaoBD  objConexao = new clsConexaoBD();
            StringBuilder strSql     = new StringBuilder();

            try
            {
                if (objAgendamento.cdAgendamento == "")
                {
                    strSql.Append("SELECT MAX(CDAGENDAMENTO) FROM TBAGENDAMENTO");
                    objAgendamento.cdAgendamento = objConexao.ExecutarComandoSqlDataSet(strSql.ToString()).Tables[0].Rows[0][0].ToString();
                }

                strSql.Clear();
                strSql.Append("DELETE FROM TBPROCEDIMENTOSAGENDAMENTO WHERE CDAGENDAMENTO = " + objAgendamento.cdAgendamento);
                objConexao.ExecutarComandoSql(strSql.ToString());

                foreach (DataGridViewRow objLinha in dtgProcedimentos.Rows)
                {
                    strSql.Clear();

                    strSql.Append("INSERT INTO TBPROCEDIMENTOSAGENDAMENTO(CDAGENDAMENTO, CDPROCEDIMENTO, QTDPROCEDIMENTO) VALUES(");
                    strSql.Append(objAgendamento.cdAgendamento + ", ");
                    strSql.Append(objLinha.Cells["CodigoProcedimento"].Value.ToString() + ", ");
                    strSql.Append(objLinha.Cells["QuantidadeProcedimento"].Value.ToString());
                    strSql.Append(")");

                    objConexao.ExecutarComandoSql(strSql.ToString());
                }
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Incluir Agendamento/ Método InserirProcedimentos/ERRO: " + objErro.Message, "ERRO",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
                strSql     = null;
            }
        }
Esempio n. 14
0
        private void btnConfirmarAgendamento_Click(object sender, EventArgs e)
        {
            clsConexaoBD  objConexao = new clsConexaoBD();
            StringBuilder strSQL     = new StringBuilder();

            try
            {
                strSQL.Append(" UPDATE TBLEMBRETES SET STDESCARTAR = TRUE WHERE CDLEMBRETE = " + strCodigo);
                objConexao.ExecutarComandoSql(strSQL.ToString());
                this.Close();
            }
            catch (Exception objErro)
            {
                MessageBox.Show(objErro.Message);
            }
            finally
            {
                objConexao = null;
                strSQL     = null;
            }
        }
        private void PreencherGridLembretes()
        {
            StringBuilder strSQL     = new StringBuilder();
            clsConexaoBD  objConexao = new clsConexaoBD();

            if (dtpData.Visible)
            {
                dtLembrete = dtpData.Value;
            }

            strSQL.Append(" SELECT  CDLEMBRETE, DESCLEMBRETE, STNOTIFICACAO, STDESCARTAR FROM  TBLEMBRETES WHERE ");
            strSQL.Append(" YEAR(DTLEMBRETE) = " + dtLembrete.Year);
            strSQL.Append(" AND MONTH(DTLEMBRETE) = " + dtLembrete.Month);
            strSQL.Append(" AND DAY(DTLEMBRETE) = " + dtLembrete.Day);

            dtgLembrete.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            dtgLembrete.DataSource = objConexao.ExecutarComandoSqlDataSet(strSQL.ToString()).Tables[0];
            dtgLembrete.Columns["CDLEMBRETE"].Visible      = false;
            dtgLembrete.Columns["DESCLEMBRETE"].HeaderText = "Lembrete";
            dtgLembrete.Columns["STNOTIFICACAO"].Visible   = false;
            dtgLembrete.Columns["STDESCARTAR"].Visible     = false;
        }
Esempio n. 16
0
        private void VerificarNotificacoes()
        {
            clsConexaoBD   objConexao = new clsConexaoBD();
            StringBuilder  strSQL     = new StringBuilder();
            DataTable      tblResultado;
            frmNotificacao objForm;

            try
            {
                strSQL.Append(" SELECT DESCLEMBRETE, CDLEMBRETE FROM TBLEMBRETES WHERE ");
                strSQL.Append(" YEAR(DTLEMBRETE) = " + DateTime.Now.Year);
                strSQL.Append(" AND MONTH(DTLEMBRETE) = " + DateTime.Now.Month);
                strSQL.Append(" AND DAY(DTLEMBRETE) = " + DateTime.Now.Day);
                strSQL.Append(" AND STNOTIFICACAO = TRUE AND STDESCARTAR = FALSE");

                tblResultado = objConexao.ExecutarComandoSqlDataSet(strSQL.ToString()).Tables[0];

                if (tblResultado.Rows.Count > 0)
                {
                    foreach (DataRow rowLinha in tblResultado.Rows)
                    {
                        objForm = new frmNotificacao(rowLinha[0].ToString(), rowLinha[1].ToString());
                        objForm.ShowDialog();
                        objForm = null;
                    }
                }
            }
            catch (Exception objErro)
            {
                throw objErro;
            }
            finally
            {
                objConexao   = null;
                tblResultado = null;
                strSQL       = null;
            }
        }
        private void btnConsultar_Click(object sender, EventArgs e)
        {
            StringBuilder strSQL     = new StringBuilder();
            clsConexaoBD  objConexao = new clsConexaoBD();

            try
            {
                strSQL.Append(" SELECT  CDLEMBRETE, DTLEMBRETE, DESCLEMBRETE, STNOTIFICACAO, STDESCARTAR FROM  TBLEMBRETES WHERE 1= 1 ");

                if (txtData.Text.Replace("/", "").Replace("/", "").Trim() != "")
                {
                    strSQL.Append(" AND YEAR(DTLEMBRETE) = " + txtData.Text.Split('/')[2]);
                    strSQL.Append(" AND MONTH(DTLEMBRETE) = " + txtData.Text.Split('/')[1]);
                    strSQL.Append(" AND DAY(DTLEMBRETE) = " + txtData.Text.Split('/')[0]);
                }

                strSQL.Append(" ORDER BY 2");

                dtgLembrete.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                dtgLembrete.DataSource = objConexao.ExecutarComandoSqlDataSet(strSQL.ToString()).Tables[0];
                dtgLembrete.Columns["CDLEMBRETE"].Visible      = false;
                dtgLembrete.Columns["DESCLEMBRETE"].HeaderText = "Lembrete";
                dtgLembrete.Columns["DTLEMBRETE"].HeaderText   = "Data do Lembrete";
                dtgLembrete.Columns["DTLEMBRETE"].Width        = 40;
                dtgLembrete.Columns["STNOTIFICACAO"].Visible   = false;
                dtgLembrete.Columns["STDESCARTAR"].Visible     = false;
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de ConsultaLembretes/Método Consultar/ERRO: " + objErro.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                strSQL     = null;
                objConexao = null;
            }
        }
Esempio n. 18
0
        private void PreencherComboProcedimentos()
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            DataTable    tblResultado;
            DataRow      objLinha;

            try
            {
                cboProcedimentos.DisplayMember = "NMPROCEDIMENTO";
                cboProcedimentos.ValueMember   = "CDPROCEDIMENTO";

                tblResultado = objConexao.ExecutarComandoSqlDataSet("SELECT CDPROCEDIMENTO, UCASE(CDPROCEDIMENTOUNIMED & ' - ' & NMPROCEDIMENTO) AS NMPROCEDIMENTO, CORPROCEDIMENTO FROM TBPROCEDIMENTOS ORDER BY NMPROCEDIMENTO").Tables[0];
                objLinha     = tblResultado.NewRow();
                tblResultado.Rows.InsertAt(objLinha, 0);

                cboProcedimentos.DataSource = tblResultado;

                foreach (DataRow rowTable in tblResultado.Rows)
                {
                    if (rowTable["CORPROCEDIMENTO"].ToString() != "")
                    {
                        lstCorProcedimento.Add(new CorProcedimento(rowTable["CDPROCEDIMENTO"].ToString(), rowTable["CORPROCEDIMENTO"].ToString()));
                    }
                }
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Incluir Agendamento/ Método PreencherComboProcedimentos/ERRO: " + objErro.Message, "ERRO",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao   = null;
                tblResultado = null;
                objLinha     = null;
            }
        }
Esempio n. 19
0
        private void btnConfirmar_Click(object sender, EventArgs e)
        {
            clsConexaoBD objConexao = new clsConexaoBD();

            try
            {
                if (objConexao.ExecutarComandoSqlDataSet("SELECT COUNT(*) FROM TBLEMBRETES WHERE DTLEMBRETE IS NULL").Tables[0].Rows.Count <= 0)
                {
                    objConexao.ExecutarComandoSql("INSERT INTO TBLEMBRETES(DESCLEMBRETE) VALUES('" + txtNotas.Text + "')");
                }
                else
                {
                    objConexao.ExecutarComandoSql("UPDATE TBLEMBRETES SET  DESCLEMBRETE = '" + txtNotas.Text + "' WHERE DTLEMBRETE IS NULL");
                }
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Anotações/Método Salvar/ERRO: " + objErro.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
            }
        }
        private void InserirAgendamentoBD(DateTime p_DtAgendar)
        {
            StringBuilder strSQL = new StringBuilder();
            clsConexaoBD objConexao = new clsConexaoBD();

            try
            {
                strSQL.Append("INSERT INTO TBAGENDAMENTO ");
                strSQL.Append("( DTAGENDAMENTO, CDPACIENTE, CDFUNCIONARIO, CDSTATUS, DTAUTORIZACAOGUIA, DTVENCIMENTOGUIA) ");
                strSQL.Append("VALUES( ");
                strSQL.Append("#" + p_DtAgendar.Date.ToString("yyyy/MM/dd") + " " + txtHoraAgendamento.Text + "#, ");
                strSQL.Append(cboPaciente.SelectedValue + ",");
                if (cboFisioterapeutas.SelectedValue.ToString() != "")
                    strSQL.Append(cboFisioterapeutas.SelectedValue + ",");
                else
                    strSQL.Append("NULL,");

                strSQL.Append(cboStatus.SelectedValue + ", ");

                if (txtAutorizacaoGuia.Text.Replace("/", "").Trim() != "")
                    strSQL.Append("#" + DateTime.Parse( txtAutorizacaoGuia.Text ).ToString("yyyy/MM/dd")+ "#,");
                else
                    strSQL.Append("NULL,");

                if (txtVencimentoGuia.Text.Replace("/", "").Trim() != "")
                    strSQL.Append("#" + DateTime.Parse(txtVencimentoGuia.Text).ToString("yyyy/MM/dd") + "#");
                else
                    strSQL.Append("NULL");

                strSQL.Append(")");

                objConexao.ExecutarComandoSql(strSQL.ToString());

                try
                {
                    InserirProcedimentos();
                }
                catch
                {
                    MessageBox.Show("Problem ao inserir os Procedimentos", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

            }
            catch (Exception objErro)
            {
                throw objErro;
            }
            finally
            {
                strSQL = null;
                objConexao = null;
            }
        }
        private void CarregarGridProcedimentos()
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            DataTable tblResultado;
            StringBuilder strSQL = new StringBuilder();
            string[] strCor;
            try
            {

                strSQL.Append("SELECT ");
                strSQL.Append("A.CDPROCEDIMENTO,  ");
                strSQL.Append("UCASE(B.CDPROCEDIMENTOUNIMED & ' - ' & B.NMPROCEDIMENTO) AS NMPROCEDIMENTO,  ");
                strSQL.Append("A.QTDPROCEDIMENTO,  ");
                strSQL.Append("B.CORPROCEDIMENTO  ");
                strSQL.Append("FROM  ");
                strSQL.Append("TBPROCEDIMENTOSAGENDAMENTO A INNER JOIN TBPROCEDIMENTOS B ON  A.CDPROCEDIMENTO = B.CDPROCEDIMENTO ");
                strSQL.Append("WHERE ");
                strSQL.Append("A.CDAGENDAMENTO =  " + objAgendamento.cdAgendamento);

                tblResultado = objConexao.ExecutarComandoSqlDataSet(strSQL.ToString()).Tables[0];

                foreach (DataRow objLinha in tblResultado.Rows)
                {
                    dtgProcedimentos.Rows.Add(objLinha[0].ToString(), objLinha[1].ToString(), objLinha[2].ToString());

                    if (objLinha[3].ToString() != "")
                    {
                        strCor = objLinha[3].ToString().Split('/');
                        dtgProcedimentos.Rows[dtgProcedimentos.Rows.Count - 1].DefaultCellStyle.BackColor =
                            Color.FromArgb(int.Parse(strCor[0]), int.Parse(strCor[1]), int.Parse(strCor[2]), int.Parse(strCor[3]));
                    }
                }
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Incluir Agendamento/ Método CarregarGridProcedimento/ERRO: " + objErro.Message, "ERRO",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
                tblResultado = null;
                strSQL = null;
            }
        }
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            clsConexaoBD objConexao = new clsConexaoBD();

            try
            {

                if (objAgendamento.cdAgendamento != "")
                {
                    if (MessageBox.Show("Deseja realmenre excluir esse agendamento?", "Excluir Agendamento", MessageBoxButtons.YesNo)
                        == System.Windows.Forms.DialogResult.Yes)
                    {
                        objConexao.ExecutarComandoSql("DELETE FROM TBPROCEDIMENTOSAGENDAMENTO WHERE CDAGENDAMENTO = " + objAgendamento.cdAgendamento);
                        objConexao.ExecutarComandoSql("DELETE FROM TBAGENDAMENTO WHERE CDAGENDAMENTO = " + objAgendamento.cdAgendamento);

                        MessageBox.Show("Exclusão do agendamento realizada!", "Exclusão de Agendamento ", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        this.Close();
                    }
                }
                else
                    MessageBox.Show("Código do Agendamento não informado, por favor, tentar novamente!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Erro na exclusão do agendamento. ERRO: " + objErro.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
            }
        }
        private void btnConfirmar_Click(object sender, EventArgs e)
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            StringBuilder strSQL = new StringBuilder();

            try
            {
                if (txtNome.Text == "")
                    MessageBox.Show("Preenche o campo Nome do Paciente!");
                else
                {
                    if (!blnAlteracao)
                    {
                        strSQL.Append("INSERT INTO TBPACIENTES(NMPACIENTE, TELPACIENTE, CODPACIENTEUNIMED, TELPACIENTE2, STATUSINATIVO) VALUES(");
                        strSQL.Append("'" + txtNome.Text + "', ");
                        if (txtTelefone.Text.Replace("(", "").Replace(")", "").Replace("-", "").Trim() != "")
                            strSQL.Append("'" + txtTelefone.Text + "', ");
                        else
                            strSQL.Append("NULL, ");

                        strSQL.Append("'" + txtCodigoPaciente.Text + "',");

                        if (txtTelefone2.Text.Replace("(", "").Replace(")", "").Replace("-", "").Trim() != "")
                            strSQL.Append("'" + txtTelefone2.Text + "' ");
                        else
                            strSQL.Append("NULL ");

                        strSQL.Append(", FALSE )");

                        objConexao.ExecutarComandoSql(strSQL.ToString());

                        MessageBox.Show("Paciente Cadastrado!");

                        txtNome.Text = "";
                        txtTelefone.Text = "";
                        txtTelefone2.Text = "";
                        txtCodigoPaciente.Text = "";
                    }
                    else
                    {
                        strSQL.Append("UPDATE TBPACIENTES SET ");
                        strSQL.Append("NMPACIENTE = '" + txtNome.Text + "', ");

                        if (txtTelefone.Text.Replace("(", "").Replace(")", "").Replace("-", "").Trim() != "")
                            strSQL.Append("TELPACIENTE = '" + txtTelefone.Text + "', ");
                        else
                            strSQL.Append("TELPACIENTE =  NULL, ");

                        if (txtTelefone2.Text.Replace("(", "").Replace(")", "").Replace("-", "").Trim() != "")
                            strSQL.Append("TELPACIENTE2 = '" + txtTelefone2.Text + "', ");
                        else
                            strSQL.Append("TELPACIENTE2 =  NULL, ");

                        strSQL.Append("CODPACIENTEUNIMED = '" + txtCodigoPaciente.Text + "', ");

                        strSQL.Append("STATUSINATIVO = " + (chkStatus.Checked ? "TRUE" : "FALSE") + " ");

                        strSQL.Append("WHERE CDPACIENTE = " + strCodigoPaciente);

                        objConexao.ExecutarComandoSql(strSQL.ToString());

                        MessageBox.Show("Alteração Realizada!");

                        blnAlteracao = false;
                        txtNome.Text = "";
                        txtTelefone.Text = "";
                        txtTelefone2.Text = "";
                        txtCodigoPaciente.Text = "";
                        strCodigoPaciente = "";
                        chkStatus.Checked = false;
                        if (dtgPacientes.SelectedRows.Count > 0)
                            dtgPacientes.SelectedRows[0].Selected = false;
                    }

                    PreencherGrid();
                }
            }
            catch (Exception objErro)
            {
                MessageBox.Show(objErro.Message);
            }
            finally
            {
                objConexao = null;
            }
        }
        private DataSet Consulta()
        {
            StringBuilder strSQL = new StringBuilder();
            clsConexaoBD objConexo = new clsConexaoBD();
            DtsRelatorio dtsAux = new DtsRelatorio();

            try
            {
                strSQL.Append(" SELECT ");
                strSQL.Append(" FORMAT(A.DTAGENDAMENTO, 'dd/MM/yyyy HH:mm') AS DATA_AGENDAMENTO, ");
                strSQL.Append(" FORMAT(A.DTAUTORIZACAOGUIA, 'dd/MM/yyyy') AS DATA_AUTORIZACAO_GUIA, ");
                strSQL.Append(" FORMAT(A.DTVENCIMENTOGUIA, 'dd/MM/yyyy') AS DATA_VENCIMENTO_GUIA, ");
                strSQL.Append(" P.CODPACIENTEUNIMED AS    CARTEIRINHA, ");
                strSQL.Append(" UCASE(P.NMPACIENTE) AS NOME_PACIENTE, ");
                strSQL.Append(" UCASE(F.NMFUNCIONARIO) AS NOME_FISIOTERAPEUTA, ");
                strSQL.Append(" UCASE(CDPROCEDIMENTOUNIMED) AS CODIGO_PROCEDIMENTO, ");
                strSQL.Append(" UCASE(NMPROCEDIMENTO) AS NOME_PROCEDIMENTO, ");
                strSQL.Append(" PR.VLPROCEDIMENTO AS VLPROCEDIMENTO  ");
                strSQL.Append(" FROM  ");
                strSQL.Append(" (((((TBAGENDAMENTO A LEFT JOIN TBFUNCIONARIOS F  ON A.CDFUNCIONARIO = F.CDFUNCIONARIO)  ");
                strSQL.Append(" INNER JOIN TBPACIENTES P ON A.CDPACIENTE = P.CDPACIENTE) ");
                strSQL.Append(" LEFT JOIN TBPROCEDIMENTOSAGENDAMENTO PA ON A.CDAGENDAMENTO = PA.CDAGENDAMENTO) ");
                strSQL.Append(" LEFT JOIN TBPROCEDIMENTOS PR ON PR.CDPROCEDIMENTO = PA.CDPROCEDIMENTO)) ");
                strSQL.Append(" WHERE 1=1 ");

                if (txtDtInicio.Text.Replace("/", "").Replace("/", "").Trim() != "")
                {
                    strSQL.Append(" AND YEAR(A.DTAGENDAMENTO) >= " + DateTime.Parse(txtDtInicio.Text).Year);
                    strSQL.Append(" AND MONTH(A.DTAGENDAMENTO) >=  " + DateTime.Parse(txtDtInicio.Text).Month);
                    strSQL.Append(" AND DAY(A.DTAGENDAMENTO) >=  " + DateTime.Parse(txtDtInicio.Text).Day);
                }

                if (txtDtFim.Text.Replace("/", "").Replace("/", "").Trim() != "")
                {
                    strSQL.Append(" AND YEAR(A.DTAGENDAMENTO) <= " + DateTime.Parse(txtDtFim.Text).Year);
                    strSQL.Append(" AND MONTH(A.DTAGENDAMENTO) <=  " + DateTime.Parse(txtDtFim.Text).Month);
                    strSQL.Append(" AND DAY(A.DTAGENDAMENTO) <=  " + DateTime.Parse(txtDtFim.Text).Day);
                }

                if (txtInicioVencGuia.Text.Replace("/", "").Replace("/", "").Trim() != "")
                {
                    strSQL.Append(" AND YEAR(A.dtVencimentoGuia) >= " + DateTime.Parse(txtInicioVencGuia.Text).Year);
                    strSQL.Append(" AND MONTH(A.dtVencimentoGuia) >=  " + DateTime.Parse(txtInicioVencGuia.Text).Month);
                    strSQL.Append(" AND DAY(A.dtVencimentoGuia) >=  " + DateTime.Parse(txtInicioVencGuia.Text).Day);
                }

                if (txtFimVencGuia.Text.Replace("/", "").Replace("/", "").Trim() != "")
                {
                    strSQL.Append(" AND YEAR(A.dtVencimentoGuia) <= " + DateTime.Parse(txtFimVencGuia.Text).Year);
                    strSQL.Append(" AND MONTH(A.dtVencimentoGuia) <=  " + DateTime.Parse(txtFimVencGuia.Text).Month);
                    strSQL.Append(" AND DAY(A.dtVencimentoGuia) <=  " + DateTime.Parse(txtFimVencGuia.Text).Day);
                }

                if (cboFisioterapeutas.SelectedValue.ToString() != "")
                    strSQL.Append(" AND F.CDFUNCIONARIO =  " + cboFisioterapeutas.SelectedValue.ToString());

                if (cboStatus.SelectedValue.ToString() != "")
                    strSQL.Append(" AND A.CDSTATUS =  " + cboStatus.SelectedValue.ToString());

                if (cboPaciente.SelectedValue.ToString() != "")
                    strSQL.Append(" AND P.CDPACIENTE =  " + cboPaciente.SelectedValue.ToString());

                strSQL.Append(" ORDER BY 1,5,7");

                return objConexo.ExecutarComandoSqlDataSet(strSQL.ToString());
            }
            catch (Exception objErro)
            {
                throw objErro;
            }
            finally
            {
                strSQL = null;
                dtsAux = null;
                objConexo = null;
            }
        }
        private void btnConfirmarAgendamento_Click(object sender, EventArgs e)
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            StringBuilder strSQL = new StringBuilder();

            try
            {
                if (this.ValidarCamposInclusao())
                {

                    // Se for inclusao
                    if (objAgendamento.cdAgendamento == "")
                    {
                        this.InserirAgendamento();
                        MessageBox.Show("Agendamento Realizado", "Incluir Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        strSQL.Append("UPDATE TBAGENDAMENTO SET ");
                        strSQL.Append("DTAGENDAMENTO = #" + dtpDataAgendamento.Value.ToString("yyyy/MM/dd") + " " + txtHoraAgendamento.Text + "#, ");
                        strSQL.Append("CDPACIENTE = " + cboPaciente.SelectedValue + ", ");
                        strSQL.Append("CDSTATUS = " + cboStatus.SelectedValue + ", ");

                        if (cboFisioterapeutas.SelectedValue.ToString() != "")
                            strSQL.Append("CDFUNCIONARIO = " + cboFisioterapeutas.SelectedValue.ToString() + ", ");
                        else
                            strSQL.Append("CDFUNCIONARIO = NULL, ");

                        if (txtAutorizacaoGuia.Text.Replace("/", "").Trim() != "")
                            strSQL.Append("DTAUTORIZACAOGUIA = #" + DateTime.Parse( txtAutorizacaoGuia.Text).ToString("yyyy/MM/dd") + "#, ");

                        if (txtVencimentoGuia.Text.Replace("/", "").Trim() != "")
                            strSQL.Append("DTVENCIMENTOGUIA = #" + DateTime.Parse(txtVencimentoGuia.Text).ToString("yyyy/MM/dd") + "#, ");

                        strSQL.Remove(strSQL.ToString().Length - 2, 1);

                        strSQL.Append(" WHERE CDAGENDAMENTO = " + objAgendamento.cdAgendamento);

                        objConexao.ExecutarComandoSql(strSQL.ToString());

                        try
                        {
                            InserirProcedimentos();
                        }
                        catch
                        {
                            MessageBox.Show("Problem ao inserir os Procedimentos", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        MessageBox.Show("Agendamento Alterado", "Alterar Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    this.Close();
                }
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Incluir Agendamento/ Método AgendamentoClick" + objErro.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
                strSQL = null;
            }
        }
Esempio n. 26
0
        private void CarregaGrid()
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            DataSet objResultado;
            StringBuilder strSQL = new StringBuilder();

            try
            {

                strSQL.Append("SELECT ");
                strSQL.Append("FORMAT(A.DTAGENDAMENTO, 'HH:mm') AS HORARIO, ");
                strSQL.Append("A.CDAGENDAMENTO,  ");
                strSQL.Append("A.DTAGENDAMENTO, ");
                strSQL.Append("P.CDPACIENTE, ");
                strSQL.Append("P.NMPACIENTE, ");
                strSQL.Append("P.TELPACIENTE, ");
                strSQL.Append("P.TELPACIENTE2, ");
                strSQL.Append("F.CDFUNCIONARIO, ");
                strSQL.Append("F.NMFUNCIONARIO, ");
                strSQL.Append("S.CDSTATUS, ");
                strSQL.Append("S.DESSTATUS, ");
                strSQL.Append("A.DTAUTORIZACAOGUIA,  ");
                strSQL.Append("A.DTVENCIMENTOGUIA, ");
                strSQL.Append("( ");
                strSQL.Append("SELECT FIRST(CORPROCEDIMENTO) FROM TBPROCEDIMENTOSAGENDAMENTO PA INNER JOIN TBPROCEDIMENTOS PRO ON PRO.CDPROCEDIMENTO = PA.CDPROCEDIMENTO  ");
                strSQL.Append("WHERE PA.CDAGENDAMENTO = A.CDAGENDAMENTO AND  CORPROCEDIMENTO <> '' GROUP BY PA.CDAGENDAMENTO   ");
                strSQL.Append(") AS COR ");
                strSQL.Append("FROM  ");
                strSQL.Append("(((TBAGENDAMENTO A INNER JOIN TBPACIENTES P ON A.CDPACIENTE = P.CDPACIENTE) ");
                strSQL.Append("LEFT JOIN TBFUNCIONARIOS F ON A.CDFUNCIONARIO = F.CDFUNCIONARIO)  ");
                strSQL.Append("INNER JOIN TBSTATUS S ON S.CDSTATUS = A.CDSTATUS)");
                strSQL.Append("WHERE  ");
                strSQL.Append("FORMAT(DTAGENDAMENTO, 'dd/MM/yyyy') = #" + dtAgenda.Value.ToString("yyyy/MM/dd") + "#  ");

                if (txtPaciente.Text.Trim() != "")
                    strSQL.Append(" AND P.NMPACIENTE LIKE '%" + txtPaciente.Text + "%' ");

                if (cboFisioterapeutas.Text != "")
                    strSQL.Append(" AND F.CDFUNCIONARIO = " + cboFisioterapeutas.SelectedValue.ToString());

                if (cboStatus.Text != "")
                    strSQL.Append(" AND S.CDSTATUS = " + cboStatus.SelectedValue.ToString());

                if (txtHorario.Text.Replace(":", "").Trim() != "")
                    strSQL.Append(" AND  FORMAT(DTAGENDAMENTO, 'HH:mm') >=  #" + DateTime.Parse(txtHorario.Text).AddMinutes(-30).ToString("HH:mm") + "# ");

                strSQL.Append(" ORDER BY  ");
                strSQL.Append("A.DTAGENDAMENTO, ");
                strSQL.Append("P.NMPACIENTE ");

                objResultado =
                    objConexao.ExecutarComandoSqlDataSet(strSQL.ToString());

                dtgAgenda.DataSource = PreencherListaAgendamento(objResultado.Tables[0]);

                //FormtarGrid();
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Agenda/Método CarregarGid/ERRO:" + objErro.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
                objResultado = null;
                strSQL = null;
            }
        }
Esempio n. 27
0
        private void InserirAgendamentoBD(DateTime p_DtAgendar)
        {
            StringBuilder strSQL     = new StringBuilder();
            clsConexaoBD  objConexao = new clsConexaoBD();

            try
            {
                strSQL.Append("INSERT INTO TBAGENDAMENTO ");
                strSQL.Append("( DTAGENDAMENTO, CDPACIENTE, CDFUNCIONARIO, CDSTATUS, DTAUTORIZACAOGUIA, DTVENCIMENTOGUIA) ");
                strSQL.Append("VALUES( ");
                strSQL.Append("#" + p_DtAgendar.Date.ToString("yyyy/MM/dd") + " " + txtHoraAgendamento.Text + "#, ");
                strSQL.Append(cboPaciente.SelectedValue + ",");
                if (cboFisioterapeutas.SelectedValue.ToString() != "")
                {
                    strSQL.Append(cboFisioterapeutas.SelectedValue + ",");
                }
                else
                {
                    strSQL.Append("NULL,");
                }

                strSQL.Append(cboStatus.SelectedValue + ", ");

                if (txtAutorizacaoGuia.Text.Replace("/", "").Trim() != "")
                {
                    strSQL.Append("#" + DateTime.Parse(txtAutorizacaoGuia.Text).ToString("yyyy/MM/dd") + "#,");
                }
                else
                {
                    strSQL.Append("NULL,");
                }

                if (txtVencimentoGuia.Text.Replace("/", "").Trim() != "")
                {
                    strSQL.Append("#" + DateTime.Parse(txtVencimentoGuia.Text).ToString("yyyy/MM/dd") + "#");
                }
                else
                {
                    strSQL.Append("NULL");
                }

                strSQL.Append(")");

                objConexao.ExecutarComandoSql(strSQL.ToString());

                try
                {
                    InserirProcedimentos();
                }
                catch
                {
                    MessageBox.Show("Problem ao inserir os Procedimentos", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception objErro)
            {
                throw objErro;
            }
            finally
            {
                strSQL     = null;
                objConexao = null;
            }
        }
Esempio n. 28
0
        private void CarregaGrid()
        {
            clsConexaoBD  objConexao = new clsConexaoBD();
            DataSet       objResultado;
            StringBuilder strSQL = new StringBuilder();

            try
            {
                strSQL.Append("SELECT ");
                strSQL.Append("FORMAT(A.DTAGENDAMENTO, 'HH:mm') AS HORARIO, ");
                strSQL.Append("A.CDAGENDAMENTO,  ");
                strSQL.Append("A.DTAGENDAMENTO, ");
                strSQL.Append("P.CDPACIENTE, ");
                strSQL.Append("P.NMPACIENTE, ");
                strSQL.Append("P.TELPACIENTE, ");
                strSQL.Append("P.TELPACIENTE2, ");
                strSQL.Append("F.CDFUNCIONARIO, ");
                strSQL.Append("F.NMFUNCIONARIO, ");
                strSQL.Append("S.CDSTATUS, ");
                strSQL.Append("S.DESSTATUS, ");
                strSQL.Append("A.DTAUTORIZACAOGUIA,  ");
                strSQL.Append("A.DTVENCIMENTOGUIA, ");
                strSQL.Append("( ");
                strSQL.Append("SELECT FIRST(CORPROCEDIMENTO) FROM TBPROCEDIMENTOSAGENDAMENTO PA INNER JOIN TBPROCEDIMENTOS PRO ON PRO.CDPROCEDIMENTO = PA.CDPROCEDIMENTO  ");
                strSQL.Append("WHERE PA.CDAGENDAMENTO = A.CDAGENDAMENTO AND  CORPROCEDIMENTO <> '' GROUP BY PA.CDAGENDAMENTO   ");
                strSQL.Append(") AS COR ");
                strSQL.Append("FROM  ");
                strSQL.Append("(((TBAGENDAMENTO A INNER JOIN TBPACIENTES P ON A.CDPACIENTE = P.CDPACIENTE) ");
                strSQL.Append("LEFT JOIN TBFUNCIONARIOS F ON A.CDFUNCIONARIO = F.CDFUNCIONARIO)  ");
                strSQL.Append("INNER JOIN TBSTATUS S ON S.CDSTATUS = A.CDSTATUS)");
                strSQL.Append("WHERE  ");
                strSQL.Append("FORMAT(DTAGENDAMENTO, 'dd/MM/yyyy') = #" + dtAgenda.Value.ToString("yyyy/MM/dd") + "#  ");

                if (txtPaciente.Text.Trim() != "")
                {
                    strSQL.Append(" AND P.NMPACIENTE LIKE '%" + txtPaciente.Text + "%' ");
                }

                if (cboFisioterapeutas.Text != "")
                {
                    strSQL.Append(" AND F.CDFUNCIONARIO = " + cboFisioterapeutas.SelectedValue.ToString());
                }

                if (cboStatus.Text != "")
                {
                    strSQL.Append(" AND S.CDSTATUS = " + cboStatus.SelectedValue.ToString());
                }

                if (txtHorario.Text.Replace(":", "").Trim() != "")
                {
                    strSQL.Append(" AND  FORMAT(DTAGENDAMENTO, 'HH:mm') >=  #" + DateTime.Parse(txtHorario.Text).AddMinutes(-30).ToString("HH:mm") + "# ");
                }

                strSQL.Append(" ORDER BY  ");
                strSQL.Append("A.DTAGENDAMENTO, ");
                strSQL.Append("P.NMPACIENTE ");

                objResultado =
                    objConexao.ExecutarComandoSqlDataSet(strSQL.ToString());

                dtgAgenda.DataSource = PreencherListaAgendamento(objResultado.Tables[0]);

                //FormtarGrid();
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Agenda/Método CarregarGid/ERRO:" + objErro.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao   = null;
                objResultado = null;
                strSQL       = null;
            }
        }
Esempio n. 29
0
        private DataSet Consulta()
        {
            StringBuilder strSQL    = new StringBuilder();
            clsConexaoBD  objConexo = new clsConexaoBD();
            DtsRelatorio  dtsAux    = new DtsRelatorio();

            try
            {
                strSQL.Append(" SELECT ");
                strSQL.Append(" FORMAT(A.DTAGENDAMENTO, 'dd/MM/yyyy HH:mm') AS DATA_AGENDAMENTO, ");
                strSQL.Append(" FORMAT(A.DTAUTORIZACAOGUIA, 'dd/MM/yyyy') AS DATA_AUTORIZACAO_GUIA, ");
                strSQL.Append(" FORMAT(A.DTVENCIMENTOGUIA, 'dd/MM/yyyy') AS DATA_VENCIMENTO_GUIA, ");
                strSQL.Append(" P.CODPACIENTEUNIMED AS    CARTEIRINHA, ");
                strSQL.Append(" UCASE(P.NMPACIENTE) AS NOME_PACIENTE, ");
                strSQL.Append(" UCASE(F.NMFUNCIONARIO) AS NOME_FISIOTERAPEUTA, ");
                strSQL.Append(" UCASE(CDPROCEDIMENTOUNIMED) AS CODIGO_PROCEDIMENTO, ");
                strSQL.Append(" UCASE(NMPROCEDIMENTO) AS NOME_PROCEDIMENTO, ");
                strSQL.Append(" PR.VLPROCEDIMENTO AS VLPROCEDIMENTO  ");
                strSQL.Append(" FROM  ");
                strSQL.Append(" (((((TBAGENDAMENTO A LEFT JOIN TBFUNCIONARIOS F  ON A.CDFUNCIONARIO = F.CDFUNCIONARIO)  ");
                strSQL.Append(" INNER JOIN TBPACIENTES P ON A.CDPACIENTE = P.CDPACIENTE) ");
                strSQL.Append(" LEFT JOIN TBPROCEDIMENTOSAGENDAMENTO PA ON A.CDAGENDAMENTO = PA.CDAGENDAMENTO) ");
                strSQL.Append(" LEFT JOIN TBPROCEDIMENTOS PR ON PR.CDPROCEDIMENTO = PA.CDPROCEDIMENTO)) ");
                strSQL.Append(" WHERE 1=1 ");

                if (txtDtInicio.Text.Replace("/", "").Replace("/", "").Trim() != "")
                {
                    strSQL.Append(" AND YEAR(A.DTAGENDAMENTO) >= " + DateTime.Parse(txtDtInicio.Text).Year);
                    strSQL.Append(" AND MONTH(A.DTAGENDAMENTO) >=  " + DateTime.Parse(txtDtInicio.Text).Month);
                    strSQL.Append(" AND DAY(A.DTAGENDAMENTO) >=  " + DateTime.Parse(txtDtInicio.Text).Day);
                }

                if (txtDtFim.Text.Replace("/", "").Replace("/", "").Trim() != "")
                {
                    strSQL.Append(" AND YEAR(A.DTAGENDAMENTO) <= " + DateTime.Parse(txtDtFim.Text).Year);
                    strSQL.Append(" AND MONTH(A.DTAGENDAMENTO) <=  " + DateTime.Parse(txtDtFim.Text).Month);
                    strSQL.Append(" AND DAY(A.DTAGENDAMENTO) <=  " + DateTime.Parse(txtDtFim.Text).Day);
                }

                if (txtInicioVencGuia.Text.Replace("/", "").Replace("/", "").Trim() != "")
                {
                    strSQL.Append(" AND YEAR(A.dtVencimentoGuia) >= " + DateTime.Parse(txtInicioVencGuia.Text).Year);
                    strSQL.Append(" AND MONTH(A.dtVencimentoGuia) >=  " + DateTime.Parse(txtInicioVencGuia.Text).Month);
                    strSQL.Append(" AND DAY(A.dtVencimentoGuia) >=  " + DateTime.Parse(txtInicioVencGuia.Text).Day);
                }

                if (txtFimVencGuia.Text.Replace("/", "").Replace("/", "").Trim() != "")
                {
                    strSQL.Append(" AND YEAR(A.dtVencimentoGuia) <= " + DateTime.Parse(txtFimVencGuia.Text).Year);
                    strSQL.Append(" AND MONTH(A.dtVencimentoGuia) <=  " + DateTime.Parse(txtFimVencGuia.Text).Month);
                    strSQL.Append(" AND DAY(A.dtVencimentoGuia) <=  " + DateTime.Parse(txtFimVencGuia.Text).Day);
                }


                if (cboFisioterapeutas.SelectedValue.ToString() != "")
                {
                    strSQL.Append(" AND F.CDFUNCIONARIO =  " + cboFisioterapeutas.SelectedValue.ToString());
                }

                if (cboStatus.SelectedValue.ToString() != "")
                {
                    strSQL.Append(" AND A.CDSTATUS =  " + cboStatus.SelectedValue.ToString());
                }


                if (cboPaciente.SelectedValue.ToString() != "")
                {
                    strSQL.Append(" AND P.CDPACIENTE =  " + cboPaciente.SelectedValue.ToString());
                }

                strSQL.Append(" ORDER BY 1,5,7");

                return(objConexo.ExecutarComandoSqlDataSet(strSQL.ToString()));
            }
            catch (Exception objErro)
            {
                throw objErro;
            }
            finally
            {
                strSQL    = null;
                dtsAux    = null;
                objConexo = null;
            }
        }
        private void PreencherGrid()
        {
            clsConexaoBD objConexao = new clsConexaoBD();

            try
            {
                dtgPacientes.DataSource = objConexao.ExecutarComandoSqlDataSet("SELECT CDPACIENTE, CODPACIENTEUNIMED, UCASE(NMPACIENTE) AS NMPACIENTE," +
                                " TELPACIENTE2, TELPACIENTE,  IIF( STATUSINATIVO = FALSE, 'ATIVO', 'INATIVO' ) AS STATUS FROM TBPACIENTES " +
                                " WHERE UCASE(NMPACIENTE) LIKE '%" + txtNome.Text.Trim().ToUpper()+"%'" +
                                "ORDER BY NMPACIENTE").Tables[0];
                dtgPacientes.Columns["CDPACIENTE"].Visible = false;
                dtgPacientes.Columns["NMPACIENTE"].HeaderText = "Nome do Paciente";
                dtgPacientes.Columns["TELPACIENTE"].HeaderText = "Celular";
                dtgPacientes.Columns["TELPACIENTE2"].HeaderText = "Telefone Residencial";
                dtgPacientes.Columns["CODPACIENTEUNIMED"].HeaderText = "Código Paciente";
                dtgPacientes.Columns["STATUS"].HeaderText = "Status";
                if (dtgPacientes.SelectedRows.Count > 0)
                    dtgPacientes.SelectedRows[0].Selected = false;

            }
            catch (Exception objErro)
            {
                MessageBox.Show(objErro.Message);
            }
            finally
            {
                objConexao = null;
            }
        }
Esempio n. 31
0
        private void VerificarNotificacoes()
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            StringBuilder strSQL = new StringBuilder();

            try
            {
                strSQL.Append(" SELECT COUNT(*) FROM TBLEMBRETES WHERE ");
                strSQL.Append(" YEAR(DTLEMBRETE) = " + dtAgenda.Value.Year);
                strSQL.Append(" AND MONTH(DTLEMBRETE) = " + dtAgenda.Value.Month);
                strSQL.Append(" AND DAY(DTLEMBRETE) = " + dtAgenda.Value.Day);

                if (int.Parse(objConexao.ExecutarComandoSqlDataSet(strSQL.ToString()).Tables[0].Rows[0][0].ToString()) > 0)
                {
                    imgNotificacao.Visible = lblLembrete.Visible = true;
                    lblLembrete.Text = "Você possui " +
                        objConexao.ExecutarComandoSqlDataSet(strSQL.ToString()).Tables[0].Rows[0][0].ToString()
                        + " lembrete(s).";
                }
                else
                    imgNotificacao.Visible = lblLembrete.Visible = false;

            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Agendamento/Método VerificarNotificacoes/ERRO: " + objErro.Message, "ERRO",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
                strSQL = null;
            }
        }
        private void InserirProcedimentos()
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            StringBuilder strSql = new StringBuilder();

            try
            {
                if (objAgendamento.cdAgendamento == "")
                {
                    strSql.Append("SELECT MAX(CDAGENDAMENTO) FROM TBAGENDAMENTO");
                    objAgendamento.cdAgendamento = objConexao.ExecutarComandoSqlDataSet(strSql.ToString()).Tables[0].Rows[0][0].ToString();
                }

                strSql.Clear();
                strSql.Append("DELETE FROM TBPROCEDIMENTOSAGENDAMENTO WHERE CDAGENDAMENTO = " + objAgendamento.cdAgendamento);
                objConexao.ExecutarComandoSql(strSql.ToString());

                foreach (DataGridViewRow objLinha in dtgProcedimentos.Rows)
                {
                    strSql.Clear();

                    strSql.Append("INSERT INTO TBPROCEDIMENTOSAGENDAMENTO(CDAGENDAMENTO, CDPROCEDIMENTO, QTDPROCEDIMENTO) VALUES(");
                    strSql.Append(objAgendamento.cdAgendamento + ", ");
                    strSql.Append(objLinha.Cells["CodigoProcedimento"].Value.ToString() + ", ");
                    strSql.Append(objLinha.Cells["QuantidadeProcedimento"].Value.ToString());
                    strSql.Append(")");

                    objConexao.ExecutarComandoSql(strSql.ToString());
                }
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Incluir Agendamento/ Método InserirProcedimentos/ERRO: " + objErro.Message, "ERRO",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
                strSql = null;
            }
        }
        private void PreencherComboPacientes()
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            DataTable tblResultado;
            DataRow objLinha;
            try
            {

                cboPaciente.DisplayMember = "NMPACIENTE";
                cboPaciente.ValueMember = "CDPACIENTE";

                tblResultado = objConexao.ExecutarComandoSqlDataSet("SELECT CDPACIENTE, UCASE(NMPACIENTE) AS NMPACIENTE FROM TBPACIENTES WHERE STATUSINATIVO = FALSE ORDER BY NMPACIENTE").Tables[0];
                objLinha = tblResultado.NewRow();
                tblResultado.Rows.InsertAt(objLinha, 0);

                cboPaciente.DataSource = tblResultado;
            }
            catch (Exception objErro)
            {
                MessageBox.Show(objErro.Message);
            }
            finally
            {
                objConexao = null;
                tblResultado = null;
                objLinha = null;
            }
        }
        private void PreencherComboProcedimentos()
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            DataTable tblResultado;
            DataRow objLinha;
            try
            {

                cboProcedimentos.DisplayMember = "NMPROCEDIMENTO";
                cboProcedimentos.ValueMember = "CDPROCEDIMENTO";

                tblResultado = objConexao.ExecutarComandoSqlDataSet("SELECT CDPROCEDIMENTO, UCASE(CDPROCEDIMENTOUNIMED & ' - ' & NMPROCEDIMENTO) AS NMPROCEDIMENTO, CORPROCEDIMENTO FROM TBPROCEDIMENTOS ORDER BY NMPROCEDIMENTO").Tables[0];
                objLinha = tblResultado.NewRow();
                tblResultado.Rows.InsertAt(objLinha, 0);

                cboProcedimentos.DataSource = tblResultado;

                foreach (DataRow rowTable in tblResultado.Rows)
                    if (rowTable["CORPROCEDIMENTO"].ToString() != "")
                        lstCorProcedimento.Add(new CorProcedimento(rowTable["CDPROCEDIMENTO"].ToString(), rowTable["CORPROCEDIMENTO"].ToString()));

            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Incluir Agendamento/ Método PreencherComboProcedimentos/ERRO: " + objErro.Message, "ERRO",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
                tblResultado = null;
                objLinha = null;
            }
        }
        private void CarregarGrid()
        {
            clsConexaoBD objConexao = new clsConexaoBD();

            try
            {
                dtgProcedimentos.DataSource =
                    objConexao.ExecutarComandoSqlDataSet("SELECT CDPROCEDIMENTO, CDPROCEDIMENTOUNIMED, UCASE(NMPROCEDIMENTO) AS NMPROCEDIMENTO, VLPROCEDIMENTO, CORPROCEDIMENTO FROM TBPROCEDIMENTOS ORDER BY 2").Tables[0];

                dtgProcedimentos.Columns["CDPROCEDIMENTO"].Visible = false;
                dtgProcedimentos.Columns["CDPROCEDIMENTOUNIMED"].HeaderText = "Código Procedimento.";
                dtgProcedimentos.Columns["NMPROCEDIMENTO"].HeaderText = "Descrição";
                dtgProcedimentos.Columns["VLPROCEDIMENTO"].HeaderText = "Valor";
                dtgProcedimentos.Columns["VLPROCEDIMENTO"].DefaultCellStyle.Format = "c";
                dtgProcedimentos.Columns["CORPROCEDIMENTO"].Visible = false;

            }
            catch (Exception objErro)
            {
                MessageBox.Show(objErro.Message);
            }
            finally
            {
                objConexao = null;
            }
        }
        private void PreencherComboFisioterapeutas()
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            DataTable tblResultado;
            DataRow objLinha;
            try
            {

                cboFisioterapeutas.DisplayMember = "NMFUNCIONARIO";
                cboFisioterapeutas.ValueMember = "CDFUNCIONARIO";

                tblResultado = objConexao.ExecutarComandoSqlDataSet("SELECT CDFUNCIONARIO, UCASE(NMFUNCIONARIO) AS NMFUNCIONARIO FROM TBFUNCIONARIOS ORDER BY NMFUNCIONARIO").Tables[0];
                objLinha = tblResultado.NewRow();
                tblResultado.Rows.InsertAt(objLinha, 0);

                cboFisioterapeutas.DataSource = tblResultado;
            }
            catch (Exception objErro)
            {
                MessageBox.Show(objErro.Message);
            }
            finally
            {
                objConexao = null;
                tblResultado = null;
                objLinha = null;
            }
        }
Esempio n. 37
0
        private void btnConfirmarAgendamento_Click(object sender, EventArgs e)
        {
            clsConexaoBD  objConexao = new clsConexaoBD();
            StringBuilder strSQL     = new StringBuilder();

            try
            {
                if (this.ValidarCamposInclusao())
                {
                    // Se for inclusao
                    if (objAgendamento.cdAgendamento == "")
                    {
                        this.InserirAgendamento();
                        MessageBox.Show("Agendamento Realizado", "Incluir Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        strSQL.Append("UPDATE TBAGENDAMENTO SET ");
                        strSQL.Append("DTAGENDAMENTO = #" + dtpDataAgendamento.Value.ToString("yyyy/MM/dd") + " " + txtHoraAgendamento.Text + "#, ");
                        strSQL.Append("CDPACIENTE = " + cboPaciente.SelectedValue + ", ");
                        strSQL.Append("CDSTATUS = " + cboStatus.SelectedValue + ", ");

                        if (cboFisioterapeutas.SelectedValue.ToString() != "")
                        {
                            strSQL.Append("CDFUNCIONARIO = " + cboFisioterapeutas.SelectedValue.ToString() + ", ");
                        }
                        else
                        {
                            strSQL.Append("CDFUNCIONARIO = NULL, ");
                        }

                        if (txtAutorizacaoGuia.Text.Replace("/", "").Trim() != "")
                        {
                            strSQL.Append("DTAUTORIZACAOGUIA = #" + DateTime.Parse(txtAutorizacaoGuia.Text).ToString("yyyy/MM/dd") + "#, ");
                        }

                        if (txtVencimentoGuia.Text.Replace("/", "").Trim() != "")
                        {
                            strSQL.Append("DTVENCIMENTOGUIA = #" + DateTime.Parse(txtVencimentoGuia.Text).ToString("yyyy/MM/dd") + "#, ");
                        }

                        strSQL.Remove(strSQL.ToString().Length - 2, 1);

                        strSQL.Append(" WHERE CDAGENDAMENTO = " + objAgendamento.cdAgendamento);

                        objConexao.ExecutarComandoSql(strSQL.ToString());

                        try
                        {
                            InserirProcedimentos();
                        }
                        catch
                        {
                            MessageBox.Show("Problem ao inserir os Procedimentos", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        MessageBox.Show("Agendamento Alterado", "Alterar Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    this.Close();
                }
            }
            catch (Exception objErro)
            {
                MessageBox.Show("Tela de Incluir Agendamento/ Método AgendamentoClick" + objErro.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objConexao = null;
                strSQL     = null;
            }
        }
        private void PreencherComboStatus()
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            DataTable tblResultado;
            DataRow objLinha;
            try
            {

                cboStatus.DisplayMember = "DESSTATUS";
                cboStatus.ValueMember = "CDSTATUS";

                tblResultado = objConexao.ExecutarComandoSqlDataSet("SELECT CDSTATUS, UCASE(DESSTATUS) AS DESSTATUS FROM TBSTATUS ORDER BY DESSTATUS").Tables[0];
                objLinha = tblResultado.NewRow();
                tblResultado.Rows.InsertAt(objLinha, 0);

                cboStatus.DataSource = tblResultado;
            }
            catch (Exception objErro)
            {
                MessageBox.Show(objErro.Message);
            }
            finally
            {
                objConexao = null;
                tblResultado = null;
                objLinha = null;
            }
        }
        private void btnConfirmar_Click(object sender, EventArgs e)
        {
            clsConexaoBD  objConexao = new clsConexaoBD();
            StringBuilder strSQL     = new StringBuilder();

            try
            {
                if (txtCodigoProcediment.Text == "" || txtDescricao.Text == "" || txtValorProcedimento.Text == "")
                {
                    MessageBox.Show("Preencha os campos obrigatórios.");
                }
                else
                {
                    if (!blnAlteracao)
                    {
                        strSQL.Append(" INSERT INTO TBPROCEDIMENTOS(CDPROCEDIMENTOUNIMED, NMPROCEDIMENTO, VLPROCEDIMENTO, CORPROCEDIMENTO) VALUES(");
                        strSQL.Append("'" + txtCodigoProcediment.Text + "',");
                        strSQL.Append("'" + txtDescricao.Text + "',");
                        strSQL.Append("'" + txtValorProcedimento.Text + "',");
                        if (blnSelecionouCor)
                        {
                            strSQL.Append("'" + colorDialog.Color.A + "/" + colorDialog.Color.R + "/" + colorDialog.Color.G + "/" + colorDialog.Color.B + "'");
                        }
                        else
                        {
                            strSQL.Append("''");
                        }
                        strSQL.Append(" )");

                        objConexao.ExecutarComandoSql(strSQL.ToString());

                        MessageBox.Show("Procedimento incluido");
                    }
                    else
                    {
                        strSQL.Append("UPDATE TBPROCEDIMENTOS SET ");
                        strSQL.Append("CDPROCEDIMENTOUNIMED = '" + txtCodigoProcediment.Text + "', ");
                        strSQL.Append("NMPROCEDIMENTO = '" + txtDescricao.Text + "', ");
                        strSQL.Append("VLPROCEDIMENTO = '" + txtValorProcedimento.Text + "' ");

                        if (blnSelecionouCor && chkCor.Checked)
                        {
                            strSQL.Append(", CORPROCEDIMENTO = '" + colorDialog.Color.A + "/" + colorDialog.Color.R + "/" + colorDialog.Color.G + "/" + colorDialog.Color.B + "'");
                        }
                        else
                        {
                            strSQL.Append(", CORPROCEDIMENTO = '' ");
                        }

                        strSQL.Append("  WHERE CDPROCEDIMENTO = " + strCodigo);

                        objConexao.ExecutarComandoSql(strSQL.ToString());

                        MessageBox.Show("Procedimento alterado");

                        if (dtgProcedimentos.SelectedRows.Count > 0)
                        {
                            dtgProcedimentos.SelectedRows[0].Selected = false;
                        }
                    }

                    txtCodigoProcediment.Text = "";
                    txtDescricao.Text         = "";
                    txtValorProcedimento.Text = "";
                    blnAlteracao     = false;
                    strCodigo        = "";
                    chkCor.Checked   = false;
                    imgCor.Enabled   = btnCor.Enabled = false;
                    imgCor.BackColor = Color.FromName("Control");
                    CarregarGrid();
                }
            }
            catch (Exception objErro)
            {
                MessageBox.Show(objErro.Message);
            }
            finally
            {
                objConexao = null;
                strSQL     = null;
            }
        }
        private void btnConfirmarAgendamento_Click(object sender, EventArgs e)
        {
            if (txtLembrete.Text == "")
            {
                MessageBox.Show("Preencha o lembrete que deseja incluir.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                clsConexaoBD  objConexao = new clsConexaoBD();
                StringBuilder strSQL     = new StringBuilder();

                try
                {
                    if (strCodigoAgendamento == "")
                    {
                        if (dtpData.Visible)
                        {
                            dtLembrete = dtpData.Value;
                        }

                        strSQL.Append(" INSERT INTO TBLEMBRETES (DTLEMBRETE, DESCLEMBRETE, STNOTIFICACAO, STDESCARTAR) VALUES (");
                        strSQL.Append("'" + dtLembrete.Date.ToString("yyyy/MM/dd") + "', ");
                        strSQL.Append("'" + (txtLembrete.Visible == true ? txtLembrete.Text : dtpData.Value.ToString("dd/MM/yyyy")) + "', ");
                        strSQL.Append(chkNotificacao.Checked == true ? "true, " : "false, ");
                        strSQL.Append("false ) ");

                        objConexao.ExecutarComandoSql(strSQL.ToString());

                        txtLembrete.Text       = "";
                        chkNotificacao.Checked = false;

                        MessageBox.Show("Lembrete cadastrado com sucesso", "AtençãCadastro de Lembrete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        if (dtpData.Visible)
                        {
                            dtLembrete = dtpData.Value;
                        }

                        strSQL.Append(" UPDATE TBLEMBRETES  SET ");
                        strSQL.Append("DESCLEMBRETE = '" + txtLembrete.Text + "' , ");
                        strSQL.Append("DTLEMBRETE = #" + dtLembrete.ToString("yyyy/MM/dd") + "# , ");
                        strSQL.Append("STNOTIFICACAO = " + (chkNotificacao.Checked == true ? "true" : "false"));
                        strSQL.Append(" WHERE ");
                        strSQL.Append(" CDLEMBRETE = " + strCodigoAgendamento);

                        objConexao.ExecutarComandoSql(strSQL.ToString());

                        btnExcluir.Enabled      = false;
                        btnNovoLembrete.Enabled = false;
                        strCodigoAgendamento    = "";
                        chkNotificacao.Checked  = false;
                        txtLembrete.Text        = "";

                        if (dtgLembrete.SelectedRows.Count > 0)
                        {
                            dtgLembrete.SelectedRows[0].Selected = false;
                        }

                        MessageBox.Show("Lembrete alterado com sucesso", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    this.PreencherGridLembretes();
                }
                catch (Exception objErro)
                {
                    MessageBox.Show("tela de Lembretes/Método ConfirmarAgendamento/ERRO: " + objErro.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    objConexao = null;
                    strSQL     = null;
                }
            }
        }
        private void btnConfirmar_Click(object sender, EventArgs e)
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            StringBuilder strSQL = new StringBuilder();

            try
            {

                if (txtCodigoProcediment.Text == "" || txtDescricao.Text == "" || txtValorProcedimento.Text == "")
                    MessageBox.Show("Preencha os campos obrigatórios.");
                else
                {

                    if (!blnAlteracao)
                    {

                        strSQL.Append(" INSERT INTO TBPROCEDIMENTOS(CDPROCEDIMENTOUNIMED, NMPROCEDIMENTO, VLPROCEDIMENTO, CORPROCEDIMENTO) VALUES(");
                        strSQL.Append("'" + txtCodigoProcediment.Text + "',");
                        strSQL.Append("'" + txtDescricao.Text + "',");
                        strSQL.Append("'" + txtValorProcedimento.Text + "',");
                        if (blnSelecionouCor)
                            strSQL.Append("'" + colorDialog.Color.A + "/" + colorDialog.Color.R + "/" + colorDialog.Color.G + "/" + colorDialog.Color.B + "'");
                        else
                            strSQL.Append("''");
                        strSQL.Append(" )");

                        objConexao.ExecutarComandoSql(strSQL.ToString());

                        MessageBox.Show("Procedimento incluido");
                    }
                    else
                    {
                        strSQL.Append("UPDATE TBPROCEDIMENTOS SET ");
                        strSQL.Append("CDPROCEDIMENTOUNIMED = '" + txtCodigoProcediment.Text + "', ");
                        strSQL.Append("NMPROCEDIMENTO = '" + txtDescricao.Text + "', ");
                        strSQL.Append("VLPROCEDIMENTO = '" + txtValorProcedimento.Text + "' ");

                        if (blnSelecionouCor && chkCor.Checked)
                            strSQL.Append(", CORPROCEDIMENTO = '" + colorDialog.Color.A + "/" + colorDialog.Color.R + "/" + colorDialog.Color.G + "/" + colorDialog.Color.B + "'");
                        else
                            strSQL.Append(", CORPROCEDIMENTO = '' ");

                        strSQL.Append("  WHERE CDPROCEDIMENTO = " + strCodigo);

                        objConexao.ExecutarComandoSql(strSQL.ToString());

                        MessageBox.Show("Procedimento alterado");

                        if (dtgProcedimentos.SelectedRows.Count > 0)
                            dtgProcedimentos.SelectedRows[0].Selected = false;
                    }

                    txtCodigoProcediment.Text = "";
                    txtDescricao.Text = "";
                    txtValorProcedimento.Text = "";
                    blnAlteracao = false;
                    strCodigo = "";
                    chkCor.Checked = false;
                    imgCor.Enabled = btnCor.Enabled = false;
                    imgCor.BackColor = Color.FromName("Control");
                    CarregarGrid();

                }

            }
            catch (Exception objErro)
            {
                MessageBox.Show(objErro.Message);
            }
            finally
            {
                objConexao = null;
                strSQL = null;
            }
        }
Esempio n. 42
0
        private void btnConfirmar_Click(object sender, EventArgs e)
        {
            clsConexaoBD  objConexao = new clsConexaoBD();
            StringBuilder strSQL     = new StringBuilder();

            try
            {
                if (txtNome.Text == "")
                {
                    MessageBox.Show("Preenche o campo Nome do Paciente!");
                }
                else
                {
                    if (!blnAlteracao)
                    {
                        strSQL.Append("INSERT INTO TBPACIENTES(NMPACIENTE, TELPACIENTE, CODPACIENTEUNIMED, TELPACIENTE2, STATUSINATIVO) VALUES(");
                        strSQL.Append("'" + txtNome.Text + "', ");
                        if (txtTelefone.Text.Replace("(", "").Replace(")", "").Replace("-", "").Trim() != "")
                        {
                            strSQL.Append("'" + txtTelefone.Text + "', ");
                        }
                        else
                        {
                            strSQL.Append("NULL, ");
                        }

                        strSQL.Append("'" + txtCodigoPaciente.Text + "',");

                        if (txtTelefone2.Text.Replace("(", "").Replace(")", "").Replace("-", "").Trim() != "")
                        {
                            strSQL.Append("'" + txtTelefone2.Text + "' ");
                        }
                        else
                        {
                            strSQL.Append("NULL ");
                        }

                        strSQL.Append(", FALSE )");

                        objConexao.ExecutarComandoSql(strSQL.ToString());

                        MessageBox.Show("Paciente Cadastrado!");

                        txtNome.Text           = "";
                        txtTelefone.Text       = "";
                        txtTelefone2.Text      = "";
                        txtCodigoPaciente.Text = "";
                    }
                    else
                    {
                        strSQL.Append("UPDATE TBPACIENTES SET ");
                        strSQL.Append("NMPACIENTE = '" + txtNome.Text + "', ");

                        if (txtTelefone.Text.Replace("(", "").Replace(")", "").Replace("-", "").Trim() != "")
                        {
                            strSQL.Append("TELPACIENTE = '" + txtTelefone.Text + "', ");
                        }
                        else
                        {
                            strSQL.Append("TELPACIENTE =  NULL, ");
                        }

                        if (txtTelefone2.Text.Replace("(", "").Replace(")", "").Replace("-", "").Trim() != "")
                        {
                            strSQL.Append("TELPACIENTE2 = '" + txtTelefone2.Text + "', ");
                        }
                        else
                        {
                            strSQL.Append("TELPACIENTE2 =  NULL, ");
                        }

                        strSQL.Append("CODPACIENTEUNIMED = '" + txtCodigoPaciente.Text + "', ");

                        strSQL.Append("STATUSINATIVO = " + (chkStatus.Checked ? "TRUE" : "FALSE") + " ");

                        strSQL.Append("WHERE CDPACIENTE = " + strCodigoPaciente);

                        objConexao.ExecutarComandoSql(strSQL.ToString());

                        MessageBox.Show("Alteração Realizada!");

                        blnAlteracao           = false;
                        txtNome.Text           = "";
                        txtTelefone.Text       = "";
                        txtTelefone2.Text      = "";
                        txtCodigoPaciente.Text = "";
                        strCodigoPaciente      = "";
                        chkStatus.Checked      = false;
                        if (dtgPacientes.SelectedRows.Count > 0)
                        {
                            dtgPacientes.SelectedRows[0].Selected = false;
                        }
                    }

                    PreencherGrid();
                }
            }
            catch (Exception objErro)
            {
                MessageBox.Show(objErro.Message);
            }
            finally
            {
                objConexao = null;
            }
        }
Esempio n. 43
0
        private void VerificarNotificacoes()
        {
            clsConexaoBD objConexao = new clsConexaoBD();
            StringBuilder strSQL = new StringBuilder();
            DataTable tblResultado;
            frmNotificacao objForm;

            try
            {
                strSQL.Append(" SELECT DESCLEMBRETE, CDLEMBRETE FROM TBLEMBRETES WHERE ");
                strSQL.Append(" YEAR(DTLEMBRETE) = " + DateTime.Now.Year);
                strSQL.Append(" AND MONTH(DTLEMBRETE) = " + DateTime.Now.Month);
                strSQL.Append(" AND DAY(DTLEMBRETE) = " + DateTime.Now.Day);
                strSQL.Append(" AND STNOTIFICACAO = TRUE AND STDESCARTAR = FALSE" );

                tblResultado = objConexao.ExecutarComandoSqlDataSet(strSQL.ToString()).Tables[0];

                if (tblResultado.Rows.Count > 0)
                {
                    foreach (DataRow rowLinha in tblResultado.Rows)
                    {
                        objForm = new frmNotificacao(rowLinha[0].ToString(), rowLinha[1].ToString());
                        objForm.ShowDialog();
                        objForm = null;
                    }
                }

            }
            catch (Exception objErro)
            {
                throw objErro;
            }
            finally
            {
                objConexao = null;
                tblResultado = null;
                strSQL = null;
            }
        }