Skip to content

Commit 9e544ca

Browse files
committed
duc
1 parent bf7a2e0 commit 9e544ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1033
-153
lines changed

TimKiemSach/.vs/TimKiemSach/v16/.suo

-5.5 KB
Binary file not shown.

TimKiemSach/TimKiemSach/Form1.Designer.cs

Lines changed: 42 additions & 79 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TimKiemSach/TimKiemSach/Form1.cs

Lines changed: 14 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -18,68 +18,31 @@ public Form1()
1818
InitializeComponent();
1919
}
2020
string cs = ConfigurationManager.ConnectionStrings["CSDL"].ConnectionString;
21-
provider thongtin;
22-
string querry;
21+
tb thongtin;
2322
private void Form1_Load(object sender, EventArgs e)
2423
{
2524

26-
thongtin = new provider();
25+
thongtin = new tb();
2726
try
2827
{
29-
querry = "select* from book";
30-
dataGridView1.DataSource = thongtin.ExecuteQuery(querry);
28+
dataGridView1.DataSource = thongtin.getTable();
3129
}
3230
catch (Exception ex)
3331
{
34-
MessageBox.Show(ex.Message, "thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
32+
MessageBox.Show(ex.Message,"thông báo",MessageBoxButtons.OK,MessageBoxIcon.Error);
3533
}
3634
}
37-
38-
private void btnTimKiem_Click(object sender, EventArgs e)
35+
SqlDataAdapter DataAdapter;
36+
private void txtTimKiem_TextChanged(object sender, EventArgs e)
3937
{
40-
try
41-
{
42-
if (string.IsNullOrEmpty(combobox.Text))
43-
{
44-
querry = "select *from book where TENSA like N'%" + txtTimKiemTen.Text + "%'";
45-
}
46-
else if (string.IsNullOrEmpty(txtTimKiemTen.Text))
47-
{
48-
querry = "select *from book where LOAISA=N'" + combobox.Text + "'";
49-
}
50-
else
51-
{
52-
querry = "select *from book where TENSA like N'%" + txtTimKiemTen.Text + "%' and LOAISA=N'" + combobox.Text + "'";
53-
}
54-
dataGridView1.DataSource = thongtin.ExecuteQuery(querry);
55-
}
56-
catch (Exception ex)
57-
{
58-
MessageBox.Show(ex.Message, "thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
59-
}
60-
}
61-
private void combobox_SelectedIndexChanged(object sender, EventArgs e)
62-
{
63-
try
64-
{
65-
if (combobox.SelectedIndex.ToString() == "8")
66-
{
67-
combobox.Text = null;
68-
}
69-
if (string.IsNullOrEmpty(combobox.Text))
70-
{
71-
querry = "select *from book";
72-
}
73-
else
74-
{
75-
querry = "select *from book where LOAISA = N'" + combobox.Text + "'";
76-
}
77-
dataGridView1.DataSource = thongtin.ExecuteQuery(querry);
78-
}
79-
catch (Exception ex)
80-
{
81-
MessageBox.Show(ex.Message, "thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
82-
}
38+
SqlConnection cn = new SqlConnection(cs);
39+
string querry = "select *from book where TENSA like N'%" + txtTimKiem.Text + "%'";
40+
DataTable dataTable = new DataTable();
41+
cn.Open();
42+
DataAdapter = new SqlDataAdapter(querry, cn);
43+
DataAdapter.Fill(dataTable);
44+
dataGridView1.DataSource = dataTable;
45+
cn.Close();
8346
}
8447
}
8548
}

TimKiemSach/TimKiemSach/Form1.resx

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -138,25 +138,4 @@
138138
<metadata name="SOLUONG.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
139139
<value>True</value>
140140
</metadata>
141-
<metadata name="MASA.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
142-
<value>True</value>
143-
</metadata>
144-
<metadata name="TENSA.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
145-
<value>True</value>
146-
</metadata>
147-
<metadata name="LOAISA.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
148-
<value>True</value>
149-
</metadata>
150-
<metadata name="NXB.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
151-
<value>True</value>
152-
</metadata>
153-
<metadata name="TACGIA.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
154-
<value>True</value>
155-
</metadata>
156-
<metadata name="TAIBAN.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
157-
<value>True</value>
158-
</metadata>
159-
<metadata name="SOLUONG.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
160-
<value>True</value>
161-
</metadata>
162141
</root>

TimKiemSach/TimKiemSach/Table.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Data;
7+
using System.Data.SqlClient;
8+
namespace TimKiemSach
9+
{
10+
class Tabl
11+
{
12+
SqlDataAdapter DataAdapter;
13+
public Table() { }
14+
public DataTable getTable()
15+
{
16+
DataTable dataTable = new DataTable();
17+
string querry = "select * from Book";
18+
using (SqlConnection connection = Connection.getConnection())
19+
{
20+
connection.Open();
21+
DataAdapter = new SqlDataAdapter(querry, connection);
22+
DataAdapter.Fill(dataTable);
23+
connection.Close();
24+
}
25+
return dataTable;
26+
}
27+
}
28+
}

TimKiemSach/TimKiemSach/TimKiemSach.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
</Compile>
5656
<Compile Include="Program.cs" />
5757
<Compile Include="Properties\AssemblyInfo.cs" />
58-
<Compile Include="provider.cs" />
58+
<Compile Include="tb.cs" />
5959
<EmbeddedResource Include="Form1.resx">
6060
<DependentUpon>Form1.cs</DependentUpon>
6161
</EmbeddedResource>
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a649facdcc4986cb5d5d8395495df891b0695dd9
1+
e1e8d0bb55996a1d4165460c89dd3fb45dadb001
Binary file not shown.

0 commit comments

Comments
 (0)