体检系统
来源:互联网 发布:seo工资 编辑:程序博客网 时间:2024/04/20 21:15
namespace Day05_体检套餐管理系统{ public partial class Form1 : Form { //采用泛型集合List保存所有的体检项目 List<HealthCheckItem> AllItems = new List<HealthCheckItem>(); //采用泛型集合List保存套餐中的体检项目 List<HealthCheckItem> items = new List<HealthCheckItem>(); Dictionary<string, HealthCheckSet> HealthSet = new Dictionary<string, HealthCheckSet>(); public Form1() { InitializeComponent(); } //选择"套餐列表"下拉列表事件 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { string setName = this.cboSets.Text; if (setName == "请选择") { this.dgvHealthList.DataSource = new BindingList<HealthCheckItem>(); lalSetName.Text = ""; lalSetPrice.Text = ""; return; } //设置套餐名称 lalSetName.Text=this.HealthSet[setName].Name; //设置套餐价格 lalSetPrice.Text = this.HealthSet[setName].Price.ToString(); //更新套餐检查项目 UpdateSet(HealthSet[setName]); //设置“删除”按钮为可用状态 this.btnDel.Enabled = true; } //更新套餐检查项目 private void UpdateSet(HealthCheckSet set) { this.dgvHealthList.DataSource = new BindingList<HealthCheckItem>(set.Items); } private void Button2_Click(object sender, EventArgs e) { string wantAdd = this.cboSets.Text; int index = this.cboSetTex.SelectedIndex ; MessageBox.Show(index.ToString()); //添加操作的关键代码 if (!this.HealthSet[wantAdd].Items.Contains(AllItems[index])) { //添加检查项目 this.HealthSet[wantAdd].Items.Add(AllItems[index]); //重新计算总价格 this.HealthSet[wantAdd].CalcPrice(); //更新 UpdateSet(this.HealthSet[wantAdd]); //刷新窗体集合A名称 this.lalSetName.Text = this.HealthSet[wantAdd].Name; //刷新集合A价格 this.lalSetPrice.Text = this.HealthSet[wantAdd].Price.ToString(); MessageBox.Show("添加成功。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("该项目存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } public void liebiao() { HealthCheckItem height = new HealthCheckItem("身高", "用于检查身高", 20); HealthCheckItem weight = new HealthCheckItem("体重", "用于检查体重", 30); HealthCheckItem vision = new HealthCheckItem("视力", "用于检查视力", 50); HealthCheckItem hearing = new HealthCheckItem("听力", "用于检查听力", 50); HealthCheckItem function = new HealthCheckItem("肝功能", "用于检查肝功能", 100); HealthCheckItem Bultrasonography = new HealthCheckItem("B超", "用于检查B超", 200); HealthCheckItem electrocardiogram = new HealthCheckItem("心电图", "用于检查心电图", 300); items.Add(height); items.Add(weight); items.Add(vision); items.Add(hearing); items.Add(function); items.Add(Bultrasonography); items.Add(electrocardiogram); foreach (HealthCheckItem item in this.items) { this.cboSetTex.Items.Add(item.Name); } this.cboSetTex.SelectedIndex = 0; } private void cboSets_SelectedIndexChanged(object sender, EventArgs e) { string setName = this.cboSets.Text; if (setName == "请选择") { this.dgvHealthList.DataSource = new BindingList<HealthCheckItem>(); label5.Text = ""; label7.Text = ""; return; } else { label5.Text = this.HealthSet[setName].Name; HealthSet[setName].CalcPrice(); label7.Text = this.HealthSet[setName].Price.ToString(); UpdateSet(HealthSet[setName]); this.btnDel.Enabled = true; } } public void Showruxue() { HealthCheckItem height = new HealthCheckItem("身高", "用于检查身高", 20); HealthCheckItem weight = new HealthCheckItem("体重", "用于检查体重", 30); HealthCheckItem vision = new HealthCheckItem("视力", "用于检查视力", 50); AllItems.Add(height); AllItems.Add(weight); AllItems.Add(vision); HealthCheckSet health = new HealthCheckSet("入学体检", AllItems); HealthSet.Add("入学体检", health); this.cboSets.Items.Add("请选择"); this.cboSets.SelectedIndex = 0; foreach (var item in HealthSet) { this.cboSets.Items.Add(item.Key); } } private void Form1_Load(object sender, EventArgs e) { //启动 liebiao(); Showruxue(); } //删除按键 private void btnDel_Click(object sender, EventArgs e) { string sename = this.cboSets.Text; if (MessageBox.Show("确认删除吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { int index = this.dgvHealthList.SelectedRows[0].Index; if (this.dgvHealthList.SelectedRows.Count > 0) { this.HealthSet[sename].Items.RemoveAt(index); label5.Text = this.HealthSet[sename].Name; HealthSet[sename].CalcPrice(); label7.Text = this.HealthSet[sename].Price.ToString(); UpdateSet(HealthSet[sename]); } else { MessageBox.Show("请选中一行", "提示"); } } } private void button1_Click(object sender, EventArgs e) { string sename = this.textBox1.Text; int count = this.cboSets.Items.Count; if (!HealthSet.Keys.ToList().Contains(sename)) { List<HealthCheckItem> health = new List<HealthCheckItem>(); HealthCheckSet hea = new HealthCheckSet(sename,health); HealthSet.Add(sename,hea); this.cboSets.Items.Add(sename); this.cboSets.SelectedIndex = count; UpdateSet(HealthSet[sename]); } else { MessageBox.Show("该套餐已经存在","提示"); } } } }
namespace Day05_体检套餐管理系统{ class HealthCheckItem { public string Decription { get; set; } public string Name { get; set; } public int Price { get; set; } public HealthCheckItem() { } public HealthCheckItem(string decription, string name, int price) { this.Decription = decription; this.Name = name; this.Price = price; } }}
namespace Day05_体检套餐管理系统{ class HealthCheckSet { public List<HealthCheckItem> Items { get; set; } public string Name { get; set; } public int Price { get; set; } public HealthCheckSet() { } public HealthCheckSet(string name,List<HealthCheckItem> items)//int price构两个函数 { this.Items = items; this.Name = name; // this.Price = price; } public void CalcPrice() { int totalPrice = 0; foreach(HealthCheckItem item in this.Items) { totalPrice += item.Price; } this.Price = totalPrice; } } }
6
0 0
- 体检系统
- 医院健康体检系统
- 体检信息管理系统功能表
- 体检套餐管理系统
- 体检套餐系统
- 体检套餐系统
- 体检套餐管理系统
- 谋天健康体检系统
- 医院体检管理系统说明书
- 体检在线Bug/Exception系统
- C# 体检套餐管理系统
- 体检
- 体检
- 体检
- 体检
- 体检
- C#oop体检套餐管理系统
- WCF医院管理系统技术解析(六)体检登记(五)对病人设置体检项目
- Android WebView的简单使用
- UML九种图之动态图
- Struts2接收数组时需要注意的问题
- Android studio 之外观设置
- 微软无人机虚拟训练平台AirSim学习
- 体检系统
- Bootstrap下拉菜单
- java匿名类总结
- Map集合的四种遍历方式
- AndroidStudio插件GsonFormat快速实现JavaBean
- 解决recyclerview notifyItemChanged 闪烁问题
- Zabbix使用总结
- C 语言不同C文件中 enum 枚举变量的使用方法
- “和平分手”一小时后……