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

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace HealthCheck
    {
        //检查项目
        class HealthCheckItem
        {
            private string name;
            public string Name
            {
                get { return name; }
                set { name = value; }
            }
    
            private string bewrite;
            public string Bewrite
            {
                get { return bewrite; }
                set { bewrite = value; }
            }
    
            private int price;
            public int Price
            {
                get { return price; }
                set { price = value; }
            }
    
            public HealthCheckItem()
            {}
            
            public HealthCheckItem(string name,int price,string bewrite)
            {
                this.name = name;
                this.price = price;
                this.bewrite = bewrite;
            }
    
            public static Dictionary<string, HealthCheckItem> ItemDic = new Dictionary<string, HealthCheckItem>()
            {
                {"身高",new HealthCheckItem("身高",5,"用于测量身高")},
                {"体重",new HealthCheckItem("体重",5,"用于测量体重")},
                {"视力",new HealthCheckItem("视力",5,"用于检查视力")},
                {"听力",new HealthCheckItem("听力",5,"用于检查听力")},
                {"肝功能",new HealthCheckItem("肝功能",200,"用于检测肝功能")},
                {"B超",new HealthCheckItem("B超",60,"用于B超检查")},
                {"心电图",new HealthCheckItem("心电图",100,"用于检查心电图")},
                {"肺活量",new HealthCheckItem("肺活量",8,"用于测量肺活量")}
            };
            
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace HealthCheck
    {
        //套餐
        class HealthCheckSet
        {
            private string name;
            public string Name
            {
                get { return name; }
                set { name = value; }
            }
    
            public List<HealthCheckItem> ItemList=new List<HealthCheckItem>();
            public static Dictionary<string, List<HealthCheckItem>> SetDic = new Dictionary<string, List<HealthCheckItem>>();
            public HealthCheckSet()
            {
                this.ItemList = new List<HealthCheckItem>();
                ItemList.Add(HealthCheckItem.ItemDic["身高"]);
                ItemList.Add(HealthCheckItem.ItemDic["体重"]);
                ItemList.Add(HealthCheckItem.ItemDic["视力"]);
                ItemList.Add(HealthCheckItem.ItemDic["听力"]);
                ItemList.Add(HealthCheckItem.ItemDic["肺活量"]);
                SetDic.Add("入学体检",this.ItemList);
            }
            public HealthCheckSet(string name)
            {
                SetDic.Add(name,this.ItemList);
            }
                
            /// <summary>
            /// Dic_Values 添加
            /// </summary>
            /// <param name="str"></param>
            public static void DicAdd(List<HealthCheckItem> list,string str)
            {
               list.Add(HealthCheckItem.ItemDic[str]);
            }
        }
    }
    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 HealthCheck
    {
        public partial class FrmMain : Form
        {
            public FrmMain()
            {
                InitializeComponent();
            }
    
            private void FrmMain_Load(object sender, EventArgs e)
            {
                cboItem.Items.Add("请选择");
                cboItem.SelectedIndex = 0;
                RenovateItem();
                HealthCheckSet set = new HealthCheckSet();
                RenovateList();
                cboList.SelectedIndex = 0;
                cboItem.Enabled = false;
                btnAddItem.Enabled = false;
                btnDeleteItem.Enabled = false;
            }
            //更新检查项目列表
            private void RenovateItem()
            {
                foreach (KeyValuePair<string, HealthCheckItem> item in HealthCheckItem.ItemDic)
                {
                    cboItem.Items.Add(item.Key);
                }
            }
            //更新套餐列表
            private void RenovateList()
            {
                cboList.Items.Clear();
                cboList.Items.Add("请选择");
                foreach (KeyValuePair<string, List<HealthCheckItem>> item in HealthCheckSet.SetDic)
                {
                    cboList.Items.Add(item.Key);
                }
                if (cboList.Items.Count>2)
                {
                    cboList.SelectedIndex = cboList.Items.Count - 1;   
                }
            }
            //套餐列表
            private void cboList_SelectedIndexChanged(object sender, EventArgs e)
            {
                if (cboList.SelectedIndex>0)
                {
                    lblChooseName.Text = cboList.Text;
                    cboItem.Enabled = true;
                    RenovateDGV();
                }
                else
                {
                    cboItem.Enabled = false;
                }
            }
            /// <summary>
            /// 刷新DGV列表
            /// </summary>
            private void RenovateDGV()
            {
                dgvHealthCheckInfo.DataSource = new BindingList<HealthCheckItem>(HealthCheckSet.SetDic[cboList.Text]);
                lblChoosePrice.Text = PriceSum(cboList.Text).ToString();
            }
            /// <summary>
            /// 检查总金额
            /// </summary>
            /// <param name="key"></param>
            /// <returns></returns>
            private int PriceSum(string key)
            {
                int sum = 0;
                foreach (HealthCheckItem item in HealthCheckSet.SetDic[key])
                {
                    sum += item.Price;
                }
                return sum;
            }
            //项目列表
            private void cboItem_SelectedIndexChanged(object sender, EventArgs e)
            {
                if (cboItem.SelectedIndex>0)
                {
                    btnAddItem.Enabled = true;
                }
                else
                {
                    btnAddItem.Enabled = false;
                    btnDeleteItem.Enabled = false;
                }
            }
            //DGV单击事件
            private void dgvHealthCheckInfo_CellClick(object sender, DataGridViewCellEventArgs e)
            {
                if (!btnDeleteItem.Enabled)
                {
                    btnDeleteItem.Enabled = true;   
                }
            }
            //删除检查项目
            private void btnDeleteItem_Click(object sender, EventArgs e)
            {
                DialogResult result = MessageBox.Show("您确定要删除吗?","警告!",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
                if (result == DialogResult.OK)
                {
                    if (dgvHealthCheckInfo.SelectedRows[0] != null && dgvHealthCheckInfo.SelectedRows[0].Cells[0] != null && dgvHealthCheckInfo.SelectedRows[0].Cells[0].Value != null)
                    {
                        //删除 套餐中所选的与内置检查项目相匹配的项
                        HealthCheckSet.SetDic[cboList.Text].Remove(HealthCheckItem.ItemDic[dgvHealthCheckInfo.SelectedRows[0].Cells["clmItemName"].Value.ToString()]);
                        RenovateDGV();
                    }
                }
            }
            //添加检查项目
            private void btnAddItem_Click(object sender, EventArgs e)
            {
                if (HealthCheckSet.SetDic[cboList.Text].Contains(HealthCheckItem.ItemDic[cboItem.Text]))
                {
                    MessageBox.Show(cboList.Text+"套餐中已存在该检查项目!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
                }
                else
                {
                    HealthCheckSet.DicAdd(HealthCheckSet.SetDic[cboList.Text],cboItem.Text);
                    RenovateDGV();
                }
            }
            //套餐添加
            private void btnAdd_Click(object sender, EventArgs e)
            {
                if (txtName.Text!="")
                {
                    foreach (string item in HealthCheckSet.SetDic.Keys)
                    {
                        if (txtName.Text.Equals(item))
                        {
                            MessageBox.Show("已经存在"+txtName.Text+"套餐!");
                            return;
                        }
                    }
                    HealthCheckSet dic = new HealthCheckSet(txtName.Text);
                    RenovateList();
                }
            }
        }
    }
  • 相关阅读:
    json编解码
    Grok 正则捕获
    logstash date插件介绍
    logstash 字段类型转换后 需要刷新
    logstash 防止实际处理时间跟事件产生时间略有偏差
    导入旧数据需要 使用date插件
    nginx和tomcat的响应时间
    解决kibana 4 关于响应时间的问题
    go 可以开发桌面应用
    windows下go语言环境
  • 原文地址:https://www.cnblogs.com/chuangege/p/5809741.html
Copyright © 2011-2022 走看看