Items for the Checkup package

Source: Internet
Author: User

The 5th Chapter Medical Examination Package Management System
1. Review of the course content

The 1th chapter: in-depth. NET Framework

. NET Framework Components

The role and composition of the CLR

. NET Program compilation process

. NET Core class libraries and namespaces

2nd. In-depth C # data types

Classes, objects, properties, encapsulation

Class diagram

Structure

Unpacking packing

Value types and reference types

Static members and Static methods

The 3rd chapter uses the collection organization related data

Operation set implements element's increment, delete, check, traverse

ArrayList

Hashtable

Operation generic set implements element's increment, delete, check, traverse

List<t>

Dictionary<k,v>

Generic type

4th chapter in-depth approach to class

constructor function

Method overloading

Communication between classes

2, knowledge carding

Classes and objects

Object

Class

Relationship of classes and objects

To create a class:

To create properties for a class: read-only, write-only, validate logic

Method: No parameter, no return value, no return value with parameter, no parameter, return value, parameter return value

Constructors: Parametric constructors, parameterless constructors

Method overloading

Static methods

Interoperation between objects

Objects work together to accomplish software functions

Packaging

Message delivery

Value types and reference types

C # Data types

Basic data types

Enumeration

Structure

Class

Generic type

Interface

Collection

List

ArrayList

List<t>

02, Dictionary

Hash table Hashtable

Dictionary dictionary<k,v>

03, queue
Queue<t>

04, Stack

Stack<t>

Display control Data binding

DataGridView Controls

Binding List Collection List<t>

Set the DataSource property to Bindinglist<t> Object

Binding Dictionary Collection Dictionary<k,v>

Set DataSource with the BindingSource object

ListView control

Binding Collection Information

Medical Checkup Package Management System

Key ideas and Code analysis:

First, the function can be removed two classes, one is Healthcheckitem (check Project Class) and Healthcheckitem (Medical checkup package). First we need to sort out the two-class relationships, and a package can contain multiple item checks.

Healthcheckitem: Includes project name, Unit price, and Description 3 properties

For example: liver function, for examination of liver function, 60

Then write a parameter constructor that assigns values to these three fields

Healthcheckset: Includes items to check, package name, Total price (all items to be checked)

So here we have to consider checking the type of project:

You can define a generic collection to store the types of items, such as list

Then write 2 constructors to list

To initialize, as follows

Finally, the class also needs a package price calculation method

There are several items that need to be initialized when the form loads:

View and delete package check-in items

Write the Updateset (Healthcheckset set) method to implement the DataGridView control to rebind the collection object

You need to call the CalcPrice () method to recalculate the total price when a physical examination item changes

Key code:

Add Medical items

Select an item from the Checkup item, click the Add button, add the selected item to the generic collection, and rebind the DataGridView

Focus: Determine if the added physical examination item exists in the existing package

New Package

Requirement Description: Enter the package name and click "OK" to add the new plan to the package collection.

Analysis on the management system of medical checkup package

Today we look at the Health Checkup package management system how to write!

First we look at the system, as follows

What we need to make clear is that the project focuses on the use of generic collections list<t> and dictionary<k,v>, based on which we have a clearer structure of the presence of in-memory data.

Before writing the system, you don't have to think about how the functionality is implemented, but first make the requirements clear, and when the requirements are clear, the functionality becomes simple.

Requirements: In order to improve the efficiency of medical staff, we need to develop a management system. We all know that a package can include a number of medical items, such as the mobile package you purchased: Free SMS and traffic, and many other services.

Analysis of Ideas:

1. According to the demand analysis, we can extract two classes, one is the package class (Healthcheckset), and the other is the physical examination item Class (Healthcheckitem).

Physical Examination Item Category:

Package category (Healthcheckset) content:

Do some initialization work in the form

First of all, we know that there may be n packages, and there are a lot of physical exams, so we need to consider using collections to store the corresponding data. The following defines some containers in memory to hold the data we care about.

When the package dropdown box selection changes, you need to load the corresponding medical item under the selected plan.

Analysis here believe that the project has been the idea of a certain understanding, the rest of the content is to be completed by everyone.

Summary: When we get a project, we first need to analyze the requirements and the overall task, then design the appropriate classes to meet the requirements and tasks, and then instantiate the object, do some initialization data, and finally through the external trigger to drive the object operation. For example, when a user chooses a plan, the information about the package is displayed to the user through the control.

Next, I'll write some important code!!

You first create two classes to store

1.

public class Healthcheckset
{
Collection of Healthcheckitem
Public list

Package price
public int price {get; set;}

Package Name
public string Name {get; set;}

Non-parametric construction
Public Healthcheckset () {}

With parametric construction
Public Healthcheckset (String name,list{
This. name = name;
This. item = Item;
}

2.

public class Healthcheckitem
{
Project description
public string Description {get; set;}
Project name
public string Name {get; set;}
Project Price
public int price {get; set;}

Non-parametric construction
Public Healthcheckitem () {}

With parametric construction
Public Healthcheckitem (String name,string description,int price)
{
This. name = name;
This. Price = Price;
This. Description = Description;
}
}
}

Then there is something to write about in the Logd event:

Set up all inspection project collections
listdictionary<string, healthcheckitem> alllist = new dictionary<string, healthcheckitem> ();

Set up a collection of inspection items in a package
list

Save a package collection using a dictionary
dictionary<string, healthcheckset> Dictionary = new dictionary<string, healthcheckset> ();

Initialize the check item
Healthcheckitem item, ITEM2, Item3, Item4, ITEM5, Item6, Item7;

Define a default plan
Healthcheckset Moren;

How to initialize a check item
public void Main ()
{
item = new Healthcheckitem ("height", "for height check", 10);
item2 = new Healthcheckitem ("Weight", "for Weight Check", 5);
Item3 = new Healthcheckitem ("Vision", "for examination of Vision", 15);
ITEM4 = new Healthcheckitem ("hearing", "for examination of Hearing", 20);
ITEM5 = new Healthcheckitem ("Liver function", "for the examination of liver function", 100);
ITEM6 = new Healthcheckitem ("B-Super", "for checking B-Ultrasound", 10);
Item7 = new Healthcheckitem ("ECG", "for examination of Electrocardiogram", 100);


Alllist.add (item. Name,item);
Alllist.add (item2. NAME,ITEM2);
Alllist.add (Item3. NAME,ITEM3);
Alllist.add (ITEM4. Name, ITEM4);
Alllist.add (ITEM5. NAME,ITEM5);
Alllist.add (ITEM6. NAME,ITEM6);
Alllist.add (Item7. NAME,ITEM7);


Dictionary. ADD (item. Name,item);

}

Generate default Plan data
public void Yuan ()
{
List. ADD (item);
List. ADD (ITEM2);
List. ADD (ITEM3);

Moren = new Healthcheckset ("Entrance Examination", list);
Calculate price
Moren. CalcPrice ();

THIS.DICTIONARY.ADD ("Entrance Examination", Moren);

}


How to load the combo list drop-down box
public void Combox ()
{
Cbm_sum. Items.clear ();
Cbm_sum. Items.Add ("--Please Select--");
foreach (String item in dictionary. Keys)
{
Cbm_sum. Items.Add (item);
}
The default first item is selected
Cbm_sum. SelectedIndex = 0;
}
Check the Load method of the Project drop-down box
public void Combox2 ()
{
Cmb_xiang. Items.clear ();
Cmb_xiang. Items.Add ("--Please Select--");
foreach (string item in Alllist.keys)
{
Cmb_xiang. Items.Add (item);
}
The default first item is selected
Cmb_xiang. SelectedIndex = 0;
}
private void Frmmain_load (object sender, EventArgs e)
{
Main ();
Yuan ();
Combox ();
Combox2 ();

}

Add a Package
private void But_add_click (object sender, EventArgs e)
{
if (txt_name. Text!= "")
{
if (dictionary. Keys.contains (Txt_name. Text))
{

MessageBox.Show ("already has the package", "hint", Messageboxbuttons.okcancel, Messageboxicon.error);
Return
}
Else
{
Instantiate to Health
ListHealthcheckset health = new Healthcheckset ();
Health. Item = Hao;
Health. Name = "";
Health. Price = 0;
THIS.DICTIONARY.ADD (Txt_name. Text, health);
Combox ();
Cbm_sum. Text = Txt_name. Text;
Txt_name. Text = "";

}


}
Else
{
MessageBox.Show ("added cannot be empty!", "hint", Messageboxbuttons.okcancel, Messageboxicon.error);
}

}
DataGridView of the filling package
public void Updateset (Healthcheckset set)
{
if (set. Item = = null)
{
Assigning a null value to a DataGridView data source
DGV. DataSource = new bindinglistReturn
}
Else
{
DGV. DataSource = new Bindinglist}

}

Choose a Package
private void Cbm_sum_selectedindexchanged (object sender, EventArgs e)
{


String setName = Cbm_sum. Text;
if (cbm_sum. text== "--Please Select--")
{
Assigning a null value to a DataGridView data source
DGV. DataSource = new bindinglist

Lab_xianshiname. Text = "";
Cmb_xiang. Text = "";
Lab_xianshiprice. Text = "";
But_new. Enabled = false;
Return

}
Else
{
Lab_xianshiname. Text = SetName;
if (dictionary[setname]!=null)
{
Bind data to DataGridView according to the package name
Updateset (Dictionary[setname]);
}
Else
{
Assigning a null value to a DataGridView data source
DGV. DataSource = new bindinglist}

Total Price According to the check items in the package name
Lab_xianshiprice. Text = Dictionary[setname]. Price.tostring ();
}


}

Delete
private void But_shan_click (object sender, EventArgs e)
{
String key = DGV. Selectedrows[0]. CELLS[1]. Value.tostring ();
This.dictionary[cbm_sum. Text]. Item.remove (Alllist[key]);

DGV. DataSource = new Bindinglist But_shan. Enabled = false;//Delete button disabled

}
public string name;
//Check
private void Dgv_cellclick (object sender, Datagr Idviewcelleventargs e)
{
if (DGV. selectedrows.count!=1| | DGV. Selectedrows[0]. CELLS[1]. Value==null)
{
MessageBox.Show ("Please choose your line correctly!", "hint", messageboxbuttons.okcancel,messageboxicon.error);
Return
}
Else
{
name = DGV. Selectedrows[0]. CELLS[1]. Value.tostring ();
But_shan. Enabled = true;//Delete button available for
}

}

Add Item
private void But_new_click (object sender, EventArgs e)
{
String name = Cmb_xiang. Text;
if (!dictionary[cbm_sum. Text]. Item.contains (Alllist[name]))
{
Dictionary[cbm_sum. Text]. Item.add (Alllist[name]);
MessageBox.Show ("Add success!", "hint", messageboxbuttons.ok,messageboxicon.information);
DGV. DataSource = new BindinglistDictionary[cbm_sum. Text]. CalcPrice ();
Total Price According to the check items in the package name
Lab_xianshiprice. Text = Dictionary[cbm_sum. Text]. Price.tostring ();
}
Else
{
MessageBox.Show ("There has been the existence of the project", "hint", Messageboxbuttons.okcancel, Messageboxicon.error);
}


}

Whether the Add button is available
private void Cmb_xiang_selectedindexchanged (object sender, EventArgs e)
{

if (Cmb_xiang. Text = = "--Please Select--" | | Cbm_sum. text== "--Please Select--")
{
But_new. Enabled = false;
}
Else
{
But_new. Enabled = true;
}

}

private void Gb_add_enter (object sender, EventArgs e)
{

}

private void Gb_main_enter (object sender, EventArgs e)
{

}

private void Txt_name_textchanged (object sender, EventArgs e)
{

}

private void Lab_name_click (object sender, EventArgs e)
{

}

private void Dgv_cellcontentclick (object sender, DataGridViewCellEventArgs e)
{

}

private void Lab_xiang_click (object sender, EventArgs e)
{

}

private void Lab_xianshiprice_click (object sender, EventArgs e)
{

}

private void Lab_price_click (object sender, EventArgs e)
{

}

private void Lab_xianshiname_click (object sender, EventArgs e)
{

}

private void Labname_click (object sender, EventArgs e)
{

}

private void Lab_sum_click (object sender, EventArgs e)
{

}

private void Backgroundworker1_dowork (object sender, DoWorkEventArgs e)
{

}


}
}

This is the approximate code for this project.

Items for the Checkup package

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.