Expensive pigtails,
I am developing a Report View of the master-detail type. The data source for this report will be a text file. It's practically ready. The problem is at the moment of transferring the data from the detail part to the report. the problem is in the detail area where multiple items will be displayed. For now to test and facilitate the development of the code includes a single occurrence, but this occurrence is being repeated several times. I am not able to make this occurrence be displayed only once. The logic I've created is to read the text file, feed a list, from the transfer list to a class, and from the class to the report dataset. I do not know if it is the ideal logic but as I am learning to program with C # it is what inspired me in the research I did. I hope I have been clear and placed all the important information. Thank you.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO;
namespace OrderProduction { public partial class FrmOrderProduction: Form { static string; static string result; static int ix;
List<string> lista = new List<string>();
DadosOrdemProducao op = new DadosOrdemProducao();
public FrmOrdemProducao()
{
InitializeComponent();
}
private void reportViewer1_Load(object sender, EventArgs e)
{
StreamReader sr = new StreamReader("C:\SACTRM\ORDEM.TXT");
while ((linha = sr.ReadLine()) != null)
{
Processa(linha);
if resultado != "")
{
lista.Add(resultado);
}
}
var DadosRelatorio = (from item in lista
select new DadosOrdemProducao()
{
OrdemProducaoId = int.Parse(lista[0]),
DescricaoProduto = lista[1],
//ESTES SÃO OS CAMPOS DE DETALHE
MatprimaDescricao = lista[2],
MatprimaQuantidade = lista[3],
MatprimaLote = lista[4]
}).ToArray();
var DataSource = new Microsoft.Reporting.WinForms.ReportDataSource("DataSetOrdemProducao", DadosRelatorio);
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(DataSource);
this.reportViewer1.RefreshReport();
}
public void Processa(string linha)
{
resultado = "";
if (linha.Contains("ORDEM"))
{
resultado = linha.Substring(6);
}
if (linha.Contains("PRODUTO"))
{
resultado = linha.Substring(8);
}
if (linha.Contains("DESCRICAOMATPRIMA"))
{
resultado = linha.Substring(18);
}
if (linha.Contains("QTDEMATPRIMA"))
{
resultado = linha.Substring(13);
}
if (linha.Contains("LOTEMATPRIMA"))
{
resultado = linha.Substring(13);
}
}
}
}