Skip to content

Commit 5c7463f

Browse files
committed
Fixed duplicate input name
1 parent e31361e commit 5c7463f

Some content is hidden

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

43 files changed

+484
-9
lines changed

Diff for: .vs/DNSManager/DesignTimeBuild/.dtbcache.v2

0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Diff for: .vs/DNSManager/v17/.futdcache.v2

128 Bytes
Binary file not shown.

Diff for: .vs/DNSManager/v17/.suo

-5.5 KB
Binary file not shown.

Diff for: .vs/ProjectEvaluation/dnsmanager.metadata.v6.1

1.28 KB
Binary file not shown.

Diff for: .vs/ProjectEvaluation/dnsmanager.projects.v6.1

88.9 KB
Binary file not shown.

Diff for: DNSManager/Form1.Designer.cs

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: DNSManager/Form1.cs

+26
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ private void buttonAdd_Click(object sender, EventArgs e)
9393
return;
9494
}
9595

96+
if (checkName(name))
97+
{
98+
MessageBox.Show("The DNS name must not be duplicated.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
99+
return;
100+
}
101+
96102
if (!IsDnsFormatValid(dns1) && !IsDnsFormatValid(dns2))
97103
{
98104
MessageBox.Show("Please enter valid format.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
@@ -118,6 +124,26 @@ private void insert(string name, string dns1, string dns2)
118124
insertCommand.ExecuteNonQuery();
119125
}
120126

127+
private bool checkName(string name)
128+
{
129+
130+
var selectQuery = "SELECT Name FROM DNS";
131+
var selectCommand = new SQLiteCommand(selectQuery, _connection);
132+
var reader = selectCommand.ExecuteReader();
133+
134+
while (reader.Read())
135+
{
136+
if (reader.GetString(0) == name)
137+
{
138+
return true;
139+
}
140+
}
141+
142+
reader.Close();
143+
144+
return false;
145+
}
146+
121147
private void buttonDelete_Click(object sender, EventArgs e)
122148
{
123149
var name = comboBoxDNS.SelectedItem?.ToString();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project>
6+
<PropertyGroup>
7+
<ApplicationRevision>0</ApplicationRevision>
8+
<ApplicationVersion>0.1.0.*</ApplicationVersion>
9+
<BootstrapperEnabled>True</BootstrapperEnabled>
10+
<Configuration>Release</Configuration>
11+
<CreateWebPageOnPublish>False</CreateWebPageOnPublish>
12+
<GenerateManifests>true</GenerateManifests>
13+
<Install>True</Install>
14+
<InstallFrom>Disk</InstallFrom>
15+
<IsRevisionIncremented>True</IsRevisionIncremented>
16+
<IsWebBootstrapper>False</IsWebBootstrapper>
17+
<MapFileExtensions>True</MapFileExtensions>
18+
<OpenBrowserOnPublish>False</OpenBrowserOnPublish>
19+
<Platform>Any CPU</Platform>
20+
<PublishDir>bin\Release\net6.0-windows\app.publish\</PublishDir>
21+
<PublishUrl>bin\publish\</PublishUrl>
22+
<PublishProtocol>ClickOnce</PublishProtocol>
23+
<PublishReadyToRun>False</PublishReadyToRun>
24+
<PublishSingleFile>False</PublishSingleFile>
25+
<SelfContained>False</SelfContained>
26+
<SignatureAlgorithm>(none)</SignatureAlgorithm>
27+
<SignManifests>False</SignManifests>
28+
<TargetFramework>net6.0-windows</TargetFramework>
29+
<UpdateEnabled>False</UpdateEnabled>
30+
<UpdateMode>Foreground</UpdateMode>
31+
<UpdateRequired>False</UpdateRequired>
32+
<WebPageFileName>Publish.html</WebPageFileName>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<BootstrapperPackage Include="Microsoft.NetCore.DesktopRuntime.6.0.x64">
36+
<Install>True</Install>
37+
<ProductName>.NET Desktop Runtime 6.0.14 (x64)</ProductName>
38+
</BootstrapperPackage>
39+
</ItemGroup>
40+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project>
6+
<PropertyGroup>
7+
<History>False|2023-05-22T00:11:32.2299052Z;</History>
8+
<LastFailureDetails />
9+
</PropertyGroup>
10+
</Project>

Diff for: DNSManager/bin/Debug/net6.0-windows/DNSManager.dll

512 Bytes
Binary file not shown.

Diff for: DNSManager/bin/Debug/net6.0-windows/DNSManager.pdb

164 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)