public void InsertEmpChange(List <tpsempchg> _list) { try { if (_list.Count <= 0) { return; } int?t = GetMaxsqno("tpsempchg", _list[0].emno); int seqno = 0; if (t.HasValue) { seqno = t.Value; } else { seqno = 0; } string gpid = UtilDatetime.FormatDateTime4(DateTime.Now); List <ColumnInfo> parameters = new List <ColumnInfo>() { new ColumnInfo() { ColumnName = "emno", ColumnValue = _list[0].emno } }; tpsemplym emp = GetSelectedObject <tpsemplym>(parameters); bool isUpdateEmployment = false; string changeType = _list[0].ctcd; using (TransactionScope scope = new TransactionScope()) { for (int i = 0; i < _list.Count; i++) { tpsempchg obj = _list[i]; obj.sqno = seqno + i + 1; obj.lmtm = DateTime.Now; obj.lmur = Function.GetCurrentUser(); obj.gpid = gpid; //get old value PropertyInfo props = emp.GetType().GetProperty(obj.chfi); if (props != null) { object v = props.GetValue(emp, null); obj.olva = v == null ? null : v.ToString(); } //判断是否立即生效 if ((obj.isim == "Y") || (obj.efdt <= DateTime.Now)) { props.SetValue(emp, obj.neva, null); obj.isby = Function.GetCurrentUser(); obj.isdt = DateTime.Now; obj.issu = "Y"; isUpdateEmployment = true; } DoInsert <tpsempchg>(obj); } if (isUpdateEmployment) { DoUpdate <tpsemplym>(emp); //更新雇佣历史 psemplymBll empBll = new psemplymBll(); empBll.CopyEmpToHistory(emp, changeType); } scope.Complete(); } } catch (UtilException ex) { throw ex; } catch (Exception ex) { throw new UtilException(ex.Message, ex); } }