Ola, Estou com um problema
Preencho um relatorio onde tem o campo Custo.
Porem, esse capmo custo eu preciso de um método que calcula o custo e retorna um valor.
public decimal CustoProduto(string _datainicial, string _produto_id)
{
decimal VALORCUSTO = 0;
decimal VLRTOTALCUSTO = 0;
decimal VLRQUANTIDADE = 0;
//PEGA O CUSTO DOS PRODUTOS DAS NOTAS FISCAIS DE ENTRADA
SqlCommand cmdTotalDebito = new SqlCommand("CustosEntradas", connPrime);
cmdTotalDebito.CommandType = System.Data.CommandType.StoredProcedure;
cmdTotalDebito.Parameters.Add(new SqlParameter("@datainicial", _datainicial));
cmdTotalDebito.Parameters.Add(new SqlParameter("@produto_id", _produto_id));
connPrime.Open();
dr = cmdTotalDebito.ExecuteReader();
while (dr.Read())
{
VALORCUSTO += Convert.ToDecimal(dr["vlrtotal"].ToString());
VLRQUANTIDADE += Convert.ToDecimal(dr["quantidade"].ToString());
}
if (VLRQUANTIDADE > 0)
{
VLRTOTALCUSTO = (VALORCUSTO / VLRQUANTIDADE);
}
dr.Close();
connPrime.Close();
return VLRTOTALCUSTO;
Como q eu faço para nesse campo do relatorio, ele execute esse metodo e preencha essa coluna com o custo?
Muito Obrigado!
Rafael Cardoso