I have a problem, I have a view
in the database that makes agroup BY
, and have another table GraficoCor
, I make every time theWhile
the first function makes an increment he pass the counter value for the variable IdCor
the second function, the second function will query having as reference the value ofIdCor
returning to color in hex for the first function.
How to do that?
Function GetFaturamentoIVEL
public static FatoFaturamentoIVELBO[] GetFaturamentoIVEL(string Operacao, Connection Cn)
{
var RsFaturamento = new Recordset();
int Cont = 0;
try
{
RsFaturamento.Open(String.Format("SELECT Operacao, AnoMes, TradeMarketing, SUM(ValorNF)AS ValorTotal FROM dbo.FatoFaturamentoIVEL WHERE TradeMarketing = 0 and AnoMes = '2016/04' GROUP BY Operacao, AnoMes, TradeMarketing ORDER BY SUM(ValorNF) ASC", Operacao), Cn, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly);
var ArrayRetorno = new FatoFaturamentoIVELBO[RsFaturamento.RecordCount];
while (!RsFaturamento.EOF)
{
FatoFaturamentoIVELBO Faturamento = new FatoFaturamentoIVELBO();
Faturamento.Operacao = RsFaturamento.Fields["Operacao"].Value.ToString();
Faturamento.AnoMes = RsFaturamento.Fields["AnoMes"].Value.ToString();
Faturamento.ValorNF = decimal.Parse(RsFaturamento.Fields["ValorTotal"].Value.ToString());
ArrayRetorno[Cont] = Faturamento;
Cont++;
RsFaturamento.MoveNext();
}
RsFaturamento.Close();
return ArrayRetorno;
}
catch (Exception ex)
{
throw new Exception("Erro: " + ex.Message);
}
}
Function GetCor
public static FatoFaturamentoIVELBO GetCor(int IdCor, Connection Cn)
{
var Cor = new FatoFaturamentoIVELBO();
var RsCor = new Recordset();
try
{
RsCor.Open(String.Format("SELECT IdCor, CodHex from dbo.GraficoCor where IdCor = " + IdCor), Cn, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly);
if (!RsCor.EOF)
{
Cor.CodHex = RsCor.Fields["CodHex"].Value.ToString();
}
return Cor;
}
catch (Exception ex)
{
throw new Exception("Erro :" + ex.Message);
}
}