Professional Documents
Culture Documents
Mã lớp: 145539
Họ và tên MSSV
Phan Thanh An 20216032
Nguyễn Minh Quân 20210705
Nguyễn Thế Nghĩa 20214024
Nguyễn Quang Hoàng 20213935
Hà Nội, 1/2024
1
MỤC LỤC
MỤC LỤC.............................................................................................................................................2
MỞ ĐẦU...............................................................................................................................................3
CHƯƠNG I: TỔNG QUAN.................................................................................................................4
1.1. YÊU CẦU CHỨC NĂNG....................................................................................................4
1.2. YÊU CẦU PHI CHỨC NĂNG............................................................................................4
1.3. GIỚI THIỆU CÔNG CỤ, PHẦN MỀM SỬ DỤNG..........................................................5
1.3.1. Visual Studio C#............................................................................................................5
1.3.2. WPF (Windows Presentation Foundation).................................................................6
1.3.3. Microsoft SQL Server...................................................................................................6
1.4. MÔ HÌNH MVVM...............................................................................................................7
CHƯƠNG II: PHÂN TÍCH THIẾT KẾ HỆ THỐNG.......................................................................8
2.1. SƠ ĐỒ FHD..........................................................................................................................8
2.2. SƠ ĐỒ DFD..........................................................................................................................9
2.2.1. DFD Mức Ngữ Cảnh (mức 0).......................................................................................9
2.2.2. DFD Mức Đỉnh (mức 1)................................................................................................9
2.2.3. DFD Mức 2..................................................................................................................10
2.3. SƠ ĐỒ ERD........................................................................................................................10
Chương III: TRIỂN KHAI HỆ THỐNG..........................................................................................11
3.1. SQL SERVER.....................................................................................................................11
3.1.1. Quản Lý Về Dịch Bệnh, Cơ Sở, Vùng Chăn Nuôi..........................................................11
3.1.2. Quản Lý Văn Bản Pháp Luật Về Chăn Nuôi..................................................................14
3.2. GIAO DIỆN........................................................................................................................15
KẾT LUẬN.........................................................................................................................................15
TÀI LIỆU THAM KHẢO..................................................................................................................16
2
MỞ ĐẦU
Trong những năm qua, ngành chăn nuôi Việt Nam đang trên đà phát triển,
là một ngành nông nghiệp rất quan trọng, đóng góp vào nhu cầu thực phẩm của
con người. Tuy nhiên, để quản lý và kiểm soát dịch bệnh, các văn bản pháp luật
quy định về chăn nuôi, các cá nhân tổ chức thực hiện sản xuất, khảo nghiệm con
giống, xử lý chất thải, cơ sở giết mổ,…… cần phải có một hệ thống quản lý dữ
liệu hiệu quả.
Bài tập lớn này sẽ tập trung vào việc thiết kế một CSDL để quản lý các thông tin
liên quan đến chăn nuôi, bao gồm thông tin về dịch bệnh; văn bản pháp luật về
CSDL chăn nuôi và thống kê các cơ sở, tổ chức, cá nhân hoạt động trong lĩnh
vực chăn nuôi. Mục đích của bài tập này là giúp hiểu rõ hơn về cách thiết kế
CSDL, tăng cường kỹ năng phân tích và thiết kế hệ thống cơ sở dữ liệu.
Nhiệm vụ của bài tập lớn này bắt đầu bằng việc phân tích yêu cầu và thiết kế các
bảng dữ liệu, quan hệ giữa chúng, các khóa chính và ngoại. Sau đó, sẽ xây dựng
các truy vấn và hàm trong CSDL để truy xuất thông tin một cách hiệu quả. Bên
cạnh đó, cũng cần thiết kế giao diện dễ dàng sử dụng.
Bản cáo cáo này gồm có 3 chương. Chương I về tổng quan chương trình quản lý
CSDL chăn nuôi. Chương II về phân tích thiết kế hệ thống, bằng cách vẽ các sơ
đồ FHD, DFD, ERD. Chương III về triển khai hệ thống.
3
CHƯƠNG I: TỔNG QUAN
Chương này đặt vấn đề cần giải quyết khi đề xuất hệ thống quản lý và
phân tích các chức năng cần thiết để giải quyết vấn đề đặt ra. Đồng thời mô tả sơ
lược các công cụ hỗ trợ của bên thứ ba được sử dụng trong đề tài.
Đăng nhập và quản lý người dùng: Yêu cầu cho phép người dùng đăng
nhập và quản lý thông tin người dùng.
Quản lý dữ liệu: Yêu cầu cho phép người dùng tạo, lưu trữ, cập nhật và
xóa dữ liệu.
Tìm kiếm và lọc dữ liệu: Yêu cầu cho phép người dùng tìm kiếm và lọc
dữ liệu theo nhiều tiêu chí khác nhau.
Hiển thị dữ liệu: Yêu cầu cho phép hiển thị dữ liệu theo cách rõ ràng,
dễ đọc và dễ hiểu.
Thao tác và xử lý dữ liệu: Yêu cầu cho phép người dùng thao tác với
dữ liệu và thực hiện các xử lý dữ liệu.
Tương tác với người dùng: Yêu cầu cho phép tương tác với người dùng
thông qua các giao diện người dùng thân thiện và dễ sử dụng.
Bảo mật và phân quyền: Yêu cầu cho phép bảo mật dữ liệu và phân
quyền truy cập cho người dùng.
Giao tiếp với các hệ thống khác: Yêu cầu cho phép phần mềm giao tiếp
với các hệ thống khác để chia sẻ và truyền dữ liệu.
Hiệu suất: Yêu cầu về hiệu suất để đảm bảo rằng phần mềm hoạt động
một cách nhanh chóng và mượt mà.
Độ tin cậy: Yêu cầu độ tin cậy để đảm bảo rằng phần mềm không gây
ra lỗi, sự cố hoặc mất dữ liệu.
4
An ninh: Yêu cầu về an ninh để đảm bảo rằng phần mềm được bảo vệ
chống lại các cuộc tấn công và lỗ hổng bảo mật.
Khả năng mở rộng: Yêu cầu về khả năng mở rộng để đảm bảo rằng
phần mềm có thể mở rộng và tích hợp với các hệ thống khác.
Khả năng tương thích: Yêu cầu về khả năng tương thích để đảm bảo
rằng phần mềm có thể hoạt động trên các hệ điều hành khác nhau và
với các phiên bản khác nhau của các công nghệ khác nhau.
Dễ sử dụng: Yêu cầu về dễ sử dụng để đảm bảo rằng người sử dụng có
thể sử dụng phần mềm một cách dễ dàng và không gặp phải khó khăn
trong việc tìm hiểu cách sử dụng.
Tính linh hoạt: Yêu cầu về tính linh hoạt để đảm bảo rằng phần mềm
có thể tùy chỉnh và cấu hình cho các nhu cầu đặc biệt của khách hàng.
Thân thiện với người dùng: Yêu cầu về thân thiện với người dùng để
đảm bảo rằng phần mềm tạo ra trải nghiệm người dùng tốt và thân
thiện.
Visual Studio là một môi trường phát triển tích hợp (IDE) do Microsoft thiết
kế, chủ yếu sử dụng cho việc phát triển ứng dụng trên nền tảng Microsoft. Dưới
đây là một tóm tắt về Visual Studio khi bạn sử dụng ngôn ngữ lập trình C#:
Môi trường IDE: Visual Studio cung cấp một giao diện người dùng thân
thiện, giúp bạn dễ dàng phát triển, chạy và gỡ lỗi ứng dụng.
Hỗ trợ C#: Visual Studio là một IDE mạnh mẽ cho ngôn ngữ lập trình C#,
giúp bạn tạo, quản lý và triển khai ứng dụng một cách thuận tiện.
Debugger Tích hợp: Bạn có thể sử dụng bộ debugger mạnh mẽ để theo
dõi và gỡ lỗi mã nguồn, giúp bạn nhanh chóng tìm và sửa lỗi.
Source Control: Visual Studio tích hợp với các hệ thống quản lý phiên bản
như Git, TFS, giúp bạn theo dõi sự thay đổi và quản lý mã nguồn.
5
Thiết kế giao diện người dùng: Cho phép bạn dễ dàng thiết kế giao diện
người dùng đồ họa mà không cần kiến thức chuyên sâu về mã nguồn.
IntelliSense: Tính năng tự động hoàn chỉnh mã giúp bạn viết mã nhanh
chóng và hiệu quả.
Tích hợp Azure: Hỗ trợ tích hợp với dịch vụ đám mây Azure, giúp bạn
triển khai và quản lý ứng dụng trên nền tảng đám mây của Microsoft.
Đây chỉ là một số điểm nổi bật của Visual Studio khi sử dụng với ngôn ngữ lập
trình C#. IDE này dễ dàng xây dựng ứng dụng và tối ưu hóa quy trình phát triển.
Quản lí dữ liệu : SQL Server hỗ trợ lưu trữ, truy xuất và quản lý dữ liệu
với hiệu suất cao và độ tin cậy.
Ngôn ngữ truy vấn T-SQL: Sử dụng Transact-SQL (T-SQL) để thực hiện
các truy vấn và thao tác dữ liệu.
6
Bảo mật dữ liệu: Cung cấp cơ chế bảo mật mạnh mẽ để bảo vệ dữ liệu,
bao gồm quản lý quyền truy cập và mã hóa.
Khả năng mở rộng: SQL Server hỗ trợ mô hình dữ liệu phức tạp, có khả
năng mở rộng để đáp ứng nhu cầu của các ứng dụng doanh nghiệp lớn.
Quản lí hiệu suất: Cung cấp các công cụ quản lý hiệu suất, theo dõi và tối
ưu hóa truy vấn để đảm bảo hoạt động hiệu quả.
Tích hợp với công nghệ Microsoft: SQL Server chặt chẽ tích hợp với
nhiều công nghệ Microsoft khác nhau, như .NET Framework và Azure, để
tối ưu hóa quy trình phát triển và triển khai.
SQL Server đóng vai trò quan trọng trong việc lưu trữ và quản lý dữ liệu cho các
ứng dụng doanh nghiệp và là một trong những hệ quản trị cơ sở dữ liệu phổ biến
trên thị trường.
2.1. SƠ ĐỒ FHD
8
Hình 2.1: sơ đồ FHD
Từ sơ đồ FHD bên trên, thiết kế hệ thống thực hiện 2 chức năng chính đó là
Quản trị hệ thống và Quản lý CSDL về chăn nuôi. Bên trong Quản trị hệ thống
gồm: Quản lý chức năng hệ thống, Quản lý thông tin người dùng và Bảo mật,
phân quyền. Bên trong Quản lý CSDL chăn nuôi gồm: Quản lý CSDL về dịch
bệnh, thống kê, báo cáo về CSDL chăn nuôi, quản lý văn bản pháp luật về CSDL
chăn nuôi.
2.2. SƠ ĐỒ DFD
9
Hình 2.2.1: sơ đồ DFD mức ngữ cảnh
10
Hình 2.2.3: lược đồ chức năng thống kê
2.3. SƠ ĐỒ ERD
Hình 2.3a: Sơ đồ ERD quản lý về dịch bệnh, cơ sở, vùng chăn nuôi
11
Hình 2.3b: Sơ đồ ERD quản lý văn bản pháp luật về chăn nuôi
3.1.1.1. Database
use master
go
use QuanLyChanNuoi
go
12
create table GiayChungNhan(
ID int identity primary key,
NoiCap nvarchar(50) foreign key references
ToChucCapGCN(Ten),
ChiTieuDanhGia nvarchar(100)
)
13
create table ODich(
Id int identity primary key,
Ten nvarchar(100),
LoaiDichBenhId int foreign key references
LoaiDichBenh(Id),
VungId int foreign key references Vung(Id),
ChuanDoanODich nvarchar(500),
TiemPhong nvarchar(100),
BanDo nvarchar(5)
)
3.1.1.2. Tạo View
a. Tạo View ổ dịch
use master
go
use VBPhapLuat
go
15
select VBPhapLuat.Ten as VanBanPhapLuat, FileDinhKem.fileVanBan as
fileDinhKem
from VBPhapLuat
left join FileDinhKem on VbPhapLuatID = VBPhapLuat.Id
Hình 2: hiển thị khi đăng nhập tài khoản không chính xác
16
Hình 3: giao diện vào cửa sổ chính
17
namespace QuanLyKho.Core
{
class RelayCommand : ICommand
{
private readonly Action<object> _execute;
private readonly Func<object, bool> _canExecute;
3.2.2 Model
3.2.2.1: Epidemic.cs
using QuanLyKho.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QuanLyKho.Model
{
public partial class Epidemic: BaseViewModel
{
private string _DisplayName01;
public string DisplayName01 { get => _DisplayName01; set { _DisplayName01 =
value; OnPropertyChanged(); } }
namespace QuanLyKho.Model
{
public partial class LegalDocument: BaseViewModel
{
private string _DisplayName;
public string DisplayName { get => _DisplayName; set { _DisplayName =
value; OnPropertyChanged(); } }
public LegalDocument() { }
}
3.2.2.3 Stactical.cs
using QuanLyKho.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QuanLyKho.Model
{
public partial class Statistical : BaseViewModel
{
private string _DisplayName;
public string DisplayName { get => _DisplayName; set { _DisplayName =
value; OnPropertyChanged(); } }
19
private int _Quantity;
public int Quantity { get => _Quantity; set { _Quantity = value;
OnPropertyChanged(); } }
private int _Id;
public int Id { get => _Id; set { _Id = value;
OnPropertyChanged(); } }
public Statistical() { }
namespace QuanLyKho.ViewModel
{
public class BaseViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
20
}
namespace QuanLyKho.ViewModel
{
public class ControlBarViewModel : BaseViewModel
{
#region commands
public ICommand CloseWindowCommand { get; set; }
public ICommand MaximizeWindowCommand { get; set; }
public ICommand MinimizeWindowCommand { get; set; }
public ICommand MouseMoveWindowCommand { get; set; }
#endregion
public ControlBarViewModel()
{
CloseWindowCommand = new RelayCommand<UserControl>((p)=> { return
p == null? false : true; }, (p)=> {
FrameworkElement window = GetWindowParent(p);
var w = window as Window;
21
if (w != null)
{
w.Close();
}
}
);
MaximizeWindowCommand = new RelayCommand<UserControl>((p) => {
return p == null ? false : true; }, (p) =>
{
FrameworkElement window = GetWindowParent(p);
var w = window as Window;
if (w != null)
{
if (w.WindowState != WindowState.Maximized)
w.WindowState = WindowState.Maximized;
else
w.WindowState = WindowState.Normal;
}
}
);
MinimizeWindowCommand = new RelayCommand<UserControl>((p) => {
return p == null ? false : true; }, (p) =>
{
FrameworkElement window = GetWindowParent(p);
var w = window as Window;
if (w != null)
{
if (w.WindowState != WindowState.Minimized)
w.WindowState = WindowState.Minimized;
else
w.WindowState = WindowState.Maximized;
}
}
);
MouseMoveWindowCommand = new RelayCommand<UserControl>((p) => {
return p == null ? false : true; }, (p) =>
{
FrameworkElement window = GetWindowParent(p);
var w = window as Window;
if (w != null)
{
w.DragMove();
}
}
);
}
FrameworkElement GetWindowParent(UserControl p)
{
FrameworkElement parent = p;
22
}
return parent;
}
}
}
3.2.3.3 EpidemicViewModel.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace QuanLyKho.ViewModel
{
public class ControlBarViewModel : BaseViewModel
{
#region commands
public ICommand CloseWindowCommand { get; set; }
public ICommand MaximizeWindowCommand { get; set; }
public ICommand MinimizeWindowCommand { get; set; }
public ICommand MouseMoveWindowCommand { get; set; }
#endregion
public ControlBarViewModel()
{
CloseWindowCommand = new RelayCommand<UserControl>((p)=> { return
p == null? false : true; }, (p)=> {
FrameworkElement window = GetWindowParent(p);
var w = window as Window;
if (w != null)
{
w.Close();
}
}
);
MaximizeWindowCommand = new RelayCommand<UserControl>((p) => {
return p == null ? false : true; }, (p) =>
{
FrameworkElement window = GetWindowParent(p);
var w = window as Window;
if (w != null)
{
if (w.WindowState != WindowState.Maximized)
w.WindowState = WindowState.Maximized;
else
w.WindowState = WindowState.Normal;
}
}
);
23
MinimizeWindowCommand = new RelayCommand<UserControl>((p) => {
return p == null ? false : true; }, (p) =>
{
FrameworkElement window = GetWindowParent(p);
var w = window as Window;
if (w != null)
{
if (w.WindowState != WindowState.Minimized)
w.WindowState = WindowState.Minimized;
else
w.WindowState = WindowState.Maximized;
}
}
);
MouseMoveWindowCommand = new RelayCommand<UserControl>((p) => {
return p == null ? false : true; }, (p) =>
{
FrameworkElement window = GetWindowParent(p);
var w = window as Window;
if (w != null)
{
w.DragMove();
}
}
);
}
FrameworkElement GetWindowParent(UserControl p)
{
FrameworkElement parent = p;
return parent;
}
}
}
3.2.3.4 HomeViewModel.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QuanLyKho.ViewModel
{
class HomeViewModel : BaseViewModel
{
24
}
3.2.3.5 LegalDocumentViewModel.cs
using QuanLyKho.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace QuanLyKho.ViewModel
{
public class LegalDocumentViewModel: BaseViewModel
{
private ObservableCollection<LegalDocument> _List = new
ObservableCollection<LegalDocument>();
public ObservableCollection<LegalDocument> List { get => _List; set { _List = value;
OnPropertyChanged(); } }
namespace QuanLyKho.ViewModel
{
public class LegalDocumentViewModel: BaseViewModel
{
private ObservableCollection<LegalDocument> _List = new
ObservableCollection<LegalDocument>();
public ObservableCollection<LegalDocument> List { get => _List; set
{ _List = value; OnPropertyChanged(); } }
27
namespace QuanLyKho.ViewModel
{
public class MainViewModel : BaseViewModel
{
public object _currentView;
public object CurrentView
{
get { return _currentView; }
set { _currentView = value; OnPropertyChanged(); }
}
//if (!Isloaded)
//{
// Isloaded = true;
// LoginWindow loginWindow = new LoginWindow();
// loginWindow.ShowDialog();
//}
if (loginWindow.DataContext == null)
return;
if (loginVM.IsLogin)
{
p.Show();
}
else
{
p.Close();
28
}
}
);
// Startup Page
CurrentView = new HomeViewModel();
}
}
}
3.2.3.8:StatiscalViewModel.cs
using QuanLyKho.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace QuanLyKho.ViewModel
{
public class StatisticalViewModel: BaseViewModel
{
private ObservableCollection<Statistical> _List = new
ObservableCollection<Statistical>();
public ObservableCollection<Statistical> List { get => _List; set
{ _List = value; OnPropertyChanged(); } }
29
set { _SelectedItem = value;
OnPropertyChanged();
if (SelectedItem != null)
{
DisplayName = SelectedItem.DisplayName;
Quantity = SelectedItem.Quantity;
}
}
}
public StatisticalViewModel()
{
AddCommand = new RelayCommand<object>((p) =>
{
if (DisplayName == null || Quantity == 0) return true;
return true;
}, (p) => {
List.Add(new Statistical(List.Count + 1, DisplayName,
Quantity));
});
30
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace QuanLyKho.View
{
/// <summary>
/// Interaction logic for Epidemic.xaml
/// </summary>
public partial class Epidemic : Window
{
public Epidemic()
{
InitializeComponent();
}
3.2.3.9 Epidemic.xaml
<Window x:Class="QuanLyKho.View.Epidemic"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:QuanLyKho.View"
mc:Ignorable="d"
xmlns:uc="clr-namespace:QuanLyKho.UserControlKteam"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
ResizeMode="NoResize"
WindowStyle="None"
WindowStartupLocation="CenterScreen"
Name="epidemic"
DataContext="{StaticResource EpidemicVM}"
Title="Quản lý dịch bệnh" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<uc:ControlBarUC Tag="{Binding Title,
ElementName=epidemic}"></uc:ControlBarUC>
</Grid>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
31
<RowDefinition ></RowDefinition>
</Grid.RowDefinitions>
<materialDesign:Card Grid.Row="0" >
<WrapPanel>
<TextBox Text="{Binding DisplayName01}" Margin="5 5 15 5"
materialDesign:HintAssist.Hint="Tên Dịch"
Style="{StaticResource
MaterialDesignFloatingHintTextBox}" />
<TextBox Text="{Binding DisplayName02}" Margin="5"
materialDesign:HintAssist.Hint="Triệu chứng"
Style="{StaticResource
MaterialDesignFloatingHintTextBox}" />
<TextBox Text="{Binding DisplayName03}" Margin="5"
materialDesign:HintAssist.Hint="Chuẩn đoán ổ Dịch"
Style="{StaticResource
MaterialDesignFloatingHintTextBox}" />
<TextBox Text="{Binding DisplayName04}" Margin="5"
materialDesign:HintAssist.Hint="Thông tin ổ dịch"
Style="{StaticResource
MaterialDesignFloatingHintTextBox}" />
<TextBox Text="{Binding DisplayName05}" Margin="5"
materialDesign:HintAssist.Hint="Tiêm Phòng"
Style="{StaticResource
MaterialDesignFloatingHintTextBox}" />
<TextBox Text="{Binding DisplayName06}" Margin="5"
materialDesign:HintAssist.Hint="Bản đồ"
Style="{StaticResource
MaterialDesignFloatingHintTextBox}" />
</WrapPanel>
</materialDesign:Card>
<materialDesign:Card Grid.Row="1" Margin="5">
<WrapPanel>
<Button Command="{Binding AddCommand}" Content="Thêm"
Margin="5" Width="100" ></Button>
<Button Command="{Binding EditCommand}" Content="Sửa"
Margin="5" Width="100"></Button>
<Button Command="{Binding DeleteCommand}" Content="Xóa"
Margin="5" Width="100"></Button>
</WrapPanel>
</materialDesign:Card>
<materialDesign:Card Grid.Row="2" Margin="5"
VerticalAlignment="Stretch">
<ListView ItemsSource="{Binding List}" SelectedItem="{Binding
SelectedItem,Mode=OneWayToSource}">
<ListView.View>
<GridView>
<GridViewColumn Header="Id"
DisplayMemberBinding="{Binding Id }"></GridViewColumn>
<GridViewColumn Header="Tên Dịch"
DisplayMemberBinding="{Binding DisplayName01 }"></GridViewColumn>
<GridViewColumn Header="Tên Triệu chứng"
DisplayMemberBinding="{Binding DisplayName02 }"></GridViewColumn>
<GridViewColumn Header="Chuẩn Đoán ổ dịch"
DisplayMemberBinding="{Binding DisplayName03 }"></GridViewColumn>
32
<GridViewColumn Header="Thông tin ổ dịch"
DisplayMemberBinding="{Binding DisplayName04 }"></GridViewColumn>
<GridViewColumn Header="Tiêm phòng"
DisplayMemberBinding="{Binding DisplayName05 }"></GridViewColumn>
<GridViewColumn Header="Bản đồ"
DisplayMemberBinding="{Binding DisplayName06 }"></GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</materialDesign:Card>
</Grid>
</Grid>
</Window>
mic.xaml
3.2.3.10 LegalDocument.xaml.cs
using QuanLyKho.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace QuanLyKho.View
{
/// <summary>
/// Interaction logic for LegalDocument.xaml
/// </summary>
public partial class LegalDocument : Window
{
public ICommand AddCommand { get; set; }
public LegalDocument()
{
InitializeComponent();
}
}
}
3.2.3.10 LegalDocument.xaml
<Window x:Class="QuanLyKho.View.LegalDocument"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
33
xmlns:local="clr-namespace:QuanLyKho.View"
mc:Ignorable="d"
xmlns:uc="clr-namespace:QuanLyKho.UserControlKteam"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
ResizeMode="NoResize"
WindowStyle="None"
WindowStartupLocation="CenterScreen"
Name="legalDocument"
DataContext="{StaticResource LegalDocumentVM}"
Title="Văn bản pháp luật" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<uc:ControlBarUC Tag="{Binding Title,
ElementName=legalDocument}"></uc:ControlBarUC>
</Grid>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition ></RowDefinition>
</Grid.RowDefinitions>
<materialDesign:Card Grid.Row="0" Margin="5" >
<WrapPanel>
<TextBox Text="{Binding DisplayName}"
materialDesign:HintAssist.Hint="Tên Văn Bản"
Style="{StaticResource
MaterialDesignFloatingHintTextBox}" Width="100" />
<TextBox Text="{Binding Quantity}"
materialDesign:HintAssist.Hint="Link văn bản"
Style="{StaticResource
MaterialDesignFloatingHintTextBox}" Width="100" />
</WrapPanel>
</materialDesign:Card>
<materialDesign:Card Grid.Row="1" Margin="5">
<WrapPanel>
<Button Command="{Binding AddCommand}" Content="Thêm"
Margin="5" Width="100" ></Button>
34
<Button Command="{Binding EditCommand}" Content="Sửa"
Margin="5" Width="100"></Button>
<Button Command="{Binding DeleteCommand}" Content="Xóa"
Margin="5" Width="100"></Button>
</WrapPanel>
</materialDesign:Card>
<materialDesign:Card Grid.Row="2" Margin="5"
VerticalAlignment="Stretch" Width="auto">
<ListView ItemsSource="{Binding List}" SelectedItem="{Binding
SelectedItem,Mode=OneWayToSource}">
<ListView.View>
<GridView>
<GridViewColumn Header="STT"
DisplayMemberBinding="{Binding Id }"></GridViewColumn>
<GridViewColumn Width="200" Header="Tên văn bản"
DisplayMemberBinding="{Binding DisplayName }"></GridViewColumn>
<GridViewColumn Header="Đường link văn bản"
DisplayMemberBinding="{Binding Quantity }"></GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</materialDesign:Card>
</Grid>
</Grid>
</Window>
3.2.3.11:statiscal.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace QuanLyKho.View
{
/// <summary>
/// Interaction logic for Statistical.xaml
/// </summary>
public partial class Statistical : Window
{
public Statistical()
{
InitializeComponent();
}
}
}
}
3.2.3.11:statistical.xaml
<Window x:Class="QuanLyKho.View.Statistical"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:QuanLyKho.View"
mc:Ignorable="d"
xmlns:uc="clr-namespace:QuanLyKho.UserControlKteam"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
ResizeMode="NoResize"
WindowStyle="None"
WindowStartupLocation="CenterScreen"
Name="statistical"
DataContext="{StaticResource StatisticalVM}"
Title="Bảng thống kê" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition></RowDefinition>
36
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<uc:ControlBarUC Tag="{Binding Title,
ElementName=statistical}"></uc:ControlBarUC>
</Grid>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition ></RowDefinition>
</Grid.RowDefinitions>
<materialDesign:Card Grid.Row="0" Margin="5" >
<WrapPanel>
<TextBox Text="{Binding DisplayName}"
materialDesign:HintAssist.Hint="Tên thống Kê"
Style="{StaticResource
MaterialDesignFloatingHintTextBox}" Width="400"
TextChanged="TextBox_TextChanged" />
<TextBox Text="{Binding Quantity}"
materialDesign:HintAssist.Hint="Số Lượng"
Style="{StaticResource
MaterialDesignFloatingHintTextBox}" Width="100"
TextChanged="TextBox_TextChanged_1" />
</WrapPanel>
</materialDesign:Card>
<materialDesign:Card Grid.Row="1" Margin="5">
<WrapPanel>
<Button Command="{Binding AddCommand}" Content="Thêm"
Margin="5" Width="100" Click="Button_Click" ></Button>
<Button Command="{Binding EditCommand}" Content="Sửa"
Margin="5" Width="100"></Button>
<Button Command="{Binding DeleteCommand}" Content="Xóa"
Margin="5" Width="100"></Button>
</WrapPanel>
</materialDesign:Card>
<materialDesign:Card Grid.Row="2" Margin="5"
VerticalAlignment="Stretch" Width="auto">
<ListView ItemsSource="{Binding List}" SelectedItem="{Binding
SelectedItem,Mode=OneWayToSource}"
SelectionChanged="ListView_SelectionChanged">
<ListView.View>
<GridView>
<GridViewColumn Header="STT"
DisplayMemberBinding="{Binding Id }"></GridViewColumn>
<GridViewColumn Header="Thống Kê báo cáo"
DisplayMemberBinding="{Binding DisplayName}"></GridViewColumn>
<GridViewColumn Header="Số Lượng"
DisplayMemberBinding="{Binding Quantity}"></GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</materialDesign:Card>
</Grid>
37
</Grid>
</Window>
3.2.4.2 App.xaml
<Application x:Class="QuanLyKho.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:QuanLyKho"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/
MaterialDesignTheme.Light.xaml" />
<ResourceDictionary
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/
MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary
Source="pack://application:,,,/MaterialDesignColors;component/Themes/
Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
<ResourceDictionary
Source="pack://application:,,,/MaterialDesignColors;component/Themes/
Recommended/Accent/MaterialDesignColor.Lime.xaml" />
<ResourceDictionary
Source="/ResourceXAML/MainResource.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
App.xaml
3.2.4.2 App.xaml.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace QuanLyKho
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
3.2.5.1 Mainwindow.xaml
<Window x:Class="QuanLyKho.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
38
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:QuanLyKho"
mc:Ignorable="d"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:uc="clr-namespace:QuanLyKho.UserControlKteam"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
ResizeMode="NoResize"
WindowStyle="None"
WindowStartupLocation="CenterScreen"
Name="mainWindow"
DataContext="{StaticResource MainVM}"
Title="Phần mềm quản lý cơ sở dữ liệu chăn nuôi" Height="600"
Width="1024">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding LoadedWindowCommand}"
CommandParameter="{Binding
ElementName=mainWindow}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<uc:ControlBarUC Tag="{Binding Title,
ElementName=mainWindow}"></uc:ControlBarUC>
</Grid>
<Grid Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Column="0">
</Grid>
</Grid>
</ScrollViewer>
</Grid>
<Grid Grid.Row="1">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="LightGray" Offset="1"/>
<GradientStop Color="#FFE6E6E6"/>
</LinearGradientBrush>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.Effect>
<DropShadowEffect BlurRadius="20" Color="#FFDEDEDE"
RenderingBias="Quality" ShadowDepth="1"/>
</Grid.Effect>
<Grid Background="#FFA46FE4">
<TextBlock Text="TRANG QUẢN LÝ"
HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="WS Simple
Gallifreyan" Foreground="Black" FontSize="16"/>
</Grid>
<StackPanel Grid.Row="1">
<Button Margin="10" Background="#FF8522BD"
BorderBrush="#FF8522BD">
<Grid Width="150">
<materialDesign:PackIcon Kind="ViewDashboard"
VerticalAlignment="Center"/>
<TextBlock HorizontalAlignment="Center"
Text="TRANG CHỦ" FontFamily="Champagne & Limousines"/>
</Grid>
</Button>
40
<TextBlock HorizontalAlignment="Center" Text="TÀI
KHOẢN" FontFamily="Champagne & Limousines"/>
</Grid>
</Button>
namespace QuanLyKho
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
//http://materialdesigninxaml.net/home
public MainWindow()
{
InitializeComponent();
}
}
3.2.6.1 LoginWindow.xaml
<Window x:Class="QuanLyKho.LoginWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:QuanLyKho"
mc:Ignorable="d"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:uc="clr-namespace:QuanLyKho.UserControlKteam"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
ResizeMode="NoResize"
WindowStyle="None"
42
WindowStartupLocation="CenterScreen"
DataContext="{StaticResource LoginVM}"
Name="loginWindow"
Title="Đăng nhập" Height="300" Width="400">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<uc:ControlBarUC Tag="{Binding Title,
ElementName=loginWindow}"></uc:ControlBarUC>
</Grid>
<materialDesign:Card Grid.Row="1" Width="330" Height="150"
HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid>
<Grid.Resources>
<Style TargetType="Grid">
<Setter Property="Margin" Value="15 0 15
0"></Setter>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<TextBox materialDesign:HintAssist.Hint="Tên đăng
nhập"
Text="{Binding UserName}"
Style="{StaticResource
MaterialDesignFloatingHintTextBox}" />
</Grid>
<Grid Grid.Row="1">
<PasswordBox x:Name="FloatingPasswordBox"
materialDesign:HintAssist.Hint="Mật khẩu"
43
Style="{StaticResource
MaterialDesignFloatingHintPasswordBox}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="PasswordChanged">
<i:InvokeCommandAction Command="{Binding
PasswordChangedCommand}"
CommandParameter="{Binding
ElementName=FloatingPasswordBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</PasswordBox>
</Grid>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button Grid.Column="0"
IsDefault="True"
Style="{StaticResource
MaterialDesignRaisedButton}"
Width="110"
Command="{Binding LoginCommand}"
CommandParameter="{Binding ElementName =
loginWindow}"
ToolTip="Resource name:
MaterialDesignRaisedButton" Content="Đăng nhập"></Button>
<Button Grid.Column="1"
Style="{StaticResource
MaterialDesignRaisedButton}"
Width="110"
Command="{Binding CloseCommand}"
CommandParameter="{Binding
ElementName=loginWindow}"
Background="OrangeRed"
ToolTip="Resource name:
MaterialDesignRaisedButton" Content="Thoát"></Button>
</Grid>
44
</Grid>
</materialDesign:Card>
</Grid>
</Window>
3.2.6.2 LoginWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace QuanLyKho
{
/// <summary>
/// Interaction logic for LoginWindow.xaml
/// </summary>
public partial class LoginWindow : Window
{
public LoginWindow()
{
InitializeComponent();
}
}
}
KẾT LUẬN
Dựa trên quá trình thiết kế CSDL chăn nuôi, bản báo cáo này đã hoàn
thành các công việc cơ bản như phân tích yêu cầu, thiết kế mô hình dữ liệu, đặc
tả các chức năng của hệ thống và xây dựng sơ đồ DFD. Qua đó, hi vọng rằng hệ
thống CSDL chăn nuôi được thiết kế sẽ giúp cho các cơ quan, tổ chức trong lĩnh
vực chăn nuôi có thể quản lý, theo dõi và nắm bắt thông tin chung về chăn nuôi
như tình hình dịch bênh, văn bản pháp luât, các cơ sở, vùng chăn nuôi.
45
Tuy nhiên, đây chỉ là một bài tập lớn trên giảng đường học tập, do đó hệ
thống CSDL chăn nuôi còn cần được phát triển và hoàn thiện hơn trong thực tế
để đáp ứng nhu cầu sử dụng của cơ quan nhà nước, doanh nghiệp và mang lại
hiệu quả kinh tế cao nhất.
46