-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmReportSold.cs
72 lines (59 loc) · 2.22 KB
/
frmReportSold.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
69
70
71
72
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.Data.SqlClient;
using Microsoft.Reporting.WinForms;
namespace pos_and_inventory_csharp
{
public partial class frmReportSold : Form
{
SqlConnection cn = new SqlConnection();
SqlCommand cm = new SqlCommand();
SqlDataReader dr;
DBConnection dbcon = new DBConnection();
frmSoldItems f;
public frmReportSold(frmSoldItems frm)
{
InitializeComponent();
cn = new SqlConnection(dbcon.MyConnection());
f = frm;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
this.Dispose();
}
private void frmReportSold_Load(object sender, EventArgs e)
{
}
public void LoadReport()
{
try
{
ReportDataSource rptDS;
this.reportViewer1.LocalReport.ReportPath = Application.StartupPath + @"\Reports\Report2.rdl";
this.reportViewer1.LocalReport.DataSources.Clear();
DataSet1 ds = new DataSet1();
SqlDataAdapter da = new SqlDataAdapter();
cn.Open();
da.SelectCommand = new SqlCommand("select c.id, c.transno, c.pcode, p.pdesc, c.price, c.qty, c.disc, c.total from tblcart as c inner join tblproduct as p on c.pcode = p.pcode where status like 'Sold' and sdate between '"+ f.dt1.Value +"' and '"+ f.dt2.Value +"'", cn);
da.Fill(ds.Tables["dtSoldReport"]);
cn.Close();
rptDS = new ReportDataSource("DataSet1", ds.Tables["dtSoldReport"]);
reportViewer1.LocalReport.DataSources.Add(rptDS);
reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
reportViewer1.ZoomMode = ZoomMode.Percent;
reportViewer1.ZoomPercent = 50;
}catch( Exception ex)
{
cn.Close();
MessageBox.Show(ex.Message,"Load Report Error");
}
}
}
}