Delphi+SQL Server实现的(GUI)户籍管理系统

1.项目简介

  本项目是一个户籍管理系统,用于记录住户身份信息,提供新户登记(增加)、户籍变更(修改)、户籍注销(删除)、户籍查询、曾用名查询、迁户记录查询以及创建备份、删除备份共8个功能。

1.1. 软件环境与开发工具

  • 操作系统:Windows 10 Home China 1809 17763
  • 数据库:SQL Server Express 2017
  • 集成开发环境:Embarcadero Delphi Architect 10.3

2. 数据库设计

2.1. 概要结构设计

  数据库Manager共包括以下3张表:

表名

说明

People

存储用户信息,是程序的核心表

Rename

存储用户改名记录,作为曾用名表

Move

存储用户的住址变更记录,作为户籍变更历史

Controller

存储系统管理员账户信息

2.2. 数据表结构分析

  4张数据表的字段分别列举如下:

字段名

含义

类型

Name

姓名

NVARCHAR(10)

Sex

性别

NCHAR(2)

ID_Num

身份证号(主键)

CHAR(18)

Address

户籍地址

NVARCHAR(100)

Tel_No

联系方式

NUMERIC(12, 0)

Date

更新时间

DATETIME

字段名

含义

类型

ID_Num

身份证号(主键)

CHAR(18)

Old_Name

曾用名

CHAR(10)

Date

改名时间(升序索引)

DATETIME

字段名

含义

类型

ID_Num

身份证号(主键)

CHAR(18)

Address

曾用户籍地

NVARCHAR(100)

Date

迁户时间(升序索引)

DATETIME

字段名

含义

类型

Username

用户名(主键)

NCHAR(10)

Alias

别名

NCHAR(10)

Password

密码

VARBINARY(128)

2.3建表语句

USE [Manager]
GO
EXEC sys.sp_dropextendedproperty @name=N'MS_Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Rename', @level2type=N'CONSTRAINT',@level2name=N'FK_Rename_People'
GO
EXEC sys.sp_dropextendedproperty @name=N'MS_Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'CONSTRAINT',@level2name=N'CK_Tel_Limit'
GO
EXEC sys.sp_dropextendedproperty @name=N'MS_Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'CONSTRAINT',@level2name=N'CK_Sex_Limit'
GO
EXEC sys.sp_dropextendedproperty @name=N'MS_Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'CONSTRAINT',@level2name=N'CK_ID_Limit'
GO
EXEC sys.sp_dropextendedproperty @name=N'MS_Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'Date'
GO
EXEC sys.sp_dropextendedproperty @name=N'MS_Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'Tel_No'
GO
EXEC sys.sp_dropextendedproperty @name=N'MS_Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'Address'
GO
EXEC sys.sp_dropextendedproperty @name=N'MS_Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'ID_Num'
GO
EXEC sys.sp_dropextendedproperty @name=N'MS_Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'Sex'
GO
EXEC sys.sp_dropextendedproperty @name=N'MS_Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'Name'
GO
EXEC sys.sp_dropextendedproperty @name=N'MS_Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Move', @level2type=N'CONSTRAINT',@level2name=N'FK_Move_People'
GO
ALTER TABLE [dbo].[People] DROP CONSTRAINT [CK_Tel_Limit]
GO
ALTER TABLE [dbo].[People] DROP CONSTRAINT [CK_Sex_Limit]
GO
ALTER TABLE [dbo].[People] DROP CONSTRAINT [CK_ID_Limit]
GO
ALTER TABLE [dbo].[Rename] DROP CONSTRAINT [FK_Rename_People]
GO
ALTER TABLE [dbo].[People] DROP CONSTRAINT [FK_People_People]
GO
ALTER TABLE [dbo].[Move] DROP CONSTRAINT [FK_Move_People]
GO
/****** Object:  Index [IX_Rename_1]    Script Date: 2019/5/27 1:20:03 ******/
DROP INDEX [IX_Rename_1] ON [dbo].[Rename]
GO
/****** Object:  Index [IX_Rename]    Script Date: 2019/5/27 1:20:03 ******/
DROP INDEX [IX_Rename] ON [dbo].[Rename]
GO
/****** Object:  Index [IX_Move_1]    Script Date: 2019/5/27 1:20:03 ******/
DROP INDEX [IX_Move_1] ON [dbo].[Move]
GO
/****** Object:  Index [IX_Move]    Script Date: 2019/5/27 1:20:03 ******/
DROP INDEX [IX_Move] ON [dbo].[Move]
GO
/****** Object:  Table [dbo].[Rename]    Script Date: 2019/5/27 1:20:03 ******/
DROP TABLE [dbo].[Rename]
GO
/****** Object:  Table [dbo].[People]    Script Date: 2019/5/27 1:20:03 ******/
DROP TABLE [dbo].[People]
GO
/****** Object:  Table [dbo].[Move]    Script Date: 2019/5/27 1:20:03 ******/
DROP TABLE [dbo].[Move]
GO
USE [master]
GO
/****** Object:  Database [Manager]    Script Date: 2019/5/27 1:20:03 ******/
DROP DATABASE [Manager]
GO
/****** Object:  Database [Manager]    Script Date: 2019/5/27 1:20:03 ******/
CREATE DATABASE [Manager] ON  PRIMARY 
( NAME = N'Citizens', FILENAME = N'D:\Program_Files_(x64)\Microsoft\SQL_Server_2017\Instances\MSSQL14.EXPRESS17\MSSQL\UserData\Citizens.mdf' , SIZE = 8192KB , MAXSIZE = 1048576KB , FILEGROWTH = 1%)
 LOG ON 
( NAME = N'Citizens_log', FILENAME = N'D:\Program_Files_(x64)\Microsoft\SQL_Server_2017\Instances\MSSQL14.EXPRESS17\MSSQL\UserData\Citizens_log.ldf' , SIZE = 8192KB , MAXSIZE = 1048576KB , FILEGROWTH = 1%)
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [Manager].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [Manager] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [Manager] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [Manager] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [Manager] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [Manager] SET ARITHABORT OFF 
GO
ALTER DATABASE [Manager] SET AUTO_CLOSE ON 
GO
ALTER DATABASE [Manager] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [Manager] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [Manager] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [Manager] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [Manager] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [Manager] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [Manager] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [Manager] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [Manager] SET  DISABLE_BROKER 
GO
ALTER DATABASE [Manager] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [Manager] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [Manager] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [Manager] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [Manager] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [Manager] SET READ_COMMITTED_SNAPSHOT OFF 
GO
ALTER DATABASE [Manager] SET HONOR_BROKER_PRIORITY OFF 
GO
ALTER DATABASE [Manager] SET RECOVERY SIMPLE 
GO
ALTER DATABASE [Manager] SET  MULTI_USER 
GO
ALTER DATABASE [Manager] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [Manager] SET DB_CHAINING OFF 
GO
USE [Manager]
GO
/****** Object:  Table [dbo].[Move]    Script Date: 2019/5/27 1:20:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Move](
	[ID_Num] [char](18) NOT NULL,
	[Address] [nvarchar](100) NOT NULL,
	[Date] [datetime] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[People]    Script Date: 2019/5/27 1:20:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[People](
	[Name] [nvarchar](10) NOT NULL,
	[Sex] [nchar](2) NOT NULL,
	[ID_Num] [char](18) NOT NULL,
	[Address] [nvarchar](100) NOT NULL,
	[Tel_No] [numeric](12, 0) NOT NULL,
	[Date] [datetime] NOT NULL,
 CONSTRAINT [PK_People] PRIMARY KEY CLUSTERED 
(
	[ID_Num] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Rename]    Script Date: 2019/5/27 1:20:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Rename](
	[ID_Num] [char](18) NOT NULL,
	[Old_Name] [char](10) NOT NULL,
	[Date] [datetime] NOT NULL
) ON [PRIMARY]
GO
INSERT [dbo].[Move] ([ID_Num], [Address], [Date]) VALUES (N'440101200101010101', N'北京市', CAST(N'2019-05-27T00:14:47.990' AS DateTime))
INSERT [dbo].[Move] ([ID_Num], [Address], [Date]) VALUES (N'440111201111111111', N'上海', CAST(N'2019-05-27T00:34:22.500' AS DateTime))
INSERT [dbo].[Move] ([ID_Num], [Address], [Date]) VALUES (N'440111201111111111', N'杭州', CAST(N'2019-05-27T00:35:12.933' AS DateTime))
INSERT [dbo].[Move] ([ID_Num], [Address], [Date]) VALUES (N'440111201111111111', N'杭州', CAST(N'2019-05-27T00:35:44.370' AS DateTime))
INSERT [dbo].[People] ([Name], [Sex], [ID_Num], [Address], [Tel_No], [Date]) VALUES (N'John', N'男 ', N'440101200101010101', N'北京市', CAST(13333333333 AS Numeric(12, 0)), CAST(N'2019-05-27T00:23:28.633' AS DateTime))
INSERT [dbo].[People] ([Name], [Sex], [ID_Num], [Address], [Tel_No], [Date]) VALUES (N'Ben', N'男 ', N'440111201111111111', N'杭州', CAST(13333333333 AS Numeric(12, 0)), CAST(N'2019-05-27T00:35:44.367' AS DateTime))
INSERT [dbo].[Rename] ([ID_Num], [Old_Name], [Date]) VALUES (N'440101200101010101', N'Alice     ', CAST(N'2019-05-27T00:08:35.767' AS DateTime))
INSERT [dbo].[Rename] ([ID_Num], [Old_Name], [Date]) VALUES (N'440101200101010101', N'Alice     ', CAST(N'2019-05-27T00:14:47.987' AS DateTime))
INSERT [dbo].[Rename] ([ID_Num], [Old_Name], [Date]) VALUES (N'440101200101010101', N'Cindarela ', CAST(N'2019-05-27T00:15:07.933' AS DateTime))
INSERT [dbo].[Rename] ([ID_Num], [Old_Name], [Date]) VALUES (N'440101200101010101', N'Alice     ', CAST(N'2019-05-27T00:18:24.390' AS DateTime))
INSERT [dbo].[Rename] ([ID_Num], [Old_Name], [Date]) VALUES (N'440101200101010101', N'Bob       ', CAST(N'2019-05-27T00:19:22.057' AS DateTime))
INSERT [dbo].[Rename] ([ID_Num], [Old_Name], [Date]) VALUES (N'440101200101010101', N'Ben       ', CAST(N'2019-05-27T00:20:54.577' AS DateTime))
INSERT [dbo].[Rename] ([ID_Num], [Old_Name], [Date]) VALUES (N'440101200101010101', N'John      ', CAST(N'2019-05-27T00:23:28.633' AS DateTime))
INSERT [dbo].[Rename] ([ID_Num], [Old_Name], [Date]) VALUES (N'440111201111111111', N'Alice     ', CAST(N'2019-05-27T00:34:22.500' AS DateTime))
INSERT [dbo].[Rename] ([ID_Num], [Old_Name], [Date]) VALUES (N'440111201111111111', N'Ben       ', CAST(N'2019-05-27T00:35:12.930' AS DateTime))
INSERT [dbo].[Rename] ([ID_Num], [Old_Name], [Date]) VALUES (N'440111201111111111', N'Ben       ', CAST(N'2019-05-27T00:35:44.370' AS DateTime))
SET ANSI_PADDING ON
GO
/****** Object:  Index [IX_Move]    Script Date: 2019/5/27 1:20:03 ******/
CREATE NONCLUSTERED INDEX [IX_Move] ON [dbo].[Move]
(
	[ID_Num] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [IX_Move_1]    Script Date: 2019/5/27 1:20:03 ******/
CREATE UNIQUE NONCLUSTERED INDEX [IX_Move_1] ON [dbo].[Move]
(
	[Date] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
/****** Object:  Index [IX_Rename]    Script Date: 2019/5/27 1:20:03 ******/
CREATE NONCLUSTERED INDEX [IX_Rename] ON [dbo].[Rename]
(
	[ID_Num] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [IX_Rename_1]    Script Date: 2019/5/27 1:20:03 ******/
CREATE UNIQUE NONCLUSTERED INDEX [IX_Rename_1] ON [dbo].[Rename]
(
	[Date] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = ON, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Move]  WITH CHECK ADD  CONSTRAINT [FK_Move_People] FOREIGN KEY([ID_Num])
REFERENCES [dbo].[People] ([ID_Num])
GO
ALTER TABLE [dbo].[Move] CHECK CONSTRAINT [FK_Move_People]
GO
ALTER TABLE [dbo].[People]  WITH CHECK ADD  CONSTRAINT [FK_People_People] FOREIGN KEY([ID_Num])
REFERENCES [dbo].[People] ([ID_Num])
GO
ALTER TABLE [dbo].[People] CHECK CONSTRAINT [FK_People_People]
GO
ALTER TABLE [dbo].[Rename]  WITH CHECK ADD  CONSTRAINT [FK_Rename_People] FOREIGN KEY([ID_Num])
REFERENCES [dbo].[People] ([ID_Num])
GO
ALTER TABLE [dbo].[Rename] CHECK CONSTRAINT [FK_Rename_People]
GO
ALTER TABLE [dbo].[People]  WITH CHECK ADD  CONSTRAINT [CK_ID_Limit] CHECK  ((len([ID_Num])=(15) OR len([ID_Num])=(18)))
GO
ALTER TABLE [dbo].[People] CHECK CONSTRAINT [CK_ID_Limit]
GO
ALTER TABLE [dbo].[People]  WITH CHECK ADD  CONSTRAINT [CK_Sex_Limit] CHECK  (([Sex]='男' OR [Sex]='女'))
GO
ALTER TABLE [dbo].[People] CHECK CONSTRAINT [CK_Sex_Limit]
GO
ALTER TABLE [dbo].[People]  WITH CHECK ADD  CONSTRAINT [CK_Tel_Limit] CHECK  ((len([Tel_No])>=(10) AND len([Tel_No])<=(12)))
GO
ALTER TABLE [dbo].[People] CHECK CONSTRAINT [CK_Tel_Limit]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'身份证绑定' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Move', @level2type=N'CONSTRAINT',@level2name=N'FK_Move_People'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'姓名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'Name'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'性别' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'Sex'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'身份证号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'ID_Num'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'家庭住址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'Address'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'联系方式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'Tel_No'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'户籍变更时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'COLUMN',@level2name=N'Date'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'限制身份证长度' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'CONSTRAINT',@level2name=N'CK_ID_Limit'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'限制性别取值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'CONSTRAINT',@level2name=N'CK_Sex_Limit'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'限制号码长度' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'People', @level2type=N'CONSTRAINT',@level2name=N'CK_Tel_Limit'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'身份证号关联' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Rename', @level2type=N'CONSTRAINT',@level2name=N'FK_Rename_People'
GO
USE [master]
GO
ALTER DATABASE [Manager] SET  READ_WRITE 
GO

3.系统实现

3.1登录业务

object Form1: TForm1
  Left = 0
  Top = 0
  BorderStyle = bsDialog
  Caption = #30331#24405#35748#35777
  ClientHeight = 329
  ClientWidth = 457
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  Position = poScreenCenter
  Visible = True
  PixelsPerInch = 96
  TextHeight = 13
  object GridPanel1: TGridPanel
    Left = 100
    Top = 135
    Width = 257
    Height = 59
    Align = alClient
    BevelOuter = bvNone
    Caption = 'GridPanel1'
    ColumnCollection = <
      item
        Value = 29.999999999999990000
      end
      item
        Value = 70.000000000000010000
      end>
    ControlCollection = <
      item
        Column = 0
        Control = Label1
        Row = 0
      end
      item
        Column = 1
        Control = Edit1
        Row = 0
      end
      item
        Column = 0
        Control = Label2
        Row = 1
      end
      item
        Column = 1
        Control = Edit2
        Row = 1
      end>
    RowCollection = <
      item
        Value = 49.999999999999990000
      end
      item
        Value = 50.000000000000020000
      end>
    ShowCaption = False
    TabOrder = 0
    ExplicitWidth = 254
    object Label1: TLabel
      Left = 0
      Top = 0
      Width = 77
      Height = 29
      Align = alClient
      Caption = #29992#25143#21517#65306
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -19
      Font.Name = #23435#20307
      Font.Style = []
      ParentFont = False
      ExplicitLeft = 51
      ExplicitTop = 1
      ExplicitWidth = 76
      ExplicitHeight = 19
    end
    object Edit1: TEdit
      Left = 77
      Top = 0
      Width = 180
      Height = 29
      Align = alClient
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -19
      Font.Name = #23435#20307
      Font.Style = []
      ParentFont = False
      TabOrder = 0
      ExplicitLeft = 127
      ExplicitTop = 1
      ExplicitWidth = 126
      ExplicitHeight = 27
    end
    object Label2: TLabel
      Left = 0
      Top = 29
      Width = 77
      Height = 30
      Align = alClient
      Caption = #23494#30721#65306
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -19
      Font.Name = #23435#20307
      Font.Style = []
      ParentFont = False
      ExplicitLeft = 70
      ExplicitWidth = 57
      ExplicitHeight = 19
    end
    object Edit2: TEdit
      Left = 77
      Top = 29
      Width = 180
      Height = 30
      Align = alClient
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -19
      Font.Name = #23435#20307
      Font.Style = []
      ParentFont = False
      PasswordChar = '*'
      TabOrder = 1
      ExplicitLeft = 127
      ExplicitWidth = 126
      ExplicitHeight = 27
    end
  end
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 457
    Height = 135
    Align = alTop
    BevelOuter = bvNone
    Caption = 'Panel1'
    ShowCaption = False
    TabOrder = 1
    ExplicitWidth = 454
    object Label3: TLabel
      Left = 0
      Top = 50
      Width = 457
      Height = 35
      Align = alClient
      Alignment = taCenter
      Caption = #36890#29992#25143#31821#31649#29702#31995#32479
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -27
      Font.Name = #38582#20070
      Font.Style = []
      ParentFont = False
      ExplicitWidth = 224
      ExplicitHeight = 27
    end
    object Panel5: TPanel
      Left = 0
      Top = 0
      Width = 457
      Height = 50
      Align = alTop
      BevelOuter = bvNone
      Caption = 'Panel5'
      ShowCaption = False
      TabOrder = 0
      ExplicitWidth = 454
    end
    object Panel7: TPanel
      Left = 0
      Top = 85
      Width = 457
      Height = 50
      Align = alBottom
      BevelOuter = bvNone
      Caption = 'Panel7'
      ShowCaption = False
      TabOrder = 1
      ExplicitTop = 91
    end
  end
  object Panel2: TPanel
    Left = 0
    Top = 194
    Width = 457
    Height = 135
    Align = alBottom
    BevelEdges = []
    BevelOuter = bvNone
    Caption = 'Panel2'
    ShowCaption = False
    TabOrder = 2
    ExplicitTop = 199
    ExplicitWidth = 454
    object Panel6: TPanel
      Left = 0
      Top = 0
      Width = 150
      Height = 25
      Align = alLeft
      BevelOuter = bvNone
      Caption = 'Panel6'
      ShowCaption = False
      TabOrder = 0
      ExplicitHeight = 40
    end
    object Panel8: TPanel
      Left = 307
      Top = 0
      Width = 150
      Height = 25
      Align = alRight
      BevelOuter = bvNone
      Caption = 'Panel8'
      ShowCaption = False
      TabOrder = 1
      ExplicitLeft = 322
      ExplicitHeight = 40
    end
    object Panel9: TPanel
      Left = 0
      Top = 25
      Width = 457
      Height = 110
      Align = alBottom
      BevelOuter = bvNone
      Caption = 'Panel9'
      ShowCaption = False
      TabOrder = 2
      ExplicitTop = 30
    end
    object GridPanel2: TGridPanel
      Left = 150
      Top = 0
      Width = 157
      Height = 25
      Align = alClient
      BevelOuter = bvNone
      Caption = 'GridPanel2'
      ColumnCollection = <
        item
          Value = 50.000000000000000000
        end
        item
          Value = 50.000000000000000000
        end>
      ControlCollection = <
        item
          Column = 0
          Control = Button1
          Row = 0
        end
        item
          Column = 1
          Control = Button2
          Row = 0
        end>
      RowCollection = <
        item
          Value = 100.000000000000000000
        end>
      ShowCaption = False
      TabOrder = 3
      ExplicitLeft = 136
      ExplicitTop = 48
      ExplicitWidth = 185
      ExplicitHeight = 41
      DesignSize = (
        157
        25)
      object Button1: TButton
        Left = 0
        Top = 0
        Width = 78
        Height = 25
        Align = alClient
        Caption = #30331#24405
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #23435#20307
        Font.Style = []
        ParentFont = False
        TabOrder = 0
        OnClick = Button1Click
        ExplicitLeft = 40
        ExplicitWidth = 75
      end
      object Button2: TButton
        Left = 80
        Top = 0
        Width = 75
        Height = 25
        Anchors = []
        Caption = #21462#28040
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clWindowText
        Font.Height = -19
        Font.Name = #23435#20307
        Font.Style = []
        ParentFont = False
        TabOrder = 1
        OnClick = Button2Click
        ExplicitLeft = 40
      end
    end
  end
  object Panel3: TPanel
    Left = 0
    Top = 135
    Width = 100
    Height = 59
    Align = alLeft
    BevelEdges = []
    BevelOuter = bvNone
    Caption = 'Panel3'
    ShowCaption = False
    TabOrder = 3
  end
  object Panel4: TPanel
    Left = 357
    Top = 135
    Width = 100
    Height = 59
    Align = alRight
    BevelOuter = bvNone
    Caption = 'Panel4'
    ShowCaption = False
    TabOrder = 4
    ExplicitLeft = 354
  end
  object ADOQuery1: TADOQuery
    Connection = DataModule1.ADOConnection1
    Parameters = <>
    Left = 24
    Top = 264
  end
end
unit Login;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, Data.DB,
  Data.Win.ADODB;

type
  TForm1 = class(TForm)
    GridPanel1: TGridPanel;
    Label1: TLabel;
    Panel1: TPanel;
    Panel2: TPanel;
    Edit1: TEdit;
    Panel3: TPanel;
    Panel4: TPanel;
    Label2: TLabel;
    Edit2: TEdit;
    Panel5: TPanel;
    Panel7: TPanel;
    Label3: TLabel;
    Panel6: TPanel;
    Panel8: TPanel;
    Panel9: TPanel;
    GridPanel2: TGridPanel;
    Button1: TButton;
    Button2: TButton;
    ADOQuery1: TADOQuery;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
  uses Main, Connect;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  // 判断用户名或密码为空
  if (Edit1.Text = '') then
  begin
    showMessage('错误:用户名不能为空!');
    Edit1.SetFocus;
  end
  else
  begin
    ADOQuery1.Close;
    ADOQuery1.SQL.Clear;
    // 尝试登录
    ADOQuery1.SQL.Add(
      'SELECT ''TRUE'' AS [Authorized], [Alias], [Username] FROM [Controller] WHERE [Username] = '
      + '''' + Edit1.Text + ''' AND [Password] = HASHBYTES(''MD5'', ''' +
      Edit2.Text + ''')'
    );
    ADOQuery1.Open;
    // 如果登陆成功
    if (ADOQuery1.FieldByName('Authorized').AsString = 'TRUE') then
    begin
      // 用户是否有别名?
      if (ADOQuery1.FieldByName('Alias').AsString <> '') then
      begin
        Form2.Label1.Caption := '欢迎您,' + trim(ADOQuery1.FieldByName('Alias').AsString)
          + '!';
      end
      // 否则,显示用户名
      else
      begin
        Form2.Label1.Caption := '欢迎您,' + trim(ADOQuery1.FieldByName('Username').AsString)
          + '!';
      end;
      Form1.Hide;
      Form2.Show;
    end
    else
    begin
      showMessage('错误:用户名或密码错误!');
    end;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Edit1.Text := '';
  Edit2.Text := '';
end;

end.

3.2主启动类

unit Main;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Menus, Vcl.StdCtrls,
  Vcl.Imaging.jpeg, Vcl.ExtCtrls;

type
  TForm2 = class(TForm)
    MainMenu1: TMainMenu;
    F1: TMenuItem;
    Q1: TMenuItem;
    M1: TMenuItem;
    A1: TMenuItem;
    G1: TMenuItem;
    N1: TMenuItem;
    M2: TMenuItem;
    Image1: TImage;
    Label1: TLabel;
    N2: TMenuItem;
    N3: TMenuItem;
    B1: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure Q1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure G1Click(Sender: TObject);
    procedure A1Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure M2Click(Sender: TObject);
    procedure N3Click(Sender: TObject);
    procedure N5Click(Sender: TObject);
    procedure B1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation
  uses Login, Edit, Rename, Move, About, Backup, Connect;

{$R *.dfm}

procedure TForm2.A1Click(Sender: TObject);
begin
  Form4.Show;
end;

procedure TForm2.B1Click(Sender: TObject);
begin
  Form7.Show;
  Form7.FileListBox1.Directory := 'D:\Program_Files_(x64)\Git\Repos\Delphi_Design\bak';
  Form7.FileListBox1.Update;
end;

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Form1.Close;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  Form2.Visible := False;
end;

procedure TForm2.G1Click(Sender: TObject);
begin
  Form3.Show;
end;

procedure TForm2.M2Click(Sender: TObject);
begin
  Form6.Show;
  Form6.ADOTable1.Close;
  Form6.ADOTable1.Open;
end;

procedure TForm2.N1Click(Sender: TObject);
begin
  Form5.Show;
  Form5.ADOTable1.Close;
  Form5.ADOTable1.Open;
end;

procedure TForm2.N3Click(Sender: TObject);
begin
  Form2.Hide;
  Label1.Caption := '';
  Form1.Show;
  Form1.SetFocus;
end;

procedure TForm2.N5Click(Sender: TObject);
begin
  Form7.Show;
  DataModule1.ADOConnection1.Close;
  Form7.FileListBox1.Directory := 'D:\Program_Files_(x64)\Git\Repos\Delphi_Design\bak';
  Form7.FileListBox1.Update;
end;

procedure TForm2.Q1Click(Sender: TObject);
begin
  Form1.Close;
end;

end.

3.3部分代码

unit Rename;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Data.Win.ADODB, Vcl.Grids,
  Vcl.DBGrids;

type
  TForm5 = class(TForm)
    ADOTable1: TADOTable;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form5: TForm5;

implementation
  uses Connect;

{$R *.dfm}

procedure TForm5.FormCreate(Sender: TObject);
begin
  ADOTable1.Active := True;
end;

end.

4. 系统设计与实现

5. 结论与尚存在的问题

  以下是本项目仍然存在的问题:

  1. 用户查询功能存在缺陷,无法在DBGrid中显示ADOQuery的查询结果;
  2. 数据库无法从*.bak文件中恢复。

6. 个人总结

  项目由可视化集成开发环境(快速应用程序开发工具)制作而成,对比于C/C++ MFC/QT、Java Swing/SWT、Python TKinter,Delphi具有方便、快捷的优势,在界面布局方面节省了大量的时间。但在另一方面,仍有个别功能只能通过编写代码实现,大量由Delphi自动生成的Object-Pascal代码使得项目维护难度提高。

  本次开发工作存在较大的失误,项目分工错误让我基本承担所有工作。此外项目的开工时间极度延后,导致工期不足,甚至无法完成基本功能。

  通过此次开发的教训,在后续课程设计乃至今后的生产环境开发都要提前估计工作量与工期,合理安排开发进度,杜绝临时赶工的行为。

7. 项目用法

  由于项目需要连接数据库程序,而不同设备的数据库配置可能存在差异,有别于直接连接到库文件的Microsoft Office Access、SQLite。由我使用Windows-32bit Release模式编译发布的可执行程序并不通用,所以请根据以下步骤编译运行:

  1. 项目提供了Citizens_log.ldf数据库日志文件和Citizens.mdf数据库主文件,这2个文件仅支持Microsoft SQL Server 2017及以上版本数据库的附加。对于之前的版本,项目额外提供了script.sql以实现数据库导入工作,此脚本最低兼容SQL Server 2008。脚本仅涉及架构,没有任何数据。如有测试需要,请在运行此脚本生成数据库后自行添加备用数据。
  2. 使用Delphi打开代码库中的Manager.dproj,定位至Connect.pas文件的窗体设计视图。
  3. 修改ADOConnection1控件的ConnectionString属性,点击Build选项,在数据库连接向导切换为您设备的配置(包括驱动程序、服务器名、登陆账号及密码、数据库名)。
  4. 定位至Backup.pas文件的窗体设计视图,同样地修改ADOQuery1控件的ConnectionString属性。
  5. 定位至Edit.pasMove.pasRename.pas,重新激活各个页面的ADOTable1,确认DBGrid能够正常显示数据库的内容。
  6. 以上,即可正常编译运行。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/953092.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

第2课 “Hello World” 与 print

1 Hello World 2 print 函数解析 2.1 基本用法 2.2 输出多个对象 2.3 使用sep参数 2.4 使用flush参数 2.5 输出到文件 3 格式化输出 3.1 格式化输出整数 3.2 格式化输出16进制整数 3.3 格式化输出浮点数(float) 3.4 格式化输出字符串(string) 3.5 输出列表与字典 …

计算机网络(四)网络层

4.1、网络层概述 简介 网络层的主要任务是实现网络互连&#xff0c;进而实现数据包在各网络之间的传输 这些异构型网络N1~N7如果只是需要各自内部通信&#xff0c;他们只要实现各自的物理层和数据链路层即可 但是如果要将这些异构型网络互连起来&#xff0c;形成一个更大的互…

qt 窗口(window/widget)绘制/渲染顺序 QPainter QPaintDevice Qpainter渲染 失效 无效 原因

qt窗体布局 窗体渲染过程 qt中窗体渲染逻辑顺序为 本窗体->子窗体/控件 递归&#xff0c;也就是说先渲染父窗体再渲染子窗体。其中子窗体按加入时的先后顺序进行渲染。通过下方的函数调用堆栈可以看出窗体都是在widget组件源码的widgetprivate::drawwidget中进行渲染的&am…

网络安全-kail linux 网络配置(基础篇)

一、网络配置 1.查看网络IP地址&#xff0c; 我的kail&#xff1a;192.168.15.128 使用ifconfig查看kail网络连接情况&#xff0c;ip地址情况 又复制了一台kail计算机的IP地址。 再看一下windows本机&#xff1a;使用ipconfig进行查看&#xff1a; 再看一下虚拟机上的win7I…

Edge浏览器内置的截长图功能

Edge浏览器内置截图功能 近年来&#xff0c;Edge浏览器不断更新和完善&#xff0c;也提供了长截图功能。在Edge中&#xff0c;只需点击右上角的“...”&#xff0c;然后选择“网页捕获”->“捕获整页”&#xff0c;即可实现长截图。这一功能的简单易用&#xff0c;使其成为…

【NLP】语言模型的发展历程 (1)

语言模型的发展历程系列博客主要包含以下文章&#xff1a; 【NLP】语言模型的发展历程 (1)【NLP】大语言模型的发展历程 (2) 本篇博客是该系列的第一篇&#xff0c;主要讲讲 语言模型&#xff08;LM&#xff0c;Language Model&#xff09; 的发展历程。 文章目录 一、统计语…

【ASP.NET学习】ASP.NET MVC基本编程

文章目录 ASP.NET MVCMVC 编程模式ASP.NET MVC - Internet 应用程序创建MVC web应用程序应用程序信息应用程序文件配置文件 用新建的ASP.NET MVC程序做一个简单计算器1. **修改视图文件**2. **修改控制器文件** 用新建的ASP.NET MVC程序做一个复杂计算器1.创建模型&#xff08;…

蓝桥云客第 5 场 算法季度赛

题目&#xff1a; 2.开赛主题曲【算法赛】 - 蓝桥云课 问题描述 蓝桥杯组委会创作了一首气势磅礴的开赛主题曲&#xff0c;其歌词可用一个仅包含小写字母的字符串 S 表示。S 中的每个字符对应一个音高&#xff0c;音高由字母表顺序决定&#xff1a;a1,b2,...,z26。字母越靠后…

计算机网络 (37)TCP的流量控制

前言 计算机网络中的TCP&#xff08;传输控制协议&#xff09;流量控制是一种重要机制&#xff0c;用于确保数据在发送方和接收方之间的传输既高效又稳定。 一、目的 TCP流量控制的主要目的是防止发送方发送数据过快&#xff0c;导致接收方无法及时处理&#xff0c;从而引起数据…

【Elasticsearch7.11】postman批量导入少量数据

JSON 文件内的数据格式&#xff0c;json文件数据条数不要过多&#xff0c;会请求参数过大&#xff0c;最好控制再10000以内。 {"index":{"_id":"baec07466732902d22a24ba01ff09751"}} {"uuid":"baec07466732902d22a24ba01ff0975…

Spring Boot 支持哪些日志框架

Spring Boot 支持多种日志框架&#xff0c;主要包括以下几种&#xff1a; SLF4J (Simple Logging Facade for Java) Logback&#xff08;默认&#xff09;Log4j 2Java Util Logging (JUL) 其中&#xff0c;Spring Boot 默认使用 SLF4J 和 Logback 作为日志框架。如果你需要使…

AIDD - 人工智能药物设计 -深度学习赋能脂质纳米颗粒设计,实现高效肺部基因递送

Nat. Biotechnol. | 深度学习赋能脂质纳米颗粒设计&#xff0c;实现高效肺部基因递送 今天为大家介绍的是来自美国麻省理工和爱荷华大学卡弗医学院团队的一篇论文。可离子化脂质&#xff08;ionizable lipids&#xff09;是脂质纳米颗粒&#xff08;lipid nanoparticles&#…

【SVN】版本发布快捷操作

摘要&#xff1a;因为每次发版都需要制作一份相同的文件夹&#xff0c;而大部分的包都不需要变更&#xff0c;但是文件又非常大&#xff0c;记录自己的操作经验。 首先在SVN Repository Browser 界面把上一次的版本复制一份&#xff0c;复制的时候重命名为新的版本号 右击要复…

AR 眼镜之-拍照/录像动效切换-实现方案

目录 &#x1f4c2; 前言 AR 眼镜系统版本 拍照/录像动效切换 1. &#x1f531; 技术方案 1.1 技术方案概述 1.2 实现方案 1&#xff09;第一阶段动效 2&#xff09;第二阶段动效 2. &#x1f4a0; 默认代码配置 2.1 XML 初始布局 2.2 监听滑动对 View 改变 3. ⚛️…

HTML5实现好看的端午节网页源码

HTML5实现好看的端午节网页源码 前言一、设计来源1.1 网站首页界面1.2 登录注册界面1.3 端午节由来界面1.4 端午节习俗界面1.5 端午节文化界面1.6 端午节美食界面1.7 端午节故事界面1.8 端午节民谣界面1.9 联系我们界面 二、效果和源码2.1 动态效果2.2 源代码 源码下载结束语 H…

Android使用系统消息与定时器实现霓虹灯效果

演示效果: 界面设计: 在帧布局FrameLayout中添加6个TextView 依次设置这6个TextView的宽&#xff0c;高&#xff0c;权重 也可在XML中直接设置 添加自定义颜色 关联自定义颜色到数组变量 关联6个TextView控件到数组变量 处理自定义系统消息 Handler _sysHandler new Han…

多活架构的实现原理与应用场景解析

一、多活架构为何如此重要? 企业的业务运营与各类线上服务紧密相连,从日常的购物消费、社交娱乐,到金融交易、在线教育等关键领域,无一不依赖于稳定可靠的信息系统。多活架构的重要性愈发凸显,它宛如一位忠诚的卫士,为业务的平稳运行保驾护航。 回想那些因系统故障引发的…

【JVM-2.2】使用JConsole监控和管理Java应用程序:从入门到精通

在Java应用程序的开发和运维过程中&#xff0c;监控和管理应用程序的性能和资源使用情况是非常重要的。JConsole是Java Development Kit&#xff08;JDK&#xff09;自带的一款图形化监控工具&#xff0c;它可以帮助开发者实时监控Java应用程序的内存、线程、类加载以及垃圾回收…

《自动驾驶与机器人中的SLAM技术》ch2:基础数学知识

目录 2.1 几何学 向量的内积和外积 旋转矩阵 旋转向量 四元数 李群和李代数 SO(3)上的 BCH 线性近似式 2.2 运动学 李群视角下的运动学 SO(3) t 上的运动学 线速度和加速度 扰动模型和雅可比矩阵 典型算例&#xff1a;对向量进行旋转 典型算例&#xff1a;旋转的复合 2.3 …

如何使用高性能内存数据库Redis

一、详细介绍 1.1、Redis概述 Redis&#xff08;Remote Dictionary Server&#xff09;是一个开源的、内存中的数据结构存储系统&#xff0c;它可以用作数据库、缓存和消息中间件。Redis支持多种类型的数据结构&#xff0c;如字符串&#xff08;strings&#xff09;、哈希&am…