体检套餐系统
来源:互联网 发布:js math方法 编辑:程序博客网 时间:2024/06/11 23:51
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 体检项目{ public class CheckSet { public string Name { get; set; } public int Price { get; set; } public List<Health> items { get; set; } public CheckSet() { items = new List<Health>(); } public CheckSet(string name,List<Health> item) { this.Name = name; this.items = item; } public void CalPrice() { int total = 0; foreach (Health h in items) { total = total + h.Price; } this.Price = total; } }}
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 体检项目{ //检查项目类 public class Health { public string Name { get; set; } public string Description { get; set; } public int Price { get; set; } public Health() { } public Health(string name,string ds,int price) { this.Name = name; this.Description = ds; 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.Windows.Forms;namespace 体检项目{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } //采用泛型集合保存 所有 的体检项目 List<Health> AllItems = new List<Health>(); //采用泛型集合保存 套餐 中的的体检项目 List<Health> items = new List<Health>(); //使用字典保存套餐集合 public Dictionary<string, CheckSet> HealthSet = new Dictionary<string, CheckSet>(); Health sg, ti, gan, B,shili; CheckSet set = new CheckSet(); private void Form1_Load(object sender, EventArgs e) { this.label5.Text = ""; this.label7.Text = ""; ADD(); Student(); } public void ADD() { sg = new Health("身高", "用于检查身高", 5); ti = new Health("体重", "用于检查体重", 5); gan = new Health("肝功能", "用于检查肝功能", 50); B = new Health("B超", "用于检查B超", 30); shili = new Health("视力", "用于检查视力", 50); AllItems.Add(sg); AllItems.Add(ti); AllItems.Add(gan); AllItems.Add(B); AllItems.Add(shili); // this.dataGridView1.DataSource = new BindingList<Health>(AllItems); this.comboBox2.Items.Add("请选择"); foreach (Health item in AllItems) { comboBox2.Items.Add(item.Name); } this.comboBox2.SelectedIndex = 0; } //设置入学套餐 public void Student() { items = new List<Health>(); items.Add(sg); items.Add(ti); items.Add(gan); set = new CheckSet("入学体检",items); //计算套餐价格 set.CalPrice(); this.HealthSet.Add("入学体检",set); //清空套餐下拉列表 this.comboBox1.Items.Clear(); //添加请选择 this.comboBox1.Items.Add("请选择"); //将 Dictionary的Key值 绑定到COMBOX1 foreach (string key in HealthSet.Keys) { this.comboBox1.Items.Add(key); } //默认选择第一项 this.comboBox1.SelectedIndex = 0; // this.dataGridView1.DataSource = new BindingList<Health>(items); } public void UpdateSet(CheckSet set) { this.dataGridView1.DataSource = new BindingList<Health>(set.items); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { string sNAME = this.comboBox1.Text; if (sNAME == "请选择") { this.dataGridView1.DataSource = null; this.label5.Text = ""; this.label7.Text = ""; return; } //设置套餐名称 this.label5.Text = this.HealthSet[sNAME].Name; //设置套餐总价 this.label7.Text = this.HealthSet[sNAME].Price.ToString(); UpdateSet(HealthSet[sNAME]); } /// <summary> /// 添加 套餐 检查的项目 方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { if (this.comboBox2.SelectedIndex==0) { MessageBox.Show("请选择一个项目"); return; } //声明一个套餐来接受 套餐 列表的文字 string CBO = comboBox1.Text; if (CBO=="请选择") { MessageBox.Show("请选择套餐!"); return; } // 判断现有套餐是否存在 int index = this.comboBox2.SelectedIndex-1; if (! this.HealthSet[CBO].items.Contains(AllItems[index])) { this.HealthSet[CBO].items.Add(AllItems[index]); this.HealthSet[CBO].CalPrice(); UpdateSet(this.HealthSet[CBO]); //刷新窗体集合名称 this.label5.Text = this.HealthSet[CBO].Name; //刷新窗体集合的 价格 this.label7.Text = this.HealthSet[CBO].Price.ToString(); MessageBox.Show("添加成功!!!","提示"); } else { MessageBox.Show("该项目已存在","提示"); } } //删除项目 private void button3_Click(object sender, EventArgs e) { string setName = this.comboBox1.Text; if (this.dataGridView1.SelectedRows.Count==0) { MessageBox.Show("没有选择删除项"); return; } //获取选中的索引 int index =this.dataGridView1.SelectedRows[0].Index; this.HealthSet[setName].items.RemoveAt(index); //重新计算价格 this.HealthSet[setName].CalPrice(); UpdateSet(HealthSet[setName]); this.label5.Text=set.Name; this.label7.Text=set.Price.ToString(); MessageBox.Show("删除成功"); } /// <summary> /// 添加套餐 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { if (this.textBox1.Text=="") { MessageBox.Show("请输入要添加的套餐名称"); return; } CheckSet se = new CheckSet(); this.HealthSet.Add(this.textBox1.Text, se); this.AddSet(); // this.comboBox1.Items.Clear(); //this.comboBox1.Items.Add("请选择"); // foreach (string item in HealthSet.Keys) // { // this.comboBox1.Items.Add(item); // } this.comboBox1.SelectedIndex = this.HealthSet.Count; MessageBox.Show("添加成功"); } public void AddSet() { this.comboBox1.Items.Clear(); this.comboBox1.Items.Add("请选择"); foreach (string item in HealthSet.Keys) { this.comboBox1.Items.Add(item); } this.comboBox1.SelectedIndex = 0; } } }
1 0
- 体检套餐管理系统
- 体检套餐系统
- 体检套餐系统
- 体检套餐管理系统
- C# 体检套餐管理系统
- 体检套餐
- 体检套餐
- 体检套餐
- C#oop体检套餐管理系统
- 体检之一:体检豪华套餐
- 体检套餐 关键代码
- 第五章 体检套餐
- 体检套餐项目
- 第五章 体检套餐
- 第五章体检套餐
- 体检之二:至尊套餐体检项目
- C#第五章 套餐体检
- C#窗体设计《体检套餐》代码
- 员工考勤
- 2.19.1 字符逆序
- WEB入门.九 导航菜单
- Vue引入远程JS文件
- 经理评分
- 体检套餐系统
- bzoj2286 [Sdoi2011]消耗战
- React-Manga 一个以React实现的漫画WebApp
- Python(windows下安装pip)
- [4]内核编译与根文件系统制作(国嵌)
- 启动MySQL错误(net start mysql 发生系统错误 5。 拒绝访问。)
- Babelfish
- 微信小程序开发知识点总结
- 说说两年的投资理财经历吧