Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
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;
            }
        }
Ejemplo n.º 4
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;
            }
        }
Ejemplo n.º 5
0
        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;
                }
            }
        }
Ejemplo n.º 6
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 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 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 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 (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;
            }
        }
Ejemplo n.º 11
0
        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;
            }
        }
Ejemplo n.º 13
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;
            }
        }
Ejemplo n.º 14
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 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;
            }
        }
Ejemplo n.º 16
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;
            }
        }
Ejemplo n.º 17
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;
            }
        }