public bool MoveData(MoveType MovingType) { if (_OrderFld == null) { return(false); } IDataReader rdr; #region Cek MovingType switch (MovingType) { case MoveType.MoveFirst: rdr = Dp.ExecuteReader( SqlMoveFirst()); break; case MoveType.MovePrevious: if (!IsError) { rdr = Dp.ExecuteReader( SqlMovePrevious(), ParamMovePrevNext); } else { rdr = Dp.ExecuteReader( SqlMoveFirst()); } break; case MoveType.MoveNext: if (!IsError) { rdr = Dp.ExecuteReader( SqlMoveNext(), ParamMovePrevNext); } else { rdr = Dp.ExecuteReader( SqlMoveLast()); } break; case MoveType.FindCriteria: rdr = Dp.ExecuteReader( SqlFindCriteria(), CriteriaParams); break; case MoveType.FindFirst: rdr = Dp.ExecuteReader( SqlFindFirst(), ParamFind); break; case MoveType.FindLast: rdr = Dp.ExecuteReader( SqlFindLast(), ParamFind); break; default: // MoveLast rdr = Dp.ExecuteReader( SqlMoveLast()); break; } #endregion try { if (rdr.Read()) { string strKeyWhere = string.Empty; FieldParam[] LoadParam = (FieldParam[]) _ParamCurrentKeyField.Clone(); for (int i = 0; i < _CurrentKeyField.Length; i++) { strKeyWhere = string.Concat(strKeyWhere, " AND ", _CurrentKeyField[i]._FieldName, "=@", _CurrentKeyField[i]._FieldName); LoadParam[i].Value = rdr.GetValue(i + 1); } if (OrderInKey) { int SizeLoadParam = LoadParam.Length; Array.Resize <FieldParam>(ref LoadParam, SizeLoadParam + 1); LoadParam[SizeLoadParam] = new FieldParam( _OrderFld, rdr.GetValue(0)); strKeyWhere = string.Concat( _OrderFld._FieldName, "=@", _OrderFld._FieldName, strKeyWhere); } else { strKeyWhere = strKeyWhere.Substring(5); } _Entity.LoadEntity(strKeyWhere, true, LoadParam); IsError = false; if (_Entity.FormMode != FormMode.FormEdit && _Entity.FormMode != FormMode.FormView) { _Entity.FormMode = FormMode.FormEdit; } } else { switch (MovingType) { case MoveType.MovePrevious: return(MoveFirst()); case MoveType.MoveNext: return(MoveLast()); } IsError = true; _Entity.FormMode = FormMode.FormError; } //if (!IsError && onAfterLoad != null) onAfterLoad(); if (onDataMoving != null) { onDataMoving(MovingType, IsError); } return(!IsError); } finally { if (rdr != null) { rdr.Close(); } } }