/// <summary> /// Saves the current list, using NHibernate. /// </summary> /// <param name="session">A reference to an object that implements the NHibernate <see cref="ISession"/> interface.</param> public virtual void Save(ISession session) { // Enumerate all items in the deleted list foreach (C businessObject in DeletedList) { businessObject.Delete(session); } // Clear the deleted list (as any items that where in there have now been deleted) DeletedList.Clear(); // Enumerate all non-deleted items and persist them foreach (C businessObject in this) { businessObject.Save(session); } }
internal void Update(InputInvoice parent) { this.RaiseListChangedEvents = false; // update (thus deleting) any deleted child objects foreach (AlbaranFacturaProveedor obj in DeletedList) { if (!GetItem(obj.OidFactura, obj.OidAlbaran)) { obj.DeleteSelf(parent); } } // add/update any current child objects foreach (AlbaranFacturaProveedor obj in this) { bool existe = false; if (obj.IsNew) { //Si el albarán se ha eliminado y se ha vuelto a insertar no hay que volver a guardarlo foreach (AlbaranFacturaProveedor albaran in DeletedList) { if (albaran.OidAlbaran == obj.OidAlbaran) { existe = true; break; } } if (existe) { continue; } obj.Insert(parent); } else { obj.Update(parent); } } // now that they are deleted, remove them from memory too DeletedList.Clear(); this.RaiseListChangedEvents = true; }
protected override void DataPortal_Update() { this.RaiseListChangedEvents = false; // update (thus deleting) any deleted child objects foreach (InputInvoice obj in DeletedList) { obj.DeleteSelf(this); } // now that they are deleted, remove them from memory too DeletedList.Clear(); try { // add/update any current child objects foreach (InputInvoice obj in this) { if (obj.IsNew) { SetNextCode(obj); obj.Insert(this); } else { obj.Update(this); } } Transaction().Commit(); } catch (Exception ex) { if (Transaction() != null) { Transaction().Rollback(); } iQExceptionHandler.TreatException(ex); } finally { BeginTransaction(); this.RaiseListChangedEvents = true; } }
protected virtual void Child_Update(params object[] parameters) { using (LoadListMode) { foreach (var child in DeletedList) { DataPortal.UpdateChild(child, parameters); } DeletedList.Clear(); foreach (var child in this) { if (child.IsDirty) { DataPortal.UpdateChild(child, parameters); } } } }
private void UndoChanges() { C child; // we are coming up one edit level _editLevel -= 1; if (_editLevel < 0) { _editLevel = 0; } // Cancel edit on all current items for (int index = Count - 1; index >= 0; index--) { child = this[index]; child.UndoChanges(); // if item is below its point of addition, remove if (child.EditLevelAdded > _editLevel) { RemoveAt(index); } } // cancel edit on all deleted items for (int index = DeletedList.Count - 1; index >= 0; index--) { child = DeletedList[index]; child.UndoChanges(); if (child.EditLevelAdded > _editLevel) { // if item is below its point of addition, remove DeletedList.RemoveAt(index); } else { // if item is no longer deleted move back to main list if (!child.IsDeleted) { UnDeleteChild(child); } } } }
protected void DataPortal_Update() { using (var manager = TransactionManager <SqlConnection, SqlTransaction> .GetManager(TestDBConnection, true)) { foreach (var oneItem in DeletedList) { Csla.DataPortal.UpdateChild(oneItem, this); } foreach (var oneItem in this) { Csla.DataPortal.UpdateChild(oneItem, this); } DeletedList.Clear(); manager.Commit(); } }
protected override void DataPortal_Update() { this.RaiseListChangedEvents = false; using (SqlConnection cn = new SqlConnection(Database.ConnectionString)) { cn.Open(); foreach (MemberFellowship item in DeletedList) { item.DeleteSelf(cn); } DeletedList.Clear(); foreach (MemberFellowship item in this) { item.Update(cn); } } this.RaiseListChangedEvents = true; }
protected virtual void Child_Update(params object[] parameters) { using (LoadListMode) { var dp = ApplicationContext.CreateInstance <DataPortal <C> >(); foreach (var child in DeletedList) { dp.UpdateChild(child, parameters); } DeletedList.Clear(); foreach (var child in this) { if (child.IsDirty) { dp.UpdateChild(child, parameters); } } } }
internal void Update(OutputDelivery parent) { try { this.RaiseListChangedEvents = false; SessionCode = parent.SessionCode; LoadLibroGanadero(); // update (thus deleting) any deleted child objects foreach (OutputDeliveryLine obj in DeletedList) { obj.DeleteSelf(parent); } // now that they are deleted, remove them from memory too DeletedList.Clear(); // add/update any current child objects foreach (OutputDeliveryLine obj in this) { if (obj.IsNew) { obj.Insert(parent); } else { obj.Update(parent); } } } catch (Exception ex) { iQExceptionHandler.TreatException(ex); } finally { this.RaiseListChangedEvents = true; } }
internal new void Save() { foreach (var item in DeletedList) { item.Child_DeleteSelf(); } DeletedList.Clear(); foreach (var item in this) { if (item.IsNew) { item.Child_Insert(this.Parent as PerfilUsuario); } else { item.Child_Update(); } } }
internal void Update(SqlCommand cm, DonateBook parent) { RaiseListChangedEvents = false; foreach (Donate item in DeletedList) { item.DeleteSelf(cm, parent); } DeletedList.Clear(); foreach (Donate item in this) { if (item.IsNew) { item.Insert(cm, parent); } else { item.Update(cm, parent); } } RaiseListChangedEvents = true; }
protected override void DataPortal_Update() { RaiseListChangedEvents = false; foreach (EditableChild item in DeletedList) { item.DeleteSelf(); } DeletedList.Clear(); foreach (EditableChild item in this) { if (item.IsNew) { item.Insert(this); } else { item.Update(this); } } RaiseListChangedEvents = true; }
internal void Update(Promocion parent) { this.RaiseListChangedEvents = false; // update (thus deleting) any deleted child objects foreach (Alumno_Promocion obj in DeletedList) obj.DeleteSelf(parent); // now that they are deleted, remove them from memory too DeletedList.Clear(); // AddItem/update any current child objects foreach (Alumno_Promocion obj in this) { if (obj.IsNew) obj.Insert(parent); else obj.Update(parent); } this.RaiseListChangedEvents = true; }
internal void Update(object parent) { RaiseListChangedEvents = false; foreach (EditableChild item in DeletedList) { item.DeleteSelf(); } DeletedList.Clear(); foreach (EditableChild item in this) { if (item.IsNew) { item.Insert(parent); } else { item.Update(parent); } } RaiseListChangedEvents = true; }
/// <summary> /// Realiza el Save de los objetos de la lista. Inserta, Actualiza o Borra en función /// de los flags de cada objeto de la lista /// </summary> /// <param name="parent">BusinessBaseEx padre de la lista</param> internal void Update(Registro parent, List <TEntidadRegistroList> lists) { try { this.RaiseListChangedEvents = false; SessionCode = parent.SessionCode; // update (thus deleting) any deleted child objects foreach (LineaRegistro obj in DeletedList) { obj.DeleteSelf(parent); } // now that they are deleted, remove them from memory too DeletedList.Clear(); // add/update any current child objects foreach (LineaRegistro obj in this) { if (!this.Contains(obj)) { if (obj.IsNew) { SetNextCode(parent, obj); obj.Insert(parent); } else { obj.Update(parent, lists); } } } } finally { this.RaiseListChangedEvents = true; } }
private void AcceptChanges(int parentEditLevel) { if (this.EditLevel - 1 != parentEditLevel) { throw new UndoException(string.Format(Resources.EditLevelMismatchException, "AcceptChanges"), this.GetType().Name, _parent != null ? _parent.GetType().Name : null, this.EditLevel, parentEditLevel + 1); } // we are coming up one edit level _editLevel -= 1; // cascade the call to all child objects foreach (C child in this) { child.AcceptChanges(_editLevel, false); // if item is below its point of addition, lower point of addition if (child.EditLevelAdded > _editLevel) { child.EditLevelAdded = _editLevel; } } // cascade the call to all deleted child objects for (int index = DeletedList.Count - 1; index >= 0; index--) { C child = DeletedList[index]; child.AcceptChanges(_editLevel, false); // if item is below its point of addition, remove if (child.EditLevelAdded > _editLevel) { DeletedList.RemoveAt(index); } } if (_editLevel < 0) { _editLevel = 0; } }
/// <summary> /// Realiza el Save de los objetos de la lista. Inserta, Actualiza o Borra en función /// de los flags de cada objeto de la lista /// </summary> /// <param name="parent">BusinessBaseEx padre de la lista</param> internal void Update(Loan parent) { try { this.RaiseListChangedEvents = false; SessionCode = parent.SessionCode; // update (thus deleting) any deleted child objects foreach (InterestRate obj in DeletedList) { obj.DeleteSelf(parent); } // now that they are deleted, remove them from memory too DeletedList.Clear(); // add/update any current child objects foreach (InterestRate obj in this) { if (!this.Contains(obj)) { if (obj.IsNew) { obj.Insert(parent); } else { obj.Update(parent); } } } } finally { this.RaiseListChangedEvents = true; } }
public void Update(IAcreedor parent, Payment item) { this.RaiseListChangedEvents = false; // update (thus deleting) any deleted child objects foreach (Payment obj in DeletedList) { obj.DeleteSelf(parent); } // now that they are deleted, remove them from memory too DeletedList.Clear(); // add/update any current child objects // no se usa un foreach porque puede variar la cantidad de elementos // si se ha cambiado alguno de fecha ya que se crea uno nuevo y se anula el anterior for (int i = 0; i < Items.Count; i++) { Payment obj = Items[i]; if (obj.Oid != item.Oid) { continue; } if (obj.IsNew) { obj.Insert(parent); } else { obj.Update(parent); } } this.RaiseListChangedEvents = true; }
protected override void DataPortal_Update() { this.RaiseListChangedEvents = false; using (SqlConnection cn = new SqlConnection(Database.ConnectionString)) { cn.Open(); SqlCommand com = cn.CreateCommand(); SqlTransaction trans = cn.BeginTransaction(); com.Transaction = trans; foreach (Course item in DeletedList) { item.DeleteSelf(cn); } DeletedList.Clear(); try { foreach (Course item in this) { if (item.IsNew) { item.Insert(com); } else { item.Update(com); } } trans.Commit(); } catch (Exception ex) { trans.Rollback(); } } this.RaiseListChangedEvents = true; }
public bool ContainsDeleted(System.Int32 orderId) { return(DeletedList.Count(i => i.OrderId == orderId) > 0); }
public bool ContainsDeleted(System.Int32 suppId) { return(DeletedList.Count(i => i.SuppId == suppId) > 0); }
public bool ContainsDeleted(System.Int32 accountId) { return(DeletedList.Count(i => i.AccountId == accountId) > 0); }
public bool ContainsDeleted(System.Int32 uniqueID) { return(DeletedList.Count(i => i.UniqueID == uniqueID) > 0); }
public bool ContainsDeleted(System.String itemId) { return(DeletedList.Count(i => i.ItemId == itemId) > 0); }
public bool ContainsDeleted(System.Int32 orderId, System.Int32 lineNum) { return(DeletedList.Count(i => i.OrderId == orderId && i.LineNum == lineNum) > 0); }
public bool ContainsDeleted(System.Int32 cartId) { return(DeletedList.Count(i => i.CartId == cartId) > 0); }
protected override void DataPortal_Update() { bool success = false; this.RaiseListChangedEvents = false; // update (thus deleting) any deleted child objects foreach (Pregunta obj in DeletedList) { obj.DeleteSelf(this); } // now that they are deleted, remove them from memory too DeletedList.Clear(); try { // AddItem/update any current child objects foreach (Pregunta obj in this) { if (obj.IsNew) { obj.Insert(this); } else { obj.Update(this); } } if (!SharedTransaction) { Transaction().Commit(); } success = true; } catch (Exception ex) { if (!SharedTransaction) { if (!SharedTransaction && Transaction() != null) { Transaction().Rollback(); } } iQExceptionHandler.TreatException(ex); success = true; } finally { if (!success) { if (Transaction() != null) { Transaction().Rollback(); } } if (!SharedTransaction) { BeginTransaction(); } this.RaiseListChangedEvents = true; } }
public bool ContainsDeleted(System.String categoryId) { return(DeletedList.Count(i => i.CategoryId == categoryId) > 0); }
private void UndoChanges(int parentEditLevel) { C child; if (this.EditLevel - 1 != parentEditLevel) { throw new Core.UndoException(string.Format(Resources.EditLevelMismatchException, "UndoChanges")); } // we are coming up one edit level _editLevel -= 1; if (_editLevel < 0) { _editLevel = 0; } bool oldRLCE = this.RaiseListChangedEvents; this.RaiseListChangedEvents = false; try { // Cancel edit on all current items for (int index = Count - 1; index >= 0; index--) { child = this[index]; child.UndoChanges(_editLevel, false); // if item is below its point of addition, remove if (child.EditLevelAdded > _editLevel) { bool oldAllowRemove = this.AllowRemove; try { this.AllowRemove = true; _completelyRemoveChild = true; RemoveAt(index); } finally { _completelyRemoveChild = false; this.AllowRemove = oldAllowRemove; } } } // cancel edit on all deleted items for (int index = DeletedList.Count - 1; index >= 0; index--) { child = DeletedList[index]; child.UndoChanges(_editLevel, false); if (child.EditLevelAdded > _editLevel) { // if item is below its point of addition, remove DeletedList.RemoveAt(index); } else { // if item is no longer deleted move back to main list if (!child.IsDeleted) { UnDeleteChild(child); } } } } finally { this.RaiseListChangedEvents = oldRLCE; OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1)); } }
private void UndoChanges(int parentEditLevel) { C child; if (this.EditLevel - 1 != parentEditLevel) { throw new UndoException(string.Format(Resources.EditLevelMismatchException, "UndoChanges"), this.GetType().Name, _parent != null ? _parent.GetType().Name : null, this.EditLevel, parentEditLevel + 1); } // we are coming up one edit level _editLevel -= 1; if (_editLevel < 0) { _editLevel = 0; } bool oldRLCE = this.RaiseListChangedEvents; this.RaiseListChangedEvents = false; try { // Cancel edit on all current items for (int index = Count - 1; index >= 0; index--) { child = this[index]; //ACE: Important, make sure to remove the item prior to // it going through undo, otherwise, it will // incur a more expensive RemoveByReference operation //DeferredLoadIndexIfNotLoaded(); //_indexSet.RemoveItem(child); child.UndoChanges(_editLevel, false); //ACE: Now that we have undone the changes, we can add the item // back in the index. //_indexSet.InsertItem(child); // if item is below its point of addition, remove if (child.EditLevelAdded > _editLevel) { bool oldAllowRemove = this.AllowRemove; try { this.AllowRemove = true; _completelyRemoveChild = true; //RemoveIndexItem(child); RemoveAt(index); } finally { _completelyRemoveChild = false; this.AllowRemove = oldAllowRemove; } } } // cancel edit on all deleted items for (int index = DeletedList.Count - 1; index >= 0; index--) { child = DeletedList[index]; child.UndoChanges(_editLevel, false); if (child.EditLevelAdded > _editLevel) { // if item is below its point of addition, remove DeletedList.RemoveAt(index); } else { // if item is no longer deleted move back to main list if (!child.IsDeleted) { UnDeleteChild(child); } } } } finally { this.RaiseListChangedEvents = oldRLCE; OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } }