Example of agileeas. NET platform development-pharmacy system-UI Layer reconstruction skills and other

Source: Internet
Author: User
Opening

In the previous article, we talked about the analysis of the UI Layer. In this article, we will talk about the CS application.ProgramSome technical things in the process, I may summarize here, but I have developed some small applications in the pharmacy system.

Skills do not represent all. There are certainly many other skills. You can share them with me. I am not talking about skills here, more is a summary of the use of design patterns.

1. Promote the parent class

2. Separate duties.

3. Abstract Public

Outline

1. Promote the methods or attributes used by each subclass to the base class.

2. Extract public methods.

Raise parent class

I think everyone will be clear about this technique, that is, placing all the attributes or methods in the subclass in a base class, and then the specific subclass inherits from the class, write some functions with its own characteristics, so that

Fully utilize the Object-oriented Inheritance technology to achieve the purpose of reuse, not only improves the maintainability of the program, but also improves readability. I think everyone is familiar with this.

Next, let's take a look at how we did it in the pharmacy system:

We can see that the core of the entire system is the specific business flow line based on the pharmacy inventory management. Let's summarize the functions required by these modules, let's abstract it here.

In this way, we create a new usercontrol control to provide the above functions for these controls.

2. In this way, we only need to inherit from the user control in a specific form control:

3. Let's take a look at the use of the print report method defined in the base class:

This will reduce a lot of unnecessary work, improve maintainability, and reduce duplication.Code.

Abstract control binding

Today, many colleagues have suggested that I abstract the data-bound controls to reduce the number of repeated codes, this also has a lot of benefits to prevent replicas in multiple locations.

After the appearance, we need to modify a lot of data synchronously, which will undoubtedly increase our workload and increase our maintenance workload. Here we will summarize the abstract of some common control binding methods in the pharmacy system.

1. Write a common method to bind a book to a commonly used drop-down list. Of course, there is no complete abstraction here, but it is to write common methods into a class and access them through static methods.

2. Because the drug type appears in multiple modules and each module is displayed in a drop-down list, we can bind these two modules here, abstract The public binding method. Let's take a look at

Specific implementation. It is also relatively simple.

3. Let's take a look at the two methods below:

4. We can abstract the above red part into a separate static method:

Next let's take a look at the specific call steps in the last two methods.

This achieves the purpose of reuse. Let's take a look at some common methods when we bind and add data columns to the gridview.

Let's take a look at the specific implementation classes abstracted into generic methods:

Next let's take a look at the data entity information of the datagridview after editing, if you do not rebind to update the content information in the list:

Let's take a look at the method for updating the row information of the original datagridview.

After using the public method, the code is called as follows:

Undoubtedly, the above method will reduce the possibility of many errors and improve the maintainability of the Code.

Summary

We have shared some common design and extraction of public methods and basic skills for improving the parent class during simple interface development. I hope this will be helpful to you, of course, because of my own level

Limited, there may be better ways to solve the problem or better ideas, please also point out, thank you.

Pharmacy system source code

More communication

Official blog: http://www.smarteas.net/

Http://www.agilelab.cn/

if you have any questions about using the agileeas. NET development platform, use the following contact methods or communication methods.

1. Telephone-Email:

He gozhou: hegezhou_hot@163.com Mobile: 18691480181 blog: http://www.cnblogs.com/hegezhou_hot/

2. QQ chat group:

308961614 Network Name: h.o. T

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.