zoukankan      html  css  js  c++  java
  • 体检套餐管理系统

    体检套餐系统

    1.加载默认体检套餐

    2.初始化检查项目

    新增套餐


    1.定义检查项目类HealthCheckItem、体检套餐类HealthCheckSet’

     //体检项目类
      public class HealthCheckItem
        {
    
          
            //项目的名称
            private string name;
    
            public string Name
            {
                get { return name; }
                set { name = value; }
            }
            //项目的价格
            private int price;
    
            public int Price
            {
                get { return price; }
                set { price = value; }
            }
            //项目的描述
            private string description;
    
            public string Description
            {
                get { return description; }
                set { description = value; }
            }
    
            //无参构造
            public HealthCheckItem()
            {
            }
            public HealthCheckItem(string name, int price, string description)
            {
                this.Name = name;
                this.Price = price;
                this.Description = description;
            }
        }
     //体检套餐类
        public class HealthCheckSet
        {
            //名称
             private string name;
    
            public string Name
            {
                get { return name; }
                set { name = value; }
            }
            private int price;
    
            public int Price
            {
                get { return price; }
                
            }
            private Dictionary<string, HealthCheckItem> items;
    
            public Dictionary<string, HealthCheckItem> Items
            {
                get { return items; }
                set { items = value; }
            }
            public HealthCheckSet()
            {
                items = new Dictionary<string, HealthCheckItem>();
            }
            public HealthCheckSet(string name, Dictionary<string, HealthCheckItem> item)
            {
                this.Name = name;
                this.Items = item;
            }
    
            //计算套餐的总价格
            public void SumPirce()
            {
                //定义一个变量,来保存总价格
                int totalprice = 0;
                //
                foreach (HealthCheckItem item in items.Values)
                {
                    totalprice+=item.Price;
                }
                this.price = totalprice;
            }
        }

    2.定义三个双列泛型集合,分别来保存所有体检项目、套餐内的套餐项目列表、套餐的集合

            //用于保存所有单个套餐项目
            HealthCheckItem height, weight, sight, hearing, liverFun, ekg, bWaves, bloodPressure, bloodTest;
            //allitem用于保存所有的套餐项目
            Dictionary<string, HealthCheckItem> Allitem = new Dictionary<string, HealthCheckItem>();
            //定义一个套餐
            HealthCheckSet set;
            //定义一个套餐内的套餐项目列表
            Dictionary<string, HealthCheckItem> item = new Dictionary<string, HealthCheckItem>();
            //定义一个套餐的集合
            Dictionary<string, HealthCheckSet> Allset = new Dictionary<string, HealthCheckSet>();

    3.在窗体加载时初始化所有体检项目和绑定下拉框,定义四个类

    初始化套餐项目、

    初始化一个套餐

    将初始化套餐信息绑定到下拉框当中

    //更新套餐检查项目

     //初始化套餐项目
            public void Init()
            {
                height = new HealthCheckItem("身高", 5, "用于检查身高.");
                weight = new HealthCheckItem("体重", 5, "用于检查体重.");
                sight = new HealthCheckItem("视力", 10, "用于检查视力.");
                hearing = new HealthCheckItem("听力", 10, "用于检查听力.");
                liverFun = new HealthCheckItem("肝功能", 50, "用于检查肝功能.");
                bWaves = new HealthCheckItem("B超", 30, "用于检查B超.");
                ekg = new HealthCheckItem("心电图", 50, "用于检查心电图.");
                bloodPressure = new HealthCheckItem("血压", 20, "用于检查血压.");
                bloodTest = new HealthCheckItem("血常规", 20, "用于检查血常规.");
                Allitem.Add(height.Name, height);
                Allitem.Add(weight.Name, weight);
                Allitem.Add(sight.Name, sight);
                Allitem.Add(hearing.Name, hearing);
                Allitem.Add(liverFun.Name, liverFun);
                Allitem.Add(bWaves.Name, bWaves);
                Allitem.Add(ekg.Name, ekg);
                Allitem.Add(bloodPressure.Name, bloodPressure);
                Allitem.Add(bloodTest.Name, bloodTest);
            }
    
            //初始化一个套餐
            public void InitHealth()
            {
                item.Add(height.Name, height);
                item.Add(weight.Name, weight);
                item.Add(sight.Name, sight);
                set = new HealthCheckSet("入学体检", item);
                set.SumPirce();
                Allset.Add("入学体检", set);
            }
    
            //将初始化套餐信息绑定到下拉框当中
            public void InitSet()
            {
                this.cboSets.Items.Clear();
                this.cboSets.Items.Add("请选择");
                foreach (string item in Allset.Keys)
                {
                    this.cboSets.Items.Add(item);
                }
                this.cboSets.SelectedIndex = 0;
            }
            //更新套餐检查项目
            public void UpdateSet(HealthCheckSet set)
            {
                this.dgvHealthList.DataSource = new BindingList<HealthCheckItem>(set.Items.Values.ToList());
            }

    4.当下拉框为“请选择”时,

    this.lblSetName.Text = "";
    this.lblSetPrice.Text = "";

    否则

    this.lblSetName.Text = name;
    this.lblSetPrice.Text = Allset[name].Price.ToString();

     private void cboSets_SelectedIndexChanged(object sender, EventArgs e)
            {
                string name = this.cboSets.Text;
                if (name == "请选择")
                {
                    this.dgvHealthList.DataSource = new BindingList<HealthCheckItem>();
                    this.lblSetName.Text = "";
                    this.lblSetPrice.Text = "";
                    return;
                }
                this.lblSetName.Text = name;
                this.lblSetPrice.Text = Allset[name].Price.ToString();
                UpdateSet(Allset[name]);  
            }

    5.点击添加时体检项目就会添加到DataGridView中

    //添加项目
            private void btnAdd_Click(object sender, EventArgs e)
            {
                if (this.cboItems.SelectedIndex == 0)
                {
                    MessageBox.Show("请选择套餐项");
                    return;
                }
                string name = this.cboSets.Text;
                if (name == "请选择")
                {
                    MessageBox.Show("请选择套餐");
                    return;
                }
                if (!Allset[name].Items.Keys.ToList().Contains(this.cboItems.Text))
                {
                    Allset[name].Items.Add(this.cboItems.Text, Allitem[this.cboItems.Text]);
                    Allset[name].SumPirce();
                    this.lblSetName.Text = name;
                    this.lblSetPrice.Text = Allset[name].Price.ToString();
                    UpdateSet(Allset[name]);
                }
                else
                {
                    MessageBox.Show("该项已经存在!");
                }
            }

    6.点击删除时,所选中的一行就会删除

    //删除项目
            private void btnDel_Click(object sender, EventArgs e)
            {
                string name = this.dgvHealthList.SelectedRows[0].Cells[0].Value.ToString();
                string healthname = this.cboSets.Text;
                Allset[healthname].Items.Remove(name);
                UpdateSet(Allset[healthname]);
            }

    7.点击添加时就会添加一个套餐名称,并显示到下拉框中

    //添加套餐名称
            private void btnOK_Click(object sender, EventArgs e)
            {
                if (this.txtHealthName.Text.Trim() != null && this.txtHealthName.Text.Trim() != "")
                {
                    HealthCheckSet set = new HealthCheckSet();
                    Allset.Add(this.txtHealthName.Text.Trim(), set);
                    InitSet();
    
                    this.cboSets.SelectedIndex = Allset.Count;
                }
                else
                {
                    MessageBox.Show("请输入添加的套餐名称");
                }
            }
  • 相关阅读:
    oraclesqlloader
    Dosinternal command and external command
    unixexpr
    Powerbuilder 6.5完全图解教程
    character set
    pbdatawindow function
    java decompile tool(recommended)
    php验证码背景色设置无效
    使用jquery validation engine判断为空的时候要根据input的type
    有些站点不能被iframe
  • 原文地址:https://www.cnblogs.com/luoxionghenku/p/8259758.html
Copyright © 2011-2022 走看看