I'm creating a form to register a license for a product.
This form serves to record which solution a client has.
In the form to add a product you only have to select product and customer .
I'm having a hard time crafting the loading logic for the form that sets " checked
" to the products that this client already has.
My initial idea is to make two queries that return a DataTable
, the first query the existing products, the second brings the products that the client owns.
First Consultation
SELECT id, nome
FROM produto
Second Consultation
SELECT produto_id
FROM licenca
JOIN produto on produto_id = produto.id
join pessoa on pessoa.id = cliente_id
where cliente_id = @id
So in loading it during the loop it will make the comparison leaving it checked the ones it already has.
foreach (DataRow row in ProdutosCLiente.Rows)
{
int id = (int)row["produto_id"];
GridProduto.Rows[id].Cells[0].Value = CheckState.Checked;
}
Can anyone tell me what would be the correct way to reference the values that will be filled? I'm having trouble making reference during loop
.