The basic functions of the banking management system are implemented using the C ++ language.

Source: Internet
Author: User

The basic functions of the banking management system are implemented using the C ++ language.

Tcp c/S architecture ABC simulation banking system

I. Function Description

1. Register a bank employee (worker), log on, and exit

2. The customer (client) opens an account, withdraws money, deposits, queries the balance, and exits.

Ii. function implementation

In the preliminary stage, there are two objects in this system, the first is the bank staff, the second is the customer, and pay attention to the sent structure and the returned structure content, therefore, each object has two structs, that is, four structs are used for each function implementation. But it is not absolute. For example, the customer's withdrawal function only uses one struct.

As a result, you also need to create two tables of the same type in the database, worker and client. The stored elements must be the same as the required struct.

1. Network ConnectionClient winsock initialization and connection; socket and connect;

Server winsock initialization and connection; socket, bind, listen to listen, receive accept;

2. Registration of bank employees: The client obtains the name and password.

Condition: when obtaining the password, if the password is different from the first password, you need to enter it again.

After receiving the employee information, the server inserts it into the database worker table and returns the operation result to the client.

3. Logon of bank employees: The client obtains the name and password.

After the server receives the employee information, a line with the same name in the select database exists in the container list (iterator it traversal) to determine whether the name and password are the same. If both are the same, the logon is successful on the server.

4. customer's account opening: Similar to Employee registration, the difference is that the customer data is inserted into the table client;

5. Deposit: A. The client obtains account_id and money (cannot be less than 0) and sends it to the server.

B. the server receives the packet, finds the corresponding person from the database through the select function, stores the required information into the list, and then uses the it traversal of the iterator to determine whether the information is consistent, then, write the information to the returned struct and return it to the client.

6. Withdrawal: Similar to the deposit principle, the difference is to determine whether the password is consistent. Note that the balance after withdrawal cannot be less than 0;

7. Balance Query: It has been processed in deposits and withdrawals. After each Deposit or withdrawal, the balance is displayed on the client.

8. The customer exits.: Directly use break on the client to jump out of the loop.

9. The clerk exits: The client needs to send a flag. The server determines that the clerk exits the function, but does not write anything in the function. After judgment, the server has performed closesocket (accpetSocket), and disabled socket and resource deletion operations.

Iii. Details

1. Get the time and date:The function now () is used to obtain data with different data types. The type used in this operation is datetime. (type: date, time, datetime, timestamp, and year)

2. correct use of database languages

3. Receive and process the information first. (Event processing sequence)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.