-1
There’s a For that goes line by line a list. This list returns me input and output of a process. The problem is that it does not return in the same row because it is either input or output.
I would like to show in the middle column the process and in the corner columns the inputs and outputs.
Since it is inside a for, it always breaks a row for the next record. It would be possible to just move up the record one row from that column above?
See the image:
HTML:
<table id="EntradaProcessoSaida" class="table">
<thead>
<tr>
<th>Entrada </th>
<th width="50%" colspan="2"><center>Processo</center></th>
<th>Saída</th>
</tr>
</thead>
<tbody>
@{
string acaoInicial = "";
string acaoFinal = "";
string tituloInicial = "";
string tituloFinal = "";
/* p.Acao = reader["ACAO"].ToString();
p.TituloAcao = reader["TituloAcao"].ToString();
p.IdAcao = (int)reader["Acao"];
p.TipoES = reader["TIPO"].ToString();
p.TituloES = reader["Titulo"].ToString();
p.CodigosES = reader["Codigo"].ToString();*/
for (int i = 0; i < ViewBag.listaTudo.Count; i++)
{
acaoInicial = ViewBag.listaTudo[i].Acao;
tituloInicial = ViewBag.listaTudo[i].TituloAcao;
string concatenaEntrada = ViewBag.listaTudo[i].TituloES + " - " + ViewBag.listaTudo[i].CodigosES;
concatenaEntrada = concatenaEntrada.Remove(concatenaEntrada.Length - 1);
if (acaoInicial != acaoFinal)
{
<tr><td colspan="4"><hr /></td></tr>
}
@*/*ENTRADA*/*@
<tr>
@if (ViewBag.listaTudo[i].TipoES == "entrada")
{
<td>@concatenaEntrada</td>
}
else
{
<td></td>
}
@*/*Processo*/*@
@if (acaoInicial != acaoFinal)
{
<td><font size="14"><b>@ViewBag.listaTudo[i].Acao</b></font></td>
<td>@ViewBag.listaTudo[i].TituloAcao</td>
}
else
{
if (tituloInicial != tituloFinal)
{
<td></td>
<td>@ViewBag.listaTudo[i].TituloAcao</td>
}
else
{
<td></td><td></td>
}
}
@*/*Saída*/*@
@if (ViewBag.listaTudo[i].TipoES == "saida")
{
<td>@concatenaEntrada</td>
}
else
{
<td></td>
}
@{
acaoFinal = ViewBag.listaTudo[i].Acao;
tituloFinal = ViewBag.listaTudo[i].TituloAcao;
cont++;
}
</tr>
}
}
</tbody>
</table>
css:
.relativeDireita {
position: relative;
/* left: 600px; */
width: 200px;
height: auto;
/*border: solid #000000 1px;*/
}
Return from the list :
SQL:
declare @processo int = 9
-- Lista ações do processo
SELECT
distinct
CASE
when ga.Descricao ='ACTION' THEN 'A'
when ga.Descricao ='PLAN' THEN 'P'
when ga.Descricao ='CHECK' THEN 'C'
when ga.Descricao ='DO' THEN 'D'
END ACAO
,
pg.Titulo TituloAcao,
pg.Id as Acao,
case
when pga.Id_Acao = 1 then
'entrada'
when pga.Id_Acao = 2 then
'saida'
end TIPO,
pga.Titulo,
UPPER
(
SUBSTRING
(
ISNULL
(
STUFF
(
(
SELECT
convert(varchar(10),c.Codigo) + ',' codigo
FROM
Qualidade_Diagrama_Processo_Grupo_Acao a
join Qualidade_Diagrama_Acao_Entidade b on (b.Id_Proc_Grupo_Acao = a.Id)
join Qualidade_Diagrama_Entidade c on (c.Id = b.Id_Entidade)
WHERE
b.Id_Proc_Grupo_Acao = ae.Id_Proc_Grupo_Acao
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)') ,1,0,''
),' '
),1,254
)
) as Codigo,
ga.Codigo_Posicao
FROM
Qualidade_Diagrama_Processo_Grupo pg
JOIN Qualidade_Diagrama_Processo p on (p.Id = pg.Id_Processo)
JOIN Qualidade_Diagrama_Grupo_Acoes ga on (ga.Id = pg.Id_Grupo_Acoes)
join setor s on (s.id = p.Setor)
join Usuario_Interno u on (u.id = p.Usuario_Criacao)
left Join Qualidade_Diagrama_Processo_Grupo_Acao pga on (pga.Id_Processo_Grupo = pg.Id)
left join Qualidade_Diagrama_Acao_Entidade ae on (ae.Id_Proc_Grupo_Acao = pga.Id)
WHERE
1=1
AND pga.Data_Exclusao is null
and p.Id = @processo
order by ga.Codigo_Posicao
You’d have to treat it on
for
but would still give a job, it would be better to generate a new list already right in the format you need and then generate html from it– Ricardo Pontual
@Ricardopunctual the problem is that the Query has been a lot of work. Ta huge and every time I touch it to list the output on the same line as the entries, I get wrong result.
– Danielle Arruda torres
I think you can do this easily on
C#
even, depending even onLinq
, and let your View do the basics, just show– Ricardo Pontual
How do you know that the input and output are matching? has a field linking the two information that are on different lines?
– Ricardo Pontual
Yes you do. By the Action Id of the process. I’m trying to bargain for what’s inside
– Danielle Arruda torres
the problem is not in the
for
yes in the data. You should have a list with Input/Process/Output in the same record, not in several. Show how you are assembling the listViewBag.listaTudo
.– Rovann Linhalis
@Rovannlinhalis I edited. I put in the question the SQL and its return
– Danielle Arruda torres
You need to do a query that returns:
Titulo Entrada | Acao | Processo | Titulo Saida
recommend to do the query first without grouping the ids, leave it for later, when the query is already returning the right data– Rovann Linhalis