体检套餐系统
2018-06-17 22:43:41来源:未知 阅读 ()
using System;
using System.Collections.Generic;
using System.Text;
namespace ExaminationList
{
public class HealthCheckItem
{
public HealthCheckItem(string name, int price, string description)
{
this.Name = name;
this.Price = price;
this.Description = description;
}
public HealthCheckItem()
{
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private string description;
public string Description
{
get { return description; }
set { description = value; }
}
private int price;
public int Price
{
get { return price; }
set { price = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ExaminationList
{
public class HealthCheckSet
{
public HealthCheckSet()
{
items = new List<HealthCheckItem>();
}
public HealthCheckSet(string name, List<HealthCheckItem> items)
{
this.Name = name;
this.items = items;
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private List<HealthCheckItem> items;
public List<HealthCheckItem> Items
{
get { return items; }
set { items = value; }
}
private int price;
public int Price
{
get { return price; }
}
public void CalcPrice()
{
int totalPrice = 0;
foreach (HealthCheckItem item in items)
{
totalPrice += item.Price;
}
this.price = totalPrice;
}
}
}
using ExaminationList;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace js
{
public partial class Form1 : Form
{
HealthCheckItem height, weight, sight, hearing, liverFun, ekg;
HealthCheckSet setA;
public Form1()
{
InitializeComponent();
}
List<HealthCheckItem> AllItem = new List<HealthCheckItem>();
List<HealthCheckItem> items = new List<HealthCheckItem>();
public Dictionary<string, HealthCheckSet> healthset = new Dictionary<string, HealthCheckSet>();
private void Form1_Load(object sender, EventArgs e)
{
lblSetName.Text = "";
lblSetPrice.Text = "";
this.btnAdd.Enabled = false;
this.btnDel.Enabled = false;
InitItems();
InitSets();
InitHealthSetList();
}
public void InitItems()
{
height = new HealthCheckItem("身高",5,"用于检查身高");
weight = new HealthCheckItem("体重",8,"用于检查体重");
sight = new HealthCheckItem("视力",10,"用于检查视力");
hearing = new HealthCheckItem("听力",10,"用于检查听力");
liverFun = new HealthCheckItem("肝功能",50,"用于检查肝功能");
ekg = new HealthCheckItem("心电图",100,"用于检查心电图");
AllItem.Add(height);
AllItem.Add(weight);
AllItem.Add(sight);
AllItem.Add(hearing);
AllItem.Add(liverFun);
AllItem.Add(ekg);
}
public void InitSets()
{
items = new List<HealthCheckItem>();
items.Add(height);
items.Add(weight);
items.Add(sight);
setA = new HealthCheckSet("入学体检",items);
setA.CalcPrice();
this.healthset.Add("入学体检",setA);
}
public void InitHealthSetList()
{
this.cboSets.Items.Clear();
this.cboSets.Items.Add("请选择");
foreach(string key in this.healthset.Keys){
this.cboSets.Items.Add(key);
}
this.cboSets.SelectedIndex = 0;
}
private void UpdateSet(HealthCheckSet set)
{
this.dgvHealthList.DataSource = new BindingList<HealthCheckItem>(this.items);
}
private void cboSets_SelectedIndexChanged(object sender, EventArgs e)
{
string setName = this.cboSets.Text;
if(setName=="请选择"){
this.dgvHealthList.DataSource = new BindingList<HealthCheckItem>();
lblSetName.Text = "";
lblSetPrice.Text = "";
return;
}
lblSetName.Text = this.healthset[setName].Name;
lblSetPrice.Text = this.healthset[setName].Price.ToString();
UpdateSet(healthset[setName]);
this.btnDel.Enabled = true;
}
private void btnDel_Click(object sender, EventArgs e)
{
string setName = this.cboSets.Text;
if(this.dgvHealthList.SelectedRows.Count==0){
MessageBox.Show("您没有选中删除项","友情提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
int index = this.dgvHealthList.SelectedRows[0].Index;
this.healthset[setName].Items.RemoveAt(index);
this.healthset[setName].CalcPrice();
UpdateSet(healthset[setName]);
this.lblSetName.Text = setA.Name;
this.lblSetPrice.Text = setA.Price.ToString();
MessageBox.Show("删除成功!","友情提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
private void cboItems_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.cboItems.Text != "请选择")
{
this.btnAdd.Enabled = true;
}
else
{
this.btnAdd.Enabled = false;
}
}
private void btnAdd_Click(object sender, EventArgs e)
{
if(this.cboItems.SelectedIndex==0){
MessageBox.Show("请选择一个项目");
return;
}
string cboSetText = this.cboSets.Text;
if(cboSetText=="请选择"){
MessageBox.Show("请选择套餐");
return;
}
int index = this.cboItems.SelectedIndex - 1;
if (!this.healthset[cboSetText].Items.Contains(AllItem[index]))
{
this.healthset[cboSetText].Items.Add(AllItem[index]);
this.healthset[cboSetText].CalcPrice();
UpdateSet(this.healthset[cboSetText]);
this.lblSetName.Text = this.healthset[cboSetText].Name;
this.lblSetPrice.Text = this.healthset[cboSetText].Price.ToString();
MessageBox.Show("添加成功!", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("该项目已存在!","友情提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
private void btnOK_Click(object sender, EventArgs e)
{
if(string.IsNullOrEmpty(this.txtHealthName.Text.Trim())){
MessageBox.Show("请输入套餐名称","友情提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
HealthCheckSet Hch = new HealthCheckSet();
this.healthset.Add(this.txtHealthName.Text.Trim(),Hch);
this.InitHealthSetList();
this.cboSets.SelectedIndex = this.healthset.Count;
MessageBox.Show("添加成功!","友情提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
}
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- 史上最全的python零基础系统学习路线图 2019-07-24
- python零基础系统学习教程之Python 变量类型 2019-07-24
- python学习教程,12306火车票抢票系统 2019-07-24
- 计算机系统 2019-07-24
- BBS(仿博客园系统)项目04(文章详情页根评论、子评论的功 2019-07-24
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash