Health Check package management system and package management system

Source: Internet
Author: User

Health Check package management system and package management system

Today, let's write a small project for the Health Check package management system.

Project requirements:

1. Load the default health check plan, as shown in

    

2. display the project details of the specified package

3. Add check item information to the specified package

4. Delete project information in the package

5. Create a package

Start:

The first thing to do is to build a form.

Then create the CheckItems class

Public class CheckItems
{
Public string description {get; set ;}
Public string name {get; set ;}
Public int price {get; set ;}
Public static List <CheckItems> list = new List <CheckItems> ();
Public static Dictionary <string, List <CheckItems> dic = new Dictionary <string, List <CheckItems> ();

}

Class contains two sets

List storage health check items

Dic storage health check package

Then add some common health check items and a basic package

CheckItems c1 = new CheckItems ();
C1.name = "height ";
C1.price = 5;
C1.description = "used to check height ";
CheckItems c2 = new CheckItems ();
C2.name = "weight ";
C2.price = 5;
C2.description = "used to check the weight ";
CheckItems c3 = new CheckItems ();
C3.name = "liver function ";
C3.price = 50;
C3.description = "used to check liver function ";
CheckItems c4 = new CheckItems ();
C4.name = "visual acuity ";
C4.price = 10;
C4.description = "used to check eyesight ";
CheckItems c5 = new CheckItems ();
C5.name = "";
C5.price = 10;
C5.description = "used to check the hearing ";
CheckItems c6 = new CheckItems ();
C6.name = "B-ultrasound ";
C6.price = 30;
C6.description = "used to check B-ultrasound ";
CheckItems c7 = new CheckItems ();
C7.name = "ECG ";
C7.price = 50;
C7.description = "used to check ECG ";
CheckItems c8 = new CheckItems ();
C8.name = "blood pressure ";
C8.price = 20;
C8.description = "used to check blood pressure ";
CheckItems c9 = new CheckItems ();
C9.name = "Blood Routine ";
C9.price = 20;
C9.description = "used to check blood routine ";

CheckItems. list. Add (c1 );
CheckItems. list. Add (c2 );
CheckItems. list. Add (c3 );
CheckItems. list. Add (c4 );
CheckItems. list. Add (c5 );
CheckItems. list. Add (c6 );
CheckItems. list. Add (c7 );
CheckItems. list. Add (c8 );
CheckItems. list. Add (c9 );

For (int I = 0; I <CheckItems. list. Count; I ++)
{
ComboBox2.Items. Add (CheckItems. list [I]. name );
}

List <CheckItems> li = new List <CheckItems> ();
Li. Add (c1 );
Li. Add (c2 );
Li. Add (c3 );
CheckItems. dic. Add ("admission exam", li );

 

Click Add to add a set of health check plans

List <CheckItems> li = new List <CheckItems> ();
String name = textBox1.Text;
CheckItems. dic. Add (name, li );
ComboBox1.Items. Add (textBox1.Text );
MessageBox. Show ("added successfully! ");

Click Add under health check package maintenance to add check items to the comboBox name package, and the price will be automatically loaded

String name = comboBox1.Text;
List <CheckItems> li = CheckItems. dic [name];

Foreach (CheckItems c in CheckItems. list)
{
If (c. name = comboBox2.Text)
{
Li. Add (c );
Sum + = c. price;
MessageBox. Show ("added successfully! ");
Break;
}
}

Label7.Text = sum. ToString ();
This. dataGridView1.DataSource = new BindingList <CheckItems> (CheckItems. dic [comboBox1.Text]);

You can delete the selected items in the package.

String name = comboBox1.Text;
List <CheckItems> li = CheckItems. dic [name];
String str = "";
Foreach (CheckItems c in CheckItems. list)
{
Str = maid [0]. Cells ["Column1"]. Value. ToString ();
If (c. name = str)
{
Li. Remove (c );
Sum-= c. price;
MessageBox. Show ("deleted successfully! ");
Break;
}
}

Label7.Text = sum. ToString ();
This. dataGridView1.DataSource = new BindingList <CheckItems> (CheckItems. dic [comboBox1.Text]);

The last step is to dynamically load the dataGrideView.

In fact, it is very simple. You only need to write the event under the combobox?selectedindexchanged event of comboBox.

Label5.Text = comboBox1.Text;


List <CheckItems> li = new List <CheckItems> ();
Li = CheckItems. dic [comboBox1.Text];
Foreach (CheckItems c in li)
{
Sum + = c. price;
}
Label7.Text = sum. ToString ();This. dataGridView1.DataSource = new BindingList <CheckItems> (CheckItems. dic [comboBox1.Text]);

In this way, a simple health check package is OVER

 

Related Article

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.