public short GetList(string szPatientID, string szVisitNo, ref List <DiagComparing> lstDiagnosisDict) { if (base.HerenHisAccess == null) { return(SystemData.ReturnValue.PARAM_ERROR); } StringBuilder sbField = new StringBuilder(); sbField.AppendFormat("*"); string szCondition = string.Format("1=1"); szCondition = string.Format("{0} AND {1} = '{2}' AND {3}='{4}'" , szCondition , SystemData.DiagComparingTable.PATIENT_ID , szPatientID , SystemData.DiagComparingTable.VISIT_NO , szVisitNo); string szSQL = string.Format(SystemData.SQL.SELECT_WHERE , sbField.ToString(), TableName, szCondition); IDataReader dataReader = null; try { dataReader = base.HerenHisAccess.ExecuteReader(szSQL, CommandType.Text); if (dataReader == null || dataReader.IsClosed || !dataReader.Read()) { return(SystemData.ReturnValue.RES_NO_FOUND); } if (lstDiagnosisDict == null) { lstDiagnosisDict = new List <DiagComparing>(); } lstDiagnosisDict.Clear(); do { DiagComparing model = new DiagComparing(); for (int i = 0; i < dataReader.FieldCount; i++) { if (dataReader.IsDBNull(i)) { continue; } PropertyInfo property = Reflect.GetPropertyInfo(typeof(DiagComparing), dataReader.GetName(i)); bool result = Reflect.SetPropertyValue(model, property, dataReader.GetValue(i)); } lstDiagnosisDict.Add(model); } while (dataReader.Read()); return(SystemData.ReturnValue.OK); } catch (Exception ex) { LogManager.Instance.WriteLog("", new string[] { "szSQL" }, new object[] { szSQL }, ex); return(SystemData.ReturnValue.EXCEPTION); } finally { base.HerenHisAccess.CloseConnnection(false); } }
public short GetBAJK13s(decimal brxh, ref List <BAJK13> lstBAJK13s) { if (base.BAJKDataAccess == null) { return(SystemData.ReturnValue.PARAM_ERROR); } StringBuilder sbField = new StringBuilder(); sbField.AppendFormat("*"); string szCondition = string.Format("1=1"); szCondition = string.Format("{0} AND {1} = {2} " , szCondition , SystemData.BAJK13Table.KEY1301 , brxh); string szSQL = string.Format(SystemData.SQL.SELECT_WHERE , sbField.ToString(), TableName, szCondition); IDataReader dataReader = null; try { dataReader = base.BAJKDataAccess.ExecuteReader(szSQL, CommandType.Text); if (dataReader == null || dataReader.IsClosed || !dataReader.Read()) { return(SystemData.ReturnValue.RES_NO_FOUND); } if (lstBAJK13s == null) { lstBAJK13s = new List <BAJK13>(); } do { BAJK13 BAJK13 = new BAJK13(); for (int i = 0; i < dataReader.FieldCount; i++) { if (dataReader.IsDBNull(i)) { continue; } PropertyInfo property = Reflect.GetPropertyInfo(typeof(BAJK13), dataReader.GetName(i)); bool result = Reflect.SetPropertyValue(BAJK13, property, dataReader.GetValue(i)); } lstBAJK13s.Add(BAJK13); } while (dataReader.Read()); return(SystemData.ReturnValue.OK); } catch (Exception ex) { LogManager.Instance.WriteLog("", new string[] { "szSQL" }, new object[] { szSQL }, ex); return(SystemData.ReturnValue.EXCEPTION); } finally { base.BAJKDataAccess.CloseConnnection(false); } }
public short GetBAJK08s(string patientID, string visitID, ref BAJK08 bAJK08) { if (base.BAJKDataAccess == null) { return(SystemData.ReturnValue.PARAM_ERROR); } StringBuilder sbField = new StringBuilder(); sbField.AppendFormat("*"); string szCondition = string.Format("1=1"); szCondition = string.Format("{0} AND {1} = '{2}' AND {3}={4} " , szCondition , SystemData.BAJK08Table.COL0801 , patientID , SystemData.BAJK08Table.COL0804 , visitID); string szSQL = string.Format(SystemData.SQL.SELECT_WHERE , sbField.ToString(), TableName, szCondition); IDataReader dataReader = null; try { dataReader = base.BAJKDataAccess.ExecuteReader(szSQL, CommandType.Text); if (dataReader == null || dataReader.IsClosed || !dataReader.Read()) { return(SystemData.ReturnValue.RES_NO_FOUND); } if (bAJK08 == null) { bAJK08 = new BAJK08(); } for (int i = 0; i < dataReader.FieldCount; i++) { if (dataReader.IsDBNull(i)) { continue; } PropertyInfo property = Reflect.GetPropertyInfo(typeof(BAJK08), dataReader.GetName(i)); bool result = Reflect.SetPropertyValue(bAJK08, property, dataReader.GetValue(i)); } return(SystemData.ReturnValue.OK); } catch (Exception ex) { LogManager.Instance.WriteLog("", new string[] { "szSQL" }, new object[] { szSQL }, ex); return(SystemData.ReturnValue.EXCEPTION); } finally { base.BAJKDataAccess.CloseConnnection(false); } }
public short GetModel(string id, ref RecBrowseRequest model) { if (base.MedQCAccess == null) { return(SystemData.ReturnValue.PARAM_ERROR); } StringBuilder sbField = new StringBuilder(); sbField.AppendFormat("*"); string szCondition = string.Format("1=1"); szCondition = string.Format("{0} AND {1} = '{2}' " , szCondition , KeyName , id); string szSQL = string.Format(SystemData.SQL.SELECT_WHERE , sbField.ToString(), TableName, szCondition); IDataReader dataReader = null; try { dataReader = base.MedQCAccess.ExecuteReader(szSQL, CommandType.Text); if (dataReader == null || dataReader.IsClosed || !dataReader.Read()) { return(SystemData.ReturnValue.RES_NO_FOUND); } model = new RecBrowseRequest(); for (int i = 0; i < dataReader.FieldCount; i++) { if (dataReader.IsDBNull(i)) { continue; } PropertyInfo property = Reflect.GetPropertyInfo(typeof(RecBrowseRequest), dataReader.GetName(i)); bool result = Reflect.SetPropertyValue(model, property, dataReader.GetValue(i)); } return(SystemData.ReturnValue.OK); } catch (Exception ex) { LogManager.Instance.WriteLog("", new string[] { "szSQL" }, new object[] { szSQL }, ex); return(SystemData.ReturnValue.EXCEPTION); } finally { base.MedQCAccess.CloseConnnection(false); } }
/// <summary> /// 拷贝同类型的两个对象的属性 /// </summary> /// <param name="source">源对象</param> /// <param name="target">目标对象</param> /// <returns>是否成功</returns> public static bool CopyProperties(object source, object target) { if (source == null || target == null || source.GetType() != target.GetType()) { return(false); } PropertyInfo[] elementProperties = source.GetType().GetProperties(); foreach (PropertyInfo property in elementProperties) { MethodInfo method = property.GetSetMethod(); if (method == null || !method.IsPublic) { continue; } if (!property.CanRead || !property.CanWrite) { continue; } Type propertyType = property.PropertyType; object propertyValue = GetPropertyValue(source, property); ICloneable cloneValue = propertyValue as ICloneable; if (cloneValue != null) { SetPropertyValue(target, property, cloneValue.Clone()); continue; } //支持IList或IDictionary接口来迭代集合 IDictionary dictionary = propertyValue as IDictionary; if (dictionary != null) { IDictionary instance = null; if (!property.CanWrite) { instance = GetPropertyValue(target, property) as IDictionary; } else { instance = CreateInstance(propertyType, null) as IDictionary; } if (instance == null) { continue; } foreach (DictionaryEntry entry in dictionary) { ICloneable clone = entry.Key as ICloneable; object key = (clone == null) ? entry.Key : clone.Clone(); if (key == null) { continue; } object value = null; if (entry.Value != null) { clone = entry.Value as ICloneable; value = (clone == null) ? entry.Value : clone.Clone(); } instance.Add(key, value); } Reflect.SetPropertyValue(target, property, instance); continue; } //支持IList或IDictionary接口来迭代集合 IList list = propertyValue as IList; if (list != null) { IList instance = null; if (!property.CanWrite) { instance = GetPropertyValue(target, property) as IList; } else { instance = CreateInstance(propertyType, null) as IList; } if (instance == null) { continue; } foreach (object item in list) { ICloneable clone = item as ICloneable; if (clone == null) { instance.Add(item); } else { instance.Add(clone.Clone()); } } Reflect.SetPropertyValue(target, property, instance); continue; } Reflect.SetPropertyValue(target, property, propertyValue); } return(true); }