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

     1  public class HealItem
     2     {
     3         //检查项目
     4         private string name;//项目名
     5         public string Name
     6         {
     7             get { return name; }
     8             set { name = value; }
     9         }
    10 
    11         private string description;// 描述
    12 
    13         public string Description
    14         {
    15             get { return description; }
    16             set { description = value; }
    17         }
    18      
    19         private int price;//价格
    20         public int Price
    21         {
    22             get { return price; }
    23             set { price = value; }
    24         }
    25 
    26         public HealItem(){ }
    27         public HealItem(string name, int price, string description)
    28         {
    29             this.Name= name;
    30             this.Price = price;
    31             this.Description = description;
    32         }
    33 
    34         public static Dictionary<string, HealItem> ItemDic = new Dictionary<string, HealItem>()
    35         {
    36             {"身高",new HealItem("身高",5,"用于测量身高")},
    37             {"体重",new HealItem("体重",5,"用于测量体重")},
    38             {"视力",new HealItem("视力",5,"用于检查视力")},
    39             {"听力",new HealItem("听力",5,"用于检查听力")},
    40             {"肝功能",new HealItem("肝功能",200,"用于检测肝功能")},
    41             {"B超",new HealItem("B超",60,"用于B超检查")},
    42             {"心电图",new HealItem("心电图",100,"用于检查心电图")},
    43             {"肺活量",new HealItem("肺活量",8,"用于测量肺活量")}
    44         };
     1  public class HealSet
     2     {
     3         //体检套餐
     4         public int  Price { get; set; }//套餐价格
     5 
     6         private string name;//套餐名称
     7         public string Name
     8         {
     9             get { return name; }
    10             set { name = value; }
    11         }
    12         //HealthCheckItem的集合,采用泛型集合List<T>作为储存HealthCheckItem的数据结构
    13         public List<HealItem> ItemList = new List<HealItem>();
    14         public static Dictionary<string, List<HealItem>> SetDic = new Dictionary<string, List<HealItem>>();
    15          /// <summary>
    16          /// 默认数据
    17          /// </summary>s
    18             public HealSet()
    19         {
    20             this.ItemList = new List<HealItem>();
    21             ItemList.Add(HealItem.ItemDic["身高"]);
    22             ItemList.Add(HealItem.ItemDic["体重"]);
    23             ItemList.Add(HealItem.ItemDic["视力"]);
    24             SetDic.Add("入学体检", this.ItemList);
    25         }
    26         public HealSet(string name)
    27         {
    28             SetDic.Add(name, this.ItemList);
    29         }
    30         public static void DicAdd(List<HealItem> list, string str)
    31         {
    32             list.Add(HealItem.ItemDic[str]);
    33         }

      1  #region 初始化数据
      2         /// <summary>
      3         /// 初始化数据
      4         /// </summary>
      5         /// <param name="sender"></param>
      6         /// <param name="e"></param>
      7         private void Form1_Load(object sender, EventArgs e)
      8         {
      9             dataGridView1.AutoGenerateColumns = false;//清除多余的值
     10             cobXiang.Items.Add("请选择");
     11             cobXiang.SelectedIndex = 0;
     12             RenovateItem();// 更新检查项目列表
     13             HealSet set = new HealSet();
     14             RenovateList();//更新套餐列表
     15             cobLie.SelectedIndex = 0;
     16             cobXiang.Enabled = true;
     17             btnAdd.Enabled = true;
     18             btnDelete.Enabled = true;
     19 
     20         }
     21         #endregion
     22 
     23         #region 更新检查项目列表
     24         /// <summary>
     25         /// 更新检查项目列表
     26         /// </summary>
     27         private void RenovateItem()
     28         {
     29             //遍历项目列表
     30             foreach (KeyValuePair<string, HealItem> item in HealItem.ItemDic)
     31             {
     32                 cobXiang.Items.Add(item.Key);
     33             }
     34         }
     35         #endregion
     36 
     37         #region  更新套餐列表
     38         /// <summary>
     39         /// 更新套餐列表
     40        /// </summary>
     41         private void RenovateList()
     42         {
     43             cobLie.Items.Clear();
     44             cobLie.Items.Add("请选择");
     45             foreach (KeyValuePair<string, List<HealItem>> item in HealSet.SetDic)
     46             {
     47                 cobLie.Items.Add(item.Key);
     48             }
     49             if (cobLie.Items.Count > 2)
     50             {
     51                 cobLie.SelectedIndex = cobLie.Items.Count - 1;
     52             }
     53         }
     54         #endregion
     55 
     56         #region 套餐列表下拉框
     57         /// <summary>
     58         /// 套餐列表下拉框
     59         /// </summary>
     60         /// <param name="sender"></param>
     61         /// <param name="e"></param>
     62         private void cobLie_SelectedIndexChanged(object sender, EventArgs e)
     63         {
     64              if (cobLie.SelectedIndex > 0)
     65             {
     66                 lblName2.Text = cobLie.Text;//选择套餐列表时给套餐名赋值
     67                 cobXiang.Enabled = true;
     68                 RenovateDGV();//刷新列表
     69             }
     70              else
     71              {
     72                  cobXiang.Enabled = true;
     73              }
     74 
     75             
     76 
     77         }
     78         #endregion
     79 
     80         #region 刷新RenovateDGV列表
     81         /// <summary>
     82         /// 刷新RenovateDGV列表
     83         /// </summary>
     84         private void RenovateDGV()
     85         {
     86             List<HealItem> list = HealSet.SetDic[cobLie.Text];
     87             dataGridView1.DataSource = new BindingList<HealItem>(HealSet.SetDic[cobLie.Text]);
     88             lblPrice1.Text = Price(cobLie.Text).ToString();//价格
     89         }
     90         #endregion
     91 
     92         #region 项目总金额
     93         /// <summary>
     94         /// 项目总金额
     95         /// </summary>
     96         /// <param name="key"></param>
     97         /// <returns></returns>
     98         private int Price(string key)
     99         {
    100             int sum = 0;
    101             foreach (HealItem item in HealSet.SetDic[key])
    102             {
    103                 sum += item.Price;
    104             }
    105             return sum;
    106         }
    107         #endregion
    108 
    109         #region 添加检查项目
    110         /// <summary>
    111         /// 添加检查项目
    112         /// </summary>
    113         /// <param name="sender"></param>
    114         /// <param name="e"></param>
    115         private void btnAdd1_Click(object sender, EventArgs e)
    116         {
    117             if (HealSet.SetDic[cobLie.Text].Contains(HealItem.ItemDic[cobXiang.Text]))
    118             {
    119                 MessageBox.Show(cobLie.Text + "套餐中已存在该检查项目!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
    120             }
    121             else
    122             {
    123                 HealSet.DicAdd(HealSet.SetDic[cobLie.Text], cobXiang.Text);
    124                 RenovateDGV();//刷新列表
    125             }
    126           
    127         }
    128         #endregion
    129 
    130         #region  检查项目列表
    131         /// <summary>
    132         /// 检查项目列表
    133         /// </summary>
    134         /// <param name="sender"></param>
    135         /// <param name="e"></param>
    136         private void cobXiang_SelectedIndexChanged(object sender, EventArgs e)
    137         {
    138             if (cobXiang.SelectedIndex > 0)
    139             {
    140                 btnAdd1.Enabled = true;
    141             }
    142             else
    143             {
    144                 btnAdd1.Enabled = false;
    145                 btnDelete.Enabled = false;
    146             }
    147 
    148 
    149         }
    150         #endregion
    151 
    152         #region 删除
    153         /// <summary>
    154         /// 删除
    155         /// </summary>
    156         /// <param name="sender"></param>
    157         /// <param name="e"></param>
    158         private void btnDelete_Click(object sender, EventArgs e)
    159         {
    160             DialogResult result = MessageBox.Show("您确定要删除吗?", "警告!", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
    161             if (result == DialogResult.OK)
    162             {
    163                 if (dataGridView1.SelectedRows[0] != null && dataGridView1.SelectedRows[0].Cells[0] != null && dataGridView1.SelectedRows[0].Cells[0].Value != null)
    164                 {
    165                     //删除 套餐中所选的与内置检查项目相匹配的项
    166                     HealSet.SetDic[cobLie.Text].Remove(HealItem.ItemDic[dataGridView1.SelectedRows[0].Cells[0].Value.ToString()]);
    167                     RenovateDGV();//刷新列表
    168                 }
    169             }
    170 
    171         }
    172         #endregion
    173 
    174         #region 新建套餐
    175         /// <summary>
    176         /// 新建套餐
    177         /// </summary>
    178         /// <param name="sender"></param>
    179         /// <param name="e"></param>
    180         private void btnAdd_Click(object sender, EventArgs e)
    181         {
    182             if (txtName.Text != "")
    183             {
    184                 foreach (string item in HealSet.SetDic.Keys)
    185                 {
    186                     if (txtName.Text.Equals(item))
    187                     {
    188                         MessageBox.Show("已经存在" + txtName.Text + "套餐!");
    189                         return;
    190                     }
    191                 }
    192                 HealSet dic = new HealSet(txtName.Text);
    193                 RenovateList();//更新套餐列表
    194             }
    195         
    196 
    197         }
    198         #endregion
  • 相关阅读:
    初认识AngularJS
    (imcomplete) UVa 10127 Ones
    UVa 10061 How many zero's and how many digits?
    UVa 11728 Alternate Task
    UVa 11490 Just Another Problem
    UVa 10673 Play with Floor and Ceil
    JSON对象和字符串的收发(JS客户端用typeof()进行判断非常重要)
    HTML.ActionLink 和 Url.Action 的区别
    EASYUI TREE得到当前节点数据的GETDATA方法
    jqueery easyui tree把已选中的节点数据拼成json或者数组(非常重要)
  • 原文地址:https://www.cnblogs.com/aaaaliling/p/8903587.html
Copyright © 2011-2022 走看看