Salary management system design and implementation

Chapter 1 Introduction

1.1. Development background
With the continuous development of computer technology, computers, as a product of the era of knowledge economy, have been widely used in various industries and fields in society. With the deepening of my country's state-owned enterprise reform and the growing prosperity of the socialist market economy, the competition among various enterprises has become increasingly fierce, forcing enterprises to adopt advanced computer hardware equipment and high-quality auxiliary software to manage various operations of the enterprise in order to improve the labor productivity and personnel efficiency of the enterprise. As a kind of management software, salary management system software is being used more and more widely in various enterprises and institutions.
Enterprise salary management is an important part of company management. As the number of employees in an enterprise increases, the salary management work of the enterprise becomes more and more complicated. Salary management not only involves the management of enterprise labor and personnel, but also an important part of enterprise financial management. Salary management needs to be connected with personnel management, and at the same time connect working hours and attendance, medical insurance, etc., to generate the basic salary, allowance, medical insurance, insurance premium, actual salary, etc. of each employee in the enterprise. Funds are the main element for the survival of an enterprise. The flow of funds affects the overall operation of the enterprise. The wages of enterprise employees are an important part of enterprise fund management. Early salary statistics and payment were processed paper materials manually, which not only took a lot of time for financial personnel and was not easy to save, but often due to personal factors, careless copying or negligence in calculation, wage payment errors occurred. Early salary management mostly used paper materials and had strong time constraints. Based on the above reasons, the enterprise salary management system uses computers for safe storage, fast calculation, and comprehensive statistics to realize the systematization, standardization, and automation of salary management. The enterprise salary management system is a typical information management system (MIS). The front-end program development tool uses Microsoft's VB6, and the back-end database uses Access database. VB6 is an object-oriented development tool, which has the advantages of rich components, simple language and powerful functions. Access database has the advantages of seamless connection with VB6, simple operation and easy use. The operation results prove that the enterprise salary management system has greatly improved work efficiency, saved manpower and material resources, and finally met the needs of enterprise financial management and employee salary payment, and has also become a symbol of modern enterprise management 1.2, system description 1.2.1, data
model
analysis
   A database is a collection of data designed by an enterprise, organization or department. It not only reflects the content of the data itself, but also reflects the relationship between the data. The data model is used in the database as a tool to abstract, represent and process data and information in the real world. Simply put, a data model is a simulation of the real world.
   Data model usually consists of three elements: data structure; data operation; data constraints.
   There are different types of data models: conceptual models and data models. The conceptual model is the first level of abstraction from the real world to the information world. This information structure does not depend on a specific computer system, nor is it a data model supported by a certain database management system. It is an intermediate level from the real world to the machine world.
The data structure of the relational model, that is, the type of object studied includes: relation, corresponding to a two-dimensional table, which is composed of rows and columns; tuple, corresponding to a row in the table; attribute, corresponding to a column in the table; primary code, corresponding to an attribute value, which can uniquely determine a tuple; component, corresponding to an attribute value in the tuple. Data manipulation of the relational model includes querying, inserting, deleting, and updating data. These operations must satisfy the integrity constraints of the relationship: entity integrity, referential integrity, and user-defined integrity.
1.2.2. Pattern structure analysis of the database system
   Pattern is the description of the logical structure and characteristics of all data in the database, and it does not design specific values. From the perspective of database management systems, although the data models they support, the database languages ​​used, and the operating system platforms they are based on may be different, they usually adopt a three-level schema structure in terms of architecture (except for individual small database systems) and provide two-level image functions.
The three-level schema structure means that the database system is composed of three levels: external schema, schema, and internal schema, as shown in Figure 1.2.

Figure 1-1 Three-level schema structure diagram
Schema is the view of database data at the logical level. It is based on a certain data model. It not only defines the logical structure of the data (such as data item composition, name, type, value range, etc.), but also defines the security, integrity and connection between data related to the data. The external schema is a subset of the schema and is a description of the logical structure of local data. It is application-specific. Because different applications may require different views of partial data, a database can have multiple external schemas, but only one. The internal mode is also called the storage mode, which is the description of the physical structure and storage structure of the data, and the representation of the data inside the database. A database has only one internal schema.
  The three-level mode is three levels of abstraction for data, enabling users to logically process data without having to deal with the specific representation and storage of data in the computer. However, the three abstraction levels must be able to connect and convert each other, and the database system provides two layers of images to complete this function. External schema/schema mapping defines the correspondence between external schemas and schemas. These image definitions are usually included in the description of the respective foreign schema. When the mode changes, it only needs to change the image accordingly, and the external mode can remain unchanged, so that the application program does not need to be modified, and the logical independence of the data is guaranteed. The schema/internal schema image fixes the corresponding relationship between the data global logical structure and the storage structure. This image definition is usually included in the schema description. If the storage structure of the database is changed, it is only necessary to make corresponding changes to the image to keep the schema unchanged, thereby ensuring the physical independence of the data.
1.2.3. Architecture analysis of the database system
   The schema structure of the database is transparent to end users and programmers, and what they see is only the external schema and application program of the database. From the perspective of end users, database systems are divided into single-user structure, master-slave structure, distributed structure and client/server structure.
1.2.4. Database management system analysis
   In a database system, several aspects such as application program, database management system, operating system, hardware, etc. must work together. Among them, the database management system plays a key intermediary role. When an application reads a piece of data from the database, it issues a command to the database management system to read the data record. The database management system checks the syntax and semantics of the command, calls the corresponding sub-mode of the application program, checks the access rights of the application program, and decides whether to execute the command. If execution is refused, an error message is returned to the user. After deciding to execute the command, the database management system calls the schema to determine which records should be read into the schema according to the definition of the sub-schema/schema image. The database management system calls the physical mode again, and decides which file, which access method to use, and which or those physical records should be read in according to the definition of the mode/physical mode image. The database management system then issues commands to the operating system to perform the read of the desired physical records. After the operating system is executed, the data is sent to the system buffer. The database management system then derives the record format to be read by the application program according to the definition of the sub-mode/mode image, transfers the data from the system buffer to the user work area of ​​the application program, and returns the status information of the command execution.
According to the functions of the database management system, it can be divided into four components. Data definition language and its translation processing program: firstly, the data definition language is used to define the database schema, storage schema, external schema, mapping between schemas at all levels, and related constraints, etc. The translation handler then translates them into the corresponding internal representation, a description of the database schema. These descriptions are stored in the data dictionary (system catalog) as the basis for the database management system to access and manage data. Data manipulation language and its translation processing program: provide basic operations such as retrieval, insertion, modification, and deletion of the database. Database operation control program: responsible for the control and management of the database operation process. Utilities: complete the establishment and maintenance of the database, as well as the conversion and communication of data formats and other functions.
The whole system starts from meeting the requirements of easy operation, friendly interface, flexibility, practicality and safety, and completes the whole process of salary management, including user management, system management, information initialization, toolbox and help eleven modules. The actual use proves that the salary management system designed in this paper can meet the needs of the company's salary management.
The thesis mainly introduces the development background of this topic, the functions to be completed and the development process. Emphatically explained the key point of system design, design idea, difficult technology and solution.

1.3. The selection and introduction of VB
Now, there are many application development products that can be purchased in the market, and there are dozens of popular ones. At present, the most popular, most used, and most advanced products that can be used as enterprise-level development tools in the Chinese market include:
Microsoft's Visual Basic,
Microsoft's Visual C,
Borland's Delphi,
Sun's Java, etc.
Among the many program development tools currently on the market, some emphasize the flexibility and execution efficiency of programming languages; However, the flexibility of the language and the convenience of the tool are inseparable. There are only convenient tools, but no flexible language support. Many specialized processing actions will take several times to process, making the original advantage of improving efficiency useless. On the contrary, if we only emphasize the flexibility of the programming language without the cooperation of convenient tools, some very simple interface processing actions will seriously waste the precious time of the programmer.
As a database system development, VB is a very ideal choice. VB stands out from many software development tools because of its easy learning, powerful functions and fast compilation speed. It provides a flexible visual design tool, perfectly and closely combines the visual interface with object-oriented technology, and encapsulates the complexity of Windows programming. Programs ranging from simple personal database applications to complex enterprise multi-level distributed systems can be developed using VB. Its friendly integrated development interface, visual two-way development mode, and good database applications support efficient program development and program operation, and are highly praised by the majority of program developers. In particular, VB's powerful support for database applications has greatly improved the efficiency of database application software development and shortened the development cycle, and is deeply loved by the majority of database application program designers. VB provides database application developers with a wealth of database development components, making database application development more powerful, more flexible in control, and faster in compiled programs. VB is a rapid visual program development tool software produced by Microsoft. With the help of Microsoft's monopoly in operating systems and office software, VB has become popular all over the world in just a few years. VB is an extremely powerful software, mainly manifested in: WYSIWYG interface design, object-based design method, extremely short software development cycle, and easy-to-maintain generated code.
Microsoft Corporation of the United States launched VB1.0 in 1991 and has gone through 6 versions so far. VB6.0 runs on win9x or winme, win2000, winxp, windowsNT and other operating systems, and is a 32-bit application development tool.

1. The basic features of VB language and the basic holding points of VB application program
VB programming language has many excellent features, and there are two basic features when using it to design application programs: visual design and event-driven programming.
In addition to some nouns and terms of general high-level languages, the Visual Basic system also has several commonly used nouns in the system. Its basic meaning is as follows:
(1) Window (Form)
A window is an interface or interface for human-computer interaction, also called a form. The human-computer interaction interface or interface of the VB system is a standard window of the Windows system, whether it is at design time or at runtime.
(2) Object (Object)
The object is a control tool that the designer can directly use to deal with the output provided by the VB system. The object types that this program is applied to include label box (Label Box), text box (Text Box), command button (Command Button), grid (Data Grid), ADO control (Adodc1) and so on. When these tools are placed on the corresponding form of the user interface, they are called objects or controls. Users can set the "properties" and "methods" of the object to facilitate the object to adapt to the input and output content of the application program designed by the user, and the generation process and structure of the object are encapsulated. Proper use of objects can reduce program and development time, and improve the work efficiency of programmers.
(3) Properties (Properties)
properties are the parameters or data interfaces of related objects provided by the VB system. The user determines the appearance and performance characteristics of the object by properly setting or changing the properties of the object, so as to effectively use the objects provided by the system. For example, the name of the object, the position displayed on the screen, the size, the color, the received or contained data content and the presentation format of the data, etc.
(4)Events
An event refers to the behavior of a certain operation (such as keystroke, click, or mouse movement) performed by a user or operator on a computer or a change in the system state. Events are commonly used in the VB system to guide the computer to execute a program. The keyboard events used by the program include KeyPress (key press) event, KeyDown event and KeyUp event; mouse events include Click (click the mouse) event and DbDlicd (double-click the mouse).
(5) Method (Method)
The method mainly refers to the process of using a certain effect on an object. It is something that the computer is asked to do during program execution. The methods of its program are Show (display) method, Hide (hide) method, Refresh (refresh) method.
(6) Procedure (Procedure)
refers to a program segment that is defined or explained, or triggered based on an event corresponding to an object.
(7) Module (Module)
A module refers to a set of declarations or definitions of some operands or procedures. System program can be roughly divided into four modules: data input, according to query, data printing and communication.

2. Visual design
Like some other visual program development tools, VB has the characteristics of visual design. When Microsoft Word first entered the market, an important functional weight to compete with WPS was the word processing function of "what you see is what you get". VB can also be said to be "what you see is what you get" when designing the application program interface. When designing, the application program interface imagined in the mind can be drawn by keyboard and mouse and freehand instead of compiling a large number of codes and then compiling. Hand-drawn, while some underlying program codes are automatically generated or modified by VB.
VB provides users with a large number of interface elements (called control objects in VB). These control objects are not unfamiliar to users who are familiar with Windows applications, such as "form", "menu", "command button", "tool button", "check box" and so on.
3. Event-driven programming
Since the emergence of the Windows operating system, the graphical user interface and multi-task and multi-process application programs require that the program design cannot be unitary. When using VB to design an application program, it is necessary to first determine how the application program interacts with the user. For example, when events such as mouse click and keyboard input occur, the code written by the user controls the response to these events. This is the so-called event-driven programming.
4. Realize menu options
Menu is one of the most important features of a program. Most programs rely on a well-defined menu to make the program easy to use and maintain. Visual Basic also provides a powerful menu creation function to make the program more standard.
This system uses the menu editor of Visual Basic to create menus or modify existing menus, and you can also use the Application Wizard of Visual Basic to operate.
5. Implement the toolbar
The CoolBar control is similar to the CoolBar seen in Office2000. CoolBar is a tool that can float on the form, and it is also a container for other ActiveX. You can also provide users with better flexibility and usefulness by moving into other spaces in CoolBar.
Select the "Component" option in the "Project" drop-down menu to display the "Component" dialog box. After selecting "Microsoft Windows Common Controls 6.0" in the "Controls" tab list, a new control is added in the tool window.
This system uses the Statubar control in the Cool tool. In the system interface, a status bar is added. In the first column, select the text in the style column, in the second column, select the system date, and in the third column, select the system time. In this way, you can see the current time and date when you operate the system at any time.
Using Access2000 to realize relational database
 The concept of database
Database is a tool for storing data and operating data. The role of the database is to organize and express information. In short, a database is a collection of information. Computer databases can be divided into two categories: non-relational databases (flat-file) and relational databases (relational). A relational database contains information from multiple data tables, and the database contains terms, object records, domains, etc. in different parts.
Create a new database
The first step to create any database is to carefully plan the database, the design must be flexible and logical. The process of creating a database structure is considered data model design.
1. Identify the required data;
2. Collect the identified fields into the table;
3. Identify the primary key field;
4. Draw a simple data chart;
5. Specification data;
6. Identify the information of the specified field;
7. Create physical tables.
Modify the established database
The modification of the database is divided into: adding, editing and deleting records. These three operations can be completed by programs created by Visual Basic, and the following chapters will describe the specific methods of realization in detail.
6. Realize the relationship between databases
The relationship between databases indicates that two libraries share a common keyword value. A connection refers to a virtual table, which is established when the user requests information from different interconnected tables, and the key fields are used to find matching records in the different interconnected tables. A more advanced form of join is called a self-join. This type of join is when a table is joined to one of its own fields, or combined fields by duplicate data in different records. There are three different types of keys in a database: primary keys, composite keys, and foreign keys. The key types used in the tables are used to describe what the library represents and how it relates to other libraries in the database.

Chapter 2 Outline Design

2.1. System overview
Looking at the salary management software of various enterprises, a good enterprise salary management software should have a simple and friendly operation interface, a safe database, hierarchical user rights management, powerful data export and backup functions, and online help documents. The system focuses on the development and design around these points.
Based on the analysis of many of the above problems, and the reference of enterprise management system. The system is divided into seven modules: system management, employee information setting, salary information management, salary settlement management, database management, toolbox, and help: system management is divided into operator
login management, user management, locking operation screen and exit. The operator login management records the user login time, which is convenient for the administrator to view.
When the user leaves temporarily, the operation screen can be locked to prevent illegal operation.
User management is divided into three parts: new common user, new administrator user, and password modification.
2.2. Employee attendance information
1. Set commute time: set the company's commute time.
2. Add employee attendance information: It is mainly divided into commute information and other attendance information. The commute information mainly records the time of commute every day; other attendance information includes: leave, absenteeism, lateness and other basic information.
3. Modify employee attendance information: When there is an error in the attendance information and needs to be modified, you can modify the corresponding record from here.
4. Query employee attendance information: query according to employee number or time to get all attendance information. Including commute, overtime and business trip information, but can not perform any operations on the information.
5. Delete attendance information: It is divided into deleting commute information and deleting other attendance information.
6. Attendance information list: It is divided into employee commute information list and other employee attendance information list.
In the information initialization part, due to different companies, the information settings of departments, positions, salary categories, and employee types may be different. The setting method can reduce the number of inputs and is convenient for users.
Toolbox part, with commonly used tools, such as calculator, notepad, EMIAL sending, etc.
Help section, for help topics, version information and about.
2.3. System functions
The system will realize the following main functions:
1. User and group management function
2. Data addition, deletion and modification functions
3. Data statistics function 4. Information preservation function
5.
Data export function 6.
Convenient database backup function 7.
Provide practical toolbox
2.4. Data flow diagram
After the user with the corresponding authority logs in correctly, he can open and add the personal file of the new employee, and after the addition is completed, he can use the data export function to export the data. The data flow diagram is shown in Figure 2-1 below:

2.5. Module diagram
As shown in the figure:

Figure 2-2 System function module diagram

Chapter 3 Database Design

3.1. Overview
In the development process of the database application system, the structural design of the database is a very important link. The quality of the database structure design will directly affect the efficiency of the application system and the effect of realization. Therefore, on the premise of fully considering the various needs of users as much as possible, the database design was carried out.
3.2. Database conceptual structure design
Database requirements analysis is the first stage of database structure design, and it is a very important stage. This stage is mainly to determine the basic data, data structure and data processing process, and form a detailed data dictionary to lay a solid foundation for further design in the future.
For a data administrator, a well-designed database starts with a sound logical design. The conceptual model is a tool for communication between users and database designers. The
entities planned according to the above design include: employee basic information entity, salary item setting information entity, employee payable information entity, employee withholding payment information entity, and employee salary information entity.

3.3. Database design
There are 18 tables in the database, as shown in Figure 3-1. It is divided into 12 main tables, namely: t_br (basic file table), t_login (operator login record table), system user (user table), AttendanceInfo (employee attendance information table), LeaveInfo (employee leave information), OvertimeInfo (employee overtime information), BasicSar (basic salary setting table), kouchu (deduction), timekaoqin (time attendance), salarysta (product unit price setting table ), salary (employee salary table), YGZJS (monthly salary settlement table) and other detailed information are as follows.

Figure 3-1 Database table

The specific description ER diagram of each entity is as follows. The basic file table t_br ER model is shown in Figure 3-2, the system user ER model is shown in Figure 3-3, and the employee attendance information table AttendanceInfo ER model is shown in Figure 3-4.

Figure 3-2 Basic file table ER diagram

Figure 3-3 System users

Figure 3-4 Employee attendance information table AttendanceInfo

1. Employee basic file table t_br, its structure is shown in Table 3-1. It is the core data of the management system to save the relevant information of employees, and all other information exists attached to this table. Use the job number as the primary key to minimize data redundancy and ensure data consistency.

Table 3-1 Basic file table t_br
field type length Mandatory field
Job number text 6 Yes
Name text 10 Yes
Gender text 10 Yes
Department text 10 Yes Salary number 10 Yes Major
text 20 Yes Position text 10 No Salary category number 10 Yes Contract start date/time Contract termination date/time Yes
Employee type text 10 Yes Birthday date/time No Seniority number 10 No Age number 3 Yes Education level text 10 No Ethnicity text 10 No Political affiliation text 10 No
ID card number text 18 Yes Hometown text 200 Yes Contact phone number 15 No Mobile phone number 15 Yes Home address text 200 Yes Health status text 10 Yes Photo OLE object No
















2. Employee attendance information table, its structure is shown in Table 3-2. Save relevant information of employee attendance information. The data in this table only saves the attendance status of employees, and does not include the attendance information of daily production output.


Table 3-2 AttendanceInfo field type and length of employee attendance information form Mandatory
fields Job Number Text 6 Yes
Name Text 10 Yes
Current Date Text 10 Yes
Entry and Exit Sign Text 2 Yes
On-duty date/time Yes Off-
duty date/time Yes Number of late
arrivals 10 No
Number of early departures 10 No

3. LeaveInfo employee leave information form, its structure is shown in Table 3-3. All user leave information is stored in this table. Deductions are made based on records during salary settlement.

Table 3-3 Employee Leave Information Form LeaveInfo
Field Type Length Mandatory Field
Job Number Text 5 Yes
Name Text 10 Yes
Sick Leave Days Numeric Long Integer Yes
Personal Leave Days Numeric Long Integer Yes
Vacation Start Time Date/Time Yes

4. Employee overtime information table, the structure is shown in Table 3-4. In order to facilitate system management, employee overtime information is also stored as an independent table.

Table 3-4 Employee Overtime Information Form OverTimeInfo
Field Type Length Mandatory Field Job
Number Text 5 Yes
Name Text 10 Yes
Special Overtime Days Number Long Integer No
Normal Overtime Days Number Long Integer No
Overtime Date Date/Time Yes

5. Staff salary table, the structure is shown in Table 3-5. This form completes the daily product attendance, and also saves the daily employee wages automatically calculated by the system. At the end of the month, it is only necessary to sum up these daily wages. Then transfer to other tables for further processing.

Table 3-5 Employee salary table salary
field type length Mandatory field
ID Automatic number yes
Job number text 5 Yes
Name text 10 Yes
Working day date/time Yes
Product type 1 text text No
Product type 2 text text No Product type 3
text No
Quantity 1 number No Quantity
2 number No
Quantity 3 number No Unit price
1 number No
Unit price 2 number No Unit
price 3 number No
Daily summary number Yes

Finally, when designing the database, consider the security of the database to prevent non-administrative personnel from opening the database with third-party software. The database file is also specially processed, and the database extension mdb is replaced with ldl, which has a certain degree of confusion. While changing the extension, the database is also encrypted. When opening the database with ACCESS, it is required to enter the password to open it, as shown in Figure 3-5. The database can only be opened when the correct password is entered. For the convenience of memory, the password to open this database is: wlz.

Figure 3-5 Asking for a password

Chapter 4 Realization of Functions

4.1. Realization of system security and authority
In order to ensure the security of the system, the database is encrypted, user and group management are adopted, and user login information is recorded. Users with advanced rights can create different groups and assign all or part of the rights to the creating user.
In order to realize this function, the system adopts a recursive method, so that users at a higher level can manage lower-level users, and the highest authority belongs to the administrator.
The specific description is as follows:
4.2. Realization of the login window
When the system logs in, it is required to input the user name and password correctly. After successful login, the main interface of the salary management system is displayed as shown in Figure 4-2. User names are divided into administrator users and ordinary users. As shown in Figure 4-1:

Figure 4-1 Login window

Part of the main code that implements the function:
Private Sub Comok_Click()
On Error GoTo Dealerror
Dim strSql As String
Dim strMsg As String
'On Error GoTo Dealerror
Dim objCn As New Connection
strcn = CS()
objCn.ConnectionString = strcn
objCn.Open
Set objRs = New Recordset
Set objRs.ActiveConnection = objCn
objRs.CursorLocation = adUseClient
strSql = "SELECT * FROM system user" objRs.Open
strSql
objRs.ActiveConnection = Nothing
objCn.Close
Set objCn = Nothing
If Logontimes >= 3 Then
MsgBox "You have exceeded the maximum number of logins! Exit System", vbOKOnly + vbCritical, "System Login"
End
Else
objRs.MoveFirst
objRs.Find "用户名=’" & txtUserName & “'”
If objRs.EOF Then
MsgBox “用户名错误!”, vbOKOnly + vbCritical, “系统登录”
txtUserName.SetFocus
txtUserName.Text = “”
Else
If objRs!口令 <> txtPassword Then
MsgBox “密码错误!请重新输入!”, vbOKOnly + vbCritical, “系统登录”
txtPassword.SetFocus
txtPassword.Text = “”
Else
‘MsgBox “欢迎使用工资管理系统”, vbOKCancel + vbOKOnly, “系统登录”
strusername = txtUserName
userpassword = txtPassword
If CmbStatus = “” Then
MsgBox “请选择登陆身份!”, vbOKOnly + vbCritical, “系统登录”
CmbStatus.SetFocus
Else
If CmbStatus.ListIndex = 0 And objRs!admin = True Then
UserAdmin = 1
End If
If CmbStatus.ListIndex = 0 And objRs!admin = False Then
X = MsgBox("You are not an administrator, you will log in as an ordinary user", vbOKCancel + vbOKOnly, "System login") End If If X = 2
Then
txtUserName.SetFocus
txtUserName.Text
= ""
txtPassword.Text = ""
Else
'add operator login time
strS ql = "insert into t_login (user, login time) values('" & txtUserName & "','" & Now & "')" Set objRs = ExecuteSQL(strSql, strMsg) Unload Me MDIForm1.Show End If End If End If End If End If Logontimes = Logontimes + 1 'Login times Exit Sub Dealerror: msg = "Program execution error, the
error
message
is
as follows :
" & vbCrLf & Err .Description ShowError msg End Sub








Dim objRs As Recordset
Dim i As Integer
Dim Logontimes As Integer
Private Sub Comcancle_Click()
n = MsgBox("You have chosen to log out of the system, you will not be able to start the management system!" & vbCrLf & "Do you really log out?", vbYesNo, "System Verification") If n = vbYes Then Unload Me
End
If
End
Sub

Figure 4-2 The main window of the salary management system

4.3. Realization of employee basic file information

Employee basic file information management, complete the entry of employee basic information in the form. Enter the corresponding information in the form according to the prompts, and finally click the "Save" button to save the information. As shown in Figure 4-3

Figure 4-3 Window for entering employee basic file information

The corresponding part of the code is as follows:
'Add basic employee information
Private Sub cmdOK_Click()
Dim rs As ADODB.Recordset
Dim strSql As String
Dim strMsg As String
Dim tmpPath As String
Dim iStm As ADODB.Stream

'如果是修改(保存照片--删除原记录--保存记录)
If blnChange = True Then
'如果不要删除
    If blnDelPhoto = False Then
           	strSql = "select * from t_br where 工号='" & txtGH.Text & "'"
        	Set rs = ExecuteSQL(strSql, strMsg)
       		 '保存到文件
        	tmpPath = App.path & "\temp.jpg"
       	 If Not IsNull(rs.Fields("照片").Value) Then
           	 Set iStm = New ADODB.Stream
           	 With iStm
                .Mode = adModeReadWrite
                .Type = adTypeBinary
                .Open
                .Write rs.Fields("照片").Value
                .SaveToFile tmpPath
            	blnDel = True
           	 End With
            	strFileName = tmpPath
            	'pic.Picture = LoadPicture(tmpPath)
            	iStm.Close
        Else
                blnDel = False
        End If
        rs.Close
    End If
   '删除记录
    strSql = "delete * from t_br where 工号='" & txtGH.Text & "'"
    Set rs = ExecuteSQL(strSql, strMsg)
Else
    strSql = "select * from t_br where 工号='" & txtGH.Text & "'"
    Set rs = ExecuteSQL(strSql, strMsg)
    If rs.EOF = False Then
        MsgBox "已有相同的工号,无法添加到数据库!", vbOKOnly + vbExclamation, "警告"
        TextFocus txtGH
        Exit Sub
    End If
    rs.Close
  
End If

strSql = "select * from t_br"
Set rs = ExecuteSQL(strSql, strMsg)
rs.AddNew
rs.Fields("job number") = txtGH.Text
rs.Fields("name") = txtName.Text
If cboPayStyle.Text = "" Then
rs.Fields("salary category") = Null
Else
rs.Fields( "PayType") = cboPayStyle.Text
End If

  If cboHealthy.Text = "" Then
   		rs.Fields("健康状况") = Null
  Else
  		rs.Fields("健康状况") = cboHealthy.Text
  End If
  
  If cboSex.Text = "" Then
    	rs.Fields("性别") = Null
  Else
  		rs.Fields("性别") = cboSex.Text
  End If
        
  If cboEmployeeStyle.Text = "" Then
  		rs.Fields("职工类型") = Null
  Else
  		rs.Fields("职工类型") = cboEmployeeStyle.Text
  End If
  
  If cboPart.Text = "" Then
  		rs.Fields("部门") = Null
  Else
  		rs.Fields("部门") = cboPart.Text
  End If
  
  If cboDuty.Text = "" Then
  		rs.Fields("职务") = Null
  Else
  		rs.Fields("职务") = cboDuty.Text
  End If
  
  If cboCulture.Text = "" Then
  		rs.Fields("文化程度") = Null
  Else
 		 rs.Fields("文化程度") = cboCulture.Text
  End If
  
  If cboNation.Text = "" Then
 		 rs.Fields("民族") = Null
  Else
  		rs.Fields("民族") = cboNation.Text
  End If
  
  '数字型
  If txtMoney.Text = "" Then
  		rs.Fields("薪金") = 0
  Else
  		rs.Fields("薪金") = txtMoney.Text
  End If
  If cboSpec.Text = "" Then
  		rs.Fields("所学专业") = Null
  Else
  		rs.Fields("所学专业") = cboSpec.Text
  End If

'Age is numeric
If txtAge.Text = "" Then
rs.Fields("age") = 0
Else
rs.Fields("age") = txtAge.Text
End If

  '日期型
  rs.Fields("生日") = dtpBirthday.Value
  
  If cboPolity.Text = "" Then
  		rs.Fields("政治面貌") = Null
  Else
  		rs.Fields("政治面貌") = cboPolity.Text
  End If
  
  If cboMarry.Text = "" Then
  		rs.Fields("婚姻状况") = Null
  Else
  		rs.Fields("婚姻状况") = cboMarry.Text
  End If
  
  If cboNativePlace.Text = "" Then
  		rs.Fields("籍贯") = Null
  Else
  		rs.Fields("籍贯") = cboNativePlace.Text
  End If
  
  If txtHandset.Text = "" Then
  		rs.Fields("手机") = 0
  Else
  		rs.Fields("手机") = txtHandset.Text
  End If
  
  If txtIdentity.Text = "" Then
  		rs.Fields("身份证号") = Null
  Else
  		rs.Fields("身份证号") = txtIdentity.Text
  End If
  If txtTelphone.Text = "" Then
 		 rs.Fields("联系电话") = Null
  Else
  		rs.Fields("联系电话") = txtTelphone.Text
  End If
  If txtHomeAddress.Text = "" Then
   		rs.Fields("家庭住址") = Null
  Else
  		rs.Fields("家庭住址") = txtHomeAddress.Text
  End If
  '日期型
  rs.Fields("合同开始时间") = dtpBBargain.Value
  rs.Fields("合同终止时间") = dtpEBargain.Value

If txtLong.Text = "" Then
rs.Fields("Senior Years") = 0
Else
rs.Fields("Senior Years") = txtLong.Text
End If
'Add Photos
Set iStm = New ADODB.Stream
If Len(strFileName) > 0 Then
With iStm
.Type = adTypeBinary 'Binary Mode.Open
.LoadFromFile
strFileName
End With
rs.Fields("Photo") = iStm.Read
rs.Update
iStm.Close
Else
rs.Update
End If

  rs.Close
  Set rs = Nothing
  cmdDel.Enabled = True
  Call DisabledControl
  cmdNew.Enabled = True
  MsgBox "添加成功"

If blnDel Then
If tmpPath <> “” Then
Kill tmpPath
End If
End If
Call RefreshGrid
End Sub

4.4. Realization of employee attendance information

4.4.1. Set employee commute time
Enter the corresponding commute information in this form, as shown in Figure 4-4, the corresponding part of the code is as follows:

Figure 4-4 Set commute time

Private Sub cmdOK_Click() '设置上下班时间
Dim sql As String
Dim rs As New ADODB.Recordset
Dim strMsg As String
sql = “delete * from TimeSetting”
Set rs = ExecuteSQL(sql, strMsg) ’ 查找数据库,读取记录
If dtpBT.Value >= DTPicker1.Value Then ’ 判断下班时间大于上班时间
MsgBox “请正确的输入时间”, vbOKOnly + vbExclamation, “警告!”
Me.dtpBT.SetFocus '设置焦点
Exit Sub
End If
If dtpBT2.Value >= DTPicker2.Value Or dtpBT2.Value <= DTPicker1.Value Or dtpBT2.Value <= dtpBT.Value Then '判断下班时间大于上班时间
MsgBox “请正确的输入时间”, vbOKOnly + vbExclamation, “警告!”
Me.dtpBT2.SetFocus '设置焦点
Exit Sub
End If
sql = “select * from TimeSetting”
Set rs = ExecuteSQL(sql, strMsg)
strMsg) If rs.EOF Then Exit Sub
















dtpBT.Value = rs.Fields("morning work time")
DTPicker1.Value = rs.Fields("morning work time")
dtpBT2.Value = rs.Fields("afternoon work time")
DTPicker2.Value = rs.Fields("afternoon work time")
End Sub

4.4.2. Add employee attendance information
1. Add commute information
The window is shown in Figure 4-5, fill in the corresponding information, part of the code is as follows:

Figure 4-5 Add employee attendance information

添加上下班信息
Private Sub cmdOK_Click()
Dim sql As String
Dim sql2 As String
Dim rs As New ADODB.Recordset
Dim strMsg As String
Dim strmsg2 As String
Dim rsTime As New ADODB.Recordset
Dim tmsetswsb, tmsetswxb, tmsetxwsb, tmsetxwxb As Date
Dim tmsb1, tmxb1 As Date
sql = “select * from AttendanceInfo order by ID desc”
sql2 = “select * from TimeSetting”
Set rs = ExecuteSQL(sql, strMsg)
Set rsTime = ExecuteSQL(sql2, strmsg2)

 If InFlag = False And OutFlag = False Then
        MsgBox "请选择上下班", vbOKOnly + vbExclamation, "警告!"
 End If
 '添加上班信息         
 If InFlag = True Then
     If txtID.Text = "" Or txtName.Text = "" Then
            MsgBox "要添加上班信息,员工编号与姓名不能为空,请输入", vbOKOnly, "提示"
     Exit Sub
End If
     
    '判断上下午上班时间是否迟到
    tmsb1 = dtpBT.Value
    h = Hour(tmsb1)
    m = Minute(tmsb1)
    s = Second(tmsb1)
    tmsb1 = CDate(h & ":" & m & ":" & s)
    tmsetswsb = CDate(rsTime.Fields("上午上班时间"))
    tmsetswxb = CDate(rsTime.Fields("上午下班时间"))
    tmsetxwsb = CDate(rsTime.Fields("下午上班时间"))
        
       '判断上午上班时间是否迟到
         If tmsb1 < tmsetswxb Then
              If tmsb1 > tmsetswsb Then
                    ilate = 1
                    MsgBox "迟到"
              Else
                    ilate = 0
                    MsgBox "正常上班"
              End If
       '判断下午上班时间是否迟到
         Else
           If tmsb1 > tmsetxwsb Then
                    ilate = 1
                    MsgBox "迟到"
              Else
                    ilate = 0
                    MsgBox "正常上班"
             End If
         End If
   aflag = "入"
rs.AddNew
        rs.Fields("工号") = txtID.Text
        rs.Fields("姓名") = txtName.Text
        rs.Fields("当前日期") = dtpET.Value
        rs.Fields("上班时间") = dtpBT.Hour & ":" & dtpBT.Minute & ":" & dtpBT.Second
        rs.Fields("出入标志") = aflag
        rs.Fields("迟到次数") = ilate
        rs.Update
        rs.Close
        MsgBox "已完成添加上班信息", vbOKOnly + vbInformation, "添加结果!"
        Unload Me
        Exit Sub
 End If

 '添加下班信息
 If OutFlag = True Then
      If txtID.Text = "" Or txtName.Text = "" Then
          MsgBox "要添加下班信息,员工编号与姓名不能为空,请输入", vbOKOnly + vbExclamation, "警告"
          Exit Sub
      End If
     
     '判断上下午下班时间是否早退
     tmxb1 = DTPicker1.Value
            h = Hour(tmxb1)
            m = Minute(tmxb1)
            s = Second(tmxb1)
     tmxb1 = CDate(h & ":" & m & ":" & s)
     tmsetxwsb = CDate(rsTime.Fields("下午上班时间"))
     tmsetswxb = CDate(rsTime.Fields("上午下班时间"))
     tmsetxwxb = CDate(rsTime.Fields("下午下班时间"))
        '判断上午下班时间
          If tmxb1 < tmsetxwsb Then
                 If tmxb1 < tmsetswxb Then
                      iearly = 1
                      MsgBox "早退"
                 Else
                      iearly = 0
                      MsgBox "正常下班"
                 End If
        '判断下午下班时间
         Else
                If tmxb1 < tmsetxwxb Then
                      iearly = 1
                      MsgBox "早退"
                Else
                      iearly = 0
                      MsgBox "正常下班"
                End If
          End If
 aflag = "出"
rs.AddNew
         rs.Fields("工号") = txtID.Text
         rs.Fields("姓名") = txtName.Text
         rs.Fields("当前日期") = dtpET.Value
         rs.Fields("下班时间") = DTPicker1.Hour & ":" & DTPicker1.Minute & ":" & DTPicker1.Second
         rs.Fields("出入标志") = aflag
         rs.Fields("早退次数") = iearly
         rs.Update
         rs.Close
         MsgBox "已完成添加下班信息", vbOKOnly + vbInformation, "添加结果!"
         Unload Me
         Exit Sub
     End If

End Sub

Private Sub Form_Load()
dtpET.Value = Date 'Initialized to the current time
End Sub

2. Set the employee’s daily production attendance.
Enter the corresponding information in this form to complete the daily production attendance, as shown in Figure 4-6. The corresponding part of the code is as follows:

Figure 4-6 Daily production attendance of employees

The "Save" button code is as follows:

Private Sub cmdOK_Click()
Dim rs As ADODB.Recordset
Dim strSql As String
Dim strMsg As String
'Field restriction as required
If ChkBoxJJ.Value = True Then
If Combo1.Text = "" Then
MsgBox "Product type cannot be empty"
TextFocus Combo1
Exit Sub
End If
If ChkBoxCP.Value = True Then
If Combo2.Text = "" Then
MsgBox "Product type two cannot be empty"
TextFocus Combo2
Exit Sub
End If
If Txt3.Text = 0 Then
MsgBox "Quantity cannot be empty"
TextFocus Txt3
Exit Sub
End If

    End If
    
     If ChkBoxCR.Value = True Then
        If Combo3.Text = "" Then
            MsgBox "产品类型三不能为空"
            TextFocus Combo3
            Exit Sub
        End If
        
         If Txt5.Text = 0 Then
            MsgBox "数量不能为空"
            TextFocus Txt5
            Exit Sub
        End If

     End If

End If


  strSql = "select * from checkinfo where 工号='" & txtGH1 & "'"

Set rs = ExecuteSQL(strSql, strMsg)

If rs.EOF = False Then

             MsgBox "已有相同的记录,无法添加到数据库!", vbOKOnly + vbExclamation, "警告"
               TextFocus txtGH1
             rs.Close
             If ChkBoxJJ.Value = True Then
                       strSql = "select * from salary"
                       Set rs = ExecuteSQL(strSql, strMsg)
                         rs.AddNew
                         
                         rs.Fields("工号") = txtGH1.Text
                         rs.Fields("姓名") = txtName.Text
                         rs.Fields("工作日") = dtpBirthday.Value
                         rs.Fields("产品类型一") = Combo1.Text
                         rs.Fields("产品类型二") = Combo2.Text
                         rs.Fields("产品类型三") = Combo3.Text
                         If Txt1.Text = "" Then
                           rs.Fields("数量一") = 0
                         Else
                           rs.Fields("数量一") = Txt1.Text
                         End If
                        If Txt3.Text = "" Then
                           rs.Fields("数量二") = 0
                         Else
                           rs.Fields("数量二") = Txt3.Text
                         End If
                         
                         If Txt5.Text = "" Then
                           rs.Fields("数量三") = 0
                         Else
                           rs.Fields("数量三") = Txt5.Text
                         End If
                         If txt2.Text = "" Then
                           rs.Fields("单价一") = 0
                         Else
                           rs.Fields("单价一") = txt2.Text
                         End If
                         
                          If txt4.Text = "" Then
                           rs.Fields("单价二") = 0
                         Else
                           rs.Fields("单价二") = txt4.Text
                         End If
                         
                          If txt6.Text = "" Then
                           rs.Fields("单价三") = 0
                         Else
                           rs.Fields("单价三") = txt6.Text
                         End If
                         
                         rs.Fields("每日汇总") = Txt7.Text
                         rs.Update
                         rs.Close
                         Set rs = Nothing
               End If
                
                 If ChkBoxJS.Value = True Then
                     strSql = "select * from timekaoqin"
                     Set rs = ExecuteSQL(strSql, strMsg)
                     rs.AddNew
                     rs.Fields("工号") = txtGH1.Text
                     rs.Fields("工作日") = dtpBirthday.Value
                     rs.Fields("上班时间") = dtpBT(0).Value
                     rs.Fields("下班时间") = DTPicker1(0).Value
                     rs.Fields("PM上班时间") = dtpBT(1).Value
                     rs.Fields("PM下班时间") = DTPicker1(1).Value
                     rs.Fields("单价") = MoTxt.Text
                     rs.Fields("工作小时数") = Timetxt6.Text
                     rs.Fields("加班时间") = Combo4.Text
                     rs.Fields("加班单价") = Text12.Text
                     rs.Fields("记时汇总") = MoTxt8.Text
                     rs.Update
                     rs.Close
                     Set rs = Nothing
                 End If
                     If ChkBoxJJ.Value = True Or ChkBoxJS.Value = True Then
                        MsgBox "添加成功"
                    Else
                        MsgBox "添加失败"
                         same = 2: same2 = 4
                    End If
                         If same = 2 And same2 = 4 Then
                                 Exit Sub
                         Else
                                 strSql = "select * from checkinfo "
                                 Set rs = ExecuteSQL(strSql, strMsg)
                                 rs.AddNew
                                 rs.Fields("工号") = txtGH1.Text
                                 rs.Fields("工作日") = dtpBirthday.Value
                                 rs.Update
                         End If
              'Call RefreshGrid
 End If

End Sub

4.5. Employee monthly salary settlement, production summary, and comprehensive processing

Enter the corresponding information in this form to complete the monthly salary settlement, output summary, and comprehensive processing, as shown in Figure 4-7. The codes of the corresponding parts are as follows:

Figure 4-July wage settlement, output summary, comprehensive processing

The corresponding part of the code is as follows:

Dim strSql As String
Dim strMsg As String
Dim rs As ADODB.Recordset
Dim dj1 As Integer
Dim dj2 As Integer
Dim dj3 As Integer

'Statistics
strSql = "select * from salary where job number='" & gh & "'"
Set rs = ExecuteSQL(strSql, strMsg)
If rs.EOF = False Then
TextNO.Text = rs.Fields("job number").Value
TextNAMe.Text = rs.Fields("name").Value
Combod.Value = rs .Fields("Working Day"
).Value Textlx(0).Text = rs.Fields("Product Type 1").Value dj1 = rs.Fields("Unit Price 1").Value dj2 = rs.Fields("Unit
Price 2").Value
dj3 =
rs.Fields("Unit Price 3").Value

          Textlx(1).Text = rs.Fields("产品类型二").Value
          Textlx(2).Text = rs.Fields("产品类型三").Value
           rs.Close
           strSql = "select sum(数量一) as 数量一,sum(数量二) as 数量二,sum(数量三) as 数量三,sum(每日汇总) as 每日汇总 from salary  group by 工号='" & gh & "' "
              Set rs = ExecuteSQL(strSql, strMsg)
         
              Textsl(0).Text = rs.Fields("数量一").Value
              Textsl(1).Text = rs.Fields("数量二").Value
              Textsl(2).Text = rs.Fields("数量三").Value
              Textzj(0).Text = Val(Textsl(0).Text) * dj1
              Textzj(1).Text = Val(Textsl(1).Text) * dj2
              Textzj(2).Text = Val(Textsl(2).Text) * dj3
              Txtgj.Text = Val(Textzj(0).Text) + Val(Textzj(1).Text) + Val(Textzj(2).Text)
        
    '奖金 福利结算
        rs.Close
        strSql = "select * from Sar_other where 工号='" & TextNO & "'"
        Set rs = ExecuteSQL(strSql, strMsg)
        Text(0).Text = rs.Fields("奖金").Value
        Text(1).Text = rs.Fields("津贴").Value
        Text(2).Text = rs.Fields("福利").Value
        Text(3).Text = rs.Fields("其他项目").Value
        
      '扣除
        rs.Close
        strSql = "select * from kouchu where 工号='" & TextNO & "'"
        Set rs = ExecuteSQL(strSql, strMsg)
        
         Tet(0).Text = rs.Fields("住宿费")
         Tet(1).Text = rs.Fields("火食费")
         Tet(2).Text = rs.Fields("公基金")
         Tet(3).Text = rs.Fields("垃圾处理费")
         Tet(4).Text = rs.Fields("医疗保险费")
         Tet(5).Text = rs.Fields("其它")
    
       
Else
        MsgBox "数据库还没有此工号的工资记录", vbOKOnly + vbExclamation, "提示"
        ChkBoxJJ.Value = False
        ChkBoxCP.Value = False
        ChkBoxCR.Value = False
        ChkBoxJS.Value = False
        Exit Sub
End If
        
    '记时统计
        rs.Close
       strSql = "select sum(加班时间) as 加班总时间,sum(工作小时数) as 工作小时数,sum(记时汇总) as 记时汇总  from timekaoqin  group by 工号='" & gh & "' "
       
       Set rs = ExecuteSQL(strSql, strMsg)
        Txt(0).Text = rs.Fields("工作小时数").Value
        Txt(2).Text = rs.Fields("加班总时间").Value
        Textgj.Text = rs.Fields("记时汇总").Value
            strSql = "select 单价,加班单价 from timekaoqin where 工号='" & gh & "'"
            Set rs = ExecuteSQL(strSql, strMsg)
            Txt(1).Text = rs.Fields("单价").Value
            Txt(3).Text = rs.Fields("加班单价").Value 

Text5.Text = Val(Textgj.Text) + Val(Textgj.Text) + Val(Text(0).Text) _

  • Val(Text(1).Text) + Val(Text(2).Text) + Val(Text(3).Text)

Text3.Text = Val(Txtgj.Text) - Val(Tet(0).Text) - Val(Tet(1).Text) _

  • Val(Tet(2).Text) - Val(Tet(3).Text) - Val(Tet(4).Text) - Val(Tet(5).Text)
    End Sub

4.6. System Tool - Realization of Chat Room
In order to provide enterprises with a better and more convenient service, effectively and quickly carry out communication among various departments in the network, and better cooperate with each other, a chat module inside the system is specially added. See Figure 4-8 and Figure 4-9 for details

			图4-8 服务器端	图4-9 客户端

The corresponding code on the server side:
Const maxn = 200 'The maximum number of clients connected to this machine at the same time
Dim user(maxn) As Boolean
Private Sub Command1_Click()
Form2.Hide
End Sub
Private Sub Command2_Click()
Load Form1
Form1.Show
End Sub

Private Sub Form_Load()
Dim str1 As String
nowuser = 0
Form2.Caption = "Management system communication software"
'Note: winsock control a monitors as a server program
a.LocalPort = 3000
a.Listen
End Sub
Private Sub a_ConnectionRequest(ByVal requestID As Long)
Dim i As Long
For i = 1 To maxn 'start when a client requests A Winsock control flag If
Not user(i) Then
user(i) = True
Exit For
End If
Next i
If i > maxn Then
Exit Sub
End If
Load b(i) 'Start a Winsock control
b(i).Accept requestID' when a client requests (0) Else b(i).SendData Text1.Text End If





Form2.Show
End Sub
Private Sub s_Close(Index As Integer)
b(Index).Close 'Note: Close the connection
Unload b(Index) 'Note: Unload a WinSock control
user(Index) = False
End Sub

Private Sub b_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim str As String
Dim i As Long
Dim n As Integer
On Error Resume Next 'Ignore disconnected hosts

b(Index).GetData str
Text1.Text = Text1.Text + str
For i = 1 To maxn
If user(i) Then
b(i).SendData str
End If
Next i
End Sub

4.7. System testing
Performance testing and analysis
The key task at this stage is to make the software meet the predetermined requirements through various types of testing and corresponding debugging. According to the division of labor, I am responsible for the entire program operation and debugging.
1. Test environment
The test environment is:
operating system: Windows2000 and above
; database system: Access2000.
2. System test requirement analysis
As an information management system application, the scientific and technological achievements management system should have the functions specified in the design documents, and each functional module can complete the corresponding tasks to ensure the correctness and security of the data entered by the user. Whether the program design and related functions meet the requirements can only be found through rigorous testing to reduce the occurrence of errors as much as possible. Therefore, the system must be tested to achieve the purpose of error correction.
Testing methods
Software testing is mainly divided into static and dynamic analysis methods. Dynamic methods include white-box and black-box methods. The system mainly uses black-box methods to test program functions.
3. System test strategy description
Test items of the entire system interface window
1. Can the relevant input or output commands be opened normally?
2. Is the page display normal? Is there an error when reading the database?
3. Is the business process reasonable and suitable for user operation?
Data Item Test Item
1. Can you identify the type and length of the input data?
2. Can exception handling ensure that the system runs under incorrect operations, and can it identify illegal data?
3. Can the database run normally when a large amount of data is input and output?
4. Can the data be written into the corresponding field when it is written into the database?

4. Design of system test scheme
The function test adopts the black box test method, and the data design is as follows: see the test report

System management module test cases:
4.1.1 Design test cases for setting operators, passwords, and permissions, as shown in the table (Table 4.1.1):

Table 4.1.1
Operator number Operator name Operator category User password
01 wlz System administrator wlz
02 wanglingzhing Ordinary user wlz

4.1.2 Set the shortcut key user and login password - the test case design is as follows

The first test case (design two sets of the same data) The second test case (two password inputs are different)
User name user password confirmation password User name user password confirmation password
1 1 1 111 111 11
The first input is consistent with the expected result, and the second input is inconsistent with the expected result

Chapter 5 Conclusion

This graduation project has not only consolidated the knowledge I have learned, but also improved myself on this basis, making me understand that demand analysis, rational design of databases, and writing codes play a very important role in the quality of software design. Due to the limitation of one's own ability, even if the code is written, it is inevitable to make mistakes even after repeated inspections. Therefore, at this stage, we strive to use the limited time to find as many errors as possible, and strive to make the system as correct as possible. We used the black-box method in the test of this system (that is, we do not care about the internal logic structure of the program, but design and test according to the function of the program). We asked a person who is not familiar with the system to perform random operations, break the habitual operation sequence, and find errors from it. At this stage, a large number of errors in the system have been corrected.

thank you

This system can be successfully completed. I am very grateful to Mr. Tang Hao and Mr. Zhou Lei for their careful guidance, and I am also very grateful to all the teachers for their cultivation in the past two years. For me, this graduation project is a test of my study in the past two years and a kind of accumulation of my usual study. I also learned a lot from it. I hope that there will be enough time in the future to have a deeper understanding, do a good job of demand analysis, and design better software for myself.

参考文献
[1]孙 越 ,Visual Basic数据库开发自学教程,人民邮电出版社,2003
[2]龚沛曾, 面向对象程序设计系列教材,高等教育出版社,2004
[3]潭 浩, 学用Visual Basic 编程 ,西安电子科技大学出版社,2000
[4]刘 萌, Visual Basic6.0 数据库开发与实例导航,人民邮电出版社,2004
[5]汤发良, 我国企业内部冲突状态的评价测度模型 ,1999
[6]Visual Basic6.0 数据库精讲100例,电子工业出版社,2003
[7]Visual Basic6.0程序设计实验, 中央广播电视大学出版社,2006
[8]http://www.csdn.com vb开发技术论坛

appendix

Add user form code as follows:
Private Sub cmdCancel_Click()
Unload Me
Exit Sub
End Sub
Private Sub cmdOK_Click()
Dim sql As String Dim
rs As ADODB.Recordset
If Trim(username.Text) = "" Then
MsgBox "Please enter Username", vbOKOnly + vbExclamation, "Warning" '
Exit Sub
username.SetFocus
Else
sql = "select * from system user where username='" & username & "'" Set re
= getrs(sql, “gzgl”)
If re.EOF = False Then
MsgBox “This user already exists, please re-enter the username”, vbOKOnly + vbExclamation, “Warning”
username.SetFocus
username.Text = “”
password.Text = “”
confirmpwd.Text = ""
Exit Sub
Else
’” & UserAdmin & “')”



















End If

    Call transactsql(sql, "gzgl")
    MsgBox "添加成功", vbOKOnly + vbExclamation, "添加结果"
     
    username.Text = ""
    password.Text = ""
    confirmpwd.Text = ""
    username.SetFocus
    If Check1 = False Then
    
        Unload Me
    End If
   
  End If
End If

End If
End Sub
Private Sub Form_Load()
Me.Left = ReadIni("Add User", "left")
Me.Top = ReadIni("Add User", "top")
End Sub

Private Sub Form_Unload(Cancel As Integer)
Call WriteIni("Add User", "left", Me.Left)
Call WriteIni("Add User", "top", Me.Top)
End Sub
Modify password form code as follows:

Private Sub cmdCancel_Click()
Unload Me
Exit Sub
End Sub
Private Sub cmdOK_Click()
Dim sql As String
Dim rs As ADODB.Recordset
If Trim(oldpwd.Text) = “” Then
MsgBox “请输入旧密码”, vbOKOnly + vbExclamation, “提示”
oldpwd.SetFocus
Exit Sub
Else
If Trim(oldpwd.Text) <> Trim(userpassword) Then
MsgBox “旧密码与登录的密码不同,请重新输入!”, vbOKOnly + vbExclamation, “提示”
oldpwd.Text = “”
oldpwd.SetFocus
ElseIf Trim(newpwd.Text) = “” Then
MsgBox “请输入新密码”, vbOKOnly + vbExclamation, “提示”
newpwd.SetFocus
Exit Sub
ElseIf Trim(newpwd.Text) <> Trim(confirmpwd.Text) Then
MsgBox "Two passwords are different", vbOKOnly + vbExclamation, "Warning"
newpwd.Text = ""
confirmpwd.Text = ""
newpwd.SetFocus
Else
userpassword = newpwd
sql = "update system user set password='" & newpwd & "'where username='" & strusername & "'" Call transactsql(
sql , "gzgl")
MsgBox "Password has been changed", vbOKOnly + vbExclamation, "Modification result"
Unload Me
End If
End If
End Sub

Private Sub Form_Load()
Me.Left = ReadIni("Change Password", "left")
Me.Top = ReadIni("Change Password", "top")

End Sub

Private Sub Form_Unload(Cancel As Integer)
Call WriteIni("Change Password", "left", Me.Left)
Call WriteIni("Change Password", "top", Me.Top)
End Sub

Data output:

Dim outType As Integer 'export type
Dim outPath As String
Dim outSql As String

Private Function outToExcel(ByVal strSql As String, ByVal WorksheeName As String, path As String) As Boolean
On Error GoTo err_outToExcel

'声明excel
Dim objExcel As Excel.Application
Dim objWorkbook As Workbook
Dim objWorksheet As Worksheet

Set objExcel = CreateObject(“Excel.Application”)
Set objWorkbook = objExcel.Workbooks.Add
Set objWorksheet = objWorkbook.Worksheets(“sheet1”)
objWorksheet.Name = WorksheeName

'State adodb
Dim rs As ADODB.Recordset
Dim strMsg As String

Set rs = ExecuteSQL(strSql, strMsg)

i = 1
rs.MoveFirst
Do While Not rs.EOF

For j = 1 To rs.Fields.Count
objExcel.Cells(i, j) = rs.Fields(j - 1)
Next
i = i + 1
rs.MoveNext
Loop

objWorkbook.SaveAs path

objWorkbook.Close
objExcel.Quit

Set objWorksheet = Nothing
Set objWorkbook = Nothing
Set objExcel = Nothing
outToExcel = True
Exit Function

'Error handling
err_outToExcel:
MsgBox Err.Description
On Error Resume Next

objWorkbook.Close
objExcel.Quit

Set objWorksheet = Nothing
Set objWorkbook = Nothing
Set objExcel = Nothing
outToExcel = False

End Function

Private Sub cmdOut_Click()
Select Case outType
Case 1 'Export to Excel
If outToExcel(outSql, “s1”, outPath) = True Then
MsgBox “Export Successful”
Else
MsgBox “Export Failed” End
If
Case 2
If outToWord(outSql, outPath) = True Then
MsgBox “Export Successful”
Else
Ms gBox " Export Failed" End
If
Case 3
If outToText(outSql, outPath) = True Then
MsgBox "Export Failed"
Else
MsgBox "Export Failed"
End If

End Select
End Sub

Private Sub cmdPath_Click()
Select Case outType
Case 1
cdgPath.Filter = “Excel文件(.xls)|.xls”
Case 2
cdgPath.Filter = “Word文件(.doc)|.doc”
Case 3
cdgPath.Filter = “记事本(.txt)|.txt”
End Select
cdgPath.ShowSave
txtPath.Text = cdgPath.FileName
End Sub

Private Sub cmdPre_Click()
SSTab1.Tab = 1
End Sub

Private Sub cmdSelNext_Click()
If optExcel.Value = True Then
outType = 1
txtMessage.Text = “导出到Excel” & vbCrLf
txtPath = App.path & “\DBBackup\1.xls”
ElseIf optWord.Value = True Then
txtMessage.Text = “导出到Word” & vbCrLf
outType = 2
txtPath = App.path & “\DBBackup\1.doc”
Else
txtMessage.Text = “导出到记事本” & vbCrLf
outType = 3
txtPath = App.path & “\DBBackup\1.txt”
End If
txtSql = “select 工号,姓名,性别,薪金,所学专业,职务,工资类别,合同开始时间,合同终止时间,职工类型,工龄,生日,年龄,文化程度,民族,婚姻状况,政治面貌,身份证号,籍贯,联系电话,手机,家庭住址,健康状况 from t_br”
SSTab1.Tab = 1
End Sub

Private Sub cmdSetNext_Click()
txtMessage.Text = ""
If optExcel.Value = True Then
txtMessage.Text = "Export to Excel" & vbCrLf
ElseIf optWord.Value = True Then
txtMessage.Text = "Export to Word" & vbCrLf
Else
txtMessage.Text = "Export to Notepad" & vb CrLf
End If

outPath = Trim(txtPath.Text)
outSql = txtSql.Text

txtMessage.Text = txtMessage.Text & vbCrLf & "The export path is:" & outPath
txtMessage.Text = txtMessage.Text & vbCrLf & "The query statement is:" & outSql
SSTab1.Tab = 2
End Sub

Private Sub cmdSetPre_Click()
SSTab1.Tab = 0
End Sub

Private Function outToWord(ByVal strSql As String, ByVal path As String) As Boolean
On Error GoTo err_outToWord
Dim wRow As Integer
Dim wCol As Integer
'声明Adodb
Dim rs As ADODB.Recordset
Dim strMsg As String

Set rs = ExecuteSQL(strSql, strMsg)
wRow = rs.RecordCount
wCol = rs.Fields.Count

  '声明Word对象
 Dim objWord As Word.Application
 Set objWord = CreateObject("word.application")
 Dim objDocument As New Document
    Set objDocument = objWord.Documents.Add
 objDocument.Tables.Add Range:=objWord.Selection.Range, NumRows:=wRow, NumColumns:=wCol

rs.MoveFirst
j = 1
Do While Not rs.EOF
 For i = 1 To wCol
   objDocument.Tables(1).Cell(j, i).Select
   objWord.Selection.Range.Text = rs.Fields(i - 1).Value
Next

j = j + 1
rs.MoveNext
Loop
objDocument.SaveAs FileName:=path

 objDocument.Close
 Set objDocument = Nothing
objWord.Quit
Set objWord = Nothing
outToWord = True
Exit Function

'错误处理
err_outToWord:
MsgBox Err.Description
On Error Resume Next
objDocument.Close
Set objDocument = Nothing
objWord.Quit
Set objWord = Nothing
outToWord = False
End Function

Private Function outToText(ByVal strSql As String, ByVal path As String) As Boolean
On Error GoTo err_outToText
Dim rs As ADODB.Recordset
Dim strMsg As String
Dim field_with() As Integer
Set rs = ExecuteSQL(strSql, strMsg)
Dim f1
f1 = FreeFile
Open path For Output As f1
ReDim field_width(rs.Fields.Count - 1)

rs.MoveFirst
Do While Not rs.EOF
For i = 0 To rs.Fields.Count - 1
field_width(i) = rs.Fields(i).DefinedSize
If field_width(i) < Len(rs.Fields(i).Name) Then
field_width(i) = Len(rs.Fields(i).Name)
End If
Print #f1, rs.Fields(i).Value;
Print #f1, Space$(field_width(i) - Len(rs.Fields(i).Value));
Next
Print #f1, “”
rs.MoveNext
Loop
Close f1
rs.Close
Set rs = Nothing
outToText = True
Exit Function
err_outToText:
MsgBox Err.Description
On Error Resume Next
Close f1
rs.Close
Set rs = Nothing
outToText = False
End Function
Private Sub Form_Load()
SSTab1.Tab = 0
End Sub

聊天室客户端相应代码:
Dim flag As Boolean '注释:连接状态变量
Private Sub a_Connect()
flag = True
End Sub
Private Sub a_DataArrival(ByVal bytesTotal As Long)
Dim i As String
a.GetData i
send.Enabled = True
Label3.Caption = “连接成功!”
comm2.MousePointer = 0
Form1.MousePointer = 0
Timer1.Enabled = False
If i = Chr(0) Then
Text2.Text = txtName.Text + " 你好! " + Chr(13) + Chr(10) + " 你是今天第一个进入本聊天室的客户。" + Chr(13) + Chr(10)
Else
Text2.Text = Text2.Text + i
End If
Text2.SelStart = Len(Text2.Text)
send.MousePointer = 0
combo1.Enabled = False
comm2.Caption = “断开连接”
Text1.SetFocus
End Sub
Private Sub a_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean) flag = False Timer1.Enabled = False comm2.MousePointer = 0 Form1.MousePointer = 0 MsgBox "Network connection failed!" Label3.Caption = "Waiting for connection" combo1.Enabled = True combo1.SetFocus a.Close comm2.Caption = "Connect" End Sub Private Sub Comm1_Click() If MsgBox("Close this chat room! Are you sure?", 36, "Exit the system") = 6 Then a.Close '
Note
:
Close
the
connection
Form1.WindowState
=
1
Unload
Me
End
If
End
Sub
Private
Sub
Comm2_Click
(
)
If comm2.Caption = "Disconnect" Then
a.Close
send.Enabled = False
comm2.Caption = "Connect"
Label3.Caption = "Waiting for connection"
combo1.Enabled = True
Timer1.Enabled = False comm2.MousePointer = 0 Form1.MousePointer = 0
Else Text2.Text = "" Label3.Caption = "Ongoing Connect..." comm2.MousePointer = 11 Form1.MousePointer = 11 Timer1.Enabled = True flag = False a.Protocol = sckTCPProtocol a.RemoteHost = combo1.Text a.RemotePort = 3000 a.Connect End If End Sub Private Sub Form_Load() If App.PrevInstance Then M sgBox "This system has been loaded, please see the task bar!", 48, "Prompt" End


















End If
flag = False
Load Form2 '读入form2进入监听
End Sub
Private Sub Send_Click()
Dim S As String
Dim k As Integer
On Error GoTo ffff '防止链路中断
send.MousePointer = 11
If Right(Text1.Text, 1) <> Chr(10) Then
S = txtName.Text + ": " + Chr(13) + Chr(10) + " " + Text1.Text + Chr(13) + Chr(10)
Else
S = Text1.Text
End If
If Len(Trim(txtName.Text)) = 0 Then
MsgBox “请输入尼称!”, vbOKOnly, “聊天室”
txtName.SetFocus
send.MousePointer = 0
Else
k = Len(Trim(Text1.Text))
If k = 0 Then
send.MousePointer = 0
MsgBox “不能发送空消息!”, vbOKOnly, “聊天室”
Text1.SetFocus
Else
If flag Then
a.SendData S
Text1.Text = ""
End If End
If
End If
Exit Sub
ffff:
MsgBox "Connection interrupted!", 48, "Prompt"
a.Close
send.MousePointer = 0
comm2.Caption = "Connection"
Label3.Caption = "Waiting for connection"
combo1.Enabled = True
comm2.MousePointer = 0
Form1.MousePointer = 0
Exit Sub
End Sub
Private Sub Timer1_Timer()
flag = False
Timer1.Enabled = False
comm2.MousePointer = 0
Form1.MousePointer = 0
MsgBox "Network connection failed (timed out)!"
Label3.Caption = "Waiting for connection"
combo1.Enabled = True
combo1.Set Focus
a. Close
comm2.Caption = "Connection"
End Sub

Guess you like

Origin blog.csdn.net/ambiguous__/article/details/130776667