1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
using Gestor.Model.Domain.Financeiro;
using Gestor.Model.Domain.Generic;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using System.Runtime.CompilerServices;
namespace Gestor.Infrastructure.Helpers
{
public static class AuxiliarFinanceiro
{
public static List<Centro> Centros
{
get;
set;
}
public static List<BancosContas> Contas
{
get;
set;
}
public static List<Gestor.Model.Domain.Financeiro.Plano> Plano
{
get;
set;
}
public static List<Gestor.Model.Domain.Financeiro.Planos> Planos
{
get;
set;
}
public static List<TipoConta> TiposConta
{
get;
set;
}
public static void Criar(SqlCommand sqlCommand)
{
DataTable dataTable = new DataTable();
sqlCommand.CommandText = "SELECT DISTINCT idcplano as id, descricao as nome, ativo FROM cplano;";
using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
{
sqlDataAdapter.SelectCommand = sqlCommand;
sqlDataAdapter.Fill(dataTable);
}
AuxiliarFinanceiro.Plano = new List<Gestor.Model.Domain.Financeiro.Plano>();
dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => AuxiliarFinanceiro.Plano.Add(new Gestor.Model.Domain.Financeiro.Plano()
{
Id = a.Field<long>("id"),
Descricao = a.Field<string>("nome"),
Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1")
}));
dataTable = new DataTable();
sqlCommand.CommandText = "SELECT DISTINCT cs.idcplanos as id, cs.descricao as nome, cs.ativo, cs.idcplano, cp.descricao FROM cplanos cs INNER JOIN cplano cp ON cs.idcplano = cp.idcplano;";
using (SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter())
{
sqlDataAdapter1.SelectCommand = sqlCommand;
sqlDataAdapter1.Fill(dataTable);
}
AuxiliarFinanceiro.Planos = new List<Gestor.Model.Domain.Financeiro.Planos>();
dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => AuxiliarFinanceiro.Planos.Add(new Gestor.Model.Domain.Financeiro.Planos()
{
Id = a.Field<long>("id"),
Descricao = a.Field<string>("nome"),
Nome = a.Field<string>("descricao"),
Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1"),
Plano = AuxiliarFinanceiro.Plano.FirstOrDefault<Gestor.Model.Domain.Financeiro.Plano>((Gestor.Model.Domain.Financeiro.Plano x) => {
if (x == null)
{
return false;
}
return x.Id == a.Field<long>("idcplano");
})
}));
dataTable = new DataTable();
sqlCommand.CommandText = "SELECT DISTINCT idconta as id, descricao as nome, ativo FROM conta;";
using (SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter())
{
sqlDataAdapter2.SelectCommand = sqlCommand;
sqlDataAdapter2.Fill(dataTable);
}
AuxiliarFinanceiro.Contas = new List<BancosContas>();
dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => AuxiliarFinanceiro.Contas.Add(new BancosContas()
{
Id = a.Field<long>("id"),
Descricao = a.Field<string>("nome"),
Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1")
}));
dataTable = new DataTable();
sqlCommand.CommandText = "SELECT DISTINCT idcentro as id, descricao as nome, ativo FROM centro;";
using (SqlDataAdapter sqlDataAdapter3 = new SqlDataAdapter())
{
sqlDataAdapter3.SelectCommand = sqlCommand;
sqlDataAdapter3.Fill(dataTable);
}
AuxiliarFinanceiro.Centros = new List<Centro>();
dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => AuxiliarFinanceiro.Centros.Add(new Centro()
{
Id = a.Field<long>("id"),
Descricao = a.Field<string>("nome"),
Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1")
}));
dataTable = new DataTable();
sqlCommand.CommandText = "SELECT DISTINCT idtipoconta as id, descricao as nome, ativo FROM tipoconta;";
using (SqlDataAdapter sqlDataAdapter4 = new SqlDataAdapter())
{
sqlDataAdapter4.SelectCommand = sqlCommand;
sqlDataAdapter4.Fill(dataTable);
}
AuxiliarFinanceiro.TiposConta = new List<TipoConta>();
dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => AuxiliarFinanceiro.TiposConta.Add(new TipoConta()
{
Id = a.Field<long>("id"),
Descricao = a.Field<string>("nome"),
Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1")
}));
}
}
}
|