-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbarrepo.cs
128 lines (94 loc) · 3.16 KB
/
barrepo.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using System.Data.SqlClient;
using System.Windows.Forms.DataVisualization.Charting;
namespace Nazam_pos
{
public partial class barrepo : Form
{
SqlConnection cn = new SqlConnection();
SqlCommand cm = new SqlCommand();
DBconnection dbcon = new DBconnection();
SqlDataReader dr;
DataTable dt;
public barrepo()
{
InitializeComponent();
cn = new SqlConnection(dbcon.Myconnection());
loadproduct();
}
private void barrepo_Load(object sender, EventArgs e)
{
dt = new DataTable();
dt.TableName = "barcode";
dt.Columns.Add("barcode", typeof(string));
dt.Columns.Add("price", typeof(decimal));
dt.Columns.Add("pname", typeof(string));
}
private void button1_Click(object sender, EventArgs e)
{
try
{
for (int i = 1; i <= int.Parse(textcpy.Text); i++)
{
ReportDocument rdlc = new ReportDocument();
dt.Rows.Add(textBox1.Text, textBox2.Text, comboBox1.Text);
string reportpath = @"Reports\CrystalReport1.rpt";
rdlc.Load(reportpath);
rdlc.SetDataSource(dt);
crystalReportViewer1.ReportSource = rdlc;
}
}
catch(Exception ex)
{
MessageBox.Show("Barcode Form Error " + ex.Message+MessageBoxButtons.OK+ MessageBoxIcon.Warning);
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void comboBox1_TextChanged(object sender, EventArgs e)
{
cn.Open();
cm = new SqlCommand("Select * from tblProducts where pname like '" + comboBox1.Text + "'", cn);
dr = cm.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
//lblVendorID.Text = dr["id"].ToString();
textBox1.Text = dr["barcode"].ToString();
textBox2.Text = dr["price"].ToString();
// textBox3.Text = dr["qty"].ToString();
// textBox4.Text = dr["pname"].ToString();
}
dr.Close();
cn.Close();
}
public void loadproduct()
{
cn.Open();
comboBox1.Items.Clear();
cm = new SqlCommand("Select * from tblProducts", cn);
dr = cm.ExecuteReader();
while (dr.Read())
{
comboBox1.Items.Add(dr["pname"].ToString());
}
dr.Close();
cn.Close();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
this.Dispose();
}
}
}