forked from PrimaverabssDeveloper/ERP10Extensibility
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CurrentAccountInfo.cs
169 lines (137 loc) · 4.59 KB
/
CurrentAccountInfo.cs
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
using StdBE100;
using StdPlatBE100;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Windows.Forms;
using VndBE100;
namespace Primavera.Party.RelatedInfo
{
/// <summary>
/// This component will display the party (costumer or supplier) current account amount.
/// The information will be displayed on the sales editor context.
/// The trigger will be caused when customer field change.
/// </summary>
public partial class CurrentAccountInfo : UserControl, IStdBEInfRelacionada
{
#region Public methods
public CurrentAccountInfo()
{
InitializeComponent();
}
#endregion
#region private variables
private StdBECategoryInfo categoryInfo;
private dynamic plataform;
private dynamic engine;
private object formContext;
#endregion
#region Private properties
private string EntityKey { get; set; }
#endregion
#region Private Methods
/// <summary>
/// Fill the grid with the selected entity account amount.
/// </summary>
void LoadGrid()
{
StringBuilder sql = new StringBuilder();
string query = string.Empty;
// Get the DocumentoVenda object by reflection.
VndBEDocumentoVenda documentoVenda = (VndBEDocumentoVenda) formContext.GetType().GetProperty("DocumentoVenda").GetValue(formContext, null);
// Get the connection string from the context.
string connectionString = plataform.BaseDados.DaConnectionStringNET
(plataform.BaseDados.DaNomeBDdaEmpresa(engine.Contexto.CodEmp) , "Default");
sql.Append("SELECT TipoDoc,TipoConta, SUM(ValorPendente) AS Total , SUM(Valortotal) AS Pendente FROM");
sql.Append(" Pendentes WHERE entidade='@1@' and TipoDoc = '@2@'");
sql.Append(" GROUP BY TipoConta,TipoDoc");
query = sql
.Replace("@1@", this.EntityKey.ToString())
.Replace("@2@", documentoVenda.Tipodoc.ToString())
.ToString();
try
{
dataGridPendentes.ReadOnly = true;
SqlConnection connection = new SqlConnection(connectionString);
SqlDataAdapter dataAdapter = new SqlDataAdapter(query, connection);
SqlCommandBuilder comBuilder = new SqlCommandBuilder(dataAdapter);
DataSet ds = new DataSet();
dataAdapter.Fill(ds);
dataGridPendentes.DataSource = ds.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
#endregion
#region _IStdBEInfRelacionada Members
/// <summary>
/// This is the binded category info.
/// </summary>
StdBECategoryInfo IStdBEInfRelacionada.BECategoryInfo
{
get
{
return this.categoryInfo;
}
set
{
this.categoryInfo = value;
}
}
/// <summary>
/// This active ERP engine.
/// </summary>
dynamic IStdBEInfRelacionada.MotorAplicacao
{
set
{
this.engine = value;
}
}
/// <summary>
/// The active ERP platform.
/// </summary>
dynamic IStdBEInfRelacionada.Plataforma
{
set
{
this.plataform = value;
}
}
/// <summary>
/// This is the context form.
/// </summary>
object IStdBEInfRelacionada.FormContexto
{
set
{
this.formContext = value;
}
}
/// <summary>
/// This is the binded category value.
/// </summary>
void IStdBEInfRelacionada.AdicionaChave(string Nome, dynamic Valor)
{
StdBECamposChave fields = new StdBECamposChave();
fields.AddCampoChave(Nome, Valor);
dynamic campo = fields.CamposChave;
this.EntityKey = (string) campo[0].Valor;
}
/// <summary>
/// This method are trigged by the ERP when the binded category value changes.
/// </summary>
void IStdBEInfRelacionada.Atualiza()
{
this.LoadGrid();
}
void IStdBEInfRelacionada.Limpa()
{
dataGridPendentes.DataSource = null;
}
#endregion
}
}