private void btn_exporthistory_Click(object sender, EventArgs e)
        {
            string         strSaveFileLocation = "";
            SaveFileDialog saveFileDialog1     = new SaveFileDialog();

            // saveFileDialog1.InitialDirectory = Path.GetDirectoryName(strPartPath);
            //设置文件类型
            saveFileDialog1.Filter = "Excel 97-2003工作簿(*.xls)|*.xls";
            //saveFileDialog1.FilterIndex = 1;//设置文件类型显示
            saveFileDialog1.FileName         = "所有历史病人基本信息"; //设置默认文件名
            saveFileDialog1.RestoreDirectory = true;         //保存对话框是否记忆上次打开的目录
            saveFileDialog1.CheckPathExists  = true;         //检查目录
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                strSaveFileLocation = saveFileDialog1.FileName;//文件路径
            }
            else
            {
                return;
            }
            DataTable ds = objPatientService.GetPabienthisInfo();

            if (ds.Rows.Count == 0)
            {
                MessageBox.Show("没有任何数据!", "系统提示!");
                return;
            }
            NPOI.HisPatientBasicInfoToExcel(ds, strSaveFileLocation);
        }
        /// <summary>
        /// 详细信息导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_patientbodyinfo_Click(object sender, EventArgs e)
        {
            int            count = 4;
            string         strSaveFileLocation = "";
            SaveFileDialog saveFileDialog1     = new SaveFileDialog();

            // saveFileDialog1.InitialDirectory = Path.GetDirectoryName(strPartPath);
            //设置文件类型
            saveFileDialog1.Filter = "Excel 97-2003工作簿(*.xls)|*.xls";
            //saveFileDialog1.FilterIndex = 1;//设置文件类型显示
            saveFileDialog1.FileName         = this.txt_bednum.Text.Trim() + "号病人详细信息"; //设置默认文件名
            saveFileDialog1.RestoreDirectory = true;                                    //保存对话框是否记忆上次打开的目录
            saveFileDialog1.CheckPathExists  = true;                                    //检查目录
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                strSaveFileLocation = saveFileDialog1.FileName;//文件路径
            }
            else
            {
                return;
            }
            DataTable dt = objPatientBodyInfoService.GetPatientIndtfoBybednum(Convert.ToInt32(this.txt_bednum.Text.Trim()));

            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("没有任何记录!", "系统提示!");
                return;
            }
            dic.Add("stime", dt.Rows[0][0].ToString());
            dic.Add("etime", dt.Rows[dt.Rows.Count - 1][0].ToString());
            if ((checkBox_30.Checked == true) && (checkBox_60.Checked == true))
            {
                MessageBox.Show("不能同时选中两种导出设置!", "系统提示");
            }
            if (checkBox_30.Checked == true)
            {
                count = 2;
            }
            if (checkBox_60.Checked == true)
            {
                count = 1;
            }

            //  Hospital.NPOI.ExportDataTableToExcel(dt, strSaveFileLocation,count);
            try
            {
                NPOI.ExcelPrint("导出数据格式.xls", dt, dic, strSaveFileLocation, count);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dic.Clear();
        }
        /// <summary>
        /// 导出病人基本信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_patient_Click(object sender, EventArgs e)
        {
            string str    = this.txt_bednum.Text.Trim();
            string bednum = "";

            if (str[0] == 35)
            {
                string subString2 = str.Substring(1, str.Length - 1);
                bednum = (Convert.ToInt16(subString2) + 256).ToString();
            }
            else
            {
                bednum = str;
            }
            string         strSaveFileLocation = "";
            SaveFileDialog saveFileDialog1     = new SaveFileDialog();

            // saveFileDialog1.InitialDirectory = Path.GetDirectoryName(strPartPath);
            //设置文件类型
            saveFileDialog1.Filter = "Excel 97-2003工作簿(*.xls)|*.xls";
            //saveFileDialog1.FilterIndex = 1;//设置文件类型显示
            saveFileDialog1.FileName         = this.txt_bednum.Text.Trim() + "号病人基本信息"; //设置默认文件名
            saveFileDialog1.RestoreDirectory = true;                                    //保存对话框是否记忆上次打开的目录
            saveFileDialog1.CheckPathExists  = true;                                    //检查目录
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                strSaveFileLocation = saveFileDialog1.FileName;//文件路径
            }
            else
            {
                return;
            }
            string    patientbednum = this.txt_bednum.Text.Trim();
            DataTable dt            = objPatientService.GetOnePabientInfo(Convert.ToInt32(bednum));

            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("没有任何记录!", "系统提示!");
                return;
            }

            NPOI.PatientBasicInfoToExcel(dt, patientbednum, strSaveFileLocation);
        }
        private void btnexpertsavedata_Click(object sender, EventArgs e)
        {
            if (usbisexited())
            {
                return;
            }
            if (Commen.machineType)
            {
                MessageBox.Show("当前设备为接收机!无法导出记录!");
                return;
            }
            string         strSaveFileLocation = "";
            SaveFileDialog saveFileDialog1     = new SaveFileDialog();

            // saveFileDialog1.InitialDirectory = Path.GetDirectoryName(strPartPath);
            //设置文件类型
            saveFileDialog1.Filter = "Excel 97-2003工作簿(*.xls)|*.xls";
            //saveFileDialog1.FilterIndex = 1;//设置文件类型显示
            saveFileDialog1.FileName         = "监护仪记录信息"; //设置默认文件名
            saveFileDialog1.RestoreDirectory = true;      //保存对话框是否记忆上次打开的目录
            saveFileDialog1.CheckPathExists  = true;      //检查目录
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                strSaveFileLocation = saveFileDialog1.FileName;//文件路径
            }
            else
            {
                return;
            }
            DataTable ds = objPatirntSaveDataService.GetPatientHisInfo();

            if (ds.Rows.Count == 0)
            {
                MessageBox.Show("没有任何数据!", "系统提示!");
                return;
            }

            NPOI.MachinePatientInfoToExcel(ds, strSaveFileLocation);
        }
        private void btnexperthistoryinfo_Click(object sender, EventArgs e)
        {
            int count = 4;

            if (this.dgv_patientinfo.Rows.Count == 0)
            {
                MessageBox.Show("未选择导出病人!", "系统提示");
                return;
            }
            string patientbednum  = this.dgv_patientinfo.CurrentRow.Cells["PatientBednum"].Value.ToString();
            string patientbedname = this.dgv_patientinfo.CurrentRow.Cells["PatientName"].Value.ToString();

            PatientInfo  patientInfo  = objPatientService.GetPatientInfoBybednum(Convert.ToInt16(patientbednum));
            HospitalInfo hospitalInfo = new HospitalInfoService().GetHospitalInfo();

            if (hospitalInfo == null)
            {
                hospitalInfo = new HospitalInfo()
                {
                    HospitalName = "医院名称",
                    Department   = "科室名称",
                };
            }
            dic.Add("name", patientInfo.PatientName);
            dic.Add("age", patientInfo.PatientAge);
            dic.Add("bednum", patientInfo.PatientBednum);
            dic.Add("patientnum", patientInfo.PatientNum);
            dic.Add("hospital", hospitalInfo.HospitalName);
            dic.Add("depart", hospitalInfo.Department);
            dic.Add("gender", patientInfo.PatientGender);

            string         strSaveFileLocation = "";
            SaveFileDialog saveFileDialog1     = new SaveFileDialog();

            // saveFileDialog1.InitialDirectory = Path.GetDirectoryName(strPartPath);
            //设置文件类型
            saveFileDialog1.Filter = "Excel 97-2003工作簿(*.xls)|*.xls";
            //saveFileDialog1.FilterIndex = 1;//设置文件类型显示
            saveFileDialog1.FileName         = patientbednum + "床病人" + "详细信息"; //设置默认文件名
            saveFileDialog1.RestoreDirectory = true;                           //保存对话框是否记忆上次打开的目录
            saveFileDialog1.CheckPathExists  = true;                           //检查目录
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                strSaveFileLocation = saveFileDialog1.FileName;//文件路径
            }
            else
            {
                return;
            }
            DataTable ds = GetDgvToTable(this.dgv_bodyinfo);

            //string a = this.dgv_patientinfo.CurrentRow.Cells["PatientBednum"].Value.ToString();
            //DataTable ds = objPatientBodyInfoService.GetPatientInfoBybednum(Convert.ToInt16(a), starttime, endtime);
            if (ds.Rows.Count == 0)
            {
                MessageBox.Show("没有任何数据!", "系统提示!");
                return;
            }
            dic.Add("stime", ds.Rows[0][0].ToString());
            dic.Add("etime", ds.Rows[ds.Rows.Count - 1][0].ToString());
            if ((checkBox_30.Checked = true) && (checkBox_60.Checked == true))
            {
                MessageBox.Show("不能同时选中两种导出设置!", "系统提示");
            }
            if (checkBox_30.Checked == true)
            {
                count = 2;
            }
            if (checkBox_60.Checked == true)
            {
                count = 1;
            }
            // NPOI.NowPatientInfoToExcel(ds, strSaveFileLocation,count);
            try
            {
                NPOI.ExcelPrint("导出数据格式.xls", ds, dic, strSaveFileLocation, count);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dic.Clear();
        }