-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoomSrchFrm.cs
58 lines (55 loc) · 1.84 KB
/
RoomSrchFrm.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
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 RoomSrchFrm : Form
{
public RoomSrchFrm()
{
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 RoomSrchFrm_Load(object sender, EventArgs e)
{
da = new SqlDataAdapter("SELECT * FROM Rooms", con);
cb = new SqlCommandBuilder(da);
da.Fill(ds, "Rooms");
dataGridView1.DataBindings.Add(new Binding("DataSource", ds, "Rooms"));
dataGridView1.ReadOnly = true;
}
private void btnSearch_Click(object sender, EventArgs e)
{
try
{
da = new SqlDataAdapter("SELECT * FROM Rooms WHERE RoomNumber='" + Convert.ToInt32(txtrmnumb.Text) + "'or RoomType='" + txttype.Text + "' or SituationNumber='" + txtsitnmb.Text + "'or RoomPrice='" + txtprice.Text + "'", con);
cb = new SqlCommandBuilder(da);
da.Fill(dt);
if (dt.Rows.Count == 0)
{
MessageBox.Show("Nothing Found!!!");
dataGridView1.DataSource = "";
}
dataGridView1.DataSource = dt;
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void BtnClose_Click(object sender, EventArgs e)
{
Close();
}
}
}