-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmthongtinsach.cs
74 lines (74 loc) · 2.65 KB
/
frmthongtinsach.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
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 BTL_QLThuvien_Csharp_Nhom10
{
public partial class frmthongtinsach : Form
{
SqlConnection con;
DataTable dssach;
public frmthongtinsach()
{
InitializeComponent();
con = new SqlConnection("Data Source=THINKPADE14/MSSQLSERVER01;Initial Catalog=QLThuVien_BTL_NET1;Integrated Security=True;User Id=sa;Password=1");
}
private DataTable loadsachbihu()
{
string truyvan = "SELECT * FROM SACH WHERE TinhTrang=N'Cu or TinhTrang=N'cu or TinhTrang=N'Chu hoi mo";
SqlCommand cmd = new SqlCommand(truyvan, con);
DataTable sachhu = new DataTable();
con.Open();
sachhu.Load(cmd.ExecuteReader());
con.Close();
return sachhu;
}
private DataTable loadsachbanchay()
{
string truyvan = "SELECT * FROM SACH WHERE MaSach IN(SELECT MaSach FROM PHIEUMUON WHERE Sach.MaSach = PHIEUMUON.MaSach)";
SqlCommand command = new SqlCommand(truyvan, con);
DataTable sachbanchay = new DataTable();
con.Open();
sachbanchay.Load(command.ExecuteReader());
con.Close();
return sachbanchay;
}
private DataTable loadsachtonkho()
{
string truyvan = "SELECT * FROM SACH WHERE MaSach NOT IN(SELECT MaSach form SACHMUON)";
SqlCommand cmd = new SqlCommand();
DataTable sachtonkho = new DataTable();
con.Open();
sachtonkho.Load(cmd.ExecuteReader());
con.Close();
return sachtonkho;
}
private void btnthongtin_Click(object sender, EventArgs e)
{
if (chksachbihu.Checked)
{
dtgthongtin.DataSource = loadsachbihu();
txttong.ForeColor = Color.Yellow;
txttong.Text = (dtgthongtin.Rows.Count).ToString();
}
if (chksachtonkho.Checked)
{
dtgthongtin.DataSource = loadsachtonkho();
txttong.ForeColor = Color.Yellow;
txttong.Text = (dtgthongtin.Rows.Count).ToString();
}
if (chksachbanchay.Checked)
{
dtgthongtin.DataSource = loadsachbanchay();
txttong.ForeColor = Color.Yellow;
txttong.Text = (dtgthongtin.Rows.Count).ToString();
}
}
}
}