示例#1
0
文件: ExportData.cs 项目: meimeic/XYS
 public void ExportElement(IExportElement element, DataSet ds)
 {
     Type type = element.GetType();
     DataTable dt = ds.Tables[type.Name];
     if (dt == null)
     {
         throw new Exception("数据集中找不到对应表:" + type.Name);
     }
     DataRow dr = dt.NewRow();
     PropertyInfo[] props = type.GetProperties();
     if (props == null || props.Length == 0)
     {
         return;
     }
     foreach (PropertyInfo pro in props)
     {
         if (IsExport(pro))
         {
             FillDataColumn(pro, dr, element);
         }
     }
     dt.Rows.Add(dr);
 }
示例#2
0
文件: LabService.cs 项目: meimeic/XYS
 private void SetProperty(string propName, object value, IExportElement element)
 {
     try
     {
         PropertyInfo pro = element.GetType().GetProperty(propName);
         if (pro != null)
         {
             pro.SetValue(element, value, null);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#3
0
文件: LabService.cs 项目: meimeic/XYS
 private void FillCustom(CustomElement custom, IExportElement data)
 {
     PropertyInfo[] props = data.GetType().GetProperties();
     foreach (PropertyInfo prop in props)
     {
         PropertyInfo prop1 = custom.GetType().GetProperty(prop.Name);
         if (prop1 != null)
         {
             prop.SetValue(data, prop1.GetValue(custom), null);
         }
     }
 }