-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrintTicketForm.cs
68 lines (63 loc) · 2.2 KB
/
PrintTicketForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using BusReservationSystem.Classes;
using Microsoft.Reporting.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BusReservationSystem
{
public partial class PrintTicketForm : Form
{
string _busNo;
public PrintTicketForm(string busNO)
{
InitializeComponent();
_busNo = busNO;
}
private void PrintTicketForm_Load(object sender, EventArgs e)
{
txtBusNo.Text = _busNo;
txtBusNo.Enabled = false;
txtCounter.Text = LogInfo.user_counter;
txtCounter.Enabled = false;
txtTicket.Text = "";
/*
//Binding Data with Report Viewer & RDLC
* ReportDataSource rds = new ReportDataSource();
* rds.name = "PassengerList";
* rds.value = bus.GetPessanger("MG-36");
*/
Bus bus = new Bus();
reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("PassengerList", bus.GetPessangers(_busNo)));
reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
reportViewer1.RefreshReport();
}
private void BtnPrintData_Click(object sender, EventArgs e)
{
Bus bus = new Bus();
DataTable data1 = new DataTable();
data1 = bus.GetPessangers(_busNo);
try
{
if (txtTicket.Text.Trim() != "")
{
var data = from row in data1.AsEnumerable()
where row.Field<int>("ticket_no") == int.Parse(txtTicket.Text)
select row;
data1 = data.CopyToDataTable();
}
}
catch (Exception)
{
MessageBox.Show("ERROR: 404\nTicket Number not found!");
}
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("PassengerList", data1));
reportViewer1.RefreshReport();
}
}
}