/// <summary> /// 生成报告VO /// </summary> /// <param name="objRow"></param> /// <param name="objReportVO"></param> private void m_mthConstructReportVO(DataRow objRow, ref clsAdvia2120ReportInf_VO objReportVO) { objReportVO.strInputDate = objRow["dat_inputdate"].ToString(); objReportVO.strSampleID = objRow["num_samplenum"].ToString(); objReportVO.strPatientID = objRow["chr_patiid"].ToString(); objReportVO.intType = int.Parse(objRow["num_typeid"].ToString()); objReportVO.intDeptCode = int.Parse(objRow["num_departid"].ToString()); objReportVO.strGetDate = objRow["dat_getdate"].ToString(); objReportVO.strTestDate = objRow["dat_testdate"].ToString(); objReportVO.intSendDoctorID = int.Parse(objRow["num_sdoctorid"].ToString()); objReportVO.intSickID = int.Parse(objRow["num_sickid"].ToString()); objReportVO.strPatientName = objRow["chr_name"].ToString(); objReportVO.strSex = objRow["chr_sexname"].ToString(); objReportVO.strState = objRow["chr_state"].ToString(); objReportVO.strReportCode = objRow["chr_code"].ToString(); objReportVO.strPatineType = objRow["patienttype"].ToString(); objReportVO.strDeptName = objRow["dept"].ToString(); objReportVO.strSendDoctorName = objRow["sdoctor"].ToString(); }
/// <summary> /// 查找 /// </summary> public void m_mthQuery() { this.m_objViewer.listView1.Items.Clear(); if (strDataBasePath != "") { string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDataBasePath + ";Persist Security Info=False;Jet OLEDB:DataBase Password='******'"; objConn = new OleDbConnection(strConnection); try { objConn.Open(); } catch (Exception) { MessageBox.Show(this.m_objViewer, "数据库连接失败,请检查数据库路径是否正确!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (m_intShowTypeSetting == 0) { string strSQL = @"select a.dat_inputdate, a.num_samplenum, a.chr_patiid, a.num_typeid, a.num_departid, a.dat_getdate, a.dat_testdate, a.num_sdoctorid, a.num_sickid, a.chr_name, a.chr_sexname, a.chr_state, a.chr_code, b.chr_name as patienttype, c.chr_name as dept, d.chr_name as sdoctor from (((report_inf a left outer join pat_type b on a.num_typeid = b.num_typeid) left outer join pat_depart c on a.num_departid = c.num_departid) left outer join send_doctor d on a.num_sdoctorid = d.num_sdoctorid)"; DataTable dt = new DataTable(); OleDbCommand objCommand = new OleDbCommand(); objCommand.Connection = objConn; #region 生成查询条件 OleDbParameter objParam = null; OleDbParameter objParam2 = null; if (this.m_objViewer.m_dtpCheckDate.Text != "") { strSQL += @" where a.dat_inputdate = :check_date"; objParam = new OleDbParameter("check_date", OleDbType.DBDate); objParam.Value = this.m_objViewer.m_dtpCheckDate.Value; objCommand.CommandText = strSQL; objCommand.Parameters.Add(objParam); } else { MessageBox.Show(this.m_objViewer, "检验日期不能为空", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); objConn.Close(); this.m_objViewer.m_dtpCheckDate.Focus(); return; } if (this.intPatientType != 0) { strSQL += @" and a.num_typeid = :patient_typeid"; objParam = new OleDbParameter("patient_typeid", OleDbType.SmallInt); objParam.Value = intPatientType; objCommand.CommandText = strSQL; objCommand.Parameters.Add(objParam); } if (this.intDetpID != 0) { strSQL += @" and a.num_departid = :dept_id"; objParam = new OleDbParameter("dept_id", OleDbType.SmallInt); objParam.Value = intDetpID; objCommand.CommandText = strSQL; objCommand.Parameters.Add(objParam); } if (this.m_objViewer.txtSampleIDFrom.Text.Trim() != "" && this.m_objViewer.txtSampleIDTo.Text.Trim() != "") { strSQL += @" and a.num_samplenum >= :sample_from and a.num_samplenum <= :sample_to"; objParam = new OleDbParameter("sample_from", OleDbType.UnsignedBigInt); objParam.Value = Int64.Parse(this.m_objViewer.txtSampleIDFrom.Text.Trim()); objParam2 = new OleDbParameter("sample_to", OleDbType.UnsignedBigInt); objParam2.Value = Int64.Parse(this.m_objViewer.txtSampleIDTo.Text.Trim()); objCommand.CommandText = strSQL; objCommand.Parameters.Add(objParam); objCommand.Parameters.Add(objParam2); } else if (this.m_objViewer.txtSampleIDFrom.Text.Trim() != "" || this.m_objViewer.txtSampleIDTo.Text.Trim() != "") { strSQL += @" and a.num_samplenum = :sample_id"; string strSampleId = (this.m_objViewer.txtSampleIDFrom.Text.Trim() == "" ? this.m_objViewer.txtSampleIDTo.Text.Trim() : this.m_objViewer.txtSampleIDFrom.Text.Trim()); objParam = new OleDbParameter("sample_id", OleDbType.UnsignedBigInt); objParam.Value = Int64.Parse(strSampleId); objCommand.CommandText = strSQL; objCommand.Parameters.Add(objParam); } else { } if (this.m_objViewer.rdbUncheck.Checked == true) { strSQL += @" and a.chr_state <> '1'"; objCommand.CommandText = strSQL; } else if (this.m_objViewer.rdbCheckd.Checked == true) { strSQL += @" and a.chr_state = '1'"; objCommand.CommandText = strSQL; } else { } #endregion strSQL += @" order by a.num_samplenum"; OleDbDataAdapter objAdapter = new OleDbDataAdapter(objCommand); objAdapter.Fill(dt); objConn.Close(); clsAdvia2120ReportInf_VO[] objReport_InfArr = null; if (dt.Rows.Count > 0) { objReport_InfArr = new clsAdvia2120ReportInf_VO[dt.Rows.Count]; ListViewItem objlvItem = null; for (int i1 = 0; i1 < dt.Rows.Count; i1++) { objReport_InfArr[i1] = new clsAdvia2120ReportInf_VO(); m_mthConstructReportVO(dt.Rows[i1], ref objReport_InfArr[i1]); objlvItem = new ListViewItem(objReport_InfArr[i1].strSampleID); //样本号 objlvItem.SubItems.Add(objReport_InfArr[i1].strPatientID); //病员号 objlvItem.SubItems.Add(objReport_InfArr[i1].strPatientName); //姓名 objlvItem.SubItems.Add(objReport_InfArr[i1].strSex); //性别 objlvItem.SubItems.Add(objReport_InfArr[i1].strGetDate); //采样日期 objlvItem.SubItems.Add(objReport_InfArr[i1].strSendDoctorName); //送检医生 objlvItem.SubItems.Add(objReport_InfArr[i1].strTestDate); //送检日期 objlvItem.SubItems.Add(objReport_InfArr[i1].strReportCode); //标识号 if (objReport_InfArr[i1].strState == "1") //状态 { objlvItem.SubItems.Add("√"); } else { objlvItem.SubItems.Add(objReport_InfArr[i1].strState); } objlvItem.Tag = objReport_InfArr[i1]; this.m_objViewer.listView1.Items.Add(objlvItem); } } } else if (m_intShowTypeSetting == 1) { string strSQL = @"select a.dat_inputdate, a.num_samplenum, a.chr_state from result_inf a"; DataTable dt = new DataTable(); OleDbCommand objCommand = new OleDbCommand(); objCommand.Connection = objConn; #region 生成查询条件 OleDbParameter objParam = null; OleDbParameter objParam2 = null; if (this.m_objViewer.m_dtpCheckDate.Text != "") { strSQL += @" where a.dat_inputdate = :check_date"; objParam = new OleDbParameter("check_date", OleDbType.DBDate); objParam.Value = this.m_objViewer.m_dtpCheckDate.Value; objCommand.CommandText = strSQL; objCommand.Parameters.Add(objParam); } else { MessageBox.Show(this.m_objViewer, "检验日期不能为空", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); objConn.Close(); this.m_objViewer.m_dtpCheckDate.Focus(); return; } if (this.m_objViewer.txtSampleIDFrom.Text.Trim() != "" && this.m_objViewer.txtSampleIDTo.Text.Trim() != "") { strSQL += @" and a.num_samplenum >= :sample_from and a.num_samplenum <= :sample_to"; objParam = new OleDbParameter("sample_from", OleDbType.UnsignedBigInt); objParam.Value = Int64.Parse(this.m_objViewer.txtSampleIDFrom.Text.Trim()); objParam2 = new OleDbParameter("sample_to", OleDbType.UnsignedBigInt); objParam2.Value = Int64.Parse(this.m_objViewer.txtSampleIDTo.Text.Trim()); objCommand.CommandText = strSQL; objCommand.Parameters.Add(objParam); objCommand.Parameters.Add(objParam2); } else if (this.m_objViewer.txtSampleIDFrom.Text.Trim() != "" || this.m_objViewer.txtSampleIDTo.Text.Trim() != "") { strSQL += @" and a.num_samplenum = :sample_id"; string strSampleId = (this.m_objViewer.txtSampleIDFrom.Text.Trim() == "" ? this.m_objViewer.txtSampleIDTo.Text.Trim() : this.m_objViewer.txtSampleIDFrom.Text.Trim()); objParam = new OleDbParameter("sample_id", OleDbType.UnsignedBigInt); objParam.Value = Int64.Parse(strSampleId); objCommand.CommandText = strSQL; objCommand.Parameters.Add(objParam); } else { } if (this.m_objViewer.rdbUncheck.Checked == true) { strSQL += @" and a.chr_state <> '1'"; objCommand.CommandText = strSQL; } else if (this.m_objViewer.rdbCheckd.Checked == true) { strSQL += @" and a.chr_state = '1'"; objCommand.CommandText = strSQL; } else { } #endregion strSQL += @" group by a.dat_inputdate, a.num_samplenum, a.chr_state order by a.num_samplenum"; objCommand.CommandText = strSQL; OleDbDataAdapter objAdapter = new OleDbDataAdapter(objCommand); objAdapter.Fill(dt); objConn.Close(); clsAdvia2120ReportInf_VO[] objReport_InfArr = null; if (dt.Rows.Count > 0) { objReport_InfArr = new clsAdvia2120ReportInf_VO[dt.Rows.Count]; ListViewItem objlvItem = null; for (int i1 = 0; i1 < dt.Rows.Count; i1++) { objReport_InfArr[i1] = new clsAdvia2120ReportInf_VO(); //<------------------ 2007-11-08 add objReport_InfArr[i1].strSampleID = dt.Rows[i1]["num_samplenum"].ToString(); objReport_InfArr[i1].strPatientID = ""; objReport_InfArr[i1].strGetDate = dt.Rows[i1]["dat_inputdate"].ToString(); objReport_InfArr[i1].strTestDate = ""; objReport_InfArr[i1].strPatientName = ""; objReport_InfArr[i1].strSex = ""; objReport_InfArr[i1].strState = dt.Rows[i1]["chr_state"].ToString(); objReport_InfArr[i1].strReportCode = ""; objReport_InfArr[i1].strSendDoctorName = ""; //------------------> objlvItem = new ListViewItem(objReport_InfArr[i1].strSampleID); //样本号 objlvItem.SubItems.Add(objReport_InfArr[i1].strPatientID); //病员号 objlvItem.SubItems.Add(objReport_InfArr[i1].strPatientName); //姓名 objlvItem.SubItems.Add(objReport_InfArr[i1].strSex); //性别 objlvItem.SubItems.Add(objReport_InfArr[i1].strGetDate); //采样日期 objlvItem.SubItems.Add(objReport_InfArr[i1].strSendDoctorName); //送检医生 objlvItem.SubItems.Add(objReport_InfArr[i1].strTestDate); //送检日期 objlvItem.SubItems.Add(objReport_InfArr[i1].strReportCode); //标识号 if (objReport_InfArr[i1].strState == "1") //状态 { objlvItem.SubItems.Add("√"); } else { objlvItem.SubItems.Add(objReport_InfArr[i1].strState); } objlvItem.Tag = objReport_InfArr[i1]; this.m_objViewer.listView1.Items.Add(objlvItem); } } } } else { MessageBox.Show(this.m_objViewer, "数库路径未设置,请点击“设置”按钮", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } return; }