第五章 体检项目
来源:互联网 发布:狼雨seo网络科技 编辑:程序博客网 时间:2024/03/29 02:00
using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using System.Windows.Forms;namespace Day05_体检套餐管理系统{ static class Program { /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } }}using System;using System.Collections.Generic;using System.Linq;using System.Text;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; } } }using System;using System.Collections.Generic;using System.Linq;using System.Text;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; } }}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 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("该套餐已经存在","提示"); } } } }
0 0
- 第五章 体检项目
- 第五章体检
- 第五章 体检套餐
- 第五章 体检套餐
- 第五章体检套餐
- C#第五章 套餐体检
- 深入.NET 第五章 体检套餐
- 深入。net和c#第五章体检套餐
- 体检之二:至尊套餐体检项目
- 常规体检项目
- 体检套餐项目
- S2 体检项目
- 个人体检都要做什么项目
- 体检
- 体检
- 体检
- 体检
- 体检
- 队列和栈和递归
- 二叉树基本操作
- css中哪些属性可以继承?
- express的api学习笔记
- JavaScript判断对象是否含有某个属性
- 第五章 体检项目
- <hadoop>YARN运行机制
- Javac工作原理分析
- EXCEL 数据驱动 只能在 32位下面使用,在64位下面就会报错 解决办法
- 数据库概述
- Linux自学信息汇总
- C#-定时关闭进程。根据定时关闭进程做的自动关闭游戏小软件。
- eclipse打开myeclipse 项目
- ubuntu 16.04LTS 下Code::Blocks 16.01 安装