Skip to content

Commit 8c58528

Browse files
committed
first commit~
0 parents  commit 8c58528

File tree

101 files changed

+4451
-0
lines changed

Some content is hidden

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

101 files changed

+4451
-0
lines changed

.vs/Dashboard/FileContentIndex/015a1306-7a0d-457b-92cb-34749e77273f.vsidx.terabox.uploading.cfg

Whitespace-only changes.

.vs/Dashboard/FileContentIndex/2d9724f1-6352-4073-bbf8-bb5af273e7c3.vsidx.terabox.uploading.cfg

Whitespace-only changes.

.vs/Dashboard/FileContentIndex/540d598d-5912-48b2-963c-2464698f3d66.vsidx.terabox.uploading.cfg

Whitespace-only changes.

.vs/Dashboard/FileContentIndex/59a98929-4909-4e45-8ba1-3c4ccd806a2d.vsidx.terabox.uploading.cfg

Whitespace-only changes.
Binary file not shown.

.vs/Dashboard/FileContentIndex/77a378cb-8327-462e-9d79-c7ac27fee877.vsidx.terabox.uploading.cfg

Whitespace-only changes.

.vs/Dashboard/FileContentIndex/874b0ad0-d1d0-4619-b79f-9f650fdda4f4.vsidx.terabox.uploading.cfg

Whitespace-only changes.

.vs/Dashboard/FileContentIndex/916c03c9-720a-4b64-bae0-f4c51f26fc1b.vsidx.terabox.uploading.cfg

Whitespace-only changes.

.vs/Dashboard/FileContentIndex/99ca81e9-aed7-48bc-aea3-914abd3cf10b.vsidx.terabox.uploading.cfg

Whitespace-only changes.

.vs/Dashboard/FileContentIndex/9a52885f-71e7-4639-bbdc-e885d3222fd7.vsidx.terabox.uploading.cfg

Whitespace-only changes.
Binary file not shown.

.vs/Dashboard/FileContentIndex/add9c1d4-07fa-4b05-9ba5-043e7cf94ad2.vsidx.terabox.uploading.cfg

Whitespace-only changes.

.vs/Dashboard/FileContentIndex/bd98d217-17f4-461e-a517-72a826ed0319.vsidx.terabox.uploading.cfg

Whitespace-only changes.

.vs/Dashboard/FileContentIndex/c3df0698-93d0-4596-8a0b-720c4cce5cf0.vsidx.terabox.uploading.cfg

Whitespace-only changes.
Binary file not shown.

.vs/Dashboard/FileContentIndex/dff9080f-a362-4f00-98cb-c5939f83e09e.vsidx.terabox.uploading.cfg

Whitespace-only changes.
Binary file not shown.
Binary file not shown.

.vs/Dashboard/FileContentIndex/read.lock

Whitespace-only changes.

.vs/Dashboard/v17/.suo

84 KB
Binary file not shown.

Dashboard.sln

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.3.32825.248
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dashboard", "Dashboard\Dashboard.csproj", "{F643BA85-A437-4185-89ED-7199C86FA167}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{F643BA85-A437-4185-89ED-7199C86FA167}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{F643BA85-A437-4185-89ED-7199C86FA167}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{F643BA85-A437-4185-89ED-7199C86FA167}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{F643BA85-A437-4185-89ED-7199C86FA167}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {F68DF63D-3A8C-4709-A773-1D932C23A565}
24+
EndGlobalSection
25+
EndGlobal

Dashboard/DAO/AccountDAO.cs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace Dashboard.DAO
9+
{
10+
public class AccountDAO
11+
{
12+
private static AccountDAO instance;
13+
14+
public static AccountDAO Instance {
15+
get { if (instance == null) instance = new AccountDAO(); return instance; }
16+
private set { instance = value; }
17+
}
18+
private AccountDAO()
19+
{
20+
21+
}
22+
private string username;
23+
public bool Login(string username, string password)
24+
{
25+
this.username = username;
26+
String query = "SELECT * FROM ACCOUNT WHERE employeeID = "+username+" AND emp_password = '"+password+"'";
27+
DataTable result = DataProvider.Instance.ExecuteQuery(query);
28+
return result.Rows.Count > 0;
29+
}
30+
public bool ChangePassword(string newpass, string oldpass)
31+
{
32+
string query = "EXECUTE Change_Password "+username+" , '"+newpass+"' , '"+oldpass+"'";
33+
int result = DataProvider.Instance.ExecuteNonQuery(query);
34+
if (result == 1)
35+
return true;
36+
else
37+
return false;
38+
}
39+
}
40+
}

Dashboard/DAO/DataProvider.cs

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data;
4+
using System.Data.SqlClient;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using System.Windows.Forms;
9+
10+
namespace Dashboard.DAO
11+
{
12+
public class DataProvider
13+
{
14+
private static DataProvider instance;
15+
public static DataProvider Instance
16+
{
17+
get { if (instance == null) instance = new DataProvider(); return DataProvider.instance; }
18+
private set { DataProvider.instance = value; }
19+
}
20+
private DataProvider() { }
21+
private static string ServerName = "DESKTOP-5A6LVJ9"; //Đổi tên lại theo Server Name của SQL
22+
private static string DatabaseName = "HEQUANTRICOSODULIEU"; //Tên database
23+
private string ConnStr = $@"Data Source={ServerName}; Initial Catalog={DatabaseName};Integrated Security=True";
24+
SqlConnection conn = null;
25+
26+
public DataTable ExecuteQuery(string query, object[] paramenter = null) //Hàm thực thi câu lệnh sqlCommand, giá trị trả về là 1 bảng giá trị
27+
{
28+
DataTable data = new DataTable(); //Khai báo biến data là 1 bảng dữ liệu
29+
using (SqlConnection conn = new SqlConnection(ConnStr)) //đảm bảo rằng đối tượng SqlConnection được giải phóng tự động sau khi sử dụng, mà không cần phải gọi phương thức Dispose() của đối tượng
30+
{
31+
conn.Open(); //Mở kết nối
32+
SqlCommand cmd = new SqlCommand(query, conn); //Thực hiện truy vấn
33+
if(paramenter != null)
34+
{
35+
string[] listPara = query.Split(' ');
36+
int i = 0; //Gọi biến chạy
37+
foreach(string item in listPara)
38+
{
39+
if(item.Contains('@'))
40+
{
41+
cmd.Parameters.AddWithValue(item, paramenter[i]);
42+
i++;
43+
}
44+
}
45+
}
46+
/* GIẢI THÍCH ĐOẠN CODE PHÍA TRÊN: Đoạn mã trên là một điều kiện IF trong ngôn ngữ lập trình C#. Nó kiểm tra xem giá trị của biến "parameter" có khác NULL hay không. Nếu khác NULL, nó sẽ thực hiện các câu lệnh trong phần thân của IF.
47+
Phần thân của IF bắt đầu bằng việc tách câu truy vấn "query" thành một danh sách các chuỗi bằng cách sử dụng phương thức Split() và chia nhỏ chuỗi thành các phần tử của một mảng. Việc chia nhỏ được thực hiện bằng cách tách các chuỗi theo khoảng trắng ' '.
48+
Sau khi có danh sách các chuỗi, vòng lặp foreach được sử dụng để duyệt qua từng phần tử trong danh sách. Nếu phần tử đó chứa ký tự '@', nó được coi là một tham số và thêm giá trị của tham số này vào trong đối tượng SqlCommand cmd bằng cách sử dụng phương thức AddWithValue(). Tham số này được lấy từ mảng "parameter" bằng cách sử dụng biến "i" như một chỉ mục để lấy giá trị tương ứng.
49+
Đoạn mã này thường được sử dụng để thêm các tham số vào câu truy vấn SQL để tránh các lỗ hổng bảo mật, cũng như đảm bảo tính nhất quán và độ tin cậy của câu truy vấn.*/
50+
try
51+
{
52+
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
53+
adapter.Fill(data); //Lấy dữ liệu từ một nguồn dữ liệu và đổ dữ liệu này vào một đối tượng data.
54+
}
55+
catch(SqlException ex)
56+
{
57+
MessageBox.Show("Có lỗi rồi! \n TÊN LỖI: " + ex.Message + "\n MÃ LỖI:" + ex.ErrorCode, "ERROR!",MessageBoxButtons.OK, MessageBoxIcon.Error);
58+
}
59+
conn.Close(); //Đóng kết nối
60+
}
61+
return data; //Trả về giá trị data
62+
}
63+
public int ExecuteNonQuery(string query, object[] parament = null) //Hàm trả về giá trị số cột
64+
{
65+
int data = 0;
66+
using (SqlConnection conn = new SqlConnection(ConnStr))
67+
{
68+
conn.Open();
69+
SqlCommand cmd = new SqlCommand(query, conn);
70+
if (parament != null)
71+
{
72+
string[] listPara = query.Split(' ');
73+
int i = 0;
74+
foreach (string item in listPara)
75+
{
76+
if (item.Contains('@'))
77+
{
78+
cmd.Parameters.AddWithValue(item, parament[i]);
79+
i++;
80+
}
81+
}
82+
}
83+
try
84+
{
85+
data = cmd.ExecuteNonQuery();
86+
}
87+
catch(SqlException ex)
88+
{
89+
MessageBox.Show("Có lỗi rồi! \n TÊN LỖI: " + ex.Message + "\n MÃ LỖI:" + ex.ErrorCode, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
90+
}
91+
conn.Close();
92+
}
93+
return data;
94+
}
95+
public object ExecuteScalar(string query, object[] parament = null) //Thực thi query trả về giá trị đầu tiên của kết quả
96+
{
97+
object data = 0;
98+
using (SqlConnection conn = new SqlConnection(ConnStr))
99+
{
100+
conn.Open();
101+
SqlCommand cmd = new SqlCommand(query, conn);
102+
if (parament != null)
103+
{
104+
string[] listPara = query.Split(' ');
105+
int i = 0;
106+
foreach (string item in listPara)
107+
{
108+
if (item.Contains('@'))
109+
{
110+
cmd.Parameters.AddWithValue(item, parament[i]);
111+
i++;
112+
}
113+
}
114+
}
115+
try
116+
{
117+
data = cmd.ExecuteScalar();
118+
}
119+
catch (SqlException ex)
120+
{
121+
MessageBox.Show("Có lỗi rồi! \n TÊN LỖI: " + ex.Message + "\n MÃ LỖI:" + ex.ErrorCode, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
122+
}
123+
conn.Close();
124+
}
125+
return data;
126+
}
127+
}
128+
}

Dashboard/Dashboard.csproj

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{F643BA85-A437-4185-89ED-7199C86FA167}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>Dashboard</RootNamespace>
10+
<AssemblyName>Dashboard</AssemblyName>
11+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Deployment" />
43+
<Reference Include="System.Drawing" />
44+
<Reference Include="System.Net.Http" />
45+
<Reference Include="System.Windows.Forms" />
46+
<Reference Include="System.Xml" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<Compile Include="DAO\AccountDAO.cs" />
50+
<Compile Include="DAO\DataProvider.cs" />
51+
<Compile Include="GUI\Dashboard.cs">
52+
<SubType>Form</SubType>
53+
</Compile>
54+
<Compile Include="GUI\Dashboard.Designer.cs">
55+
<DependentUpon>Dashboard.cs</DependentUpon>
56+
</Compile>
57+
<Compile Include="GUI\Login.cs">
58+
<SubType>Form</SubType>
59+
</Compile>
60+
<Compile Include="GUI\Login.Designer.cs">
61+
<DependentUpon>Login.cs</DependentUpon>
62+
</Compile>
63+
<Compile Include="GUI\Panel\Account\ChangePassword.cs">
64+
<SubType>Form</SubType>
65+
</Compile>
66+
<Compile Include="GUI\Panel\Account\ChangePassword.Designer.cs">
67+
<DependentUpon>ChangePassword.cs</DependentUpon>
68+
</Compile>
69+
<Compile Include="GUI\Panel\Bill.cs">
70+
<SubType>Form</SubType>
71+
</Compile>
72+
<Compile Include="GUI\Panel\Bill.Designer.cs">
73+
<DependentUpon>Bill.cs</DependentUpon>
74+
</Compile>
75+
<Compile Include="GUI\Panel\Account\Account.cs">
76+
<SubType>Form</SubType>
77+
</Compile>
78+
<Compile Include="GUI\Panel\Account\Account.Designer.cs">
79+
<DependentUpon>Account.cs</DependentUpon>
80+
</Compile>
81+
<Compile Include="Program.cs" />
82+
<Compile Include="Properties\AssemblyInfo.cs" />
83+
<EmbeddedResource Include="GUI\Dashboard.resx">
84+
<DependentUpon>Dashboard.cs</DependentUpon>
85+
</EmbeddedResource>
86+
<EmbeddedResource Include="GUI\Login.resx">
87+
<DependentUpon>Login.cs</DependentUpon>
88+
</EmbeddedResource>
89+
<EmbeddedResource Include="GUI\Panel\Account\ChangePassword.resx">
90+
<DependentUpon>ChangePassword.cs</DependentUpon>
91+
</EmbeddedResource>
92+
<EmbeddedResource Include="GUI\Panel\Bill.resx">
93+
<DependentUpon>Bill.cs</DependentUpon>
94+
</EmbeddedResource>
95+
<EmbeddedResource Include="GUI\Panel\Account\Account.resx">
96+
<DependentUpon>Account.cs</DependentUpon>
97+
</EmbeddedResource>
98+
<EmbeddedResource Include="Properties\Resources.resx">
99+
<Generator>ResXFileCodeGenerator</Generator>
100+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
101+
<SubType>Designer</SubType>
102+
</EmbeddedResource>
103+
<Compile Include="Properties\Resources.Designer.cs">
104+
<AutoGen>True</AutoGen>
105+
<DependentUpon>Resources.resx</DependentUpon>
106+
</Compile>
107+
<None Include="Properties\Settings.settings">
108+
<Generator>SettingsSingleFileGenerator</Generator>
109+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
110+
</None>
111+
<Compile Include="Properties\Settings.Designer.cs">
112+
<AutoGen>True</AutoGen>
113+
<DependentUpon>Settings.settings</DependentUpon>
114+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
115+
</Compile>
116+
</ItemGroup>
117+
<ItemGroup>
118+
<None Include="GUI\App.config" />
119+
</ItemGroup>
120+
<ItemGroup>
121+
<Folder Include="DTO\" />
122+
</ItemGroup>
123+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
124+
</Project>

Dashboard/GUI/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
5+
</startup>
6+
</configuration>

0 commit comments

Comments
 (0)