-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmSoldItems.cs
71 lines (64 loc) · 2.2 KB
/
frmSoldItems.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
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;
namespace pos_and_inventory_csharp
{
public partial class frmSoldItems : Form
{
SqlConnection cn = new SqlConnection();
SqlCommand cm = new SqlCommand();
SqlDataReader dr;
DBConnection dbcon = new DBConnection();
public frmSoldItems()
{
InitializeComponent();
cn = new SqlConnection(dbcon.MyConnection());
dt1.Value = DateTime.Now;
dt2.Value = DateTime.Now;
LoadRecord();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
this.Dispose();
}
public void LoadRecord()
{
int i = 0;
double _total = 0;
dataGridView1.Rows.Clear();
cn.Open();
cm = 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 '"+ dt1.Value +"' and '"+ dt2.Value +"'", cn);
dr = cm.ExecuteReader();
while (dr.Read())
{
i += 1;
_total += double.Parse(dr["total"].ToString());
dataGridView1.Rows.Add(i, dr["id"].ToString(), dr["transno"].ToString(), dr["pcode"].ToString(), dr["pdesc"].ToString(), dr["price"].ToString(), dr["qty"].ToString(), dr["disc"].ToString(), dr["total"].ToString());
}
dr.Close();
cn.Close();
lblTotal.Text = _total.ToString("#,##0.00");
}
private void dt1_ValueChanged(object sender, EventArgs e)
{
LoadRecord();
}
private void dt2_ValueChanged(object sender, EventArgs e)
{
LoadRecord();
}
private void btnPrint_Click(object sender, EventArgs e)
{
frmReportSold frm = new frmReportSold(this);
frm.LoadReport();
frm.ShowDialog();
}
}
}