-1
Hello, I have the following problem, I have a view
in the bank that makes a group by
, and I have another table GraficoCor
, I want to make it every time While
of the first function make an increment, it passes the counter value to the variable IdCor
of the second function, the second function will make the query having as reference the value of the IdCor
returning the hexadecimal color to the first function.
How would you 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);
}
}
Again? I took the trouble to try to answer the other question and you erased it! Wouldn’t it be easier to try to be more specific in your doubt than to erase the questions and create new ones?
– Jéf Bueno
Sorry, I thought the previous one was poorly formulated. But I did it, I’ll post the solution.
– Igor Lessa