//[Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Delete(GLAccountTypeCriteria criteria) { bool cancel = false; OnDeleting(criteria, ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); using (var command = new SqlCommand("[dbo].[spCFM_GLAccountType_Delete]", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag)); //result: The number of rows changed, inserted, or deleted. -1 for select statements; 0 if no rows were affected, or the statement failed. int result = command.ExecuteNonQuery(); if (result == 0) { throw new DBConcurrencyException("The entity is out of date on the client. Please update the entity and try again. This could also be thrown if the sql statement failed to execute."); } } } OnDeleted(); }
public static void DeleteGLAccountType(System.Int32 gLAccountTypeID) { var criteria = new GLAccountTypeCriteria { GLAccountTypeID = gLAccountTypeID }; new GLAccountType().DataPortal_Delete(criteria); }
/// <summary> /// Returns a <see cref="GLAccountType"/> object of the specified criteria. /// </summary> /// <param name="createdBy">No additional detail available.</param> /// <returns>A <see cref="GLAccountType"/> object of the specified criteria.</returns> public static GLAccountType GetByCreatedBy(System.Int32 createdBy) { var criteria = new GLAccountTypeCriteria { CreatedBy = createdBy }; return(new GLAccountType().DataPortal_Fetch(criteria)); }
/// <summary> /// Returns a <see cref="GLAccountType"/> object of the specified criteria. /// </summary> /// <param name="gLAccountTypeID">No additional detail available.</param> /// <returns>A <see cref="GLAccountType"/> object of the specified criteria.</returns> public static GLAccountType GetByGLAccountTypeID(System.Int32 gLAccountTypeID) { var criteria = new GLAccountTypeCriteria { GLAccountTypeID = gLAccountTypeID }; return(new GLAccountType().DataPortal_Fetch(criteria)); }
/// <summary> /// CodeSmith generated stub method that is called after the child <see cref="GLAccountType"/> object with the specified criteria has been deleted. /// </summary> //partial void OnDeleted(); //partial void OnChildLoading(Csla.Core.IPropertyInfo childProperty, ref bool cancel); #endregion #region Exists Command /// <summary> /// Determines if a record exists in the GLAccountType table in the database for the specified criteria. /// </summary> /// <param name="criteria">The criteria parameter is an <see cref="GLAccountType"/> object.</param> /// <returns>A boolean value of true is returned if a record is found.</returns> public static GLAccountType Exists(GLAccountTypeCriteria criteria) { try { return(new GLAccountType().DataPortal_Fetch(criteria)); } catch (Exception ex) { } return(null); }
/// <summary> /// Returns a <see cref="GLAccountType"/> object of the specified criteria. /// </summary> /// <param name="updatedBy">No additional detail available.</param> /// <returns>A <see cref="GLAccountType"/> object of the specified criteria.</returns> public static GLAccountType GetByUpdatedBy(System.Int32?updatedBy) { var criteria = new GLAccountTypeCriteria { }; if (updatedBy.HasValue) { criteria.UpdatedBy = updatedBy.Value; } return(new GLAccountType().DataPortal_Fetch(criteria)); }
/// <summary> /// Returns a <see cref="GLAccountType"/> object of the specified criteria. /// </summary> /// <param name="gLEntityTypeID">No additional detail available.</param> /// <returns>A <see cref="GLAccountType"/> object of the specified criteria.</returns> public static GLAccountType GetByGLEntityTypeID(System.Int32?gLEntityTypeID) { var criteria = new GLAccountTypeCriteria { }; if (gLEntityTypeID.HasValue) { criteria.GLEntityTypeID = gLEntityTypeID.Value; } return(new GLAccountType().DataPortal_Fetch(criteria)); }
private GLAccountTypeList DataPortal_Fetch(GLAccountTypeCriteria criteria) { bool cancel = false; OnFetching(criteria, ref cancel); if (cancel) { return(null); } //RaiseListChangedEvents = false; // Fetch Child objects. using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); using (var command = new SqlCommand("[dbo].[spCFM_GLAccountType_Select]", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag)); command.Parameters.AddWithValue("@p_CodeHasValue", criteria.CodeHasValue); command.Parameters.AddWithValue("@p_GLEntityTypeIDHasValue", criteria.GLEntityTypeIDHasValue); command.Parameters.AddWithValue("@p_UpdatedByHasValue", criteria.UpdatedByHasValue); command.Parameters.AddWithValue("@p_UpdatedOnHasValue", criteria.UpdatedOnHasValue); using (var reader = command.ExecuteReader()) { if (reader.Read()) { var rowParser = reader.GetRowParser <CFMData.GLAccountType>(); do { this.Add(CFMData.GLAccountType.GetGLAccountType(rowParser, reader)); }while(reader.Read()); } OnFetched(); return(this); } } } //RaiseListChangedEvents = true; }
private GLAccountType DataPortal_Fetch(GLAccountTypeCriteria criteria) { bool cancel = false; OnFetching(criteria, ref cancel); if (cancel) { return(null); } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); using (var command = new SqlCommand("[dbo].[spCFM_GLAccountType_Select]", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag)); command.Parameters.AddWithValue("@p_CodeHasValue", criteria.CodeHasValue); command.Parameters.AddWithValue("@p_GLEntityTypeIDHasValue", criteria.GLEntityTypeIDHasValue); command.Parameters.AddWithValue("@p_UpdatedByHasValue", criteria.UpdatedByHasValue); command.Parameters.AddWithValue("@p_UpdatedOnHasValue", criteria.UpdatedOnHasValue); using (var reader = command.ExecuteReader()) { var rowParser = reader.GetRowParser <GLAccountType>(); if (reader.Read()) { return(GetGLAccountType(rowParser, reader)); } else { throw new Exception(String.Format("The record was not found in 'dbo.GLAccountType' using the following criteria: {0}.", criteria)); } } } } OnFetched(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Update() { bool cancel = false; OnUpdating(ref cancel); if (cancel) { return; } if (OriginalGLAccountTypeID != GLAccountTypeID) { // Insert new child. GLAccountType item = new GLAccountType { GLAccountTypeID = GLAccountTypeID, Code = Code, Name = Name, IsActive = IsActive, CreatedBy = CreatedBy, CreatedOn = CreatedOn, CanHaveBankAccount = CanHaveBankAccount, CanHaveBankCards = CanHaveBankCards, IsMandatory = IsMandatory }; if (GLEntityTypeID.HasValue) { item.GLEntityTypeID = GLEntityTypeID.Value; } if (UpdatedBy.HasValue) { item.UpdatedBy = UpdatedBy.Value; } if (UpdatedOn.HasValue) { item.UpdatedOn = UpdatedOn.Value; } item.DataPortal_Update(); // Mark editable child lists as dirty. This code may need to be updated to one-to-one relationships. foreach (GLAccount itemToUpdate in GLAccounts) { itemToUpdate.GLAccountTypeID = GLAccountTypeID; } // Create a new connection. using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } //FieldManager.UpdateChildren(this, connection); } // Delete the old. var criteria = new GLAccountTypeCriteria { GLAccountTypeID = OriginalGLAccountTypeID }; DataPortal_Delete(criteria); // Mark the original as the new one. OriginalGLAccountTypeID = GLAccountTypeID; OnUpdated(); return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_GLAccountType_Update]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_OriginalGLAccountTypeID", this.OriginalGLAccountTypeID); command.Parameters.AddWithValue("@p_GLAccountTypeID", this.GLAccountTypeID); command.Parameters.AddWithValue("@p_Code", ADOHelper.NullCheck(this.Code)); command.Parameters.AddWithValue("@p_Name", this.Name); command.Parameters.AddWithValue("@p_GLEntityTypeID", ADOHelper.NullCheck(this.GLEntityTypeID)); command.Parameters.AddWithValue("@p_IsActive", this.IsActive); command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy); command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn); command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy)); command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn)); command.Parameters.AddWithValue("@p_CanHaveBankAccount", this.CanHaveBankAccount); command.Parameters.AddWithValue("@p_CanHaveBankCards", this.CanHaveBankCards); command.Parameters.AddWithValue("@p_IsMandatory", this.IsMandatory); //result: The number of rows changed, inserted, or deleted. -1 for select statements; 0 if no rows were affected, or the statement failed. int result = command.ExecuteNonQuery(); if (result == 0) { throw new DBConcurrencyException("The entity is out of date on the client. Please update the entity and try again. This could also be thrown if the sql statement failed to execute."); } _originalGLAccountTypeIDProperty = this.GLAccountTypeID; } UpdateChildren(this, connection, trans); //FieldManager.UpdateChildren(this, connection); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnUpdated(); }
/// <summary> /// CodeSmith generated stub method that is called when deleting the child <see cref="GLAccountType"/> object. /// </summary> /// <param name="criteria"><see cref="GLAccountTypeCriteria"/> object containing the criteria of the object to delete.</param> /// <param name="cancel">Value returned from the method indicating whether the object deletion should proceed.</param> //partial void OnDeleting(GLAccountTypeCriteria criteria, ref bool cancel); /// <summary> /// CodeSmith generated stub method that is called when deleting the child <see cref="GLAccountType"/> object. /// </summary> /// <param name="criteria"><see cref="GLAccountTypeCriteria"/> object containing the criteria of the object to delete.</param> /// <param name="connection"></param> /// <param name="cancel">Value returned from the method indicating whether the object deletion should proceed.</param> partial void OnDeleting(GLAccountTypeCriteria criteria, SqlConnection connection, ref bool cancel);
/// <summary> /// CodeSmith generated stub method that is called when fetching the child <see cref="GLAccountType"/> object. /// </summary> /// <param name="criteria"><see cref="GLAccountTypeCriteria"/> object containing the criteria of the object to fetch.</param> /// <param name="cancel">Value returned from the method indicating whether the object fetching should proceed.</param> partial void OnChildFetching(GLAccountTypeCriteria criteria, ref bool cancel);
/// <summary> /// CodeSmith generated stub method that is called when deleting the <see cref="GLAccountType"/> object. /// </summary> /// <param name="criteria"><see cref="GLAccountTypeCriteria"/> object containing the criteria of the object to delete.</param> /// <param name="cancel">Value returned from the method indicating whether the object deletion should proceed.</param> partial void OnDeleting(GLAccountTypeCriteria criteria, ref bool cancel);
public static GLAccountTypeList GetByCriteria(GLAccountTypeCriteria criteria) { return(new GLAccountTypeList().DataPortal_Fetch(criteria)); // return DataPortal.Fetch<GLAccountTypeList>(criteria); }