예제 #1
0
        /// <summary>
        /// 查询加载数据方法
        /// Modify by xlb 2013-05-30
        /// </summary>
        private void LoadData()
        {
            try
            {
                //add by 2013-6-14   xll
                string valueStr = DrectSoft.Service.DS_SqlService.GetConfigValueByKey("AutoScoreMainpage");
                string sql      = MedicalRecordManage.Object.DaoCommand._SELECT_MEDICAL_RECORD_BORROW_SQL;
                if (valueStr.ToLower().Contains("iem_mainpage_diagnosis_sx"))
                {
                    sql = MedicalRecordManage.Object.DaoCommand._SELECT_MEDICAL_RECORD_BORROW_SQL_ZY;
                }

                List <DbParameter> sqlParams = new List <DbParameter>();
                if (this.txtDoctor.Text.Trim() != null && this.txtDoctor.Text.Trim() != "")
                {
                    sql = sql + " and i.applyname like @doc ";
                    SqlParameter param1 = new SqlParameter("@doc", SqlDbType.VarChar);
                    param1.Value = "%" + this.txtDoctor.Text.Trim() + "%";
                    sqlParams.Add(param1);
                }
                if (this.txtName.Text.Trim() != null && this.txtName.Text.Trim() != "")
                {
                    sql = sql + " and i.name like @name ";
                    SqlParameter param2 = new SqlParameter("@name", SqlDbType.VarChar);
                    param2.Value = "%" + this.txtName.Text.Trim() + "%";
                    sqlParams.Add(param2);
                }
                if (this.txtNumber.Text.Trim() != null && this.txtNumber.Text.Trim() != "")
                {
                    sql = sql + " and i.patid like '%'||@patId||'%' ";
                    SqlParameter param3 = new SqlParameter("@patId", SqlDbType.VarChar);
                    param3.Value = this.txtNumber.Text.Trim();
                    sqlParams.Add(param3);
                }

                if (this.lookUpEditorDepartment.Text != null && this.lookUpEditorDepartment.Text.Trim() != "")
                {
                    if (lookUpEditorDepartment.CodeValue != "0000")
                    {
                        sql = sql + " and i.outhosdept = @dept";
                        SqlParameter param4 = new SqlParameter("@dept", SqlDbType.VarChar);
                        param4.Value = lookUpEditorDepartment.CodeValue;
                        sqlParams.Add(param4);
                    }
                }

                if (this.dateStart.Text.Trim() != null && this.dateStart.Text.Trim() != "")
                {
                    string ds = this.dateStart.DateTime.ToString("yyyy-MM-dd 00:00:00");
                    sql = sql + " and  to_char(i.applydate,'yyyy-mm-dd hh24:mi:ss') >= @ds";
                    SqlParameter param5 = new SqlParameter("@ds", SqlDbType.VarChar);
                    param5.Value = ds;
                    sqlParams.Add(param5);
                }
                if (this.dateEnd.Text.Trim() != null && this.dateEnd.Text.Trim() != "")
                {
                    string de = this.dateEnd.DateTime.ToString("yyyy-MM-dd 23:59:59");
                    sql = sql + " and  to_char(i.applydate,'yyyy-mm-dd hh24:mi:ss') <= @de";
                    SqlParameter param6 = new SqlParameter("@de", SqlDbType.VarChar);
                    param6.Value = de;
                    sqlParams.Add(param6);
                }
                if (this.cbxStatus.Text != "")
                {
                    sql = sql + " and  i.status = @st";
                    SqlParameter param7 = new SqlParameter("@st", SqlDbType.VarChar);
                    param7.Value = ComponentCommand.GetStatusValue(this.cbxStatus.Text);
                    sqlParams.Add(param7);
                }
                DataTable dataTable = DrectSoft.DSSqlHelper.DS_SqlHelper.ExecuteDataTable(sql, sqlParams, CommandType.Text);
                //压缩数据源生成新的数据源
                //压缩DateSet中的记录,将住院诊断信息合并
                ComponentCommand.ImpressDataSet(ref dataTable, "id", "cyzd");
                //
                ComponentCommand.InitializeStatusInfo(ref dataTable);
                string ResultName = string.Empty;//声明最终要在列表显示的姓名的内容
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    ResultName = SqlUtil.GetPatsBabyContent(SqlUtil.App, dataTable.Rows[i]["noofinpat"].ToString());
                    dataTable.Rows[i]["Name"] = ResultName;
                    if (dataTable.Rows[i]["isbaby"].ToString() == "1")
                    {
                        dataTable.Rows[i]["PATID"] = SqlUtil.GetPatsBabyMother(dataTable.Rows[i]["mother"].ToString());
                    }
                }
                this.dbGrid.DataSource = dataTable;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }