public FrmDataExport(string bednum)
        {
            InitializeComponent();
            int    bed    = Convert.ToInt16(bednum);
            string bedstr = "";

            if (bed > 255)
            {
                bedstr = "#" + (bed - 256).ToString();
            }
            else
            {
                bedstr = bed.ToString();
            }
            this.txt_bednum.Text = bedstr;
            PatientInfo  patientInfo  = objPatientService.GetPatientInfoBybednum(Convert.ToInt16(bednum));
            HospitalInfo hospitalInfo = new HospitalInfoService().GetHospitalInfo();

            if (hospitalInfo == null)
            {
                hospitalInfo              = new HospitalInfo();
                hospitalInfo.Department   = "科室名称";
                hospitalInfo.HospitalName = "医院名称";
            }
            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);
        }
Ejemplo n.º 2
0
        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();
        }