private void ZwrotyForm_PrintItemClick(object sender, EventArgs e) { if (DataGrid.CurrentRow != null && DataGrid.CurrentRow.DataBoundItem != null) { Zwrot zwrot = (Zwrot)DataGrid.CurrentRow.DataBoundItem; ReportForm form = new ReportForm(); form.ReportPath = "Reports\\ZwrotReport.rdlc"; form.LocalReport.SetParameters(new ReportParameter("kontrahent", zwrot.Kontrahent.Kod + " - " + zwrot.Kontrahent.Nazwa)); form.AddDataSource("Zwrot", new object[] { zwrot }); form.AddDataSource("PozycjeZwrotu", zwrot.Pozycje.OrderBy(p => p.Ident).ToList()); form.ShowDialog(); } }
private void analizujButton_Click(object sender, EventArgs e) { var login = Enova.Business.Old.DB.Web.User.LoginedUser.LoginedEnova; if (login == null) { MessageBox.Show("Nie jesteś zalogowany do bazy Enova. Skontaktuj się z Administratorem"); return; } if (DataGrid.CurrentRow != null && DataGrid.CurrentRow.DataBoundItem != null) { this.Cursor = Cursors.WaitCursor; this.Enabled = false; using (Session session = login.CreateSession(true, false, "Zwrot.Analiza")) { Zwrot zwrot = (Zwrot)DataGrid.CurrentRow.DataBoundItem; ZwrotAnaliza analiza = zwrot.AnalizujZwrot(session); ReportForm form = new ReportForm(); form.ReportPath = "ZwrotAnalizaSimpleReport.rdlc"; form.Title = "Analiza zwrotu"; form.LocalReport.SetParameters(new ReportParameter[] { new ReportParameter("numer", zwrot.ID.ToString()), new ReportParameter("dataDodania", zwrot.DataDodania.ToShortDateString()), new ReportParameter("dataModyfikacji", zwrot.DataModyfikacji.ToShortDateString()), new ReportParameter("kontrahent", zwrot.Kontrahent.ToString()), new ReportParameter("opis", zwrot.OpisLine) }); int idx = 0; foreach (ZwrotAnalizaDokHandlowyOld dh in analiza.Dokumenty) { if (idx <= 9) { form.LocalReport.SetParameters(new ReportParameter("dokument" + idx.ToString(), dh.NumerPelny)); } idx++; } if (idx < 9) { for (int i = idx; i <= 9; i++) { form.LocalReport.SetParameters(new ReportParameter("dokument" + i.ToString(), string.Empty)); } } form.AddDataSource("Pozycje", analiza.Pozycje); form.ShowDialog(); } this.Enabled = true; this.Cursor = Cursors.Default; } }