博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
体检套餐管理系统
阅读量:5009 次
发布时间:2019-06-12

本文共 5558 字,大约阅读时间需要 18 分钟。

 

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);
        }

    }

}

 

转载于:https://www.cnblogs.com/1234wwww/p/6558490.html

你可能感兴趣的文章
树-线索二叉树
查看>>
JAVA遇见HTML——Servlet篇:Servlet基础
查看>>
第二章 Vue快速入门--20 品牌案例-完成品牌列表的添加功能+ 21 品牌案例-根据Id完成品牌的删除...
查看>>
Java单例模式
查看>>
重温WCF之消息契约(MessageContract)(六)
查看>>
Excel2007制作直方图和正态分布曲线图
查看>>
android adb常用指令
查看>>
Android框架之路——GreenDao3.2.2的使用
查看>>
类方法WCF学习笔记-KnowTypeAttribute用法
查看>>
平台程序微信平台开发应用的签名
查看>>
程序卡OK6410裸板更新程序_update
查看>>
MYSQL用户名:root
查看>>
JavaScript 开发规范要求
查看>>
Devstack 安装OpenStack Pike版本(单机环境)
查看>>
Javascript 函数初探
查看>>
类的定义、声明使用
查看>>
转载,gini系数代码对应的公式
查看>>
编译安装mysql-5.6.40
查看>>
年终总结
查看>>
初创互联网公司技术架构变迁之路
查看>>