体检套餐主代码

Posted 南城。

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了体检套餐主代码相关的知识,希望对你有一定的参考价值。

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 HealthCheckItem
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        //全部体检项目
        List<HealthCheckItems> alllist = new List<HealthCheckItems>();

        //套餐
        List<HealthCheckItemSet> taoCanList = new List<HealthCheckItemSet>();

        private void label2_Click(object sender, EventArgs e)
        {

        }
        /// <summary>
        /// 套餐名称
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e)
        {
            dgvname.AutoGenerateColumns = false;

            HealthCheckItems item = new HealthCheckItems();
            item.Name = "身高";
            item.Description = "用于检查身高";
            item.Price = "12";
            HealthCheckItems item2 = new HealthCheckItems();
            item2.Name = "肝功能";
            item2.Description = "由于检查肝功能";
            item2.Price = "16";
            HealthCheckItems item3 = new HealthCheckItems();
            item3.Name = "听力";
            item3.Description = "由于检查听力";
            item3.Price = "15";
            HealthCheckItems item4 = new HealthCheckItems();
            item4.Name = "视力";
            item4.Description = "由于检查视力";
            item4.Price = "15";
            HealthCheckItems item5 = new HealthCheckItems();
            item5.Name = "B超";
            item5.Description = "由于检查B超";
            item5.Price = "15";
            alllist.Add(item);
            alllist.Add(item2);
            alllist.Add(item3);
            alllist.Add(item4);
            alllist.Add(item5);
            for (int i = 0; i < alllist.Count; i++)
            {
                cmbname.Items.Add(alllist[i].Name);
            }
            ff();
            d();
            Bang();
        }
        /// <summary>
        /// 套餐列表
        /// </summary>
        public void ff() 
        {
            
            HealthCheckItemSet item = new HealthCheckItemSet();
            item.Name = "请选择";
            HealthCheckItemSet item2 = new HealthCheckItemSet();
            item2.Name = "入学体检";
            taoCanList.Add(item);
            taoCanList.Add(item2);
            cmbbiao.DataSource = new List<HealthCheckItemSet>(taoCanList);
            cmbbiao.DisplayMember = "Name";
        }
        public void d()
        {
            //List<HealthCheckItems> list = new List<HealthCheckItems>();
            //HealthCheckItems item = new HealthCheckItems();
            //item.Name = "身高";
            //item.Description = "用于检查身高";
            //item.Price = "12";
            //HealthCheckItems item2 = new HealthCheckItems();
            //item2.Name = "肝功能";
            //item2.Description = "由于检查肝功能";
            //item2.Price = "16";
            //HealthCheckItems item3 = new HealthCheckItems();
            //item3.Name = "听力";
            //item3.Description = "由于检查听力";
            //item3.Price = "15";
            //list.Add(item);
            //list.Add(item2);
            //list.Add(item3);
            //dgvname.DataSource = new List<HealthCheckItems>(list);
        }
       public  List<HealthCheckItems> list = new List<HealthCheckItems>();

        /// <summary>
        /// 绑定入学体检套餐项目
        /// </summary>
       public void Bang()
       {
           foreach (var item in alllist)
           {
               if (item.Name.Equals("肝功能"))
               {
                   list.Add(item);
               }
               if (item.Name.Equals("身高"))
               {
                   list.Add(item);
               }
               if (item.Name.Equals("视力"))
               {
                   list.Add(item);
               }
           }
       }
       private void cmbbiao_SelectedValueChanged(object sender, EventArgs e)
       {
           foreach (var item in taoCanList)
           {
               if (cmbbiao.Text == item.Name)
               {
                   show();
               }
               else
               {
                   if (cmbbiao.Text.Equals("请选择"))
                   {
                       dgvname.DataSource = null;
                       lblj.Text = "";
                       lblname.Text = "";
                   }
               }
           }


       }
        public void show(){
              int a = 0;
            dgvname.DataSource = new List<HealthCheckItems>(list);
                //加载事件
                for (int i = 0; i < list.Count; i++)
                {
                    a +=int.Parse( list[i].Price);
                }
                lblj.Text =a.ToString();
            }
    
    
        //套餐名
        private void cmbbiao_SelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (var item in taoCanList)
            {
                if (cmbbiao.Text == cmbbiao.Text)
                {
                    lblname.Text = cmbbiao.Text;
                }
            }
            
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            if(dgvname.SelectedRows.Count!=1)
            {
                return;
            }
         
            string a = dgvname.SelectedRows[0].Cells[0].Value.ToString();
       
            for (int i = 0; i < list.Count; i++)
            {
                if(a.Equals(list[i].Name)){
                   
                    list.RemoveAt(i);
                    show();
                }
                
            }
        }

        private void groupBox2_Enter(object sender, EventArgs e)
        {

        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            //循环判断是哪个项目
            foreach (var item in alllist)
            {
                if (item.Name.Equals(cmbname.Text)) {
                    //判断该套餐是否有重复项目
                    foreach (var li in list)
                    {
                        if (li.Name.Equals(cmbname.Text))
                        {
                            MessageBox.Show("重复了");
                            return;
                        }
                    }
                  list.Add(item);
                    show();
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            HealthCheckItemSet hcis = new HealthCheckItemSet();

            hcis.Name = txtname.Text;
            taoCanList.Add(hcis);
            //重新绑定组合框数据源
            cmbbiao.DataSource = new List<HealthCheckItemSet>(taoCanList);
            cmbbiao.DisplayMember = "Name";
        }

      
    }
}

 

以上是关于体检套餐主代码的主要内容,如果未能解决你的问题,请参考以下文章

体检套餐管理系统

体检套餐的笔记

C#体检套餐项目

体检套餐管理系统

第五章 体检套餐管理系统

体检套餐管理系统