Пример #1
0
        protected void ASPxCallback1_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e)
        {
            UsuariosControle controleUsuarios = new UsuariosControle();

            string senhaAtual = txtSenhaAntiga.Value.ToString();
            string novaSenha = txtNovaSenha.Value.ToString();
            string confirmacao = txtConfirmacao.Value.ToString();
            string usuario = controleUsuarios.GetUsuarioByLogin(HttpContext.Current.Session["pUId"].ToString()).UsuarioID.ToString();

            if (Control.UsuariosControle.ConfirmaSenhaAtual(usuario, senhaAtual))
            {
                Model.Usuarios usu = new Model.Usuarios();
                usu.Senha = novaSenha;
                usu.UsuarioID = int.Parse(usuario);
                Control.UsuariosControle obj = new Control.UsuariosControle();
                obj.Atualizar(usu);
                e.Result = "OK";
            }
            else {
                e.Result = "ERRO:Senha Atual não confere !!!";
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     Control.UsuariosControle controleUsuario = new Control.UsuariosControle();
     if (!IsPostBack && !IsCallback)
     {
         hdfDadosUsuario["IDUSUARIO"] = controleUsuario.GetUsuarioByLogin(HttpContext.Current.Session["pUId"].ToString()).UsuarioID.ToString();
         hdfDadosUsuario["UNDFUNCIONAL"] = Control.UndFuncionalCtrl.getUndFuncByUsuID(hdfDadosUsuario["IDUSUARIO"].ToString()).ToString();
         txtUsuarioPodeAgendar.Text = controleUsuario.UsuarioPodeAgendarPagamento(hdfDadosUsuario["IDUSUARIO"].ToString()).ToString();
     }
     else {
         string param = Request.Params["__CALLBACKPARAM"];
     }
 }
Пример #3
0
        protected void SqlDataSource2_Init(object sender, EventArgs e)
        {
            if (!IsCallback)
            {
                Control.UsuariosControle ctrlUsu = new Control.UsuariosControle();
                string idUsu = ctrlUsu.GetUsuarioByLogin(HttpContext.Current.Session["pUId"].ToString()).UsuarioID.ToString();
                string idUndFunc = Control.UndFuncionalCtrl.getUndFuncByUsuID(idUsu).ToString();
                string undOrc = Control.UnidadeOrcamentariaCtrl.GetUnidadeOrcamentriaByUnidadeFuncional(idUndFunc).undUnificado;

                Control.PerfilCtrl perfil = new Control.PerfilCtrl();

                bool perfilConsultaGeral = perfil.getPermissaoConsultaProcessos(idUsu);

                perfil = null;

                if (!perfilConsultaGeral)
                {
                    SqlDataSource2.SelectCommand = "select undunificado, undnome from unidadeorcamentaria where " +
                                    "undunificado IN ( " +
                                    "    SELECT UO.undunificado " +
                                    "    FROM unidadeorcamentaria UO " +
                                    "    JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " +
                                    "    WHERE " +
                                    "    uog.uogunidadegestora = " +
                                    "    (SELECT UOG.uogunidadegestora " +
                                    "        FROM unidadeorcamentaria UO " +
                                    "        JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " +
                                    "        where uo.undunificado = '" + undOrc + "' " +
                                    "    ) " +
                                    ") ";
                }
                else {
                    SqlDataSource2.SelectCommand = "select undunificado, undnome from unidadeorcamentaria ";
                }
                SqlDataSource2.DataBind();
            }
        }
Пример #4
0
        protected XPDataView AtualizarGrid()
        {
            Control.UsuariosControle ctrlUsu = new Control.UsuariosControle();
            string dataCadINI = "";
            string dataCadFIM = "";
            string envolvido = "";
            string procNum = "";
            string undorca = "";
            string situacao = "";
            string usuarioEnvio = "";
            string assunto = "";
            string usuarioDefault = ctrlUsu.GetUsuarioByLogin(HttpContext.Current.Session["pUId"].ToString()).UsuarioID.ToString();

            Control.PerfilCtrl perfil = new Control.PerfilCtrl();

            bool perfilConsultaGeral = perfil.getPermissaoConsultaProcessos(usuarioDefault);

            perfil = null;

            string sqlTable = "select " +
                                "id," +
                                "NUMERO," +
                                "datahoracadastro," +
                                "responsavel," +
                                "nome," +
                                "ENVID," +
                                "descricao," +
                                "UNDABREV ," +
                                "unidfuncnome," +
                                "undunificado," +
                                "usuarioenvio," +
                                "Cast(valor as numeric(15,2)) valor," +
                                "cast(VAL_LIQUIDADO as numeric(15,2)) VAL_LIQUIDADO," +
                                "CENNOME," +
                                "SITUACAO_ATUAL " +
                                "from CONSULTA_PROCESSOS ";

            if (dtCadastroIni.Value != null)
            {
                dataCadINI = "'" + DateTime.Parse(dtCadastroIni.Value.ToString()).ToShortDateString().Replace("/", ".") + "' ";
            }
            else
            {
                dataCadINI = "DATAHORACADASTRO";
            }

            if (dtCadastroFim.Value != null)
            {
                dataCadFIM = "'" + DateTime.Parse(dtCadastroFim.Value.ToString()).ToShortDateString().Replace("/", ".") + "' ";
            }
            else
            {
                dataCadFIM = "DATAHORACADASTRO";
            }

            if (cbbEnvolvido.Value != null)
            {
                envolvido = cbbEnvolvido.Value.ToString();
            }
            else
            {
                envolvido = "ENVID ";
            }

            if (txtNumProcesso.Value != null)
            {
                procNum = " like '" + txtNumProcesso.Value.ToString() + "%'";
            }
            else
            {
                procNum = " = NUMERO ";
            }

            if (cbbUndOrc.Value != null)
            {
                undorca = "= '" + cbbUndOrc.Value.ToString() + "' ";
            }
            else
            {

                if (!perfilConsultaGeral)
                {
                    string idUndFunc = Control.UndFuncionalCtrl.getUndFuncByUsuID(usuarioDefault).ToString();
                    string undOrcCad = Control.UnidadeOrcamentariaCtrl.GetUnidadeOrcamentriaByUnidadeFuncional(idUndFunc).undUnificado;

                    undorca = "in (    SELECT UO.undunificado " +
                        "    FROM unidadeorcamentaria UO " +
                        "    JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " +
                        "    WHERE " +
                        "    uog.uogunidadegestora = " +
                        "    (SELECT UOG.uogunidadegestora " +
                        "        FROM unidadeorcamentaria UO " +
                        "        JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " +
                        "        where uo.undunificado = '" + undOrcCad + "' " +
                        "    ) ) ";
                }
                else {
                    undorca = "= UNDUNIFICADO ";
                }
            }

            if (cbbAssunto.Value != null)
            {
                assunto =  cbbAssunto.Value.ToString() ;
            }
            else
            {
                assunto = "ASSID ";
            }

            string idSituacao = string.Empty;

            if (cbbSituacao.Value != null)
            {
                situacao = cbbSituacao.Value.ToString();
            }

            //usuarioEnvio = "USUARIOENVIO";

            sqlTable += " WHERE ";
            sqlTable += " (";
            sqlTable += " (DATAHORACADASTRO >= " + dataCadINI + ") ";
            sqlTable += " AND ";
            sqlTable += " (DATAHORACADASTRO <= " + dataCadFIM + ")";
            sqlTable += " ) ";
            sqlTable += " AND ";
            sqlTable += " ENVID = " + envolvido;
            sqlTable += " AND ";
            sqlTable += " NUMERO " + procNum;
            sqlTable += " AND ";
            //sqlTable += " UNDUNIFICADO = " + undorca;
            sqlTable += " UNDUNIFICADO " + undorca;
            if(cbbSituacao.Value != null){
                //sqlTable += "and (" + situacao + " in (Select idSituacaoProjeto from webtramite where idProcesso = proc.ID)) ";
                sqlTable += "and SITID in (Select sit.id from webgruposituacoes gsit join websituacaoprocesso sit on sit.id_gruposituacao = gsit.id where gsit.id = " + cbbSituacao.Value + ")";
            }
            //sqlTable += " AND ";
            //sqlTable += "USUARIOENVIO = " + usuarioEnvio;
            sqlTable += " AND ASSID = "+ assunto;
            sqlTable += "AND ((EXCLUIR IS NULL AND EXERCICIO <> (SELECT FIRST 1 ENTEXERCICIO FROM ENTIDADE)) ";
            sqlTable += "OR ";
            sqlTable += "(EXERCICIO = (SELECT FIRST 1 ENTEXERCICIO FROM ENTIDADE)))";

            DevExpress.Xpo.Session xpoSession = new DevExpress.Xpo.Session();
            XpoDataSource1.Session = xpoSession;

            //string connTeste = AcessoDados.AcessoDados.GetConnectionStringXPO();
            XpoDataSource1.Session.Connection = Persist.GetConn.getConn();

            SelectedData resultSet = xpoSession.ExecuteQuery(sqlTable);
            XPDataView dv = new XPDataView();

            dv.AddProperty("ID", typeof(int));
            dv.AddProperty("NUMERO", typeof(string));
            dv.AddProperty("DATAHORACADASTRO", typeof(DateTime));
            dv.AddProperty("RESPONSAVEL", typeof(string));
            dv.AddProperty("NOME", typeof(string));
            dv.AddProperty("ENVID", typeof(int));
            dv.AddProperty("DESCRICAO", typeof(string));
            dv.AddProperty("UNDABREV", typeof(string));
            dv.AddProperty("UNIDFUNCNOME", typeof(string));
            dv.AddProperty("UNDUNIFICADO", typeof(int));
            dv.AddProperty("USUARIOENVIO", typeof(int));
            dv.AddProperty("VALOR", typeof(decimal));
            dv.AddProperty("VAL_LIQUIDADO", typeof(decimal));
            dv.AddProperty("CENNOME", typeof(string));
            dv.AddProperty("SITUACAO_ATUAL", typeof(string));

            dv.LoadData(resultSet);

            ASPxGridView1.DataSource = dv;
            Session["DTable"] = dv;
            ASPxGridView1.DataBind();

            return dv;
        }
        protected XPDataView AtualizarGrid()
        {
            UsuariosControle ctrlUsu = new Control.UsuariosControle();

            string usuarioDefault = ctrlUsu.GetUsuarioByLogin(HttpContext.Current.Session["pUId"].ToString()).UsuarioID.ToString();

            PerfilCtrl perfil = new Control.PerfilCtrl();

            bool perfilConsultaGeral = perfil.getPermissaoConsultaProcessos(usuarioDefault);

            perfil = null;

            string centrocusto = string.Empty;
            string undorca = string.Empty;

            string sqlTable = "select distinct " +
                                "CENCOD,"+
                                "CENNOME,"+
                                "FONCOD,"+
                                "FONNOME,"+
                                "UNDUNIFICADO,"+
                                "UNDNOME,"+
                                "CCCMESES,"+
                                "DESPJAN,"+
                                "DESPFEV,"+
                                "DESPMAR,"+
                                "DESPABR,"+
                                "DESPMAI,"+
                                "DESPJUN,"+
                                "DESPJUL,"+
                                "DESPAGO,"+
                                "DESPSET,"+
                                "DESPOUT,"+
                                "DESPNOV,"+
                                "DESPDEZ,"+
                                "DIDJAN,"+
                                "DIDFEV,"+
                                "DIDMAR,"+
                                "DIDABR,"+
                                "DIDMAI,"+
                                "DIDJUN,"+
                                "DIDJUL,"+
                                "DIDAGO,"+
                                "DIDSET,"+
                                "DIDOUT,"+
                                "DIDNOV,"+
                                "DIDDEZ,"+
                                "SALDOJAN,"+
                                "SALDOFEV,"+
                                "SALDOMAR,"+
                                "SALDOABR,"+
                                "SALDOMAI,"+
                                "SALDOJUN,"+
                                "SALDOJUL,"+
                                "SALDOAGO,"+
                                "SALDOSET,"+
                                "SALDOOUT,"+
                                "SALDONOV,"+
                                "SALDODEZ " +
                                "from VW_FLX_REL_EXT_CENCUSTO_GRID ";

            if (cbbCentroCusto.Value != null)
            {
                centrocusto = cbbCentroCusto.Value.ToString();
            }
            else
            {
                centrocusto = "CENCOD ";
            }

            if (cbbUndOrc.Value != null)
            {
                undorca = "= '" + cbbUndOrc.Value.ToString() + "' ";
            }
            else
            {

                if (!perfilConsultaGeral)
                {
                    string idUndFunc = Control.UndFuncionalCtrl.getUndFuncByUsuID(usuarioDefault).ToString();
                    string undOrcCad = Control.UnidadeOrcamentariaCtrl.GetUnidadeOrcamentriaByUnidadeFuncional(idUndFunc).undUnificado;

                    undorca = "in (    SELECT UO.undunificado " +
                        "    FROM unidadeorcamentaria UO " +
                        "    JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " +
                        "    WHERE " +
                        "    uog.uogunidadegestora = " +
                        "    (SELECT UOG.uogunidadegestora " +
                        "        FROM unidadeorcamentaria UO " +
                        "        JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " +
                        "        where uo.undunificado = '" + undOrcCad + "' " +
                        "    ) ) ";
                }
                else
                {
                    undorca = "= UNDUNIFICADO ";
                }
            }

            ////usuarioEnvio = "USUARIOENVIO";

            sqlTable += " WHERE ";
            sqlTable += " CENCOD = " + centrocusto;
            sqlTable += " AND ";
            sqlTable += " UNDUNIFICADO " + undorca;

            DevExpress.Xpo.Session xpoSession = new DevExpress.Xpo.Session();
            XpoDataSource1.Session = xpoSession;

            XpoDataSource1.Session.Connection = Persist.GetConn.getConn();

            SelectedData resultSet = xpoSession.ExecuteQuery(sqlTable);
            XPDataView dv = new XPDataView();

            dv.AddProperty("CENCOD", typeof(int));
            dv.AddProperty("CENNOME", typeof(string));
            dv.AddProperty("FONCOD", typeof(int));
            dv.AddProperty("FONNOME", typeof(string));
            dv.AddProperty("UNDUNIFICADO", typeof(string));
            dv.AddProperty("UNDNOME", typeof(string));
            dv.AddProperty("CCCMESES", typeof(decimal));
            dv.AddProperty("DESPJAN", typeof(decimal));
            dv.AddProperty("DESPFEV", typeof(decimal));
            dv.AddProperty("DESPMAR", typeof(decimal));
            dv.AddProperty("DESPABR", typeof(decimal));
            dv.AddProperty("DESPMAI", typeof(decimal));
            dv.AddProperty("DESPJUN", typeof(decimal));
            dv.AddProperty("DESPJUL", typeof(decimal));
            dv.AddProperty("DESPAGO", typeof(decimal));
            dv.AddProperty("DESPSET", typeof(decimal));
            dv.AddProperty("DESPOUT", typeof(decimal));
            dv.AddProperty("DESPNOV", typeof(decimal));
            dv.AddProperty("DESPDEZ", typeof(decimal));
            dv.AddProperty("DIDJAN", typeof(decimal));
            dv.AddProperty("DIDFEV", typeof(decimal));
            dv.AddProperty("DIDMAR", typeof(decimal));
            dv.AddProperty("DIDABR", typeof(decimal));
            dv.AddProperty("DIDMAI", typeof(decimal));
            dv.AddProperty("DIDJUN", typeof(decimal));
            dv.AddProperty("DIDJUL", typeof(decimal));
            dv.AddProperty("DIDAGO", typeof(decimal));
            dv.AddProperty("DIDSET", typeof(decimal));
            dv.AddProperty("DIDOUT", typeof(decimal));
            dv.AddProperty("DIDNOV", typeof(decimal));
            dv.AddProperty("DIDDEZ", typeof(decimal));
            dv.AddProperty("SALDOJAN", typeof(decimal));
            dv.AddProperty("SALDOFEV", typeof(decimal));
            dv.AddProperty("SALDOMAR", typeof(decimal));
            dv.AddProperty("SALDOABR", typeof(decimal));
            dv.AddProperty("SALDOMAI", typeof(decimal));
            dv.AddProperty("SALDOJUN", typeof(decimal));
            dv.AddProperty("SALDOJUL", typeof(decimal));
            dv.AddProperty("SALDOAGO", typeof(decimal));
            dv.AddProperty("SALDOSET", typeof(decimal));
            dv.AddProperty("SALDOOUT", typeof(decimal));
            dv.AddProperty("SALDONOV", typeof(decimal));
            dv.AddProperty("SALDODEZ", typeof(decimal));

            dv.LoadData(resultSet);

            ASPxGridView1.DataSource = dv;
            Session["DTable"] = dv;
            ASPxGridView1.DataBind();

            return dv;
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["pUId"] != null)
            {
                string idUsu = "";
                string idUndFunc = "";
                string undOrc = "";
                Control.UsuariosControle controleUsuarios = new Control.UsuariosControle();
                idUsu = controleUsuarios.GetUsuarioByLogin(HttpContext.Current.Session["pUId"].ToString()).UsuarioID.ToString();
                idUndFunc = Control.UndFuncionalCtrl.getUndFuncByUsuID(idUsu).ToString();

                undOrc = Control.UnidadeOrcamentariaCtrl.GetUnidadeOrcamentriaByUnidadeFuncional(idUndFunc).undUnificado;

                if (IsCallback) {
                    if (ASPxGridView1.IsCallback) {
                        string param = Request.Params["__CALLBACKPARAM"];
                        if (!param.Contains("|Limpar") && !param.Contains("|CUSTOMCALLBACK0"))
                        {
                             atualizaGridEmpenhos("");
                        }
                    }
                }
            }
            else
            {
                if (!IsCallback)
                {
                    Response.Redirect("../Default1.aspx");
                }
                else
                {
                    ASPxWebControl.RedirectOnCallback("../Default1.aspx");
                }
            }
        }
Пример #7
0
        public void atualizaGridEmpenhos(string tipo)
        {
            string unidOrc = "";
            string empenhoNum = "";
            string dataIni = "";
            string dataFim = "";
            string credor = "";
            string processo = "";

            if (!tipo.Equals("Limpar"))
            {
                bool parametro = Control.Configuracoes.Dados.getParametroGradeDIDComplementar();

                if (cbbUndOrc.Value != null)
                {
                    unidOrc = "'" + cbbUndOrc.Value.ToString() + "'";
                }
                else
                {
                    Control.UsuariosControle ctrlUsu = new Control.UsuariosControle();

                    string idUsu = ctrlUsu.GetUsuarioByLogin(HttpContext.Current.Session["pUId"].ToString()).UsuarioID.ToString();
                    string idUndFunc = Control.UndFuncionalCtrl.getUndFuncByUsuID(idUsu).ToString();

                    string undOrcCad = Control.UnidadeOrcamentariaCtrl.GetUnidadeOrcamentriaByUnidadeFuncional(idUndFunc).undUnificado;
                    if (parametro == false)
                    {
                        unidOrc = "    SELECT UO.undunificado " +
                                "    FROM unidadeorcamentaria UO " +
                                "    JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " +
                                "    WHERE " +
                                "    uog.uogunidadegestora = " +
                                "    (SELECT UOG.uogunidadegestora " +
                                "        FROM unidadeorcamentaria UO " +
                                "        JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " +
                                "        where uo.undunificado = '" + undOrcCad + "' " +
                                "    ) ";
                    }
                    else {
                        unidOrc = " select UNDUNIFICADO from SCI_USUARIOS_UNDORC where usu_codigo = " + idUsu + " ";
                    }
                }

                if (txtNumEmpenho.Value != null)
                {
                    empenhoNum = "'" + txtNumEmpenho.Value.ToString() + "'";
                }
                else
                {
                    empenhoNum = "emp.empnumero";
                }

                if (dtCadastroIni.Value != null)
                {
                    dataIni = "'" + dtCadastroIni.Value.ToString().Substring(0, 10) + "'";
                }
                else
                {
                    dataIni = "emp.empdata";
                }

                if (dtCadastroFim.Value != null)
                {
                    dataFim = "'" + dtCadastroFim.Value.ToString().Substring(0, 10) + "'";
                }
                else
                {
                    dataFim = "emp.empdata";
                }

                if (cbbCredor.Value != null)
                {
                    credor = "'" + cbbCredor.Value.ToString() + "'";
                }
                else
                {
                    credor = "emp.emppessoa";
                }

                if ( txtNumProcesso.Value != null)
                {
                    processo = "AND PROC.NUMERO = '" + txtNumProcesso.Value.ToString() + "'";
                }
                else
                {
                    processo = "";
                }

                string sqlTable = "select uo.undunificado, uo.undabrev, emp.empdata, emp.empnumero, emp.emppessoa, " +
                                    "emp.empnomepessoa, emp.empnatureza, (emp.empvalor - coalesce(ema.emavalor, 0)) empvalor, lic.licnumero, lic.licdata,"+
                                    "coalesce(proc.NUMERO,(select numero from webprocesso where id = emp.empsemdid)) NUMERO, " +
                                    "case when emp.empstatus = 'T' then 'NORMAL' else 'Erro' end " +
                                    "empstatus, " +
                                    "case " +
                                    "    when emp.empfundeb = 1 then '1 - Magistério 60%' " +
                                    "    when emp.empfundeb = 2 then '2 - Administrativo 40%' " +
                                    "    when emp.empfundeb = 3 then '3 - MDE - Outros' " +
                                    "    else null " +
                                    "end " +
                                    "empfundeb, EMP.empcod, " +
                                    "CTR.CTRNUMERO, CTR.CTRDATA " +
                                    "from empenho emp " +
                                    "join unidadeorcamentaria uo on uo.undcodorgao = emp.emporgao and uo.undcodigo = emp.empunidade " +
                                    "left join licitacao lic on lic.liccod = emp.emplicitacao " +
                                    "LEFT JOIN CONTRATOS CTR ON CTR.ctrcod = EMP.empcontrato " +
                                    "LEFT JOIN WEBPROCESSO PROC ON PROC.ID = EMP.EMPDID "+
                                    "Left join empenhoanulacao ema on ema.emaempenho = emp.empcod " +
                                    "where uo.undunificado IN (" + unidOrc + ") "+
                                    " and emp.empnumero = " + empenhoNum + " and emp.emppessoa = " + credor +
                                    " and (emp.empdata >= " + dataIni.Replace("/", ".") + " and emp.empdata <= " + dataFim.Replace("/", ".") + ") " +  processo +
                                    " order by emp.empdata desc";

                DevExpress.Xpo.Session xpoSession = new DevExpress.Xpo.Session();
                XpoDataSource1.Session = xpoSession;

                //string connTeste = AcessoDados.AcessoDados.GetConnectionStringXPO();
                XpoDataSource1.Session.Connection = Persist.GetConn.getConn();
                //XpoDataSource1.Session.ConnectionString = connTeste;

                SelectedData resultSet = xpoSession.ExecuteQuery(sqlTable);
                XPDataView dv = new XPDataView();

                dv.AddProperty("UNDUNIFICADO", typeof(string));
                dv.AddProperty("UNDABREV", typeof(string));
                dv.AddProperty("EMPDATA", typeof(DateTime));
                dv.AddProperty("EMPNUMERO", typeof(string));
                dv.AddProperty("EMPPESSOA", typeof(string));
                dv.AddProperty("EMPNOMEPESSOA", typeof(string));
                dv.AddProperty("EMPNATUREZA", typeof(string));
                dv.AddProperty("EMPVALOR", typeof(double));
                dv.AddProperty("LICNUMERO", typeof(string));
                dv.AddProperty("LICDATA", typeof(DateTime));
                dv.AddProperty("NUMERO", typeof(string));
                dv.AddProperty("EMPSTATUS", typeof(string));
                dv.AddProperty("EMPFUNDEB", typeof(double));
                dv.AddProperty("EMPCOD", typeof(int));
                dv.AddProperty("CTRNUMERO", typeof(string));
                dv.AddProperty("CTRDATA", typeof(DateTime));

                dv.LoadData(resultSet);

                ASPxGridView1.DataSource = dv;
                Session["DTable"] = dv;
                ASPxGridView1.DataBind();

            }
            else {
                ASPxGridView1.DataSourceID = string.Empty;
                ASPxGridView1.DataBind();
            }
        }
        protected void ASPxPopupControl4_WindowCallback(object source, DevExpress.Web.ASPxPopupControl.PopupWindowCallbackArgs e)
        {
            if (!chkRestosPagar.Checked)
            {
                if (e.Parameter.ToString() == "L")
                {
                    ASPxLabel3.Enabled = true;
                    ASPxLabel12.Enabled = true;
                    ASPxLabel13.Enabled = true;
                    ASPxLabel14.Enabled = true;
                    ASPxLabel16.Enabled = true;
                    txtBanco.Enabled = true;
                    txtAgencia.Enabled = true;
                    txtDVAG.Enabled = true;
                    txtConta.Enabled = true;
                    txtDVCC.Enabled = true;
                    txtNota.Enabled = true;
                    lbNotaFiscal.Enabled = true;

                    Envolvidos env = Control.EnvolvidoCtrl.getDadosBancariosEnvolvidoByProcesso(txtProcNumero.Text);

                    txtBanco.Text = env._banco;
                    txtAgencia.Text = env._agencia;
                    txtDVAG.Text = env._DVagencia;
                    txtConta.Text = env._conta;
                    txtDVCC.Text = env._DVconta;

                    decimal SaldoLiq = Control.DIDLPCtrl.getSaldoLiquidacao(txtProcNumero.Text);
                    txtValorSaldo2.Text = SaldoLiq.ToString();
                    lbSaldo.Text = "Saldo a Liquidar";
                    txtLegend.Text = "Liquidações Solicitadas";
                    ASPxPopupControl4.HeaderText = "Criar DID Complementar de Liquidação";

                    AtualizarGridLiqPag("L");
                }
                else
                {
                    ASPxLabel3.Enabled = true;
                    ASPxLabel12.Enabled = false;
                    ASPxLabel13.Enabled = true;
                    ASPxLabel14.Enabled = false;
                    ASPxLabel16.Enabled = false;
                    txtNota.Enabled = false;
                    txtNota.BackColor = System.Drawing.Color.LightGray;
                    lbNotaFiscal.Enabled = false;
                    txtBanco.Enabled = false;
                    txtBanco.BackColor = System.Drawing.Color.LightGray;
                    txtAgencia.Enabled = false;
                    txtAgencia.BackColor = System.Drawing.Color.LightGray;

                    txtDVAG.Enabled = false;
                    txtDVAG.BackColor = System.Drawing.Color.LightGray;
                    txtConta.Enabled = false;
                    txtConta.BackColor = System.Drawing.Color.LightGray;
                    txtDVCC.Enabled = false;
                    txtDVCC.BackColor = System.Drawing.Color.LightGray;

                    txtMesReferencia.Enabled = false;
                    txtMesReferencia.BackColor = System.Drawing.Color.LightGray;

                    txtData.Enabled = false;
                    txtDataRecebimentoNota.Enabled = false;
                    txtData.BackColor = System.Drawing.Color.LightGray;
                    txtDataRecebimentoNota.BackColor = System.Drawing.Color.LightGray;

                    decimal SaldoPag = Control.DIDLPCtrl.getSaldoPagamento(txtProcNumero.Text);
                    lbSaldo.Text = "Saldo a Pagar";
                    txtLegend.Text = "Pagamentos Solicitados";
                    txtValorSaldo2.Text = SaldoPag.ToString();
                    ASPxPopupControl4.HeaderText = "Criar DID Complementar de Pagamento";
                    AtualizarGridLiqPag("P");
                }
            }
            else {
                if (e.Parameter.ToString() == "L")
                {
                    ASPxLabel3.Enabled = true;
                    ASPxLabel12.Enabled = true;
                    ASPxLabel13.Enabled = true;
                    ASPxLabel14.Enabled = true;
                    ASPxLabel16.Enabled = true;
                    txtBanco.Enabled = true;
                    txtAgencia.Enabled = true;
                    txtDVAG.Enabled = true;
                    txtConta.Enabled = true;
                    txtDVCC.Enabled = true;
                    txtNota.Enabled = true;
                    lbNotaFiscal.Enabled = true;

                    Envolvidos env = Control.EnvolvidoCtrl.getDadosBancariosEnvolvidoByProcesso(txtProcNumero.Text);

                    txtBanco.Text = env._banco;
                    txtAgencia.Text = env._agencia;
                    txtDVAG.Text = env._DVagencia;
                    txtConta.Text = env._conta;
                    txtDVCC.Text = env._DVconta;

                    //double SaldoLiq = Control.DIDLPCtrl.getSaldoLiquidacao(txtProcNumero.Text);

                    var didLP = new Control.DIDLPCtrl();
                    decimal SaldoLiq = didLP.getSaldoRPNaoProcessado(txtProcNumero.Text);
                    txtValorSaldo2.Text = SaldoLiq.ToString();
                    lbSaldo.Text = "Saldo a Liquidar";
                    txtLegend.Text = "DID Complementar de RP Não Processado";
                    ASPxPopupControl4.HeaderText = "DID Complementar de RP Não Processado";

                    AtualizarGridLiqPag("L");
                }
                else
                {
                    ASPxLabel3.Enabled = true;
                    ASPxLabel12.Enabled = false;
                    ASPxLabel13.Enabled = true;
                    ASPxLabel14.Enabled = false;
                    ASPxLabel16.Enabled = false;
                    txtNota.Enabled = false;
                    txtNota.BackColor = System.Drawing.Color.LightGray;
                    lbNotaFiscal.Enabled = false;
                    txtBanco.Enabled = false;
                    txtBanco.BackColor = System.Drawing.Color.LightGray;
                    txtAgencia.Enabled = false;
                    txtAgencia.BackColor = System.Drawing.Color.LightGray;

                    txtDVAG.Enabled = false;
                    txtDVAG.BackColor = System.Drawing.Color.LightGray;
                    txtConta.Enabled = false;
                    txtConta.BackColor = System.Drawing.Color.LightGray;
                    txtDVCC.Enabled = false;
                    txtDVCC.BackColor = System.Drawing.Color.LightGray;

                    txtMesReferencia.Enabled = false;
                    txtMesReferencia.BackColor = System.Drawing.Color.LightGray;

                    txtData.Enabled = false;
                    txtDataRecebimentoNota.Enabled = false;
                    txtData.BackColor = System.Drawing.Color.LightGray;
                    txtDataRecebimentoNota.BackColor = System.Drawing.Color.LightGray;

                    //double SaldoPag = Control.DIDLPCtrl.getSaldoPagamento(txtProcNumero.Text);
                    var didLP = new Control.DIDLPCtrl();
                    decimal SaldoPag = didLP.getSaldoRPProcessado(txtProcNumero.Text);
                    lbSaldo.Text = "Saldo a Pagar";
                    txtLegend.Text = "DID Complementar de RP Processado";
                    txtValorSaldo2.Text = SaldoPag.ToString();
                    ASPxPopupControl4.HeaderText = "DID Complementar de RP Processado";
                    AtualizarGridLiqPag("P");
                }
            }
            //Localizar a fonte de recurso do Processo Original

            FbCommand comando = new FbCommand();

            string fontes = string.Empty;

            string sqlFonteDID = "select o.seq from weborigemrecursodid o join webdid d on  d.id = o.iddid " +
                                    "where d.numero = " + txtProcNumero.Text;

            FbConnection connFonte = Persist.GetConn.getConn();
            comando = new FbCommand(sqlFonteDID, connFonte);
            connFonte.Open();
            FirebirdSql.Data.FirebirdClient.FbDataReader drFonte = comando.ExecuteReader();

            while (drFonte.Read())
            {
                if (string.IsNullOrEmpty(fontes))
                {
                    fontes = "'" + drFonte["SEQ"].ToString() + "'";
                }
                else
                {
                    fontes += ",'" + drFonte["SEQ"].ToString() + "'";
                }
            }
            drFonte.Close();
            connFonte.Close();

            string parametroContas = System.Configuration.ConfigurationManager.AppSettings["PrefeituraContasLiquidacao"].ToString();
            if (parametroContas == "true")
            {
                string sqlContas = "select fonnome, concod, connome,  " +
                                    "coalesce((select TOTAL from sp_saldo('31.12.9999',c.concod,'31.12.9999',0,0)),0) SALDO " +
                                    "from conta c " +
                                    "join fonterecurso f on f.foncod = c.confonterecurso " +
                                    "where f.foncod in (" + fontes + ")";

                FbConnection connContas = Persist.GetConn.getConn();
                comando = new FbCommand(sqlContas, connContas);
                connContas.Open();
                System.Data.DataTable dtContas = new System.Data.DataTable();
                FbDataAdapter dta = new FbDataAdapter(comando);
                dta.Fill(dtContas);

                cbbContasFonte.DataSource = dtContas;
                cbbContasFonte.DataBind();
                connContas.Close();
            }

            txtData.Text = DateTime.Now.ToShortDateString();
            txtDataDID.Text = DateTime.Now.ToShortDateString();
            txtDataRecebimentoNota.Text = DateTime.Now.ToShortDateString();

            Control.UsuariosControle controleUsuarios = new Control.UsuariosControle();
            txtUsuario.Text = controleUsuarios.GetUsuarioByLogin(HttpContext.Current.Session["pUId"].ToString()).UsuarioID.ToString();
            txtUndFuncional.Text = Control.UndFuncionalCtrl.getUndFuncByUsuID(txtUsuario.Text).ToString();

            Session["ContasBanco"] = null;

            gridContasBancarias.DataSourceID = string.Empty;
            gridContasBancarias.DataBind();

            controleUsuarios = null;
            txtMesReferencia.Focus();
        }
        public XPDataView atualizaGridEmpenhos(string tipo)
        {
            string unidOrc = "";
            string unidOrcDefault = "";
            string empenhoNum = "";
            string dataIni = "";
            string dataFim = "";
            string credor = "";
            string sql = string.Empty;

            XPDataView dv = new XPDataView();

            if (!tipo.Equals("Limpar"))
            {
                if (!chkRestosPagar.Checked)
                {
                    Control.UsuariosControle ctrlUsu = new Control.UsuariosControle();

                    bool parametro = Control.Configuracoes.Dados.getParametroGradeDIDComplementar();

                    string idUsu = ctrlUsu.GetUsuarioByLogin(HttpContext.Current.Session["pUId"].ToString()).UsuarioID.ToString();
                    string idUndFunc = Control.UndFuncionalCtrl.getUndFuncByUsuID(idUsu).ToString();

                    unidOrcDefault = Control.UnidadeOrcamentariaCtrl.GetUnidadeOrcamentriaByUnidadeFuncional(idUndFunc).undUnificado;

                    if (cbbUndOrc.Value != null)
                    {
                        unidOrc = "'" + cbbUndOrc.Value.ToString() + "'";
                    }
                    else
                    {
                        unidOrc = "uo.undunificado";
                    }

                    if (txtNumEmpenho.Value != null)
                    {
                        empenhoNum = "'" + txtNumEmpenho.Value.ToString() + "'";
                    }
                    else
                    {
                        empenhoNum = "emp.empnumero";
                    }

                    if (dtCadastroIni.Value != null)
                    {
                        dataIni = "'" + dtCadastroIni.Value.ToString().Substring(0, 10) + "'";
                    }
                    else
                    {
                        dataIni = "emp.empdata";
                    }

                    if (dtCadastroFim.Value != null)
                    {
                        dataFim = "'" + dtCadastroFim.Value.ToString().Substring(0, 10) + "'";
                    }
                    else
                    {
                        dataFim = "emp.empdata";
                    }

                    if (cbbCredor.Value != null)
                    {
                        credor = "'" + cbbCredor.Value.ToString() + "'";
                    }
                    else
                    {
                        credor = "emp.emppessoa";
                    }

                    sql = "select uo.undunificado, uo.undabrev, emp.empdata, emp.empnumero, emp.emppessoa, " +
                    "emp.empnomepessoa, emp.empnatureza, (emp.empvalor - coalesce(ema.emavalor,0)) empvalor, lic.licnumero, lic.licdata,proc.numero PROCNUMERO,  did.id DIDID," +
                    "case when emp.empstatus = 'T' then 'NORMAL' else 'Erro' end " +
                    "empstatus, " +
                    "(select * from SP_FLUXUS_SALDOLIQUIDACAO(proc.id)) SALDOLIQUIDACAO," +
                    "(select * from SP_FLUXUS_SALDOPAGAMENTO(proc.id)) SALDOPAGAMENTO," +
                    "case " +
                    "    when emp.empfundeb = 1 then '1 - Magistério 60%' " +
                    "    when emp.empfundeb = 2 then '2 - Administrativo 40%' " +
                    "    when emp.empfundeb = 3 then '3 - MDE - Outros' " +
                    "    else null " +
                    "end " +
                    "empfundeb, EMP.empcod, " +
                    "CTR.CTRNUMERO, CTR.CTRDATA " +
                    "from empenho emp " +
                    "join unidadeorcamentaria uo on uo.undcodorgao = emp.emporgao and uo.undcodigo = emp.empunidade " +
                    "left join licitacao lic on lic.liccod = emp.emplicitacao " +
                    "LEFT JOIN CONTRATOS CTR ON CTR.ctrcod = EMP.empcontrato " +
                    "join webprocesso proc on emp.empdid = proc.id " +
                    "join webDID did on did.numero = proc.numero " +
                    "Left join empenhoanulacao ema on ema.emaempenho = emp.empcod " +
                    "where ";

                    //if (parametro == false)
                    //{
                    //    sql += "uo.undunificado in (SELECT UO.undunificado " +
                    //    "    FROM unidadeorcamentaria UO " +
                    //    "    JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " +
                    //    "    WHERE " +
                    //    "    uog.uogunidadegestora = " +
                    //    "    (SELECT UOG.uogunidadegestora " +
                    //    "        FROM unidadeorcamentaria UO " +
                    //    "        JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " +
                    //    "        where uo.undunificado = '" + unidOrcDefault + "' " +
                    //    "    ) " +
                    //    ")";
                    //}
                    //else
                    //{
                        sql += "uo.undunificado in (select UNDUNIFICADO from SCI_USUARIOS_UNDORC where usu_codigo = " + idUsu;
                        sql += " union " +
                            "SELECT UNDUNIFICADO FROM unidadeorcamentaria UN " +
                            "JOIN webunidadefuncional UF ON UF.unidorccod = UN.undcodigo AND UF.unidorcorg = UN.undcodorgao " +
                            "JOIN sci_usuarios USU ON USU.usu_idundfuncional = UF.unidfuncid " +
                            "WHERE USU.usu_codigo = " + idUsu;
                        sql += " )";
                    //}

                    if (txtNumEmpenho.Value == null && dtCadastroIni.Value == null && dtCadastroFim.Value == null && cbbCredor.Value == null)
                    {
                        sql += " and (((select * from SP_FLUXUS_SALDOLIQUIDACAO(proc.id)) + (select * from SP_FLUXUS_SALDOPAGAMENTO(proc.id))) <> 0) ";
                    }

                    sql += " and emp.empnumero = " + empenhoNum + " and emp.emppessoa = " + credor + " and uo.undunificado =" + unidOrc +
                                    " and (emp.empdata >= " + dataIni.Replace("/", ".") + " and emp.empdata <= " + dataFim.Replace("/", ".") + ") " +
                                    "order by emp.empdata desc";
                }
                else
                {
                    Control.UsuariosControle ctrlUsu = new Control.UsuariosControle();

                    bool parametro = Control.Configuracoes.Dados.getParametroGradeDIDComplementar();

                    string idUsu = ctrlUsu.GetUsuarioByLogin(HttpContext.Current.Session["pUId"].ToString()).UsuarioID.ToString();
                    string idUndFunc = Control.UndFuncionalCtrl.getUndFuncByUsuID(idUsu).ToString();

                    unidOrcDefault = Control.UnidadeOrcamentariaCtrl.GetUnidadeOrcamentriaByUnidadeFuncional(idUndFunc).undUnificado;

                    if (cbbUndOrc.Value != null)
                    {
                        unidOrc = "'" + cbbUndOrc.Value.ToString() + "'";
                    }
                    else
                    {
                        unidOrc = "uo.undunificado";
                    }

                    if (txtNumEmpenho.Value != null)
                    {
                        empenhoNum = "'" + txtNumEmpenho.Value.ToString() + "'";
                    }
                    else
                    {
                        empenhoNum = "rpemp.rpenumero";
                    }

                    if (dtCadastroIni.Value != null)
                    {
                        dataIni = "'" + dtCadastroIni.Value.ToString().Substring(0, 10) + "'";
                    }
                    else
                    {
                        dataIni = "rpemp.rpedata";
                    }

                    if (dtCadastroFim.Value != null)
                    {
                        dataFim = "'" + dtCadastroFim.Value.ToString().Substring(0, 10) + "'";
                    }
                    else
                    {
                        dataFim = "rpemp.rpedata";
                    }

                    if (cbbCredor.Value != null)
                    {
                        credor = "'" + cbbCredor.Value.ToString() + "'";
                    }
                    else
                    {
                        credor = "rpemp.rpepessoa";
                    }

                    sql = "select uo.undunificado, uo.undabrev, rpemp.rpedata, rpemp.rpenumero, rpemp.rpepessoa, pes.pesnome as empnomepessoa, " +
                    "rpemp.rpenatureza, (rpemp.rpevalor - coalesce(rpema.rpavalor,0)) rpempvalor, lic.licnumero, lic.licdata, " +
                    "proc.numero PROCNUMERO,  did.id DIDID, " +
                    "case when rpemp.rpestatus = 'T' then 'NORMAL' else 'Erro' end rpempstatus, " +
                    "(select VALORLIQ from SP_FLUXUS_SALDORP_NPROC(rpemp.rpenumero)) SALDOLIQUIDACAO, " +
                    "(select VALORLIQ from SP_FLUXUS_SALDORP_PROC(rpemp.rpenumero)) SALDOPAGAMENTO, " +
                    "case " +
                    "when rpemp.rpefundeb = 1 then '1 - Magistério 60%' " +
                    "when rpemp.rpefundeb = 2 then '2 - Administrativo 40%' " +
                    "when rpemp.rpefundeb = 3 then '3 - MDE - Outros' " +
                    "else null end rpefundeb, rpEMP.rpecod, CTR.CTRNUMERO, CTR.CTRDATA " +
                    "from rpempenho rpemp " +
                    "join unidadeorcamentaria uo on uo.undcodorgao = rpemp.rpeorgao and uo.undcodigo = rpemp.rpeunidade " +
                    "left join licitacao lic on lic.liccod = rpemp.rpelicitacao " +
                    "LEFT JOIN CONTRATOS CTR ON CTR.ctrcod = rpEMP.rpecontrato " +
                    "join webprocesso proc on rpemp.rpedid = proc.id " +
                    "join webDID did on did.numero = proc.numero " +
                    "Left join rpempenhoanulacao rpema on rpema.rparpempenho = rpemp.rpecod " +
                    "join pessoa pes on pes.pescod = rpemp.rpepessoa where ";

                    sql += "uo.undunificado in (select UNDUNIFICADO from SCI_USUARIOS_UNDORC where usu_codigo = " + idUsu ;
                    sql += " union "+
                        "SELECT UNDUNIFICADO FROM unidadeorcamentaria UN "+
                        "JOIN webunidadefuncional UF ON UF.unidorccod = UN.undcodigo AND UF.unidorcorg = UN.undcodorgao "+
                        "JOIN sci_usuarios USU ON USU.usu_idundfuncional = UF.unidfuncid "+
                        "WHERE USU.usu_codigo = " + idUsu;
                    sql += " )";

                    sql += " and rpemp.rpenumero = " + empenhoNum + " and rpemp.rpepessoa = " + credor + " and uo.undunificado =" + unidOrc +
                            " and (rpemp.rpedata >= " + dataIni.Replace("/", ".") + " and rpemp.rpedata <= " + dataFim.Replace("/", ".") + ") " +
                            "order by rpemp.rpedata desc";
                }

                DevExpress.Xpo.Session xpoSession = new DevExpress.Xpo.Session();
                XpoDataSource1.Session = xpoSession;

                //string connTeste = AcessoDados.AcessoDados.GetConnectionStringXPO();
                XpoDataSource1.Session.Connection = Persist.GetConn.getConn();
                //XpoDataSource1.Session.ConnectionString = connTeste;

                SelectedData resultSet = xpoSession.ExecuteQuery(sql);

                dv.AddProperty("UNDUNIFICADO", typeof(string));
                dv.AddProperty("UNDABREV", typeof(string));
                dv.AddProperty("EMPDATA", typeof(DateTime));
                dv.AddProperty("EMPNUMERO", typeof(string));
                dv.AddProperty("EMPPESSOA", typeof(string));
                dv.AddProperty("EMPNOMEPESSOA", typeof(string));
                dv.AddProperty("EMPNATUREZA", typeof(string));
                dv.AddProperty("EMPVALOR", typeof(double));
                dv.AddProperty("LICNUMERO", typeof(string));
                dv.AddProperty("LICDATA", typeof(DateTime));
                dv.AddProperty("PROCNUMERO", typeof(string));
                dv.AddProperty("DIDID", typeof(int));
                dv.AddProperty("EMPSTATUS", typeof(string));
                dv.AddProperty("SALDOLIQUIDACAO", typeof(double));
                dv.AddProperty("SALDOPAGAMENTO", typeof(double));
                dv.AddProperty("EMPFUNDEB", typeof(string));
                dv.AddProperty("EMPCOD", typeof(int));
                dv.AddProperty("CTRNUMERO", typeof(string));
                dv.AddProperty("CTRDATA", typeof(DateTime));

                dv.LoadData(resultSet);

                ASPxGridView1.DataSource = dv;
                ASPxGridView1.DataBind();

            }
            else
            {
                ASPxGridView1.DataSourceID = string.Empty;
                ASPxGridView1.DataBind();
            }

            Session["DTGRIDEMPENHO"] = dv;
            return dv;
        }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string idUsu = "";
            string idUndFunc = "";
            string undOrc = "";

            if (HttpContext.Current.Session["pUId"] != null)
            {
                Control.UsuariosControle controleUsuarios = new Control.UsuariosControle();
                idUsu = controleUsuarios.GetUsuarioByLogin(HttpContext.Current.Session["pUId"].ToString()).UsuarioID.ToString();
                idUndFunc = Control.UndFuncionalCtrl.getUndFuncByUsuID(idUsu).ToString();

                undOrc = Control.UnidadeOrcamentariaCtrl.GetUnidadeOrcamentriaByUnidadeFuncional(idUndFunc).undUnificado;
                SqlDataSource1.SelectParameters["undOrc"].DefaultValue = undOrc;
                SqlDataSource1.DataBind();
                SqlDataSource2.SelectParameters["undOrc"].DefaultValue = undOrc;
                SqlDataSource2.SelectParameters["idUsu"].DefaultValue = idUsu;
                SqlDataSource2.DataBind();
            }
            else
            {
                if (!IsCallback)
                {
                    Response.Redirect("../Default1.aspx");
                }
                else
                {
                    ASPxWebControl.RedirectOnCallback("../Default1.aspx");
                }
            }

            if (!IsCallback)
            {
                if (ASPxGridView1.IsCallback)
                {
                    string param = Request.Params["__CALLBACKPARAM"];
                    if (param.Contains("|CUSTOMCALLBACK0"))
                    {
                        //atualizaGridEmpenhos("");
                    }
                }
                else
                {
                    string teste = Request.Params["__CALLBACKPARAM"];

                    if (!Page.IsPostBack)
                    {
                        //Session["DTable"] = string.Empty;
                    }
                }
            }
            else
            {
                string param = Request.Params["__CALLBACKPARAM"];
                string target = Request.Form["__EVENTTARGET"];
                if (param.Contains("|PAGERONCLICK") || param.Contains("|SORT") || param.Contains("|COLUMNMOVE") || param.Contains("|EXPANDROW") || param.Contains("|COLLAPSEROW") || param.Contains("|SHOWDETAILROW"))
                {
                    //atualizarGridEventos();
                    //AtualizarGridLiqPag("L");
                }
                else
                {
                    if (param.Contains("|REFRESH"))
                    {
                        //atualizaGridEmpenhos("");
                    }

                }
            }
        }
        protected XtraReport GetReport()
        {
            string dataRef = string.Empty;
            rel_SaldoProgramacaoDespesa report = new rel_SaldoProgramacaoDespesa();

            if (ASPxDateEdit1.Value == null)
            {
                dataRef = DateTime.Now.ToShortDateString();
            }
            else
            {
                dataRef = DateTime.Parse(ASPxDateEdit1.Value.ToString()).ToShortDateString();
            }

            report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "DATAREF", Value = dataRef, Type = typeof(string), Visible = false });

            if (ASPxTokenBox1.Value != null && ASPxTokenBox1.Text.ToString() != string.Empty)
            {

                string undOrc = ASPxTokenBox1.Value.ToString();
                //report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "UNDORCAMENTARIA", Value = undOrc, Type = typeof(string), Visible = false });
                report.FilterString = "[UNIDADEORC] In ('" + undOrc.Replace(",", "','") + "')";
            }
            else {
                string idUsu = "";

                var ctrlUsu = new Control.UsuariosControle();
                var usuarioInfo = ctrlUsu.getSessionUsuarioInfo();
                idUsu = usuarioInfo.Item2;

                var unidades = Control.UnidadeOrcamentariaCtrl.recuperaListaByListUndOrcUSU(idUsu);

                string undOrc = string.Empty;
                foreach (System.Data.DataRow dr in unidades.Rows) {

                    if (!string.IsNullOrEmpty(undOrc))
                    {
                        undOrc += ",'" + dr["undUnificado"].ToString() + "'";
                    }
                    else {
                        undOrc += "'" + dr["undUnificado"].ToString() + "'";
                    }
                }
                report.FilterString = "[UNIDADEORC] In (" + undOrc +")";

            }

            if (tokenCentroCusto.Value != null && tokenCentroCusto.Text.ToString() != string.Empty)
            {
                string centroCusto = tokenCentroCusto.Value.ToString();
                //report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "CENTROCUSTO", Value = centroCusto, Type = typeof(string), Visible = false });

                if (!string.IsNullOrEmpty(report.FilterString))
                {
                    report.FilterString += " and [CENCOD] In ('" + centroCusto.Replace(",", "','") + "')";
                }
                else {
                    report.FilterString += " [CENCOD] In ('" + centroCusto.Replace(",", "','") + "')";
                }
            }

            if (tokenClassCentroCusto.Value != null && tokenClassCentroCusto.Text.ToString() != string.Empty) {
                string classCentroCusto = tokenClassCentroCusto.Value.ToString();
                //report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "CLASSCENTROCUSTO", Value = classCentroCusto, Type = typeof(string), Visible = false });

                if (!string.IsNullOrEmpty(report.FilterString))
                {
                    report.FilterString += " and [CCCID] In ('" + classCentroCusto.Replace(",", "','") + "')";
                }
                else
                {
                    report.FilterString += " [CCCID] In ('" + classCentroCusto.Replace(",", "','") + "')";
                }
            }

            report.CreateDocument();
            return report;
        }
        protected void SqlDataSource1_Init(object sender, EventArgs e)
        {
            if (!IsCallback)
            {
                string idUsu = "";
                string idUndFunc = "";
                string undOrc = "";

                var ctrlUsu = new Control.UsuariosControle();
                var usuarioInfo = ctrlUsu.getSessionUsuarioInfo();
                idUsu = usuarioInfo.Item2;
                idUndFunc = usuarioInfo.Item3;
                undOrc = usuarioInfo.Item4;

                //Control.PerfilCtrl perfil = new Control.PerfilCtrl();

                bool perfilConsultaGeral = Convert.ToBoolean(usuarioInfo.Item6);

                //perfil = null;

                if (!perfilConsultaGeral)
                {
                    SqlDataSource1.SelectCommand = "select undCodigo, undCodOrgao, undUnificado,undNome,undAbrev, usu_codigo, usu_nome " +
                                "from " +
                                "( " +
                                "select undCodigo, undCodOrgao, undUnificado,undNome,undAbrev, usu.usu_codigo, usu.usu_nome " +
                                "from unidadeorcamentaria uo " +
                                "join webunidadefuncional uf on uf.unidorccod = uo.undcodigo and uf.unidorcorg = uo.undcodorgao " +
                                "join sci_usuarios usu on usu.usu_idundfuncional = uf.unidfuncid " +
                                "union " +
                                "select undCodigo, undCodOrgao, uo.undUnificado,undNome,undAbrev, usu.usu_codigo, usu.usu_nome " +
                                "from unidadeorcamentaria uo " +
                                "join sci_usuarios_undorc UU on UU.undunificado = uo.undunificado " +
                                "join sci_usuarios usu on usu.usu_codigo = UU.usu_codigo " +
                                ") q1 " +
                                "where q1.usu_codigo =" + idUsu;
                }
                else
                {
                    SqlDataSource1.SelectCommand = "select undunificado, UNDABREV from unidadeorcamentaria ";
                }
                SqlDataSource1.DataBind();
            }
        }
        protected XPDataView AtualizarGrid()
        {
            Control.UsuariosControle ctrlUsu = new Control.UsuariosControle();

            string usuarioDefault = ctrlUsu.GetUsuarioByLogin(HttpContext.Current.Session["pUId"].ToString()).UsuarioID.ToString();

            Control.PerfilCtrl perfil = new Control.PerfilCtrl();

            bool perfilConsultaGeral = perfil.getPermissaoConsultaProcessos(usuarioDefault);

            perfil = null;

            string dataIni = string.Empty;
            string dataFim = string.Empty;
            string envolvido = string.Empty;
            string procNum = string.Empty;
            string undorca = string.Empty;

            string sqlTable = "select " +
                                "CTRCOD," +
                                "CTRNUMERO," +
                                "CTRPESSOA," +
                                "CTRCONTROLEPORUO," +
                                "PESNOME," +
                                "UO," +
                                "adcobjeto ," +
                                "adcinicio," +
                                "adcfinal," +
                                "licnumero," +
                                "liccod," +
                                "MODALIDADE," +
                                "IDMODALIDADE, " +
                                "VALORCONTRATO, " +
                                "SALDOCONTRATO, " +
                                "SITUACAOADITIVOS " +
                                "from VW_FLX_CONTRATOS ";

            if (dtCadastroIni.Value != null)
            {
                dataIni = "'" + DateTime.Parse(dtCadastroIni.Value.ToString()).ToShortDateString().Replace("/", ".") + "' ";
            }
            else
            {
                dataIni = "ADCINICIO";
            }

            if (dtCadastroFim.Value != null)
            {
                dataFim = "'" + DateTime.Parse(dtCadastroFim.Value.ToString()).ToShortDateString().Replace("/", ".") + "' ";
            }
            else
            {
                dataFim = "ADCFINAL";
            }

            if (cbbEnvolvido.Value != null)
            {
                envolvido = cbbEnvolvido.Value.ToString();
            }
            else
            {
                envolvido = "CTRPESSOA ";
            }

            if (txtNumProcesso.Value != null)
            {
                procNum = " like '" + txtNumProcesso.Value.ToString() + "%'";
            }
            else
            {
                procNum = " = CTRNUMERO ";
            }

            if (cbbUndOrc.Value != null)
            {
                undorca = "= '" + cbbUndOrc.Value.ToString() + "' ";
            }
            else
            {

                if (!perfilConsultaGeral)
                {
                    string idUndFunc = Control.UndFuncionalCtrl.getUndFuncByUsuID(usuarioDefault).ToString();
                    string undOrcCad = Control.UnidadeOrcamentariaCtrl.GetUnidadeOrcamentriaByUnidadeFuncional(idUndFunc).undUnificado;

                    undorca = "in (    SELECT UO.undunificado " +
                        "    FROM unidadeorcamentaria UO " +
                        "    JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " +
                        "    WHERE " +
                        "    uog.uogunidadegestora = " +
                        "    (SELECT UOG.uogunidadegestora " +
                        "        FROM unidadeorcamentaria UO " +
                        "        JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " +
                        "        where uo.undunificado = '" + undOrcCad + "' " +
                        "    ) ) ";
                }
                else
                {
                    undorca = "= UO ";
                }
            }

            ////usuarioEnvio = "USUARIOENVIO";

            sqlTable += " WHERE ";
            sqlTable += " (";
            sqlTable += " (ADCFINAL >= " + dataFim + ") ";
            sqlTable += " AND ";
            sqlTable += " (ADCINICIO <= " + dataIni + ")";
            sqlTable += " ) ";
            sqlTable += " AND ";
            sqlTable += " CTRPESSOA = " + envolvido;
            sqlTable += " AND ";
            sqlTable += " CTRNUMERO " + procNum;
            sqlTable += " AND ";
            sqlTable += " UO " + undorca;

            DevExpress.Xpo.Session xpoSession = new DevExpress.Xpo.Session();
            XpoDataSource1.Session = xpoSession;

            XpoDataSource1.Session.Connection = Persist.GetConn.getConn();

            var resultSet = xpoSession.ExecuteQuery(sqlTable);
            var dv = new XPDataView();

            dv.AddProperty("CTRCOD", typeof(int));
            dv.AddProperty("CTRNUMERO", typeof(string));
            dv.AddProperty("CTRPESSOA", typeof(DateTime));
            dv.AddProperty("CTRCONTROLEPORUO", typeof(string));
            dv.AddProperty("PESNOME", typeof(string));
            dv.AddProperty("UO", typeof(int));
            dv.AddProperty("ADCOBJETO", typeof(string));
            dv.AddProperty("ADCINICIO", typeof(string));
            dv.AddProperty("ADCFINAL", typeof(string));
            dv.AddProperty("LICNUMERO", typeof(int));
            dv.AddProperty("LICCOD", typeof(int));
            dv.AddProperty("MODALIDADE", typeof(decimal));
            dv.AddProperty("IDMODALIDADE", typeof(decimal));
            dv.AddProperty("VALORCONTRATO", typeof(decimal));
            dv.AddProperty("SALDOCONTRATO", typeof(decimal));
            dv.AddProperty("SITUACAOADITIVOS", typeof(string));

            dv.LoadData(resultSet);

            ASPxGridView1.DataSource = dv;
            Session["DTable"] = dv;
            ASPxGridView1.DataBind();

            return dv;
        }