-
Notifications
You must be signed in to change notification settings - Fork 0
/
PricesFrmSrch.cs
52 lines (48 loc) · 1.64 KB
/
PricesFrmSrch.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
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.Windows.Forms;
namespace Reception
{
public partial class PricesFrmSrch : Form
{
public PricesFrmSrch()
{
InitializeComponent();
}
SqlDataAdapter da;
SqlConnection con = new SqlConnection("Data Source=PEDRAM-PC;Initial Catalog=ProjectREC;Integrated Security=True");
SqlCommandBuilder cb;
DataTable dt = new DataTable();
DataSet ds = new DataSet();
private void PricesFrmSrch_Load(object sender, EventArgs e)
{
da = new SqlDataAdapter("SELECT * FROM Prices", con);
cb = new SqlCommandBuilder(da);
da.Fill(ds, "Prices");
dataGridView1.DataBindings.Add(new Binding("DataSource", ds, "Prices"));
dataGridView1.ReadOnly = true;
}
private void btnSearch_Click(object sender, EventArgs e)
{
da = new SqlDataAdapter("SELECT * FROM Prices WHERE UsedServicesID='" + txtservId.Text + "' or UsedServicesName='" + txtservname.Text + "'or UsedServicesPrice='" + txtservprice.Text + "'", con);
cb = new SqlCommandBuilder(da);
da.Fill(dt);
if (dt.Rows.Count == 0)
{
MessageBox.Show("Nothing Found!!!");
dataGridView1.DataSource = "";
}
dataGridView1.DataSource = dt;
}
private void BtnClose_Click(object sender, EventArgs e)
{
Close();
}
}
}