├── .gitattributes
├── .gitignore
├── LICENSE.txt
├── README.md
├── SIPAM.sln
└── SIPAM
├── App.config
├── App.xaml
├── App.xaml.cs
├── ApplyWindow.xaml
├── ApplyWindow.xaml.cs
├── DbOperation
├── DbClass.cs
└── MySqlKeepAlive.cs
├── EncryptionDecryptionFunction
└── MD5EncryptionDecryption.cs
├── GlobalFunction
├── DbConfigOperate.cs
└── IpAddressConvert.cs
├── GlobalVariable
└── Variable.cs
├── ICON.ico
├── Language
└── zh-CN.xaml
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── MainWindowPage
├── DBSettingPage.xaml
├── DBSettingPage.xaml.cs
├── LoginPage.xaml
└── LoginPage.xaml.cs
├── ManagePage
├── About.xaml
├── About.xaml.cs
├── AddressManage.xaml
├── AddressManage.xaml.cs
├── Approve.xaml
├── Approve.xaml.cs
├── GroupManage.xaml
├── GroupManage.xaml.cs
├── Organization.xaml
├── Organization.xaml.cs
├── User.xaml
└── User.xaml.cs
├── ManageWindow.xaml
├── ManageWindow.xaml.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── RegisterWindow.xaml
├── RegisterWindow.xaml.cs
├── Resources
├── ICON.ico
└── 待办事项.svg
├── SIPAM.csproj
├── UserPage
├── ApplyPage.xaml
├── ApplyPage.xaml.cs
├── MyAddress.xaml
└── MyAddress.xaml.cs
├── ViewModes
└── ViewModes.cs
├── Windows
├── ChangePasswordWindow.xaml
└── ChangePasswordWindow.xaml.cs
├── auzq3-didx5-001.ico
├── packages.config
└── 全部资产.ico
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Oo]ut/
33 | [Ll]og/
34 | [Ll]ogs/
35 |
36 | # Visual Studio 2015/2017 cache/options directory
37 | .vs/
38 | # Uncomment if you have tasks that create the project's static files in wwwroot
39 | #wwwroot/
40 |
41 | # Visual Studio 2017 auto generated files
42 | Generated\ Files/
43 |
44 | # MSTest test Results
45 | [Tt]est[Rr]esult*/
46 | [Bb]uild[Ll]og.*
47 |
48 | # NUnit
49 | *.VisualState.xml
50 | TestResult.xml
51 | nunit-*.xml
52 |
53 | # Build Results of an ATL Project
54 | [Dd]ebugPS/
55 | [Rr]eleasePS/
56 | dlldata.c
57 |
58 | # Benchmark Results
59 | BenchmarkDotNet.Artifacts/
60 |
61 | # .NET Core
62 | project.lock.json
63 | project.fragment.lock.json
64 | artifacts/
65 |
66 | # ASP.NET Scaffolding
67 | ScaffoldingReadMe.txt
68 |
69 | # StyleCop
70 | StyleCopReport.xml
71 |
72 | # Files built by Visual Studio
73 | *_i.c
74 | *_p.c
75 | *_h.h
76 | *.ilk
77 | *.meta
78 | *.obj
79 | *.iobj
80 | *.pch
81 | *.pdb
82 | *.ipdb
83 | *.pgc
84 | *.pgd
85 | *.rsp
86 | *.sbr
87 | *.tlb
88 | *.tli
89 | *.tlh
90 | *.tmp
91 | *.tmp_proj
92 | *_wpftmp.csproj
93 | *.log
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio LightSwitch build output
298 | **/*.HTMLClient/GeneratedArtifacts
299 | **/*.DesktopClient/GeneratedArtifacts
300 | **/*.DesktopClient/ModelManifest.xml
301 | **/*.Server/GeneratedArtifacts
302 | **/*.Server/ModelManifest.xml
303 | _Pvt_Extensions
304 |
305 | # Paket dependency manager
306 | .paket/paket.exe
307 | paket-files/
308 |
309 | # FAKE - F# Make
310 | .fake/
311 |
312 | # CodeRush personal settings
313 | .cr/personal
314 |
315 | # Python Tools for Visual Studio (PTVS)
316 | __pycache__/
317 | *.pyc
318 |
319 | # Cake - Uncomment if you are using it
320 | # tools/**
321 | # !tools/packages.config
322 |
323 | # Tabs Studio
324 | *.tss
325 |
326 | # Telerik's JustMock configuration file
327 | *.jmconfig
328 |
329 | # BizTalk build output
330 | *.btp.cs
331 | *.btm.cs
332 | *.odx.cs
333 | *.xsd.cs
334 |
335 | # OpenCover UI analysis results
336 | OpenCover/
337 |
338 | # Azure Stream Analytics local run output
339 | ASALocalRun/
340 |
341 | # MSBuild Binary and Structured Log
342 | *.binlog
343 |
344 | # NVidia Nsight GPU debugger configuration file
345 | *.nvuser
346 |
347 | # MFractors (Xamarin productivity tool) working folder
348 | .mfractor/
349 |
350 | # Local History for Visual Studio
351 | .localhistory/
352 |
353 | # BeatPulse healthcheck temp database
354 | healthchecksdb
355 |
356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
357 | MigrationBackup/
358 |
359 | # Ionide (cross platform F# VS Code tools) working folder
360 | .ionide/
361 |
362 | # Fody - auto-generated XML schema
363 | FodyWeavers.xsd
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) [year] [fullname]
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SIPAM
2 |
3 | 需要sqlite单用户本地版的请移步IPAM-NOTE项目
4 |
5 | https://github.com/yaobus/IPAM-NOTE.git
6 |
7 | 一、前言
8 |
9 | SIPAM主要用于解决工作中需要对多个网段的IP地址进行分配的工作
10 |
11 | 软件基于C#开发的PC客户端和mariaDB
12 |
13 | 目前市面上也有开源的ipam系统,但是功能有点复杂,不适合我这种需求简单的用户
14 |
15 | 所以我自己就写了这么一坨东西,目前处于测试版,功能尚不完善,使用需谨慎!使用需谨慎!使用需谨慎!
16 |
17 | 二、软件如何使用
18 |
19 | 第一步:准备一个MariaDB(MySQL)数据库
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 | 链接: https://pan.baidu.com/s/1xA4EN3Ue9FDmGbkUp8nExw?pwd=ipam 提取码: ipam
45 |
--------------------------------------------------------------------------------
/SIPAM.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.8.34330.188
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SIPAM", "SIPAM\SIPAM.csproj", "{9997BE06-985E-44E9-A271-3C7D9E782514}"
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 | {9997BE06-985E-44E9-A271-3C7D9E782514}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {9997BE06-985E-44E9-A271-3C7D9E782514}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {9997BE06-985E-44E9-A271-3C7D9E782514}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {9997BE06-985E-44E9-A271-3C7D9E782514}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | VisualSVNWorkingCopyRoot = .
24 | SolutionGuid = {D925DB7F-0E48-43E7-9229-8B11EE1BD4DD}
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/SIPAM/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/SIPAM/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/SIPAM/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using SIPAM.DbOperation;
9 |
10 | namespace SIPAM
11 | {
12 | ///
13 | /// App.xaml 的交互逻辑
14 | ///
15 | public partial class App : Application
16 | {
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/SIPAM/ApplyWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Text.RegularExpressions;
7 | using System.Threading;
8 | using System.Threading.Tasks;
9 | using System.Windows;
10 | using System.Windows.Controls;
11 | using System.Windows.Data;
12 | using System.Windows.Documents;
13 | using System.Windows.Input;
14 | using System.Windows.Media;
15 | using System.Windows.Media.Imaging;
16 | using System.Windows.Shapes;
17 | using MySqlConnector;
18 | using SIPAM.DbOperation;
19 | using SIPAM.GlobalVariable;
20 | using static SIPAM.ViewModes.ViewModes;
21 |
22 | namespace SIPAM
23 | {
24 | ///
25 | /// ApplyWindow.xaml 的交互逻辑
26 | ///
27 | public partial class ApplyWindow : Window
28 | {
29 | public ApplyWindow()
30 | {
31 | InitializeComponent();
32 | }
33 |
34 |
35 | private void Window_Loaded(object sender, RoutedEventArgs e)
36 | {
37 | //窗口最大化
38 | // this.WindowState = WindowState.Maximized;
39 |
40 | //加载已登录用户信息
41 | TbUser.Text = Variable.UserInfo.User;
42 | TbName.Text = Variable.UserInfo.Name;
43 | TbDepartment.Text = Variable.UserInfo.Department;
44 | //SelectIpUser.Text = TbUser.Text;
45 | TbGroup.Text = Variable.UserInfo.Group;
46 | MySqlKeepAlive.Start();
47 | RbApply_OnClick(null, null);
48 |
49 |
50 | }
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | private void Window_MouseDown(object sender, MouseButtonEventArgs e)
60 | {
61 | if (e.ChangedButton == MouseButton.Left)
62 | {
63 | DragMove();
64 | }
65 | }
66 |
67 |
68 |
69 |
70 | ///
71 | /// 调整尺寸
72 | ///
73 | ///
74 | ///
75 | private void ResizeButton_Click(object sender, RoutedEventArgs e)
76 | {
77 |
78 | // 获取桌面工作区域大小
79 | double workAreaWidth = SystemParameters.WorkArea.Width;
80 | double workAreaHeight = SystemParameters.WorkArea.Height;
81 |
82 | // 将窗口大小设置为工作区域大小
83 | this.Width = workAreaWidth;
84 | this.Height = workAreaHeight;
85 | this.Left = SystemParameters.WorkArea.Left;
86 | this.Top = SystemParameters.WorkArea.Top;
87 |
88 | }
89 |
90 |
91 | ///
92 | /// 结束程序
93 | ///
94 | ///
95 | ///
96 | private void CloseButton_Click(object sender, RoutedEventArgs e)
97 | {
98 | this.Close();
99 | }
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 | private void SizeButton_OnClick(object sender, RoutedEventArgs e)
112 | {
113 | if (this.WindowState == WindowState.Normal)
114 | {
115 | this.WindowState = WindowState.Maximized;
116 | }
117 | else
118 | {
119 | this.WindowState = WindowState.Normal;
120 | }
121 | }
122 |
123 |
124 | ///
125 | /// 登出
126 | ///
127 | ///
128 | ///
129 | private void BT_LoginOut_OnClick(object sender, RoutedEventArgs e)
130 | {
131 |
132 |
133 | Window mainWindow = new MainWindow();
134 | var window = Window.GetWindow(this); //关闭父窗体
135 | window?.Close();
136 |
137 | //打开新窗口
138 | mainWindow.Show();
139 |
140 |
141 | }
142 |
143 |
144 | ///
145 | /// 加载申请界面
146 | ///
147 | ///
148 | ///
149 | private void RbApply_OnClick(object sender, RoutedEventArgs e)
150 | {
151 | ApplyOptionPlan.Children.Clear();
152 | ApplyOptionPlan.Children.Add(new UserPage.ApplyPage());
153 |
154 | }
155 |
156 | ///
157 | /// 关于
158 | ///
159 | ///
160 | ///
161 | ///
162 | private void RbAbout_OnClick(object sender, RoutedEventArgs e)
163 | {
164 | ApplyOptionPlan.Children.Clear();
165 | ApplyOptionPlan.Children.Add(new ManagePage.About());
166 | }
167 |
168 |
169 |
170 | private void RbMyAddress_OnClick(object sender, RoutedEventArgs e)
171 | {
172 | ApplyOptionPlan.Children.Clear();
173 | ApplyOptionPlan.Children.Add(new UserPage.MyAddress());
174 | }
175 | }
176 | }
177 |
--------------------------------------------------------------------------------
/SIPAM/DbOperation/DbClass.cs:
--------------------------------------------------------------------------------
1 | using MySqlConnector;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using SIPAM.GlobalVariable;
8 | using SIPAM.ManagePage;
9 | using System.Collections;
10 |
11 | namespace SIPAM.DbOperation
12 | {
13 | internal class DbClass
14 | {
15 | public static MySqlConnector.MySqlConnection MySqlConnection;
16 |
17 | //连接MYSQL数据库
18 | public static MySqlConnector.MySqlConnection ConnectionMysql(string dbConnectInfo)
19 | {
20 |
21 | MySqlConnection = new MySqlConnection(dbConnectInfo);
22 |
23 | return MySqlConnection;
24 | }
25 |
26 |
27 |
28 | ///
29 | /// 在指定的mysql连接上执行sql语句,返回MySqlDataReader
30 | ///
31 | /// sql语句
32 | ///
33 | public static MySqlDataReader CarrySqlCmd(string sql)
34 | {
35 | string query = AddressManage.ReplaceChineseComma(sql);
36 |
37 | try
38 | {
39 | if (MySqlConnection.State != System.Data.ConnectionState.Open)
40 | {
41 | MySqlConnection.Open();
42 | }
43 | }
44 | catch (Exception e)
45 | {
46 | Console.WriteLine(e);
47 | //throw;
48 | }
49 |
50 |
51 | MySqlCommand cmdCommand = new MySqlCommand(query, MySqlConnection);
52 | MySqlDataReader reader = cmdCommand.ExecuteReader();
53 |
54 | return reader;
55 |
56 |
57 | }
58 |
59 |
60 | ///
61 | /// 执行mysql修改,插入数据
62 | ///
63 | /// sql语句
64 | /// 返回受影响的行数,为int值
65 | public static int ModifySql(string sql)
66 | {
67 |
68 | string query = AddressManage.ReplaceChineseComma(sql);
69 |
70 | try
71 | {
72 | MySqlConnection = DbClass.ConnectionMysql(Variable.DbConnectInfo);
73 | MySqlConnection.Open(); //连接数据库
74 | MySqlCommand SqlCommand = new MySqlCommand(query, MySqlConnection);
75 | return SqlCommand.ExecuteNonQuery();
76 | }
77 | catch (Exception e)
78 | {
79 | Console.WriteLine(e.ToString());
80 | return 0;
81 | }
82 |
83 |
84 | }
85 |
86 |
87 | ///
88 | /// 查询表中的数据数量,返回数据条数
89 | ///
90 | ///
91 | ///
92 | public static int ExecuteScalarTableNum(string sql)
93 | {
94 | string query = AddressManage.ReplaceChineseComma(sql);
95 |
96 | using (MySqlConnection connection = new MySqlConnection(Variable.DbConnectInfo))
97 | {
98 | connection.Open();
99 |
100 |
101 | using (MySqlCommand command = new MySqlCommand(query, connection))
102 | {
103 | // 使用 ExecuteScalar 获取总行数
104 | int rowCount = Convert.ToInt32(command.ExecuteScalar());
105 |
106 | return rowCount;
107 |
108 | //MessageBox.Show( GlobalFunction.IpAddressConvert.IpToDecimal(IpTextBox.Text).ToString());
109 |
110 | }
111 |
112 |
113 | }
114 |
115 | }
116 |
117 |
118 |
119 |
120 | public static string ExecuteSql(string sql)
121 | {
122 |
123 | if (MySqlConnection.State != System.Data.ConnectionState.Open)
124 | {
125 | MySqlConnection.Open();
126 | }
127 |
128 |
129 | MySqlCommand command = new MySqlCommand(sql, MySqlConnection);
130 |
131 | command.ExecuteNonQuery();
132 |
133 |
134 |
135 | return sql;
136 | }
137 |
138 |
139 |
140 |
141 | ///
142 | /// 异步执行sql语句
143 | ///
144 | /// 要执行的SQL语句
145 | ///
146 | public static async Task ExecuteSqlAsync(string sql)
147 | {
148 | string query = AddressManage.ReplaceChineseComma(sql);
149 |
150 | // 创建 MySqlConnection 对象
151 | using (MySqlConnection connection = new MySqlConnection(Variable.DbConnectInfo))
152 | {
153 | try
154 | {
155 | // 异步打开连接
156 | await connection.OpenAsync();
157 |
158 |
159 | // 执行异步 SQL 查询
160 | using (MySqlCommand command = new MySqlCommand(query, connection))
161 | {
162 | await command.ExecuteNonQueryAsync();
163 | }
164 |
165 | }
166 | catch (Exception ex)
167 | {
168 | Console.WriteLine("Error: " + ex.Message);
169 | }
170 |
171 | }
172 |
173 |
174 |
175 | }
176 |
177 |
178 | ///
179 | /// 获取查询返回的数据
180 | ///
181 | ///
182 | ///
183 | ///
184 | public static string GetReaderString(MySqlDataReader reader, string name)
185 | {
186 |
187 |
188 | string value = (reader[name] != DBNull.Value) ? reader[name].ToString() : string.Empty;
189 |
190 |
191 |
192 | return value;
193 |
194 |
195 | }
196 |
197 |
198 | ///
199 | /// 异步执行无返回值的sql语句,并返回受影响的行数
200 | ///
201 | ///
202 | ///
203 | public static async Task ExecuteNonQueryAsync(string sql)
204 | {
205 | int rowsAffected = 0;
206 | using (MySqlConnection connection = new MySqlConnection(Variable.DbConnectInfo))
207 | {
208 |
209 |
210 |
211 | await connection.OpenAsync();
212 |
213 | using (MySqlCommand command = new MySqlCommand(sql, connection))
214 | {
215 | //// 设置参数值
216 | //command.Parameters.AddWithValue("@value1", "some_value1");
217 | //command.Parameters.AddWithValue("@value2", "some_value2");
218 |
219 | // 执行 INSERT 语句
220 | rowsAffected = await command.ExecuteNonQueryAsync();
221 | }
222 | }
223 |
224 | return rowsAffected;
225 | }
226 |
227 |
228 | }
229 | }
230 |
--------------------------------------------------------------------------------
/SIPAM/DbOperation/MySqlKeepAlive.cs:
--------------------------------------------------------------------------------
1 | using MySqlConnector;
2 | using SIPAM.GlobalVariable;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Timers;
9 |
10 | namespace SIPAM.DbOperation
11 | {
12 | public class MySqlKeepAlive
13 | {
14 | private static Timer _timer;
15 |
16 | public static void Start()
17 | {
18 | _timer = new Timer(300000); // 300000 毫秒 = 5 分钟
19 | _timer.Elapsed += OnTimedEvent;
20 | _timer.AutoReset = true;
21 | _timer.Enabled = true;
22 | }
23 |
24 | private static void OnTimedEvent(Object source, ElapsedEventArgs e)
25 | {
26 | var connection = DbClass.ConnectionMysql(Variable.DbConnectInfo);
27 |
28 |
29 | try
30 | {
31 | connection.Open();
32 | using (var command = new MySqlCommand("SELECT 1", connection))
33 | {
34 | command.ExecuteNonQuery();
35 | Console.WriteLine("KeepAlive query succeeded");
36 | }
37 | }
38 | catch (Exception ex)
39 | {
40 | Console.WriteLine($"KeepAlive query failed: {ex.Message}");
41 | }
42 |
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/SIPAM/EncryptionDecryptionFunction/MD5EncryptionDecryption.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Security.Cryptography;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SIPAM.EncryptionDecryptionFunction
9 | {
10 | internal class Md5EncryptionDecryption
11 | {
12 | ///
13 | /// 计算字符串的MD5值
14 | ///
15 | ///
16 | ///
17 | ///
18 | public static string MyTextMd5(string str, int num)
19 | {
20 | MD5CryptoServiceProvider md5Hash = new MD5CryptoServiceProvider();
21 | byte[] hashBytes = md5Hash.ComputeHash(Encoding.GetEncoding("GB2312").GetBytes(str));
22 | StringBuilder tmpBuilder = new StringBuilder();
23 | foreach (byte i in hashBytes)
24 | {
25 | tmpBuilder.Append(i.ToString("x2"));
26 |
27 | }
28 |
29 | if (num >= 4 && num <= 32)
30 | {
31 | return tmpBuilder.ToString().Substring((32 - num) / 2, num);
32 | }
33 | else
34 | {
35 | return tmpBuilder.ToString().Substring(12, 8);//默认返回8位
36 | }
37 | }
38 |
39 |
40 |
41 |
42 |
43 | ///
44 | /// 计算字符串的MD5值
45 | ///
46 | /// 密码字符串
47 | /// 16
48 | ///
49 | public static string PasswordMd5(string str, int num = 16)
50 | {
51 | MD5CryptoServiceProvider md5Hash = new MD5CryptoServiceProvider();
52 | byte[] hashBytes = md5Hash.ComputeHash(Encoding.GetEncoding("GB2312").GetBytes(str + "Okra-Remote"));
53 | StringBuilder tmpBuilder = new StringBuilder();
54 | foreach (byte i in hashBytes)
55 | {
56 | tmpBuilder.Append(i.ToString("x2"));
57 |
58 | }
59 |
60 | if (num >= 8 && num <= 32)
61 | {
62 | return tmpBuilder.ToString().Substring((32 - num) / 2, num).ToUpper();
63 | }
64 | else
65 | {
66 | return tmpBuilder.ToString().Substring(12, 16).ToUpper();//默认返回16位
67 | }
68 | }
69 |
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/SIPAM/GlobalFunction/DbConfigOperate.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json.Linq;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows;
10 | using SIPAM.GlobalVariable;
11 | using System.Net;
12 |
13 | namespace SIPAM.GlobalFunction
14 | {
15 | internal class DbConfigOperate
16 | {
17 |
18 | ///
19 | /// 读取数据库连接配置文件
20 | ///
21 | /// 配置文件路径
22 | ///
23 | public static JObject GetDbConfig(string path)
24 | {
25 |
26 | if (!File.Exists(path))
27 | {
28 | JObject jObject = null;
29 | return jObject;
30 | }
31 | else
32 | {
33 |
34 | try
35 | {
36 | StreamReader streamReader = File.OpenText(path);
37 | JsonTextReader jsonTextReader = new JsonTextReader(streamReader);
38 | JObject jObject = (JObject)JToken.ReadFrom(jsonTextReader);
39 | streamReader.Close();
40 | return jObject;
41 | }
42 | catch (Exception e)
43 | {
44 |
45 | File.Delete(path);
46 | MessageBox.Show("配置文件损坏,请重新配置!" + "\r\n" + e.ToString());
47 |
48 | return null;
49 | }
50 |
51 |
52 | }
53 |
54 | }
55 |
56 | ///
57 | /// 读取配置文件
58 | ///
59 | public static void ReadConfig()
60 | {
61 |
62 | Variable.JObject = GetDbConfig(Variable.DbPath);//从指定配置文件读取配置信息,返回JObject对象
63 |
64 | }
65 |
66 |
67 | ///
68 | /// 解析数据库配置文件
69 | ///
70 | public static void AnalysisDatabaseConfig()
71 | {
72 | ReadConfig();
73 | #region 解析配置文件
74 |
75 | //读取数据库配置,并连接数据库
76 | JObject jObject = Variable.JObject;
77 |
78 |
79 |
80 | if (jObject != null)
81 | {
82 | try
83 | {
84 | Variable.DbConnectInfo = "server=" + jObject["ServerAddress"].ToString() + ";port=" +
85 | jObject["ServerPort"].ToString() + ";user=" + jObject["DbUser"].ToString() +
86 | ";password=" + jObject["DbPassword"].ToString() + ";database=" +
87 | jObject["DbName"].ToString() + ";";
88 |
89 |
90 | }
91 | catch (Exception)
92 | {
93 | //输出数据库配置信息载入错误信息!
94 |
95 | Variable.DbConnectInfo = null;
96 | }
97 | }
98 | else
99 | {
100 | //输出数据库配置信息载入错误信息!
101 |
102 | Variable.DbConnectInfo = null;
103 | }
104 |
105 | #endregion
106 |
107 |
108 | }
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/SIPAM/GlobalFunction/IpAddressConvert.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SIPAM.GlobalFunction
9 | {
10 | internal class IpAddressConvert
11 | {
12 |
13 | ///
14 | /// 将IP地址转换为十进制
15 | ///
16 | ///
17 | ///
18 | public static uint IpToDecimal(string ip)
19 | {
20 |
21 |
22 | // 将 IP 地址字符串解析为 IPAddress 对象
23 | IPAddress ipAddress = IPAddress.Parse(ip);
24 |
25 | // 获取 IP 地址的字节数组
26 | byte[] ipAddressBytes = ipAddress.GetAddressBytes();
27 |
28 | // 将字节数组转换为 10 进制数
29 | uint decimalIpAddress = (uint)(ipAddressBytes[0] << 24 | ipAddressBytes[1] << 16 | ipAddressBytes[2] << 8 | ipAddressBytes[3]);
30 |
31 |
32 | return decimalIpAddress;
33 | }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/SIPAM/GlobalVariable/Variable.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json.Linq;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Net.Sockets;
7 | using System.Net;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 |
11 | namespace SIPAM.GlobalVariable
12 | {
13 | internal class Variable
14 | {
15 |
16 |
17 | //数据库路径
18 | public static string DbPath = Directory.GetCurrentDirectory() + @"\config\db_config.json";//指定配置文件路径
19 |
20 |
21 | //数据库配置信息
22 | public static JObject JObject;
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | //----------------------Database-Info-------------------------
31 | //Remote-Server-Core服务器ip地址
32 | //public IPAddress IpAddress;
33 |
34 | //Remote-Server-Core服务器端口
35 | //public Int32 ServerPort;
36 |
37 | //数据库连接信息
38 | public static string DbConnectInfo;
39 |
40 |
41 |
42 | //当前登录的用户信息
43 | public static ViewModes.ViewModes.UserInfo UserInfo = new ViewModes.ViewModes.UserInfo(0, "", "", "", "", "", "", "", "", null, 0);
44 |
45 |
46 |
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/SIPAM/ICON.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yaobus/SIPAM/c76eabead57a89fe06a0eaf354949a7a24baea48/SIPAM/ICON.ico
--------------------------------------------------------------------------------
/SIPAM/Language/zh-CN.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 | 简单IP地址分配记录管理系统
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 | IP地址段
43 | 子网掩码
44 | 子网IP地址数量
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 |
--------------------------------------------------------------------------------
/SIPAM/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
41 |
54 |
58 |
59 |
60 |
61 |
62 |
63 |
67 |
69 |
71 |
72 |
73 |
74 |
75 |
76 |
82 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/SIPAM/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace SIPAM
17 | {
18 | ///
19 | /// MainWindow.xaml 的交互逻辑
20 | ///
21 | public partial class MainWindow : Window
22 | {
23 | public MainWindow()
24 | {
25 | InitializeComponent();
26 | LoadLoginPage();
27 | }
28 |
29 |
30 | ///
31 | /// 程序初始页面为登录页面时状态为0
32 | ///
33 | public int LoadStatus = 0;
34 |
35 |
36 |
37 |
38 | ///
39 | /// 加载程序初始界面为登录界面
40 | ///
41 | public void LoadLoginPage()
42 | {
43 | MainWindowPlan.Children.Clear();
44 | MainWindowPlan.Children.Add(new MainWindowPage.LoginPage());
45 |
46 | }
47 |
48 |
49 |
50 |
51 |
52 | ///
53 | /// 切换程序语言
54 | ///
55 | ///
56 | ///
57 | private void LanguageSelect_SelectionChanged(object sender, SelectionChangedEventArgs e)
58 | {
59 |
60 | }
61 |
62 |
63 |
64 |
65 | ///
66 | /// 切换数据库设置和登录面板
67 | ///
68 | ///
69 | ///
70 | private void SettingButton_Click(object sender, RoutedEventArgs e)
71 | {
72 |
73 |
74 | if (LoadStatus == 0)
75 | {
76 | MainWindowPlan.Children.Clear();
77 | MainWindowPlan.Children.Add(new MainWindowPage.DBSettingPage());
78 | LoadStatus = 1;
79 | }
80 | else
81 | {
82 | MainWindowPlan.Children.Clear();
83 | MainWindowPlan.Children.Add(new MainWindowPage.LoginPage());
84 | LoadStatus = 0;
85 | }
86 |
87 |
88 | }
89 |
90 |
91 |
92 | ///
93 | /// 关闭程序
94 | ///
95 | ///
96 | ///
97 | private void CloseButton_Click(object sender, RoutedEventArgs e)
98 | {
99 | this.Close();
100 | }
101 |
102 |
103 | ///
104 | /// 允许程序任意位置拖动
105 | ///
106 | ///
107 | ///
108 | private void Window_MouseDown(object sender, MouseButtonEventArgs e)
109 | {
110 |
111 | if (e.ChangedButton == MouseButton.Left)
112 | {
113 | DragMove();
114 | }
115 |
116 | }
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/SIPAM/MainWindowPage/DBSettingPage.xaml:
--------------------------------------------------------------------------------
1 |
15 |
16 |
17 |
18 |
19 |
32 |
33 |
34 |
35 |
48 |
49 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
82 |
83 |
92 |
93 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/SIPAM/MainWindowPage/DBSettingPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json.Linq;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows;
9 | using System.Windows.Controls;
10 | using System.Windows.Data;
11 | using System.Windows.Documents;
12 | using System.Windows.Input;
13 | using System.Windows.Media;
14 | using System.Windows.Media.Imaging;
15 | using System.Windows.Navigation;
16 | using System.Windows.Shapes;
17 | using SIPAM.GlobalFunction;
18 | using SIPAM.GlobalVariable;
19 | using MySqlConnector;
20 | using SIPAM.DbOperation;
21 | using ControlzEx.Standard;
22 |
23 | namespace SIPAM.MainWindowPage
24 | {
25 | ///
26 | /// DBSettingPage.xaml 的交互逻辑
27 | ///
28 | public partial class DBSettingPage : UserControl
29 | {
30 | public DBSettingPage()
31 | {
32 | InitializeComponent();
33 | }
34 |
35 |
36 | ///
37 | /// 窗口加载状态
38 | ///
39 | public bool WindowLoadedStatus = false;
40 |
41 |
42 | ///
43 | /// 修改了数据库地址
44 | ///
45 | ///
46 | ///
47 | private void DbHost_OnTextChanged(object sender, TextChangedEventArgs e)
48 | {
49 |
50 |
51 | SaveConfig();
52 |
53 |
54 |
55 | }
56 |
57 |
58 |
59 | ///
60 | /// 窗口加载完毕
61 | ///
62 | ///
63 | ///
64 | private void DBSettingPage_OnLoaded(object sender, RoutedEventArgs e)
65 | {
66 | WindowLoadedStatus = true;
67 | LoadConfig();
68 | }
69 |
70 |
71 | ///
72 | /// 修改了数据库端口
73 | ///
74 | ///
75 | ///
76 | private void DbPort_OnTextChanged(object sender, TextChangedEventArgs e)
77 | {
78 | SaveConfig();
79 | }
80 |
81 |
82 | ///
83 | /// 修改了数据库名称
84 | ///
85 | ///
86 | ///
87 | ///
88 | private void DbName_OnTextChanged(object sender, TextChangedEventArgs e)
89 | {
90 | SaveConfig();
91 | }
92 |
93 |
94 | ///
95 | /// 修改了数据库用户
96 | ///
97 | ///
98 | ///
99 | ///
100 | private void DbUser_OnTextChanged(object sender, TextChangedEventArgs e)
101 | {
102 | SaveConfig();
103 | }
104 |
105 |
106 | ///
107 | /// 修改了数据库密码
108 | ///
109 | ///
110 | ///
111 | ///
112 | private void DbPassword_OnPasswordChanged(object sender, RoutedEventArgs e)
113 | {
114 | SaveConfig();
115 | }
116 |
117 | ///
118 | /// 加载配置信息到编辑框
119 | ///
120 | private void LoadConfig()
121 | {
122 | DbConfigOperate.ReadConfig();
123 |
124 |
125 |
126 | if (Variable.JObject != null)
127 | {
128 |
129 |
130 | try
131 | {
132 | DbHost.Text = Variable.JObject["ServerAddress"].ToString();
133 | DbPort.Text = Variable.JObject["ServerPort"].ToString();
134 | DbUser.Text = Variable.JObject["DbUser"].ToString();
135 | DbPassword.Password = Variable.JObject["DbPassword"].ToString();
136 | DbName.Text = Variable.JObject["DbName"].ToString();
137 |
138 | }
139 | catch (Exception)
140 | {
141 |
142 | }
143 |
144 |
145 |
146 | }
147 | else
148 | {
149 | MessageBox.Show("未发现数据库配置文件!\r 点击“确定”立刻配置数据库!","数据库配置文件不存在",MessageBoxButton.OK,MessageBoxImage.Warning);
150 | }
151 |
152 |
153 | }
154 |
155 | ///
156 | /// 保存配置
157 | ///
158 | public void SaveConfig()
159 | {
160 |
161 | if (WindowLoadedStatus == true)
162 | {
163 | JObject jObject = new JObject();
164 |
165 | jObject.Add("ServerAddress", DbHost.Text);
166 | jObject.Add("ServerPort", DbPort.Text);
167 | jObject.Add("DbName", DbName.Text);
168 | jObject.Add("DbUser", DbUser.Text);
169 | jObject.Add("DbPassword", DbPassword.Password);
170 |
171 |
172 | //获取程序启动目录
173 | string path = System.IO.Directory.GetCurrentDirectory() + @"\config\db_config.json";
174 | string outStr = Newtonsoft.Json.JsonConvert.SerializeObject(jObject, Newtonsoft.Json.Formatting.Indented);
175 |
176 | if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\config"))
177 | {
178 | Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\config");
179 | }
180 | else
181 | {
182 | if (!File.Exists(path))
183 | {
184 | StreamWriter streamWriter = new StreamWriter(path, false, Encoding.UTF8);
185 |
186 | streamWriter.WriteLine(outStr);
187 |
188 | streamWriter.Close();
189 |
190 | // MessageBox.Show("保存成功!");
191 |
192 | }
193 | else
194 | {
195 | StreamWriter streamWriter = new StreamWriter(path, false, Encoding.UTF8);
196 |
197 | streamWriter.WriteLine(outStr);
198 |
199 | streamWriter.Close();
200 |
201 | // MessageBox.Show("保存成功!");
202 | }
203 | }
204 |
205 |
206 |
207 |
208 | }
209 |
210 |
211 |
212 | }
213 |
214 |
215 | ///
216 | /// 初始表单创建
217 | ///
218 | ///
219 | ///
220 | private void InitializationButton_OnClick(object sender, RoutedEventArgs e)
221 | {
222 | GlobalFunction.DbConfigOperate.AnalysisDatabaseConfig();//解析数据库配置
223 | //LoadBar.Visibility = Visibility.Visible;
224 |
225 | //第一步,连接数据库
226 |
227 | if (Variable.DbConnectInfo != null)
228 | {
229 | try
230 | {
231 | DbClass.MySqlConnection = DbClass.ConnectionMysql(Variable.DbConnectInfo);
232 | DbClass.MySqlConnection.Open(); //连接数据库
233 | CheckDatabase();
234 | }
235 | catch (Exception)
236 | {
237 |
238 | MessageBox.Show("数据库连接失败!请检查数据库配置!", "数据库连接失败!", MessageBoxButton.OK, MessageBoxImage.Warning);
239 | }
240 |
241 | }
242 |
243 |
244 | }
245 |
246 |
247 | ///
248 | /// 检查数据库中表是否存在,不存在则创建表
249 | ///
250 | ///
251 | private void CheckDatabase()
252 | {
253 | string[] tableNames = { "users", "network", "logs", "groups", "department" };
254 |
255 | string databaseName = DbName.Text;
256 |
257 | int x = 0;
258 |
259 | foreach (string tableName in tableNames)
260 | {
261 |
262 | string query = string.Format("SELECT 1 FROM `{0}` LIMIT 1", tableName);
263 |
264 |
265 | MySqlCommand command = new MySqlCommand(query, DbClass.MySqlConnection);
266 |
267 | // 尝试执行查询
268 | try
269 | {
270 | command.ExecuteScalar();
271 | Console.WriteLine("表单已存在");
272 | }
273 | catch (MySqlException ex)
274 | {
275 | if (ex.Number == 1146) // MySQL 错误码:表不存在
276 | {
277 | Console.WriteLine("表单不存在,即将创建表单!");
278 |
279 | // 创建表
280 | CreateNewTable(DbClass.MySqlConnection, tableName);
281 | x++;
282 |
283 | }
284 | else
285 | {
286 | throw; // 如果是其他 MySQL 异常,抛出异常
287 | }
288 | }
289 |
290 |
291 | }
292 |
293 | if (x == 5)
294 | {
295 |
296 | Console.WriteLine("表单创建完成,即将装载初始数据!");
297 | //装载初始数据
298 | InsertDefaultData();
299 | Console.WriteLine("初始数据装载完毕!");
300 | }
301 |
302 | MessageBox.Show("初始表单创建完毕,请返回登录页面!", "完成", MessageBoxButton.OK, MessageBoxImage.Information);
303 |
304 | // LoadBar.Visibility = Visibility.Hidden;
305 | }
306 |
307 |
308 |
309 |
310 |
311 |
312 | /// 创建新表的方法
313 | private static void CreateNewTable(MySqlConnection connection, string tableName)
314 | {
315 | string query = "";
316 |
317 | // 创建表的 SQL 语句
318 | if (tableName == "users")
319 | {
320 | query = "CREATE TABLE `users` ( `id` int NOT NULL, `user` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `name` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `password` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `department` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `group` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `email` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `tel` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `date` datetime NULL DEFAULT NULL, `status` int NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE)";
321 |
322 | }
323 | else if (tableName == "network")
324 | {
325 | query = "CREATE TABLE `network`(`id` int NOT NULL, `tableName` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `network` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `netmask` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `description` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `authority` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '授权用户组', `creator` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `date` datetime NULL DEFAULT NULL, `status` int NULL DEFAULT NULL, `attention` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '注意事项', PRIMARY KEY (`id`) USING BTREE) ";
326 | }
327 | else if (tableName == "logs")
328 | {
329 | query = "CREATE TABLE `logs` ( `id` int NOT NULL AUTO_INCREMENT, `applyUser` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `applyNetwork` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `tableName` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `ip` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL, `userName` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `userDepartment` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `userTel` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `userPhone` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `deviceType` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `deviceModel` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `deviceMac` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `deviceAddress` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `applyDate` datetime NULL DEFAULT NULL COMMENT '申请日期', `applyStatus` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '申请状态,0:已申请,但还未批准,1已批准,2已驳回', `ratifyUser` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '批准人', `ratifyDate` datetime NULL DEFAULT NULL COMMENT '批准日期', `ratifyNote` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '批准备注', PRIMARY KEY (`id`) USING BTREE) \r\n";
330 | }
331 | else if (tableName == "groups")
332 | {
333 | query = "CREATE TABLE `groups` ( `id` int NOT NULL COMMENT '管理员群组必须是1号群组,待审核是2号群组,请勿修改', `group` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `description` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `authority` varchar(9) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '权限', `creator` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `date` datetime NULL DEFAULT NULL, `status` int NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE) ";
334 | }
335 | else if (tableName == "department")
336 | {
337 | query = "CREATE TABLE `department` ( `id` int NOT NULL, `department` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `description` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `network` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `creator` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `date` datetime NULL DEFAULT NULL, `status` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL) ";
338 | }
339 |
340 | // 执行 SQL 命令来创建新表
341 | MySqlCommand command = new MySqlCommand(query, connection);
342 | command.ExecuteNonQuery();
343 | }
344 |
345 |
346 | ///
347 | /// 装载初始数据
348 | ///
349 | private void InsertDefaultData()
350 | {
351 |
352 | //装载用户群组初始数据
353 | //管理员
354 | string sql = string.Format("INSERT INTO `groups` (id,`group`,description,authority,creator,date,status) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}',{6})", 1, "admin", "管理员用户组", "111111111", "system", DateTime.Now, 0);
355 | DbClass.ModifySql(sql);
356 |
357 | //游客
358 | sql = string.Format("INSERT INTO `groups` (id,`group`,description,authority,creator,date,status) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}',{6})", 2, "guest", "已注册待审核用户组", "100000000", "system", DateTime.Now, 0);
359 | DbClass.ModifySql(sql);
360 |
361 | //普通用户组
362 | sql = string.Format("INSERT INTO `groups` (id,`group`,description,authority,creator,date,status) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}',{6})", 3, "user", "一般用户组", "100000000", "system", DateTime.Now, 0);
363 | DbClass.ModifySql(sql);
364 |
365 |
366 | //装载部门初始数据
367 | sql = string.Format("INSERT INTO department (id,department,description,network,creator,date,status) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}',{6})", 1, "system", "系统用户组", "", "system", DateTime.Now, 0);
368 | DbClass.ModifySql(sql);
369 |
370 | //装载管理员初始数据
371 | sql = string.Format("INSERT INTO users (`id`, `user`, `name`, `password`, `department`, `group`, `email`, `tel`, `phone`, `date`, `status`) VALUES (1, 'admin', 'admin', '375EF066B038516A', 'system', '1', 'admin@admin.com', '', '', '{0}', 0)",DateTime.Now);
372 | DbClass.ModifySql(sql);
373 |
374 | }
375 |
376 | }
377 | }
378 |
--------------------------------------------------------------------------------
/SIPAM/MainWindowPage/LoginPage.xaml:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 |
17 |
18 |
30 |
38 |
39 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
72 |
73 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/SIPAM/MainWindowPage/LoginPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data.SqlClient;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 | using MySqlConnector;
17 | using SIPAM.DbOperation;
18 | using SIPAM.EncryptionDecryptionFunction;
19 | using SIPAM.GlobalVariable;
20 | using SIPAM.Windows;
21 |
22 | namespace SIPAM.MainWindowPage
23 | {
24 | ///
25 | /// LoginPage.xaml 的交互逻辑
26 | ///
27 | public partial class LoginPage : UserControl
28 | {
29 | public LoginPage()
30 | {
31 | InitializeComponent();
32 | }
33 |
34 |
35 |
36 |
37 |
38 | ///
39 | /// 登录
40 | ///
41 | ///
42 | ///
43 | private void LoginButton_Click(object sender, RoutedEventArgs e)
44 | {
45 | GlobalFunction.DbConfigOperate.AnalysisDatabaseConfig();//解析数据库配置
46 |
47 |
48 | //第一步,连接数据库
49 |
50 | if (Variable.DbConnectInfo != null)
51 | {
52 | try
53 | {
54 | DbClass.MySqlConnection = DbClass.ConnectionMysql(Variable.DbConnectInfo);
55 | DbClass.MySqlConnection.Open(); //连接数据库
56 |
57 | }
58 | catch (Exception)
59 | {
60 | MessageBox.Show("数据库连接失败!请检查数据库配置");
61 | }
62 |
63 | //第二步,查询比对管理员登录信息
64 | string sql = string.Format("SELECT * FROM users WHERE user='{0}'", UserNameBox.Text);
65 |
66 | MySqlDataReader reader = DbClass.CarrySqlCmd(sql);
67 | if (reader.Read())
68 | {
69 |
70 | string password = reader.GetString("PASSWORD");
71 |
72 | if (password == Md5EncryptionDecryption.PasswordMd5(UserPasswordBox.Password))//密码正确
73 | {
74 | //查看用户群组
75 | int group = Convert.ToInt32(reader.GetString("group"));
76 |
77 |
78 | GetUserInfo(reader);
79 |
80 |
81 |
82 | //释放连接资源
83 | reader.Dispose();
84 |
85 | //判断用户类型,弹出相应的页面
86 | switch (group)
87 | {
88 | //管理员组
89 | case 1:
90 |
91 | Window mainWindow = new ManageWindow();
92 | var window = Window.GetWindow(this);//关闭父窗体
93 | window?.Close();
94 |
95 | //打开新窗口
96 | mainWindow.Show();
97 | break;
98 |
99 | //游客组
100 | case 2:
101 |
102 | MessageBox.Show("用户正在等待审核!","等待审核",MessageBoxButton.OK,MessageBoxImage.Exclamation);
103 |
104 | break;
105 |
106 | //普通用户组
107 | default:
108 |
109 | mainWindow = new ApplyWindow();
110 | window = Window.GetWindow(this);//关闭父窗体
111 | window?.Close();
112 |
113 | //打开新窗口
114 | mainWindow.Show();
115 |
116 | break;
117 | }
118 |
119 |
120 | }
121 | else
122 | {
123 | MessageBox.Show("用户名或密码错误!");
124 | }
125 |
126 | }
127 | else
128 | {
129 | MessageBox.Show("用户名或密码错误!");
130 | }
131 |
132 | }
133 |
134 |
135 | }
136 |
137 | //检查输入的数据是否为空,为空则输出空字符串,否则原样输出
138 | public Func processInput = input => string.IsNullOrEmpty(input) ? "" : input;
139 |
140 |
141 |
142 |
143 |
144 | ///
145 | /// 获取用户信息
146 | ///
147 | ///
148 | public void GetUserInfo(MySqlDataReader reader)
149 | {
150 |
151 |
152 | Variable.UserInfo.Id = reader.GetInt32("id");
153 |
154 | //MessageBox.Show(Variable.UserInfo.Id.ToString());
155 |
156 | Variable.UserInfo.User = reader.GetString("user");
157 | Variable.UserInfo.Name = reader.GetString("name");
158 | Variable.UserInfo.Password = reader.GetString("password");
159 | Variable.UserInfo.Department = reader.GetString("department");
160 | Variable.UserInfo.Group = reader.GetString("group");
161 |
162 |
163 | Variable.UserInfo.Email = processInput(reader.GetString("email"));
164 | Variable.UserInfo.Tel = processInput(reader.GetString("tel"));
165 | Variable.UserInfo.Phone = processInput(reader.GetString("phone"));
166 | Variable.UserInfo.Date = reader.GetDateTime("date");
167 | Variable.UserInfo.Status = reader.GetInt32("status");
168 |
169 |
170 |
171 | }
172 |
173 |
174 |
175 |
176 | ///
177 | /// 点击注册按钮
178 | ///
179 | ///
180 | ///
181 | private void RegisterButton_Click(object sender, RoutedEventArgs e)
182 | {
183 | Window registerWindow = new RegisterWindow();
184 | var window = Window.GetWindow(this);//关闭父窗体
185 | window?.Close();
186 |
187 | //打开新窗口
188 | registerWindow.Show();
189 |
190 |
191 |
192 | }
193 |
194 |
195 | ///
196 | /// 加载修改密码界面
197 | ///
198 | ///
199 | ///
200 | private void PasswordButton_Click(object sender, RoutedEventArgs e)
201 | {
202 |
203 |
204 |
205 | Window changPasswordWindow = new ChangePasswordWindow();
206 | var window = Window.GetWindow(this);//关闭父窗体
207 | window?.Close();
208 |
209 | //打开新窗口
210 | changPasswordWindow.Show();
211 |
212 |
213 |
214 | }
215 |
216 | private void UserPasswordBox_OnKeyDown(object sender, KeyEventArgs e)
217 | {
218 | if (e.Key == Key.Enter)
219 | {
220 | LoginButton_Click(null, null);
221 | }
222 | }
223 | }
224 | }
225 |
--------------------------------------------------------------------------------
/SIPAM/ManagePage/About.xaml:
--------------------------------------------------------------------------------
1 |
15 |
16 |
17 |
22 |
26 |
27 |
31 |
32 |
36 |
37 |
42 |
43 |
47 |
48 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/SIPAM/ManagePage/About.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Security.Policy;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows;
9 | using System.Windows.Controls;
10 | using System.Windows.Data;
11 | using System.Windows.Documents;
12 | using System.Windows.Input;
13 | using System.Windows.Media;
14 | using System.Windows.Media.Imaging;
15 | using System.Windows.Navigation;
16 | using System.Windows.Shapes;
17 |
18 | namespace SIPAM.ManagePage
19 | {
20 | ///
21 | /// About.xaml 的交互逻辑
22 | ///
23 | public partial class About : UserControl
24 | {
25 | public About()
26 | {
27 | InitializeComponent();
28 | }
29 |
30 |
31 | private void UIElement_OnMouseDown(object sender, MouseButtonEventArgs e)
32 | {
33 | Process.Start("https://github.com/yaobus/SIPAM.git");
34 | }
35 |
36 | private void IpamNoteTextBlock_OnMouseDown(object sender, MouseButtonEventArgs e)
37 | {
38 | Process.Start("https://github.com/yaobus/IPAM-NOTE");
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/SIPAM/ManagePage/Approve.xaml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
31 |
32 |
39 |
40 |
41 |
42 |
43 |
48 |
49 |
50 |
51 |
52 |
62 |
72 |
82 |
83 |
93 |
94 |
104 |
105 |
115 |
116 |
117 |
127 |
128 |
129 |
130 |
140 |
141 |
151 |
152 |
162 |
163 |
164 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
195 |
196 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
249 |
250 |
251 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
268 |
276 |
277 |
278 |
279 |
283 |
284 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
300 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
318 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
334 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
350 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
366 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
382 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
398 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
414 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
--------------------------------------------------------------------------------
/SIPAM/ManagePage/Approve.xaml.cs:
--------------------------------------------------------------------------------
1 | using MySqlConnector;
2 | using SIPAM.DbOperation;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Collections.ObjectModel;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows;
10 | using System.Windows.Controls;
11 | using System.Windows.Data;
12 | using System.Windows.Documents;
13 | using System.Windows.Input;
14 | using System.Windows.Media;
15 | using System.Windows.Media.Imaging;
16 | using System.Windows.Navigation;
17 | using System.Windows.Shapes;
18 | using static SIPAM.ViewModes.ViewModes;
19 |
20 | namespace SIPAM.ManagePage
21 | {
22 | ///
23 | /// Overview.xaml 的交互逻辑
24 | ///
25 | public partial class Approve : UserControl
26 | {
27 | public Approve()
28 | {
29 | InitializeComponent();
30 | }
31 |
32 |
33 |
34 | ///
35 | /// 启动时加载待批准申请
36 | ///
37 | ///
38 | ///
39 | private void Approve_OnLoaded(object sender, RoutedEventArgs e)
40 | {
41 | ApproveListView.ItemsSource = approveInfos;
42 |
43 |
44 | //加载申请列表
45 | LoadApproveInfos();
46 |
47 |
48 | }
49 |
50 |
51 | ObservableCollection approveInfos = new ObservableCollection();
52 |
53 | ObservableCollection approveInfosTemp = new ObservableCollection();
54 |
55 | ///
56 | /// 加载申请信息列表
57 | ///
58 | private void LoadApproveInfos()
59 | {
60 | approveInfos.Clear();
61 |
62 | //查询IP段信息,status=1则用户被删除
63 | string sql = "SELECT * FROM `logs` WHERE applyStatus=0";
64 |
65 |
66 | MySqlDataReader reader = DbClass.CarrySqlCmd(sql);
67 |
68 | int x = 0;
69 |
70 | while (reader.Read())
71 | {
72 | x++;
73 | int id = x;
74 | string applyUser = reader.GetString("applyUser");
75 | string applyNetwork = reader.GetString("applyNetwork");
76 | string ip = reader.GetString("ip");
77 | string userName = reader.GetString("userName");
78 | string userDepartment = reader.GetString("userDepartment");
79 | string userPhone = reader.GetString("userPhone");
80 | string deviceType = reader.GetString("deviceType");
81 | string deviceAddress = reader.GetString("deviceAddress");
82 | string applyStatus = reader.GetString("applyStatus");
83 | string tableName = reader.GetString("tableName");
84 |
85 |
86 | approveInfos.Add(new ApproveInfo(id, applyUser, applyNetwork, ip, userName, userDepartment, userPhone, deviceType, deviceAddress,tableName));
87 |
88 |
89 | }
90 |
91 | reader.Dispose();
92 |
93 | }
94 |
95 |
96 |
97 | ///
98 | /// 批准申请
99 | ///
100 | ///
101 | ///
102 | private void ApproveButton_OnClick(object sender, RoutedEventArgs e)
103 | {
104 |
105 | MessageBoxResult result =
106 | MessageBox.Show("确认批准申请?", "确认?", MessageBoxButton.YesNo, MessageBoxImage.Question);
107 |
108 | if (result == MessageBoxResult.Yes)
109 | {
110 | //要批准的IP地址
111 | List ipList = StatisticsIp(TbApplyIp.Text);
112 |
113 | UpdateIpStatus(ipList);
114 |
115 |
116 | }
117 |
118 |
119 | //重新加载申请信息列表
120 | LoadApproveInfos();
121 | }
122 |
123 |
124 | ///
125 | /// 分配IP地址(锁定),更新LOG
126 | ///
127 | ///
128 | private void UpdateIpStatus(List ipList)
129 | {
130 | string tableName = approveInfos[ApproveListView.SelectedIndex].TableName;
131 |
132 | for (int i = 0; i < ipList.Count; i++)
133 | {
134 | if (!string.IsNullOrWhiteSpace(ipList[i]))
135 | {
136 | //Description 记录IP地址使用人
137 | string sql = string.Format("UPDATE `{0}` SET `AddressStatus` = 4 , `ApplyUser` = '{1}', `Description` = '{2}' , `UserDepartment` = '{3}' , `PhoneNumber` = '{4}' , `DeviceAddress` = '{5}', `RatifyTime` = '{6}' WHERE `Address` = {7}", tableName, approveInfosTemp[0].ApplyUser, approveInfosTemp[0].UserName, approveInfosTemp[0].UserDepartment, approveInfosTemp[0].UserPhone, approveInfosTemp[0].DeviceAddress,DateTime.Now, ipList[i]);
138 |
139 |
140 | DbClass.ExecuteSql(sql);
141 | // Console.WriteLine(sql);
142 |
143 |
144 | //applyStatus=0,待批准;applyStatus=1,已批准;applyStatus=2,已驳回;
145 | sql = string.Format("UPDATE `logs` SET `applyStatus` = '1', `ratifyUser` = '{0}', `ratifyDate` = '{1}' , `ratifyNote` = '{2}' WHERE `tableName` = '{3}' AND `ip` = '{4}'",GlobalVariable.Variable.UserInfo.Name,DateTime.Now,TbNote.Text, tableName, TbApplyIp.Text);
146 | DbClass.ExecuteSql(sql);
147 |
148 |
149 | }
150 |
151 |
152 |
153 |
154 |
155 |
156 | }
157 |
158 |
159 | }
160 |
161 |
162 |
163 | ///
164 | /// 统计已选IP地址
165 | ///
166 | private List StatisticsIp(string ipSub)
167 | {
168 | List ipList = new List(ipSub.Split('|'));
169 |
170 |
171 |
172 | return ipList;
173 | }
174 |
175 |
176 | ///
177 | /// 驳回申请
178 | ///
179 | ///
180 | ///
181 | private void RejectButton_OnClick(object sender, RoutedEventArgs e)
182 | {
183 | MessageBoxResult result =
184 | MessageBox.Show("确认驳回申请?IP地址将被释放!", "确认?", MessageBoxButton.YesNo, MessageBoxImage.Question);
185 |
186 | if (result == MessageBoxResult.Yes)
187 | {
188 | //要驳回的IP地址
189 | List ipList = StatisticsIp(TbApplyIp.Text);
190 |
191 | ReleaseIp(ipList);
192 |
193 |
194 | }
195 |
196 |
197 | //重新加载申请信息列表
198 | LoadApproveInfos();
199 | }
200 |
201 |
202 | ///
203 | /// 释放IP地址(解除锁定),更新LOG
204 | ///
205 | ///
206 | private void ReleaseIp(List ipList)
207 | {
208 | string tableName = approveInfos[ApproveListView.SelectedIndex].TableName;
209 |
210 | for (int i = 0; i < ipList.Count; i++)
211 | {
212 | if (!string.IsNullOrWhiteSpace(ipList[i]))
213 | {
214 | string sql = string.Format("UPDATE `{0}` SET `AddressStatus` = 2 WHERE `Address` = {1}", tableName, ipList[i]);
215 |
216 |
217 | DbClass.ExecuteSql(sql);
218 | // Console.WriteLine(sql);
219 |
220 |
221 | //applyStatus=0,待批准;applyStatus=1,已批准;applyStatus=2,已驳回;
222 | sql = string.Format("UPDATE `logs` SET `applyStatus` = '2', `ratifyUser` = '{0}', `ratifyDate` = '{1}' , `ratifyNote` = '{2}' WHERE `tableName` = '{3}' AND `ip` = '{4}'", GlobalVariable.Variable.UserInfo.Name, DateTime.Now, TbNote.Text, tableName, TbApplyIp.Text);
223 | DbClass.ExecuteSql(sql);
224 |
225 |
226 | }
227 |
228 |
229 |
230 |
231 |
232 |
233 | }
234 |
235 |
236 | }
237 |
238 |
239 |
240 |
241 | ///
242 | /// 点击加载当前所选申请内容
243 | ///
244 | ///
245 | ///
246 | private void ApproveListView_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
247 | {
248 | int index = ApproveListView.SelectedIndex;
249 | if (index != -1)
250 | {
251 | ApproveButton.Visibility = Visibility.Visible;
252 |
253 | RejectButton.Visibility= Visibility.Visible;
254 | approveInfosTemp.Clear();
255 |
256 | approveInfosTemp.Add(approveInfos[ApproveListView.SelectedIndex]);
257 |
258 |
259 | TbApplyUser.Text = approveInfos[ApproveListView.SelectedIndex].ApplyUser;
260 | TbApplyNetwork.Text = approveInfos[ApproveListView.SelectedIndex].ApplyNetwork;
261 | TbApplyIp.Text = approveInfos[ApproveListView.SelectedIndex].ApplyIp;
262 | UserName.Text = approveInfos[ApproveListView.SelectedIndex].UserName;
263 | TbDepartment.Text = approveInfos[ApproveListView.SelectedIndex].UserDepartment;
264 | TbPhone.Text = approveInfos[ApproveListView.SelectedIndex].UserPhone;
265 | TbDeviceType.Text = approveInfos[ApproveListView.SelectedIndex].DeviceType;
266 | TbDeviceAddress.Text = approveInfos[ApproveListView.SelectedIndex].DeviceAddress;
267 | TbIpNumber.Text = GetIpCount(TbApplyIp.Text).ToString();
268 |
269 |
270 |
271 |
272 |
273 |
274 | }
275 | else
276 | {
277 | ApproveButton.Visibility = Visibility.Hidden;
278 |
279 | RejectButton.Visibility = Visibility.Hidden;
280 | }
281 |
282 |
283 |
284 |
285 |
286 | }
287 |
288 |
289 |
290 | ///
291 | /// 获取该用户申请的IP地址总数量
292 | ///
293 | ///
294 | ///
295 | private int GetIpCount(string applyIps)
296 | {
297 | List ipList = StatisticsIp(applyIps);
298 | List newList=new List();
299 | for (int i = 0; i < ipList.Count; i++)
300 | {
301 | if (!string.IsNullOrWhiteSpace(ipList[i]))
302 | {
303 | newList.Add(ipList[i]);
304 | }
305 |
306 | }
307 |
308 | return newList.Count;
309 |
310 | }
311 |
312 |
313 | private void Approve_OnSizeChanged(object sender, SizeChangedEventArgs e)
314 | {
315 | YLine.Width = SystemParameters.WorkArea.Size.Height - 60;
316 | }
317 | }
318 | }
319 |
--------------------------------------------------------------------------------
/SIPAM/ManagePage/Organization.xaml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
29 |
30 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
48 |
49 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
67 |
68 |
73 |
81 |
82 |
83 |
86 |
87 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
105 |
106 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
122 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
153 |
158 |
159 |
160 |
161 |
171 |
172 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
204 |
205 |
220 |
221 |
238 |
239 |
242 |
258 |
259 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
300 |
301 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
--------------------------------------------------------------------------------
/SIPAM/ManagePage/Organization.xaml.cs:
--------------------------------------------------------------------------------
1 | using ControlzEx.Standard;
2 | using MySqlConnector;
3 | using SIPAM.DbOperation;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Collections.ObjectModel;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows;
11 | using System.Windows.Controls;
12 | using System.Windows.Data;
13 | using System.Windows.Documents;
14 | using System.Windows.Input;
15 | using System.Windows.Media;
16 | using System.Windows.Media.Imaging;
17 | using System.Windows.Navigation;
18 | using System.Windows.Shapes;
19 | using static SIPAM.ViewModes.ViewModes;
20 |
21 | namespace SIPAM.ManagePage
22 | {
23 | ///
24 | /// Organization.xaml 的交互逻辑
25 | ///
26 | public partial class Organization : UserControl
27 | {
28 | public Organization()
29 | {
30 | InitializeComponent();
31 | }
32 |
33 |
34 | ///
35 | /// 页面加载完毕
36 | ///
37 | ///
38 | ///
39 | private void Organization_OnLoaded(object sender, RoutedEventArgs e)
40 | {
41 |
42 | OrgListView.ItemsSource = departmentInfos;
43 |
44 | LoadDepartmentData();
45 | }
46 |
47 | ///
48 | /// 窗口尺寸被改变
49 | ///
50 | ///
51 | ///
52 | private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
53 | {
54 | YLine.Width = SystemParameters.WorkArea.Size.Height - 60;
55 | }
56 |
57 |
58 | private string SelectDepartment = "";
59 |
60 | ///
61 | /// 部门被选中
62 | ///
63 | ///
64 | ///
65 | private void OrgListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
66 | {
67 | int index = OrgListView.SelectedIndex;
68 | if (index != -1)
69 | {
70 | SelectDepartment = departmentInfos[index].Department;
71 |
72 | DelButton.Visibility = Visibility.Visible;
73 | EditButton.Visibility = Visibility.Visible;
74 |
75 | GroupTextBox.Text = departmentInfos[OrgListView.SelectedIndex].Department;
76 | DescriptionText.Text = departmentInfos[OrgListView.SelectedIndex].Description;
77 | }
78 |
79 |
80 |
81 |
82 |
83 |
84 | }
85 |
86 |
87 |
88 |
89 |
90 |
91 | ///
92 | /// 保存部门信息
93 | ///
94 | ///
95 | ///
96 | private void AddButton_OnClick(object sender, RoutedEventArgs e)
97 | { //显示保存按钮
98 |
99 | GroupTextBox.IsEnabled = true;
100 | DescriptionText.IsEnabled = true;
101 | SaveButton.Visibility = Visibility.Visible;
102 |
103 | //0新增部门,1编辑部门
104 | EditStatus = 0;
105 |
106 | }
107 |
108 |
109 |
110 | private void SaveButton_OnClick(object sender, RoutedEventArgs e)
111 | {
112 | //新增
113 | if (EditStatus == 0)
114 | {
115 | if (GroupTextBox.Text != "" && DescriptionText.Text != "")
116 | {
117 | string sqlTemp = string.Format("SELECT COUNT(*) FROM department WHERE department ='{0}' AND status = '0'", GroupTextBox.Text);
118 |
119 | int x = DbClass.ExecuteScalarTableNum(sqlTemp);
120 |
121 | if (x == 0)
122 | {
123 | int num = DbClass.ExecuteScalarTableNum("SELECT COUNT(*) FROM department");
124 |
125 |
126 | string sql = string.Format("INSERT INTO `department` (`id`, `department`, `description`, `creator`, `date`, `status`) VALUES ({0}, '{1}', '{2}', '{3}', '{4}', '0')", num + 1, GroupTextBox.Text, DescriptionText.Text, GlobalVariable.Variable.UserInfo.User, DateTime.Now);
127 |
128 | DbClass.ModifySql(sql);
129 |
130 | LoadDepartmentData();
131 |
132 | SaveButton.Visibility = Visibility.Collapsed;
133 | GroupTextBox.IsEnabled = false;
134 | DescriptionText.IsEnabled = false;
135 | }
136 | else
137 | {
138 |
139 | MessageBox.Show("名称已存在,请勿重复添加!", "重复", MessageBoxButton.OK, MessageBoxImage.Information);
140 |
141 | }
142 |
143 |
144 |
145 | }
146 | else
147 | {
148 | MessageBox.Show("请完整填写部门信息!", "确定", MessageBoxButton.OK, MessageBoxImage.Information);
149 | }
150 | }
151 |
152 | else//编辑
153 | {
154 | if (GroupTextBox.Text != "" && DescriptionText.Text != "")
155 | {
156 | string sql = string.Format("UPDATE `department` SET `department` = '{0}',`description`='{1}' WHERE `department` = '{2}' AND `description` ='{3}'", GroupTextBox.Text,DescriptionText.Text, departmentInfos[OrgListView.SelectedIndex].Department, departmentInfos[OrgListView.SelectedIndex].Description);
157 |
158 | Console.WriteLine(sql);
159 |
160 | DbClass.ModifySql(sql);
161 |
162 | LoadDepartmentData();
163 |
164 | SaveButton.Visibility = Visibility.Collapsed;
165 | EditButton.Visibility = Visibility.Collapsed;
166 | GroupTextBox.IsEnabled = false;
167 | DescriptionText.IsEnabled = false;
168 |
169 |
170 | }
171 | else
172 | {
173 | MessageBox.Show("请完整填写部门信息!", "确定", MessageBoxButton.OK, MessageBoxImage.Information);
174 | }
175 | }
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 | }
184 |
185 |
186 | ObservableCollection departmentInfos = new ObservableCollection();
187 |
188 | private int EditStatus;
189 |
190 | ///
191 | /// 从数据库获取部门信息
192 | ///
193 | private void LoadDepartmentData()
194 | {
195 | departmentInfos.Clear();
196 |
197 | //查询IP段信息
198 | string sql = "SELECT * FROM department WHERE status!=1";
199 |
200 | MySqlDataReader reader = DbClass.CarrySqlCmd(sql);
201 |
202 | int id = 0;
203 | while (reader.Read())
204 | {
205 | id++;
206 | string department = reader.GetString("department");
207 | string description = reader.GetString("description");
208 | string network = DbClass.GetReaderString(reader, "network");
209 | string creator = reader.GetString("creator");
210 | DateTime date = reader.GetDateTime("date");
211 |
212 |
213 | departmentInfos.Add(new DepartmentInfo(id, department, description, network, creator, date));
214 |
215 |
216 | }
217 |
218 | reader.Dispose();
219 |
220 |
221 | }
222 |
223 |
224 |
225 |
226 | ///
227 | /// 删除部门
228 | ///
229 | ///
230 | ///
231 | private void DelButton_OnClick(object sender, RoutedEventArgs e)
232 | {
233 |
234 |
235 | MessageBoxResult result = MessageBox.Show("确认删除该数据吗?注意此操作不可逆!", "你最好知道自己在做什么!", MessageBoxButton.OKCancel,
236 | MessageBoxImage.Information);
237 |
238 | if (result == MessageBoxResult.OK)
239 | {
240 | string sql = string.Format("UPDATE `department` SET `Status` = 1 WHERE `department` = '{0}'", SelectDepartment);
241 | DbClass.ModifySql(sql);
242 | LoadDepartmentData();
243 | SaveButton.Visibility = Visibility.Collapsed;
244 |
245 | }
246 | }
247 |
248 |
249 | ///
250 | /// 修改部门
251 | ///
252 | ///
253 | ///
254 | private void EditButton_OnClick(object sender, RoutedEventArgs e)
255 | {
256 | //0新增部门,1编辑部门
257 | EditStatus = 1;
258 | GroupTextBox.IsEnabled=true;
259 | DescriptionText.IsEnabled=true;
260 | SaveButton.Visibility=Visibility.Visible;
261 |
262 |
263 |
264 |
265 | }
266 | }
267 | }
268 |
--------------------------------------------------------------------------------
/SIPAM/ManagePage/User.xaml.cs:
--------------------------------------------------------------------------------
1 | using MySqlConnector;
2 | using SIPAM.DbOperation;
3 | using System;
4 | using System.Collections;
5 | using System.Collections.Generic;
6 | using System.Collections.ObjectModel;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Text.RegularExpressions;
10 | using System.Threading.Tasks;
11 | using System.Windows;
12 | using System.Windows.Controls;
13 | using System.Windows.Data;
14 | using System.Windows.Documents;
15 | using System.Windows.Input;
16 | using System.Windows.Media;
17 | using System.Windows.Media.Imaging;
18 | using System.Windows.Navigation;
19 | using System.Windows.Shapes;
20 | using static SIPAM.ViewModes.ViewModes;
21 |
22 | namespace SIPAM.ManagePage
23 | {
24 | ///
25 | /// User.xaml 的交互逻辑
26 | ///
27 | public partial class User : UserControl
28 | {
29 | public User()
30 | {
31 | InitializeComponent();
32 | }
33 |
34 | ///
35 | /// 加载用户列表,部门表项,群组表项
36 | ///
37 | ///
38 | ///
39 | private void User_OnLoaded(object sender, RoutedEventArgs e)
40 | {
41 | UserListView.ItemsSource = userInfos;
42 | CbGroup.ItemsSource = groupList;
43 | //CbDepartment.ItemsSource = departmentList;
44 |
45 | // LoadDepartment();
46 |
47 | LoadGroupData();
48 |
49 | LoadUserData();
50 | }
51 |
52 |
53 | ///
54 | /// 点击选择用户,加载用户信息到编辑框
55 | ///
56 | ///
57 | ///
58 | private void UserListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
59 | {
60 | if (UserListView.SelectedIndex != -1)
61 | {
62 | EditButton.IsEnabled = true;
63 | CbGroup.IsEnabled = true;
64 | TbUser.Text = userInfos[UserListView.SelectedIndex].User;
65 | TbName.Text = userInfos[UserListView.SelectedIndex].Name;
66 | CbDepartment.Text= userInfos[UserListView.SelectedIndex].Department;
67 |
68 |
69 | //CbDepartment.SelectedIndex = GetValueKey(userInfos[UserListView.SelectedIndex].Department, departmentDictionary) +1;
70 |
71 |
72 |
73 |
74 |
75 |
76 | TbTel.Text = userInfos[UserListView.SelectedIndex].Tel;
77 | TbPhone.Text = userInfos[UserListView.SelectedIndex].Phone;
78 |
79 |
80 | CbGroup.SelectedIndex = GetValueKey(userInfos[UserListView.SelectedIndex].Group, groupDic) - 1;
81 |
82 | TbEmail.Text = userInfos[UserListView.SelectedIndex].Email;
83 | }
84 | else
85 | {
86 | EditButton.IsEnabled = false;
87 | CbGroup.IsEnabled = false;
88 | }
89 |
90 |
91 |
92 |
93 | }
94 |
95 | private Dictionary departmentDictionary = new Dictionary();
96 |
97 | private List departmentList = new List();
98 |
99 | ///
100 | /// 加载部门数据,并查询当前输入的键值对应的KEY
101 | ///
102 | private void LoadDepartment()
103 | {
104 |
105 | departmentDictionary.Clear();
106 | departmentList.Clear();
107 |
108 | string sql = "SELECT * FROM department";
109 |
110 |
111 | MySqlDataReader reader = DbClass.CarrySqlCmd(sql);
112 |
113 |
114 | while (reader.Read())
115 | {
116 | int id = reader.GetInt32("id");
117 | string department = reader.GetString("department");
118 |
119 |
120 | departmentDictionary.Add(id, department);
121 | departmentList.Add(department);
122 |
123 | }
124 |
125 | reader.Dispose();
126 |
127 |
128 |
129 |
130 | }
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 | ///
139 | /// 调整页面高度
140 | ///
141 | ///
142 | ///
143 | private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
144 | {
145 | YLine.Width = SystemParameters.WorkArea.Size.Height - 60;
146 | }
147 |
148 |
149 |
150 |
151 | ObservableCollection userInfos = new ObservableCollection();
152 |
153 | private List groupList = new List();
154 |
155 | private Dictionary groupDic = new Dictionary();
156 |
157 |
158 | ///
159 | /// 从数据库获取用户信息
160 | ///
161 | private void LoadUserData()
162 | {
163 | userInfos.Clear();
164 |
165 |
166 |
167 | //查询IP段信息,status=1则用户被删除
168 | string sql = "SELECT * FROM users WHERE status!=1";
169 |
170 | MySqlDataReader reader = DbClass.CarrySqlCmd(sql);
171 |
172 |
173 | while (reader.Read())
174 | {
175 | int id = reader.GetInt32("id");
176 | string user = reader.GetString("user");
177 | string name = reader.GetString("name");
178 | string department = reader.GetString("department");
179 | string group = reader.GetString("group");
180 | string email = reader.GetString("email");
181 | string tel = reader.GetString("tel");
182 | string phone = reader.GetString("phone");
183 | DateTime date = reader.GetDateTime("date");
184 | int status = reader.GetInt32("status");
185 |
186 | int index = Convert.ToInt32(group);
187 | string groupName = groupDic[index];
188 |
189 |
190 | userInfos.Add(new UserInfo(id, user, name, "", department, groupName, email, tel, phone, date, status));
191 |
192 |
193 | }
194 |
195 | reader.Dispose();
196 |
197 |
198 | }
199 |
200 |
201 | ///
202 | /// 从数据库获取群组信息
203 | ///
204 | private void LoadGroupData()
205 | {
206 | groupList.Clear();
207 |
208 | groupDic.Clear();
209 |
210 |
211 | //查询群组
212 | string sql = "SELECT * FROM `groups` WHERE status!=1";
213 |
214 |
215 |
216 | MySqlDataReader reader = DbClass.CarrySqlCmd(sql);
217 |
218 |
219 | while (reader.Read())
220 | {
221 | int id = reader.GetInt32("id");
222 | string group = reader.GetString("group");
223 |
224 | groupList.Add(group);
225 | groupDic.Add(id, group);
226 |
227 | }
228 |
229 | reader.Dispose();
230 |
231 |
232 | }
233 |
234 |
235 | ///
236 | /// 通过键值获取KEY
237 | ///
238 | ///
239 | ///
240 | private int GetValueKey(string groupName, Dictionary dictionary)
241 | {
242 | int index = -1;
243 | foreach (var pair in dictionary)
244 | {
245 | if (pair.Value == groupName)
246 | {
247 | index = pair.Key;
248 |
249 | }
250 | }
251 |
252 | return index;
253 | }
254 |
255 |
256 |
257 | ///
258 | /// 编辑用户信息
259 | ///
260 | ///
261 | ///
262 | private void EditButton_OnClick(object sender, RoutedEventArgs e)
263 | {
264 | SaveButton.Visibility = Visibility.Visible;
265 | ResetPassword.Visibility = Visibility.Visible;
266 | }
267 |
268 | ///
269 | /// 保存修改
270 | ///
271 | ///
272 | ///
273 | private void SaveButton_OnClick(object sender, RoutedEventArgs e)
274 | {
275 |
276 | if (TbUser.Text=="admin")
277 | {
278 | MessageBox.Show("Admin用户组无法更改,请勿骚操作!", "快住手", MessageBoxButton.OK, MessageBoxImage.Information);
279 | }
280 | else
281 | {
282 | if (CbGroup.SelectedIndex != -1)
283 | {
284 | int groupId = CbGroup.SelectedIndex + 1;
285 |
286 | string sql = string.Format("UPDATE `users` SET `group` = '{0}' WHERE `id` = {1}", groupId, userInfos[UserListView.SelectedIndex].Id);
287 |
288 | //DbClass.CarrySqlCmd(sql);
289 |
290 |
291 | DbClass.ExecuteSql(sql);
292 |
293 | SaveButton.Visibility = Visibility.Hidden;
294 | ResetPassword.Visibility = Visibility.Hidden;
295 |
296 | LoadUserData();
297 | }
298 | else
299 | {
300 | MessageBox.Show("用户群组为必选项", "用户群组未设定", MessageBoxButton.OK, MessageBoxImage.Information);
301 | }
302 | }
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 | }
311 |
312 |
313 | ///
314 | /// 重置密码
315 | ///
316 | ///
317 | ///
318 | private void ResetPassword_OnClick(object sender, RoutedEventArgs e)
319 | {
320 |
321 |
322 |
323 |
324 | MessageBoxResult result = MessageBox.Show("该用户密码将被重置为123456\r是否继续?", "重置用户密码", MessageBoxButton.YesNo, MessageBoxImage.Question);
325 |
326 | if (result == MessageBoxResult.Yes)
327 | {
328 | string sql = string.Format("UPDATE `users` SET `password` = '375EF066B038516A' WHERE `id` = {0}", userInfos[UserListView.SelectedIndex].Id);
329 |
330 | //DbClass.CarrySqlCmd(sql);
331 | DbClass.ExecuteSql(sql);
332 | SaveButton.Visibility = Visibility.Hidden;
333 | ResetPassword.Visibility = Visibility.Hidden;
334 | MessageBox.Show("密码重置成功!", "密码重置成功", MessageBoxButton.OK, MessageBoxImage.Information);
335 | }
336 |
337 |
338 |
339 |
340 | }
341 |
342 | }
343 | }
344 |
--------------------------------------------------------------------------------
/SIPAM/ManageWindow.xaml:
--------------------------------------------------------------------------------
1 |
28 |
29 |
30 |
31 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
66 |
67 |
68 |
69 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
113 |
114 |
115 |
116 |
117 |
118 |
124 |
125 |
126 |
127 |
128 |
129 |
134 |
135 |
143 |
144 |
152 |
153 |
161 |
162 |
163 |
164 |
165 |
166 |
174 |
175 |
176 |
184 |
185 |
193 |
194 |
195 |
196 |
197 |
201 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
--------------------------------------------------------------------------------
/SIPAM/ManageWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using SIPAM.DbOperation;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Shapes;
15 | using SIPAM.ManagePage;
16 |
17 | namespace SIPAM
18 | {
19 | ///
20 | /// ManageWindow.xaml 的交互逻辑
21 | ///
22 | public partial class ManageWindow : Window
23 | {
24 | public ManageWindow()
25 | {
26 | InitializeComponent();
27 | }
28 |
29 |
30 | ///
31 | /// 结束程序
32 | ///
33 | ///
34 | ///
35 | private void CloseButton_Click(object sender, RoutedEventArgs e)
36 | {
37 | this.Close();
38 | }
39 |
40 | private void Window_MouseDown(object sender, MouseButtonEventArgs e)
41 | {
42 | if (e.ChangedButton == MouseButton.Left)
43 | {
44 |
45 |
46 | try
47 | {
48 |
49 | DragMove();
50 | }
51 | catch (Exception exception)
52 | {
53 | Console.WriteLine(exception);
54 | //throw;
55 | }
56 | }
57 | }
58 |
59 |
60 |
61 | ///
62 | /// 最大化和标准窗口大小切换
63 | ///
64 | ///
65 | ///
66 | private void ResizeButton_Click(object sender, RoutedEventArgs e)
67 | {
68 |
69 |
70 |
71 | // 获取屏幕的工作区大小
72 | double screenWidth = SystemParameters.WorkArea.Width;
73 | double screenHeight = SystemParameters.WorkArea.Height;
74 |
75 | // 获取任务栏的高度
76 | double taskbarHeight = SystemParameters.PrimaryScreenHeight - SystemParameters.WorkArea.Height;
77 |
78 | // 设置窗口样式为无边框
79 | WindowStyle = WindowStyle.None;
80 |
81 | // 设置窗口大小为屏幕的宽度,高度为屏幕工作区的高度减去任务栏的高度
82 | Width = screenWidth;
83 | Height = screenHeight - taskbarHeight;
84 |
85 | // 设置窗口位置为屏幕的左上角
86 | Left = 0;
87 | Top = 0;
88 |
89 | }
90 |
91 |
92 | ///
93 | /// 窗口加载完毕后载入功能页面
94 | ///
95 | ///
96 | ///
97 | private void Window_Loaded(object sender, RoutedEventArgs e)
98 | {
99 | // this.WindowState=WindowState.Maximized;
100 | ManageOptionPlan.Children.Clear();
101 | ManageOptionPlan.Children.Add(new ManagePage.Approve());
102 |
103 | MySqlKeepAlive.Start();
104 |
105 |
106 | }
107 |
108 |
109 |
110 | ///
111 | /// 加载地址管理页面
112 | ///
113 | ///
114 | ///
115 | private void RB_AddressManage_Click(object sender, RoutedEventArgs e)
116 | {
117 | ManageOptionPlan.Children.Clear();
118 | AddressManage addressManage = new AddressManage();
119 | addressManage.Style = (Style)FindResource("AddressManageStyle");
120 | ManageOptionPlan.Children.Add(addressManage);
121 | }
122 |
123 |
124 |
125 |
126 | private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
127 | {
128 |
129 | foreach (UIElement child in ManageOptionPlan.Children)
130 | {
131 | if (child is FrameworkElement frameworkElement)
132 | {
133 | frameworkElement.Width = e.NewSize.Width;
134 | frameworkElement.Height = e.NewSize.Height-30;
135 | }
136 | }
137 |
138 |
139 | }
140 |
141 |
142 |
143 |
144 | ///
145 | /// 群组管理
146 | ///
147 | ///
148 | ///
149 | private void RB_Group_Click(object sender, RoutedEventArgs e)
150 | {
151 | ManageOptionPlan.Children.Clear();
152 | ManageOptionPlan.Children.Add(new ManagePage.GroupManage());
153 | }
154 |
155 | ///
156 | /// 部门管理
157 | ///
158 | ///
159 | ///
160 | private void RB_Org_Click(object sender, RoutedEventArgs e)
161 | {
162 | ManageOptionPlan.Children.Clear();
163 | ManageOptionPlan.Children.Add(new ManagePage.Organization());
164 | }
165 |
166 |
167 | private void RB_User_Click(object sender, RoutedEventArgs e)
168 | {
169 | ManageOptionPlan.Children.Clear();
170 | ManageOptionPlan.Children.Add(new ManagePage.User());
171 | }
172 |
173 |
174 | ///
175 | /// 加载审批页面
176 | ///
177 | ///
178 | ///
179 | private void RB_approve_OnClick(object sender, RoutedEventArgs e)
180 | {
181 | ManageOptionPlan.Children.Clear();
182 | ManageOptionPlan.Children.Add(new ManagePage.Approve());
183 | }
184 |
185 |
186 |
187 | ///
188 | /// 改变窗口尺寸
189 | ///
190 | ///
191 | ///
192 | private void SizeButton_OnClick(object sender, RoutedEventArgs e)
193 | {
194 | if (this.WindowState == WindowState.Normal)
195 | {
196 | this.WindowState = WindowState.Maximized;
197 | }
198 | else
199 | {
200 | this.WindowState = WindowState.Normal;
201 | }
202 |
203 | }
204 |
205 |
206 | ///
207 | /// 显示关于页面
208 | ///
209 | ///
210 | ///
211 | private void RB_About_OnClick(object sender, RoutedEventArgs e)
212 | {
213 | ManageOptionPlan.Children.Clear();
214 | ManageOptionPlan.Children.Add(new ManagePage.About());
215 | }
216 |
217 |
218 |
219 | ///
220 | /// 登出
221 | ///
222 | ///
223 | ///
224 | private void BT_LoginOut_OnClick(object sender, RoutedEventArgs e)
225 | {
226 | Window mainWindow = new MainWindow();
227 | var window = Window.GetWindow(this); //关闭父窗体
228 | window?.Close();
229 |
230 | //打开新窗口
231 | mainWindow.Show();
232 | }
233 | }
234 | }
235 |
--------------------------------------------------------------------------------
/SIPAM/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // 有关程序集的一般信息由以下
8 | // 控制。更改这些特性值可修改
9 | // 与程序集关联的信息。
10 | [assembly: AssemblyTitle("SIPAM")]
11 | [assembly: AssemblyDescription("SIPAM-简单IP地址分配管理系统")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("642390042@qq.com")]
14 | [assembly: AssemblyProduct("SIPAM")]
15 | [assembly: AssemblyCopyright("Copyright © 2023")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // 将 ComVisible 设置为 false 会使此程序集中的类型
20 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
21 | //请将此类型的 ComVisible 特性设置为 true。
22 | [assembly: ComVisible(false)]
23 |
24 | //若要开始生成可本地化的应用程序,请设置
25 | //.csproj 文件中的 CultureYouAreCodingWith
26 | //在 中。例如,如果你使用的是美国英语。
27 | //使用的是美国英语,请将 设置为 en-US。 然后取消
28 | //对以下 NeutralResourceLanguage 特性的注释。 更新
29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置
36 | //(未在页面中找到资源时使用,
37 | //或应用程序资源字典中找到时使用)
38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
39 | //(未在页面中找到资源时使用,
40 | //、应用程序或任何主题专用资源字典中找到时使用)
41 | )]
42 |
43 |
44 | // 程序集的版本信息由下列四个值组成:
45 | //
46 | // 主版本
47 | // 次版本
48 | // 生成号
49 | // 修订号
50 | //
51 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
52 | //通过使用 "*",如下所示:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/SIPAM/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SIPAM.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SIPAM.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 重写当前线程的 CurrentUICulture 属性,对
51 | /// 使用此强类型资源类的所有资源查找执行重写。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
65 | ///
66 | internal static System.Drawing.Icon ICON {
67 | get {
68 | object obj = ResourceManager.GetObject("ICON", resourceCulture);
69 | return ((System.Drawing.Icon)(obj));
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/SIPAM/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\ICON.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
--------------------------------------------------------------------------------
/SIPAM/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SIPAM.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.8.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/SIPAM/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/SIPAM/RegisterWindow.xaml:
--------------------------------------------------------------------------------
1 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
36 |
44 |
45 |
49 |
50 |
51 |
52 |
60 |
73 |
74 |
75 |
76 |
80 |
81 |
92 |
93 |
100 |
101 |
108 |
109 |
120 |
121 |
135 |
136 |
137 |
138 |
143 |
151 |
162 |
173 |
184 |
185 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
--------------------------------------------------------------------------------
/SIPAM/RegisterWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using MySqlConnector;
2 | using SIPAM.DbOperation;
3 | using SIPAM.EncryptionDecryptionFunction;
4 | using SIPAM.GlobalVariable;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Text.RegularExpressions;
10 | using System.Threading.Tasks;
11 | using System.Windows;
12 | using System.Windows.Controls;
13 | using System.Windows.Data;
14 | using System.Windows.Documents;
15 | using System.Windows.Input;
16 | using System.Windows.Media;
17 | using System.Windows.Media.Imaging;
18 | using System.Windows.Shapes;
19 | using static SIPAM.ViewModes.ViewModes;
20 |
21 | namespace SIPAM
22 | {
23 | ///
24 | /// RegisterWindow.xaml 的交互逻辑
25 | ///
26 | public partial class RegisterWindow : Window
27 | {
28 | public RegisterWindow()
29 | {
30 | InitializeComponent();
31 | }
32 |
33 |
34 | ///
35 | /// 点击提交申请按钮
36 | ///
37 | ///
38 | ///
39 | private void SubmitButton_OnClick(object sender, RoutedEventArgs e)
40 | {
41 |
42 |
43 | //输入无误,进行下一步操作
44 | if (CheckInput() == 0)
45 | {
46 | //查询用户名是否重复
47 | string sql = string.Format("SELECT COUNT(*) FROM users WHERE user='{0}'", UserNameBox.Text);
48 |
49 | int num = DbClass.ExecuteScalarTableNum(sql);
50 |
51 | //查询用户名是否没有重复
52 | if (num == 0)
53 | {
54 | //查询用户总数量sql
55 | sql = "SELECT COUNT(*) FROM users";
56 |
57 | num = DbClass.ExecuteScalarTableNum(sql);
58 |
59 | string password = Md5EncryptionDecryption.PasswordMd5(UserPasswordBox.Password);
60 |
61 | string department = departmentList[DepartmentComboBox.SelectedIndex];
62 |
63 | string tel = TelBox.Text;
64 |
65 | if (TelBox.Text == "")
66 | {
67 | tel = "";
68 | }
69 | else
70 | {
71 | tel = TelBox.Text;
72 | }
73 |
74 |
75 | //组合插入新用户的sql语句
76 | sql = string.Format("INSERT INTO users ( id, `user`, `name`, `password`, department, `group`, email, tel, phone, date, `status` ) VALUES ({0},'{1}','{2}','{3}','{4}',{5},'{6}','{7}','{8}','{9}',{10})", num + 1, UserNameBox.Text, RealNameBox.Text, password, department, 2, EmailBox.Text, tel, PhoneBox.Text, DateTime.Now, 0);
77 |
78 | //Console.WriteLine(sql);
79 | DbClass.ModifySql(sql);
80 |
81 |
82 |
83 | MessageBoxResult result = MessageBox.Show("注册申请已提交,请等待管理员审核!\r即将返回登录页面!", "注册成功,等待审核", MessageBoxButton.OK, MessageBoxImage.Information);
84 |
85 | if (result == MessageBoxResult.OK)
86 | {
87 | BackButton_OnClick(null, null);
88 | }
89 |
90 | }
91 | else
92 | {
93 | //用户名已存在
94 | MessageBox.Show("用户名已存在");
95 | }
96 |
97 |
98 |
99 | }
100 |
101 |
102 | //string sql = "SELECT COUNT(*) FROM users";
103 |
104 |
105 |
106 |
107 | }
108 |
109 |
110 | ///
111 | /// 检查用户输入是否合法
112 | ///
113 | ///
114 | private int CheckInput()
115 | {
116 |
117 | string message = "";
118 | int index = 0;
119 |
120 | //1.校验用户名
121 | if (UserNameBox.Text.Length < 3)
122 | {
123 | index += 1;
124 | message += index + ":用户名长度需要大于3位字符\r";
125 |
126 | }
127 |
128 |
129 | //2.校验密码长度是否小于6位
130 | if (UserPasswordBox.Password.Length < 6)
131 | {
132 | index += 1;
133 | message += index + ":密码长度需要大于等于6位字符\r";
134 |
135 | }
136 |
137 |
138 | //3.判断两次输入的密码是否一致
139 | if (UserPasswordBoxAgain.Password != UserPasswordBox.Password)
140 | {
141 | index += 1;
142 | message += index + ":两次密码输入不一致\r";
143 | }
144 |
145 |
146 | //4.校验用户姓名是否大于等于2位
147 | if (RealNameBox.Text.Length < 2)
148 | {
149 | index += 1;
150 | message += index + ":姓名应大于2位字符\r";
151 |
152 | }
153 |
154 |
155 | //5.校验是否选择了部门
156 | if (DepartmentComboBox.SelectedIndex == -1)
157 | {
158 | index += 1;
159 | message += index + ":请选择你所在的部门\r";
160 |
161 | }
162 |
163 | //6.校验是否输入了格式正确的EMAIL
164 | if (!IsValidEmail(EmailBox.Text))
165 | {
166 | index += 1;
167 | message += index + ":请输入正确的邮箱地址\r";
168 |
169 | }
170 |
171 | //7.校验是否输入了格式正确的手机号码
172 | if (!IsValidPhoneNumber(PhoneBox.Text))
173 | {
174 |
175 | index += 1;
176 | message += index + ":请输入正确的手机号码\r";
177 |
178 | }
179 |
180 | if (index > 0)
181 | {
182 | MessageBox.Show(message, "发现" + index + "项内容需要注意!", MessageBoxButton.OK, MessageBoxImage.Warning);
183 | return index;
184 | }
185 | else
186 | {
187 | return 0;
188 | }
189 |
190 |
191 |
192 | }
193 |
194 | ///
195 | /// 检查是否是瞎几把输入的邮箱地址
196 | ///
197 | ///
198 | ///
199 | private static bool IsValidEmail(string email)
200 | {
201 | // 定义邮箱地址的正则表达式模式
202 | string pattern = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$";
203 |
204 | // 使用 Regex 类来进行匹配
205 | Regex regex = new Regex(pattern);
206 |
207 | // 调用 IsMatch 方法检查邮箱地址是否匹配模式
208 | return regex.IsMatch(email);
209 | }
210 |
211 | ///
212 | /// 检查是否是瞎几把输入的手机号码
213 | ///
214 | ///
215 | ///
216 | private static bool IsValidPhoneNumber(string phoneNumber)
217 | {
218 | // 定义手机号码的正则表达式
219 | string pattern = @"^1[3456789]\d{9}$";
220 |
221 | // 使用正则表达式进行匹配
222 | return Regex.IsMatch(phoneNumber, pattern);
223 | }
224 |
225 |
226 | ///
227 | /// 允许窗口任意拖动
228 | ///
229 | ///
230 | ///
231 | private void RegisterWindow_OnMouseDown(object sender, MouseButtonEventArgs e)
232 | {
233 | if (e.ChangedButton == MouseButton.Left)
234 | {
235 | DragMove();
236 | }
237 |
238 | }
239 |
240 | ///
241 | /// 结束程序
242 | ///
243 | ///
244 | ///
245 | private void CloseButton_OnClick(object sender, RoutedEventArgs e)
246 | {
247 | this.Close();
248 | }
249 |
250 |
251 | ///
252 | /// 返回登录界面
253 | ///
254 | ///
255 | ///
256 | private void BackButton_OnClick(object sender, RoutedEventArgs e)
257 | {
258 | Window mainWindow = new MainWindow();
259 | var window = Window.GetWindow(this); //关闭父窗体
260 | window?.Close();
261 |
262 | //打开新窗口
263 | mainWindow.Show();
264 |
265 |
266 | }
267 |
268 |
269 | ///
270 | /// 窗口加载完毕,检查数据库连接是否正常
271 | ///
272 | ///
273 | ///
274 | private void RegisterWindow_OnLoaded(object sender, RoutedEventArgs e)
275 | {
276 | GlobalFunction.DbConfigOperate.AnalysisDatabaseConfig(); //解析数据库配置
277 |
278 |
279 | //第一步,连接数据库
280 |
281 | if (Variable.DbConnectInfo != null)
282 | {
283 | try
284 | {
285 | DbClass.MySqlConnection = DbClass.ConnectionMysql(Variable.DbConnectInfo);
286 | DbClass.MySqlConnection.Open(); //连接数据库
287 | DepartmentComboBox.ItemsSource = departmentList;
288 | LoadDepartmentList();
289 |
290 | }
291 | catch (Exception)
292 | {
293 | MessageBox.Show("数据库连接失败!请检查数据库配置");
294 | }
295 | }
296 | }
297 |
298 |
299 | private List departmentList = new List();
300 |
301 | ///
302 | /// 加载部门数据
303 | ///
304 | private void LoadDepartmentList()
305 | {
306 | departmentList.Clear();
307 |
308 | string sql = "SELECT * FROM department";
309 |
310 | MySqlDataReader reader = DbClass.CarrySqlCmd(sql);
311 |
312 |
313 | while (reader.Read())
314 | {
315 |
316 | string department = reader.GetString("department");
317 |
318 |
319 |
320 |
321 | departmentList.Add(department);
322 |
323 | }
324 |
325 | reader.Dispose();
326 |
327 |
328 |
329 |
330 | }
331 | }
332 | }
333 |
--------------------------------------------------------------------------------
/SIPAM/Resources/ICON.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yaobus/SIPAM/c76eabead57a89fe06a0eaf354949a7a24baea48/SIPAM/Resources/ICON.ico
--------------------------------------------------------------------------------
/SIPAM/Resources/待办事项.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/SIPAM/UserPage/MyAddress.xaml:
--------------------------------------------------------------------------------
1 |
15 |
16 |
19 |
20 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/SIPAM/UserPage/MyAddress.xaml.cs:
--------------------------------------------------------------------------------
1 | using MySqlConnector;
2 | using SIPAM.DbOperation;
3 | using SIPAM.GlobalVariable;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Collections.ObjectModel;
7 | using System.Linq;
8 | using System.Runtime.Remoting.Messaging;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 | using System.Windows;
12 | using System.Windows.Controls;
13 | using System.Windows.Data;
14 | using System.Windows.Documents;
15 | using System.Windows.Input;
16 | using System.Windows.Media;
17 | using System.Windows.Media.Imaging;
18 | using System.Windows.Navigation;
19 | using System.Windows.Shapes;
20 | using static SIPAM.ViewModes.ViewModes;
21 |
22 | namespace SIPAM.UserPage
23 | {
24 | ///
25 | /// MyAddress.xaml 的交互逻辑
26 | ///
27 | public partial class MyAddress : UserControl
28 | {
29 | public MyAddress()
30 | {
31 | InitializeComponent();
32 | }
33 |
34 |
35 |
36 | ///
37 | /// 加载用户已申请IP
38 | ///
39 | ///
40 | ///
41 | private void MyAddress_OnLoaded(object sender, RoutedEventArgs e)
42 | {
43 | MyAddressListView.ItemsSource = myAddressInfos;
44 |
45 |
46 | //加载对应群组地址数据
47 | LoadAddressData(Convert.ToInt32(Variable.UserInfo.Group));
48 |
49 |
50 | }
51 |
52 |
53 | //已分配网段
54 | ObservableCollection AddressInfos = new ObservableCollection();
55 |
56 | //已申请地址
57 | ObservableCollection myAddressInfos = new ObservableCollection();
58 |
59 | ///
60 | /// 从数据库获取网段信息
61 | ///
62 | ///
63 | private void LoadAddressData(int groupId)
64 | {
65 |
66 | AddressInfos.Clear();
67 |
68 |
69 | string sql = string.Format("SELECT * FROM network WHERE authority LIKE '%g{0}p%'", groupId);
70 |
71 |
72 | // 查询IP段信息
73 | MySqlDataReader reader = DbClass.CarrySqlCmd(sql);
74 |
75 |
76 | while (reader.Read())
77 | {
78 | int id = reader.GetInt32("id");
79 | string tableName = reader.GetString("tableName");
80 | string network = reader.GetString("Network");
81 | DateTime date=DateTime.Now;
82 |
83 |
84 | AddressInfos.Add(new AddressInfo(id, tableName, network, "", "", "", "", "", date));
85 | }
86 |
87 | reader.Dispose();
88 |
89 | int index = 0;
90 | for (int i = 0; i < AddressInfos.Count; i++)
91 | {
92 | sql = string.Format("SELECT * FROM `{0}` WHERE `ApplyUser`='{1}'", AddressInfos[i].TableName, GlobalVariable.Variable.UserInfo.User);
93 | //Console.WriteLine(sql);
94 |
95 | MySqlDataReader reader2 = DbClass.CarrySqlCmd(sql);
96 |
97 | while (reader2.Read())
98 | {
99 | index++;
100 | string network = AddressInfos[i].Network;
101 | int address = reader2.GetInt32("Address");
102 | string applyUser = reader2.GetString("ApplyUser");
103 | string description = reader2.GetString("Description");
104 | string userDepartment = reader2.GetString("UserDepartment");
105 | string userPhone = reader2.GetString("PhoneNumber");
106 | string deviceAddress = reader2.GetString("DeviceAddress");
107 |
108 |
109 | myAddressInfos.Add(new MyAddressInfo(index,network, address, applyUser, description, userDepartment, userPhone, deviceAddress));
110 | }
111 |
112 | reader2.Dispose();
113 | }
114 |
115 |
116 |
117 |
118 | }
119 |
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/SIPAM/ViewModes/ViewModes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace SIPAM.ViewModes
8 | {
9 | internal class ViewModes
10 | {
11 |
12 |
13 | ///
14 | /// ip地址信息
15 | ///
16 | public class IpAddressInfo
17 | {
18 | //IP地址
19 | public int Address { get; set; }
20 |
21 | //地址状态
22 | public int AddressStatus { get; set; }
23 |
24 | //注释
25 | public string Description { get; set; }
26 |
27 | //IP地址申请人
28 | public string ApplyUser { get; set; }
29 |
30 | //地址用途
31 | public string UseTo { get; set; }
32 |
33 | //使用人部门
34 | public string UserDepartment { get; set; }
35 |
36 | //使用人EMAIL
37 | public string Email { get; set; }
38 |
39 | //使用人电话
40 | public string UserTel { get; set; }
41 |
42 | // 使用人手机号
43 | public string PhoneNumber { get; set; }
44 |
45 | //设备类型
46 | public string DeviceType { get; set; }
47 |
48 | //设备型号
49 | public string DeviceModel { get; set; }
50 |
51 | //设备MAC地址
52 | public string DeviceMac { get; set; }
53 |
54 | //设备所在位置
55 | public string DeviceAddress { get; set; }
56 |
57 | //地址申请时间
58 | public DateTime ApplyTime { get; set; }
59 |
60 | // 批准人
61 | public string Ratify { get; set; }
62 |
63 | // 批准时间
64 | public DateTime RatifyTime { get; set; }
65 |
66 |
67 | public IpAddressInfo(int address, int addressStatus, string description, string applyUser, string useTo,
68 | string userDepartment, string email, string userTel, string phoneNumber, string deviceType, string deviceModel,
69 | string deviceMac, string deviceAddress, DateTime applyTime, string ratify, DateTime ratifyTime)
70 | {
71 | Address = address;
72 | AddressStatus = addressStatus;
73 | Description = description;
74 | ApplyUser = applyUser;
75 | UseTo = useTo;
76 | UserDepartment = userDepartment;
77 | Email = email;
78 | UserTel = userTel;
79 | PhoneNumber = phoneNumber;
80 | DeviceType = deviceType;
81 | DeviceModel = deviceModel;
82 | DeviceMac = deviceMac;
83 | DeviceAddress = deviceAddress;
84 | ApplyTime = applyTime;
85 | Ratify = ratify;
86 | RatifyTime = ratifyTime;
87 |
88 | }
89 | }
90 |
91 |
92 | ///
93 | /// 用户信息
94 | ///
95 | public class UserInfo
96 | {
97 | public int Id { get; set; }
98 |
99 | public string User { get; set; }
100 |
101 | public string Name { get; set; }
102 |
103 | public string Password { get; set; }
104 |
105 | public string Department { get; set; }
106 |
107 | public string Group { get; set; }
108 |
109 | public string Email { get; set; }
110 |
111 | public string Tel { get; set; }
112 |
113 | public string Phone { get; set; }
114 |
115 | public DateTime? Date { get; set; }
116 |
117 | public int Status { get; set; }
118 |
119 | public UserInfo(int id, string user, string name, string password, string department, string group, string email, string tel, string phone, DateTime? date, int status)
120 | {
121 | Id = id;
122 | User = user;
123 | Name = name;
124 | Password = password;
125 | Department = department;
126 | Group = group;
127 | Email = email;
128 | Tel = tel;
129 | Phone = phone;
130 | Date = date;
131 | Status = status;
132 | }
133 |
134 | }
135 |
136 |
137 | ///
138 | /// 用户组信息
139 | ///
140 | public class GroupInfo
141 | {
142 | public int Id { get; set; }
143 |
144 | public string GroupName { get; set; }
145 |
146 | public string Description { get; set; }
147 |
148 | //网段
149 | public string Authority { get; set; }
150 |
151 | public string Creator { get; set; }
152 |
153 | public DateTime Date { get; set; }
154 |
155 | public GroupInfo(int id, string groupName, string description, string authority, string creator, DateTime date)
156 | {
157 | Id = id;
158 | GroupName = groupName;
159 | Description = description;
160 | Authority = authority;
161 | Creator = creator;
162 | Date = date;
163 |
164 | }
165 |
166 | }
167 |
168 |
169 | ///
170 | /// 网段信息
171 | ///
172 | public class AddressInfo
173 | {
174 | public int Id { get; set; }
175 |
176 | public string TableName { get; set; }
177 |
178 | public string Network { get; set; }
179 |
180 | public string Netmask { get; set; }
181 |
182 | public string Attention { get; set; }
183 |
184 | public string Description { get; set; }
185 |
186 | public string Authority { get; set; }
187 |
188 |
189 | public string Creator { get; set; }
190 |
191 | public DateTime Date { get; set; }
192 |
193 |
194 |
195 | public AddressInfo(int id, string tableName, string network, string netmask, string attention, string description, string authority, string creator, DateTime date)
196 | {
197 | Id = id;
198 | TableName = tableName;
199 | Network = network;
200 | Netmask = netmask;
201 | Attention = attention;
202 | Description = description;
203 | Authority = authority;
204 | Creator = creator;
205 | Date = date;
206 |
207 | }
208 |
209 | }
210 |
211 |
212 | ///
213 | /// 部门信息
214 | ///
215 | public class DepartmentInfo
216 | {
217 | public int Id { get; set; }
218 |
219 | public string Department { get; set; }
220 |
221 | public string Description { get; set; }
222 |
223 | public string Network { get; set; }
224 |
225 | public string Creator { get; set; }
226 |
227 | public DateTime Date { get; set; }
228 |
229 | public DepartmentInfo(int id, string department, string description, string network, string creator, DateTime date)
230 | {
231 | Id = id;
232 | Department = department;
233 | Description = description;
234 | Network = network;
235 | Creator = creator;
236 | Date = date;
237 |
238 | }
239 |
240 | }
241 |
242 |
243 |
244 | public class ApproveInfo
245 | {
246 | //序号
247 | public int Id { get; set; }
248 |
249 | //申请用户
250 | public string ApplyUser { get; set; }
251 |
252 | //申请网段
253 | public string ApplyNetwork { get; set; }
254 |
255 | //申请的Ip
256 | public string ApplyIp { get; set; }
257 |
258 | //使用人
259 | public string UserName { get; set; }
260 |
261 | //使用人部门
262 | public string UserDepartment { get; set; }
263 |
264 | //使用人电话
265 | public string UserPhone { get; set; }
266 |
267 | //设备类型
268 | public string DeviceType { get; set; }
269 |
270 | //设备位置
271 | public string DeviceAddress { get; set; }
272 |
273 | //网段表名
274 | public string TableName { get; set; }
275 |
276 |
277 | public ApproveInfo(int id, string applyUser, string applyNetwork, string applyIp, string userName, string userDepartment, string userPhone, string deviceType, string deviceAddress, string tableName)
278 | {
279 | Id = id;
280 | ApplyUser = applyUser;
281 | ApplyNetwork = applyNetwork;
282 | ApplyIp = applyIp;
283 | UserName = userName;
284 | UserDepartment = userDepartment;
285 | UserPhone = userPhone;
286 | DeviceType = deviceType;
287 | DeviceAddress = deviceAddress;
288 | TableName = tableName;
289 |
290 | }
291 | }
292 |
293 |
294 | ///
295 | /// 我已申请的IP地址信息
296 | ///
297 | public class MyAddressInfo
298 | {
299 | public int Index { get; set; }
300 |
301 | public string Network { get; set; }
302 |
303 | public int Address { get; set; }
304 |
305 | public string ApplyUser { get; set; }
306 |
307 | public string Description { get; set; }
308 |
309 | public string UserDepartment { get; set; }
310 |
311 | public string UserPhone { get; set; }
312 |
313 | public string DeviceAddress { get; set; }
314 |
315 |
316 | public MyAddressInfo(int index, string network, int address, string applyUser, string description, string userDepartment, string userPhone, string deviceAddress)
317 | {
318 | Index = index;
319 | Network = network;
320 | Address = address;
321 | ApplyUser = applyUser;
322 | Description = description;
323 | UserDepartment = userDepartment;
324 | UserPhone = userPhone;
325 | DeviceAddress = deviceAddress;
326 | }
327 | }
328 | }
329 | }
330 |
--------------------------------------------------------------------------------
/SIPAM/Windows/ChangePasswordWindow.xaml:
--------------------------------------------------------------------------------
1 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
31 |
39 |
40 |
44 |
45 |
46 |
47 |
48 |
49 |
52 |
65 |
66 |
74 |
75 |
76 |
84 |
85 |
93 |
94 |
95 |
96 |
97 |
100 |
101 |
102 |
103 |
104 |
105 |
119 |
120 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/SIPAM/Windows/ChangePasswordWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using MySqlConnector;
2 | using SIPAM.DbOperation;
3 | using SIPAM.EncryptionDecryptionFunction;
4 | using SIPAM.GlobalVariable;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows;
11 | using System.Windows.Controls;
12 | using System.Windows.Data;
13 | using System.Windows.Documents;
14 | using System.Windows.Input;
15 | using System.Windows.Media;
16 | using System.Windows.Media.Imaging;
17 | using System.Windows.Shapes;
18 |
19 | namespace SIPAM.Windows
20 | {
21 | ///
22 | /// ChangePasswordWindow.xaml 的交互逻辑
23 | ///
24 | public partial class ChangePasswordWindow : Window
25 | {
26 | public ChangePasswordWindow()
27 | {
28 | InitializeComponent();
29 | }
30 |
31 |
32 | ///
33 | /// 返回
34 | ///
35 | ///
36 | ///
37 | private void BackButton_OnClick(object sender, RoutedEventArgs e)
38 | {
39 | Window mainWindow = new MainWindow();
40 | var window = Window.GetWindow(this); //关闭父窗体
41 | window?.Close();
42 |
43 | //打开新窗口
44 | mainWindow.Show();
45 | }
46 |
47 |
48 |
49 | ///
50 | /// 修改密码
51 | ///
52 | ///
53 | ///
54 | private void PasswordButton_OnClick(object sender, RoutedEventArgs e)
55 | {
56 | //输入输入无误,进行下一步操作
57 | if (CheckInput()==0)
58 | {
59 | //解析数据库配置
60 | GlobalFunction.DbConfigOperate.AnalysisDatabaseConfig();
61 |
62 | //第一步,连接数据库
63 |
64 | if (Variable.DbConnectInfo != null)
65 | {
66 | try
67 | {
68 | DbClass.MySqlConnection = DbClass.ConnectionMysql(Variable.DbConnectInfo);
69 | DbClass.MySqlConnection.Open(); //连接数据库
70 |
71 | }
72 | catch (Exception)
73 | {
74 | MessageBox.Show("数据库连接失败!请检查数据库配置");
75 | }
76 |
77 | //第二步,查询比对用户登录信息
78 | string sql = string.Format("SELECT * FROM users WHERE user='{0}'", TbUserName.Text);
79 |
80 | MySqlDataReader reader = DbClass.CarrySqlCmd(sql);
81 | if (reader.Read())
82 | {
83 |
84 | string password = reader.GetString("PASSWORD");
85 | string newPassword = Md5EncryptionDecryption.PasswordMd5(UserPasswordBox.Password);
86 |
87 | if (password == Md5EncryptionDecryption.PasswordMd5(UserOldPassword.Password))//密码正确
88 | {
89 |
90 | sql = string.Format("UPDATE `users` SET `password` = '{0}' WHERE `user` = '{1}'", newPassword, TbUserName.Text);
91 |
92 | Console.WriteLine(sql);
93 |
94 | DbClass.ModifySql(sql);
95 |
96 | MessageBoxResult result = MessageBox.Show("密码已修改,请使用新密码登录!", "密码修改成功", MessageBoxButton.OK,
97 | MessageBoxImage.Information);
98 |
99 | if (result == MessageBoxResult.OK)
100 | {
101 | BackButton_OnClick(null, null);
102 | }
103 |
104 |
105 |
106 | //释放连接资源
107 | reader.Dispose();
108 |
109 |
110 |
111 |
112 | }
113 | else
114 | {
115 | MessageBox.Show("用户名或密码错误!");
116 | }
117 |
118 | }
119 | else
120 | {
121 | MessageBox.Show("用户名或密码错误!");
122 | }
123 |
124 | }
125 |
126 |
127 |
128 | }
129 |
130 |
131 |
132 | }
133 |
134 | ///
135 | /// 检查用户输入是否合法
136 | ///
137 | ///
138 | private int CheckInput()
139 | {
140 |
141 | string message = "";
142 | int index = 0;
143 |
144 | //1.校验用户名
145 | if (TbUserName.Text.Length < 3)
146 | {
147 | index += 1;
148 | message += index + ":用户名长度需要大于3位字符\r";
149 |
150 | }
151 |
152 |
153 | //2.校验密码长度是否小于6位
154 | if (UserPasswordBox.Password.Length < 6)
155 | {
156 | index += 1;
157 | message += index + ":密码长度需要大于等于6位字符\r";
158 |
159 | }
160 |
161 |
162 | //3.判断两次输入的密码是否一致
163 | if (UserPasswordBoxAgain.Password != UserPasswordBox.Password)
164 | {
165 | index += 1;
166 | message += index + ":两次密码输入不一致\r";
167 | }
168 |
169 |
170 |
171 | if (index > 0)
172 | {
173 | MessageBox.Show(message, "发现" + index + "项内容需要注意!", MessageBoxButton.OK, MessageBoxImage.Warning);
174 | return index;
175 | }
176 | else
177 | {
178 | return 0;
179 | }
180 |
181 |
182 |
183 | }
184 |
185 | }
186 | }
187 |
--------------------------------------------------------------------------------
/SIPAM/auzq3-didx5-001.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yaobus/SIPAM/c76eabead57a89fe06a0eaf354949a7a24baea48/SIPAM/auzq3-didx5-001.ico
--------------------------------------------------------------------------------
/SIPAM/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/SIPAM/全部资产.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yaobus/SIPAM/c76eabead57a89fe06a0eaf354949a7a24baea48/SIPAM/全部资产.ico
--------------------------------------------------------------------------------