コード例 #1
0
ファイル: PersistenciaDB.cs プロジェクト: radtek/Gradual
        public HistoricoDatasResponse ObterListaHistoricoDatas()
        {
            AcessaDados lAcessaDados = new AcessaDados();

            HistoricoDatasResponse response = new HistoricoDatasResponse();

            response.Lista   = new List <string>();
            response.Retorno = HistoricoDatasResponse.RETORNO_ERRO;

            try
            {
                lAcessaDados.ConnectionStringName = gNomeConexaoSQL;

                using (DbCommand lDbCommand = lAcessaDados.CreateCommand(CommandType.StoredProcedure, "prc_lst_historico_datas"))
                {
                    DataTable lDataTable = lAcessaDados.ExecuteDbDataTable(lDbCommand);

                    if (null != lDataTable && lDataTable.Rows.Count > 0)
                    {
                        for (int i = 0; i <= lDataTable.Rows.Count - 1; i++)
                        {
                            response.Lista.Add((lDataTable.Rows[i]["vlDias"]).DBToString());
                        }
                    }
                }
                response.Retorno = TextoEmailResponse.RETORNO_OK;
            }
            catch (Exception ex)
            {
                logger.Error("ObterListaHistoricoDatas(): Ocorreu um erro ao acessar o banco de dados: " + ex.Message);
            }

            return(response);
        }
コード例 #2
0
        private void MontarDiasHistorico()
        {
            try
            {
                ISaldoDevedor serv = Ativador.Get <ISaldoDevedor>();

                HistoricoDatasResponse listaDias = serv.ObterListaHistoricoDias();

                treeDiasHistorico.Nodes.Clear();
                foreach (string item in listaDias.Lista)
                {
                    string ano = item.Substring(0, 4);
                    string mes = item.Substring(5, 2);
                    string dia = item.Substring(8, 2);

                    if (!treeDiasHistorico.Nodes.ContainsKey(ano))
                    {
                        treeDiasHistorico.Nodes.Add(ano, "Ano: " + ano);
                    }

                    if (!treeDiasHistorico.Nodes[ano].Nodes.ContainsKey(ano + mes))
                    {
                        treeDiasHistorico.Nodes[ano].Nodes.Add(ano + mes, "Mês: " + mes);
                    }

                    if (!treeDiasHistorico.Nodes[ano].Nodes[ano + mes].Nodes.ContainsKey(ano + mes + dia))
                    {
                        treeDiasHistorico.Nodes[ano].Nodes[ano + mes].Nodes.Add(ano + mes + dia, "Dia: " + dia);
                    }
                }
                btnGerarHistorico.Enabled = false;
            }
            catch (Exception ex)
            {
                string msg = "Obter Dados: " + ex.Message;
                MessageBox.Show(msg, "Histórico Movimento", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }