-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathForm2.cs
More file actions
95 lines (89 loc) · 3.3 KB
/
Copy pathForm2.cs
File metadata and controls
95 lines (89 loc) · 3.3 KB
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
91
92
93
94
95
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 Microsoft.Reporting.WinForms;
using System.Data.SqlClient;
using System.Configuration;
namespace UniqueRestaurant
{
public partial class Form2 : Form
{
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlcon"].ToString());
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
if (c == "")
{
DataSet2 cashier = GetData();
ReportDataSource datasource = new ReportDataSource("DataSet2", cashier.Tables[0]);
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.DataSources.Add(datasource);
reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
this.reportViewer1.RefreshReport();
}
else
{
DataSet2 cashier = GetData2();
ReportDataSource datasource = new ReportDataSource("DataSet2", cashier.Tables[0]);
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.DataSources.Add(datasource);
reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
this.reportViewer1.RefreshReport();
}
}
DateTime a, b;
string c ="";
public void pass( DateTime startdate, DateTime EndDate)
{
a = startdate;
b = EndDate;
}
public void pass2(string search, DateTime startdate, DateTime EndDate)
{
a = startdate;
b = EndDate;
c = search;
}
private DataSet2 GetData()
{
using (SqlCommand cmd = new SqlCommand("Select * from tblRecord where DateTime between '" + a + "' and '" + b + "'"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = cn;
sda.SelectCommand = cmd;
using (DataSet2 dsCustomers = new DataSet2())
{
sda.Fill(dsCustomers, "DataTable2");
return dsCustomers;
}
}
}
}
private DataSet2 GetData2()
{
using (SqlCommand cmd = new SqlCommand("Select * from tblRecord where Description like '" + c + "%' and DateTime between '" + a + "' and '" + b + "'"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = cn;
sda.SelectCommand = cmd;
using (DataSet2 dsCustomers = new DataSet2())
{
sda.Fill(dsCustomers, "DataTable2");
return dsCustomers;
}
}
}
}
}
}