Report in Report View type Master-Detail

Asked

Viewed 52 times

1

Dear collections,

I am developing a report through the Report View type master-detail. The data source of this report will be a text file. Almost done. The problem is at the moment of transferring the data from the detail to the report. the problem is in the detail area where several items will be displayed. For now for testing and facilitating code development includes a single occurrence, but this occurrence is repeating several times. I’m not getting to make this show once. The logic I created is to read the text file, feed a list, transfer from the list to a class and from the class to the report dataset. I do not know if it is the ideal logic but how I am learning to program with C# is what inspired me in the research I did. I hope I have been clear and put all 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 Ordemproducao { public partial class Frmordemproduction : Form { Static string line; 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);
        }
    }
}

}

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.