Skip to content

Commit 8fa9ca6

Browse files
committed
hoi
1 parent 8296efd commit 8fa9ca6

File tree

278 files changed

+14544
-13972
lines changed

Some content is hidden

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

278 files changed

+14544
-13972
lines changed

Phân công lần 2/GiaoDien/.vs/GiaoDien/config/applicationhost.config

Lines changed: 1034 additions & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

sach_da_muon/GiaoDien/GiaoDien.sln renamed to Phân công lần 2/GiaoDien/GiaoDien.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 17
4-
VisualStudioVersion = 17.0.31717.71
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31729.503
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GiaoDien", "GiaoDien\GiaoDien.csproj", "{D1F47C13-FE48-4407-8D6E-AAA96C2472A1}"
77
EndProject

Phân công lần 2/GiaoDien/GiaoDien/AdjustData.Designer.cs

Lines changed: 454 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
using GiaoDien.DAO;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.ComponentModel;
5+
using System.Data;
6+
using System.Drawing;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
using System.Windows.Forms;
11+
12+
namespace GiaoDien
13+
{
14+
public partial class AdjustData : Form
15+
{
16+
public AdjustData()
17+
{
18+
InitializeComponent();
19+
//this.TopMost = true;
20+
//this.FormBorderStyle = FormBorderStyle.Fixed3D;
21+
//this.WindowState = FormWindowState.Maximized;
22+
ShowBookData();
23+
}
24+
void ShowBookData()
25+
{
26+
string query = "SELECT MASA 'Mã sách', TENSA 'Tên sách', LOAISA 'Loại sách', NXB 'Nhà xuất bản', TACGIA 'Tác giả', TAIBAN 'Tái bản', SOLUONG 'Số lượng' FROM Book";
27+
data.DataSource = DataProvider.Instance.ExecuteQuery(query);
28+
}
29+
private void updBtn_Click(object sender, EventArgs e)
30+
{
31+
string bookId = bookIDText.Text;
32+
string bookTitle = bookTitleText.Text;
33+
string bookType = bookTypeText.Text;
34+
string publisher = publishText.Text;
35+
string author = authorText.Text;
36+
string edition = editText.Text;
37+
string quantity = quantityText.Text;
38+
if (IsNullData(bookId, bookTitle, bookType, publisher, author, edition, quantity))
39+
MessageBox.Show("Nhập không đủ dữ liệu. Vui lòng kiểm tra lại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
40+
else
41+
{
42+
if (!IsValidNumber(edition))
43+
MessageBox.Show("Thông tin 'Lần tái bản' không hợp lệ. Vui lòng kiểm tra lại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
44+
else if (!IsValidNumber(quantity))
45+
MessageBox.Show("Thông tin 'Số lượng' không hợp lệ. Vui lòng kiểm tra lại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
46+
else
47+
{
48+
if (UpdateBook(bookId, bookTitle, bookType, publisher, author, edition, quantity) == 0)
49+
MessageBox.Show("Mã sách không hợp lệ. Vui lòng kiểm tra lại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
50+
else
51+
{
52+
MessageBox.Show("Cập nhật dữ liệu thành công !!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
53+
ShowBookData();
54+
bookTitleText.Clear();
55+
bookTypeText.Clear();
56+
publishText.Clear();
57+
authorText.Clear();
58+
editText.Clear();
59+
quantityText.Clear();
60+
}
61+
}
62+
}
63+
}
64+
bool IsNullData(string bookID, string bookTitle, string bookType, string publisher, string author, string edition, string quantity)
65+
{
66+
if (String.IsNullOrEmpty(bookID) || String.IsNullOrEmpty(bookTitle) || String.IsNullOrEmpty(bookType) || String.IsNullOrEmpty(publisher) || String.IsNullOrEmpty(author) || String.IsNullOrEmpty(edition) || String.IsNullOrEmpty(quantity))
67+
return true;
68+
return false;
69+
}
70+
bool IsValidNumber(string str)
71+
{
72+
if (str.Trim() == "")
73+
return false;
74+
for (int i = 0; i < str.Length; i++)
75+
{
76+
if (!char.IsNumber(str[i]))
77+
return false;
78+
}
79+
if (Int64.Parse(str) < 0)
80+
return false;
81+
return true;
82+
}
83+
int UpdateBook(string bookID, string bookTitle, string bookType, string publisher, string author, string edition, string quantity)
84+
{
85+
string query = "UPDATE Book SET TENSA = N'" + bookTitle + "', LOAISA = N'" + bookType + "', NXB = N'" + publisher + "', TACGIA = N'" + author + "', TAIBAN = " + edition + ", SOLUONG = " + quantity + " WHERE MASA = '" + bookID + "'";
86+
return DataProvider.Instance.ExecuteNonQuery(query);
87+
}
88+
private void data_CellClick(object sender, DataGridViewCellEventArgs e)
89+
{
90+
91+
int index = e.RowIndex;
92+
if (index >= 0)
93+
{
94+
bookIDText.Text = data.Rows[index].Cells["Mã sách"].Value.ToString();
95+
bookTitleText.Text = data.Rows[index].Cells["Tên sách"].Value.ToString();
96+
bookTypeText.Text = data.Rows[index].Cells["Loại sách"].Value.ToString();
97+
publishText.Text = data.Rows[index].Cells["Nhà xuất bản"].Value.ToString();
98+
authorText.Text = data.Rows[index].Cells["Tác giả"].Value.ToString();
99+
editText.Text = data.Rows[index].Cells["Tái bản"].Value.ToString();
100+
quantityText.Text = data.Rows[index].Cells["Số lượng"].Value.ToString();
101+
}
102+
}
103+
104+
105+
}
106+
}

0 commit comments

Comments
 (0)