-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmReceipt.cs
90 lines (76 loc) · 3.73 KB
/
frmReceipt.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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 frmReceipt : Form
{
SqlConnection cn = new SqlConnection();
SqlCommand cm = new SqlCommand();
DBConnection dbcon = new DBConnection();
SqlDataReader dr;
frmPOS f;
string store = "ICM Womai Technology Sdn. Bhd.";
string address = "A-1-19 @ Eve Suite , Ara Damansara, No 1A, Jalan PJU 1A/41, Kota Damansara, 47810, Petaling Jaya, Selangor.";
public frmReceipt(frmPOS frm)
{
InitializeComponent();
cn = new SqlConnection(dbcon.MyConnection());
f = frm;
}
private void frmReceipt_Load(object sender, EventArgs e)
{
this.reportViewer1.RefreshReport();
}
public void LoadReport(string pcash, string pchange)
{
ReportDataSource rptDataSource;
try
{
this.reportViewer1.LocalReport.ReportPath = Application.StartupPath + @"\Reports\Report1.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, c.price, c.qty, c.disc, c.total, c.sdate, c.status, p.pdesc from tblcart as c inner join tblProduct as p on p.pcode = c.pcode where transno like '"+ f.lblTransno.Text +"'",cn);
da.Fill(ds.Tables["dtSold"]);
cn.Close();
ReportParameter pVatable = new ReportParameter("pVatable", f.lblVatable.Text);
ReportParameter pVat = new ReportParameter("pVat", f.lblVat.Text);
ReportParameter pDiscount = new ReportParameter("pDiscount", f.lblDiscount.Text);
ReportParameter pTotal = new ReportParameter("pTotal", f.lblTotal.Text);
ReportParameter pCash = new ReportParameter("pCash", pcash);
ReportParameter pChange = new ReportParameter("pChange", pchange);
ReportParameter pStore = new ReportParameter("pStore", store);
ReportParameter pAddress = new ReportParameter("pAddress", address);
ReportParameter pTransaction = new ReportParameter("pTransaction", "Invoice #: " + f.lblTransno.Text);
reportViewer1.LocalReport.SetParameters(pVatable);
reportViewer1.LocalReport.SetParameters(pVat);
reportViewer1.LocalReport.SetParameters(pDiscount);
reportViewer1.LocalReport.SetParameters(pTotal);
reportViewer1.LocalReport.SetParameters(pCash);
reportViewer1.LocalReport.SetParameters(pChange);
reportViewer1.LocalReport.SetParameters(pStore);
reportViewer1.LocalReport.SetParameters(pAddress);
reportViewer1.LocalReport.SetParameters(pTransaction);
rptDataSource = new ReportDataSource("DataSet1", ds.Tables["dtSold"]);
reportViewer1.LocalReport.DataSources.Add(rptDataSource);
reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
reportViewer1.ZoomMode = ZoomMode.Percent;
reportViewer1.ZoomPercent = 100;
}catch (Exception ex)
{
cn.Close();
MessageBox.Show(ex.Message, "Exception Error");
}
}
}
}