/// <summary> /// Inserts data into the data base using the information in the current /// CSLA editable child business object of type <see cref="BudgetType"/> /// </summary> /// <returns></returns> public void Child_Insert(SqlConnection connection, SqlTransaction trans) { bool cancel = false; OnChildInserting(connection, ref cancel, trans); if (cancel) { return; } if (connection.State != ConnectionState.Open) { connection.Open(); } using (var command = new SqlCommand("[dbo].[spCFM_BudgetType_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_BudgetTypeID", this.BudgetTypeID); command.Parameters.AddWithValue("@p_Code", this.Code); command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name)); command.ExecuteNonQuery(); // Update the original non-identity primary key value. _originalBudgetTypeIDProperty = this.BudgetTypeID; } UpdateChildren(this, connection, trans); OnChildInserted(); }
public void Child_Update(ApplicationUser applicationUser, SystemRole systemRole, SqlConnection connection, SqlTransaction trans) { bool cancel = false; OnChildUpdating(applicationUser, systemRole, connection, ref cancel, trans); if (cancel) { return; } if (connection.State != ConnectionState.Open) { connection.Open(); } using (var command = new SqlCommand("[dbo].[spCFM_ApplicationRole_Update]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_ApplicationRoleID", this.ApplicationRoleID); command.Parameters.AddWithValue("@p_Name", this.Name); command.Parameters.AddWithValue("@p_SystemRoleID", systemRole != null ? systemRole.SystemRoleID : this.SystemRoleID); command.Parameters.AddWithValue("@p_IsSystemRole", this.IsSystemRole); command.Parameters.AddWithValue("@p_IsActive", this.IsActive); command.Parameters.AddWithValue("@p_CreatedBy", applicationUser != null ? applicationUser.ApplicationUserID : this.CreatedBy); command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn); command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(applicationUser != null ? applicationUser.ApplicationUserID : this.UpdatedBy)); command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn)); //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."); } // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query. if (systemRole != null && systemRole.SystemRoleID != this.SystemRoleID) { _systemRoleIDProperty = systemRole.SystemRoleID; } // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query. if (applicationUser != null && applicationUser.ApplicationUserID != this.CreatedBy) { _createdByProperty = applicationUser.ApplicationUserID; } // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query. if (applicationUser != null && applicationUser.ApplicationUserID != this.UpdatedBy) { _updatedByProperty = applicationUser.ApplicationUserID; } } // A child relationship exists on this Business Object but its type is not a child type (E.G. EditableChild). // TODO: Please override OnChildUpdated() and update this child manually. // UpdateChildren(this, connection); OnChildUpdated(); }
/// <summary> /// Updates the corresponding record in the data base with the information in the current /// CSLA editable child business object of type <see cref="BusinessArea"/> /// </summary> /// <returns></returns> public void Child_Update(SqlConnection connection, SqlTransaction trans) { bool cancel = false; OnChildUpdating(connection, ref cancel, trans); if (cancel) { return; } if (connection.State != ConnectionState.Open) { connection.Open(); } using (var command = new SqlCommand("[dbo].[spCFM_BusinessArea_Update]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_BusinessAreaID", this.BusinessAreaID); command.Parameters.AddWithValue("@p_Code", this.Code); command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name)); command.Parameters.AddWithValue("@p_BusinessDivisionID", this.BusinessDivisionID); //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."); } } UpdateChildren(this, connection, trans); OnChildUpdated(); }
/// <summary> /// Inserts data into the data base using the information in the current /// CSLA editable child business object of type <see cref="BankTransaction"/> /// </summary> /// <returns></returns> public void Child_Insert(SqlConnection connection, SqlTransaction trans) { bool cancel = false; OnChildInserting(connection, ref cancel, trans); if (cancel) { return; } if (connection.State != ConnectionState.Open) { connection.Open(); } using (var command = new SqlCommand("[dbo].[spCFM_BankTransaction_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_BankTransactionID", this.BankTransactionID); command.Parameters["@p_BankTransactionID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_BankAccountID", ADOHelper.NullCheck(this.BankAccountID)); command.Parameters.AddWithValue("@p_TransactionDate", this.TransactionDate); command.Parameters.AddWithValue("@p_AccountNumber", this.AccountNumber); command.Parameters.AddWithValue("@p_AccountName", this.AccountName); command.Parameters.AddWithValue("@p_CurrencyCode", this.CurrencyCode); command.Parameters.AddWithValue("@p_ClosingBalanace", this.ClosingBalanace); command.Parameters.AddWithValue("@p_TransactionAmount", this.TransactionAmount); command.Parameters.AddWithValue("@p_TransactionCode", this.TransactionCode); command.Parameters.AddWithValue("@p_Narrative", ADOHelper.NullCheck(this.Narrative)); command.Parameters.AddWithValue("@p_SerialNumber", ADOHelper.NullCheck(this.SerialNumber)); command.Parameters.AddWithValue("@p_SegmentAccountNumber", ADOHelper.NullCheck(this.SegmentAccountNumber)); command.Parameters.AddWithValue("@p_PaymentTransactionID", ADOHelper.NullCheck(this.PaymentTransactionID)); command.Parameters.AddWithValue("@p_InstructionID", ADOHelper.NullCheck(this.InstructionID)); command.Parameters.AddWithValue("@p_ValueDate", ADOHelper.NullCheck(this.ValueDate)); command.Parameters.AddWithValue("@p_TransactionDateTimeUTC", ADOHelper.NullCheck(this.TransactionDateTimeUTC)); command.Parameters.AddWithValue("@p_DebtorName", ADOHelper.NullCheck(this.DebtorName)); command.Parameters.AddWithValue("@p_CreditorName", ADOHelper.NullCheck(this.CreditorName)); command.Parameters.AddWithValue("@p_EndToEndID", ADOHelper.NullCheck(this.EndToEndID)); command.Parameters.AddWithValue("@p_RemittanceInformation1", ADOHelper.NullCheck(this.RemittanceInformation1)); command.Parameters.AddWithValue("@p_RemittanceInfoformation2", ADOHelper.NullCheck(this.RemittanceInfoformation2)); command.Parameters.AddWithValue("@p_PayiDType", ADOHelper.NullCheck(this.PayiDType)); command.Parameters.AddWithValue("@p_PayID", ADOHelper.NullCheck(this.PayID)); command.Parameters.AddWithValue("@p_ReversalreasonCode", ADOHelper.NullCheck(this.ReversalreasonCode)); command.Parameters.AddWithValue("@p_OriginalTransactionID", ADOHelper.NullCheck(this.OriginalTransactionID)); 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.ExecuteNonQuery(); // Update identity primary key value. _bankTransactionIDProperty = (System.Int32)command.Parameters["@p_BankTransactionID"].Value; } UpdateChildren(this, connection, trans); OnChildInserted(); }
public void Child_Insert(ApplicationUser applicationUser, Client client, SqlConnection connection, SqlTransaction trans) { bool cancel = false; OnChildInserting(applicationUser, client, connection, ref cancel, trans); if (cancel) { return; } if (connection.State != ConnectionState.Open) { connection.Open(); } using (var command = new SqlCommand("[dbo].[spCFM_FinAdministratorClient_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_FinAdministratorClientID", this.FinAdministratorClientID); command.Parameters["@p_FinAdministratorClientID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_FinAdministratorID", this.FinAdministratorID); command.Parameters.AddWithValue("@p_ClientId", client != null ? client.ClientID : this.ClientId); command.Parameters.AddWithValue("@p_StartDate", this.StartDate); command.Parameters.AddWithValue("@p_EndDate", ADOHelper.NullCheck(this.EndDate)); command.Parameters.AddWithValue("@p_IsActive", this.IsActive); command.Parameters.AddWithValue("@p_CreatedBy", applicationUser != null ? applicationUser.ApplicationUserID : this.CreatedBy); command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn); command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(applicationUser != null ? applicationUser.ApplicationUserID : this.UpdatedBy)); command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn)); command.ExecuteNonQuery(); // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query. if (client != null && client.ClientID != this.ClientId) { _clientIdProperty = client.ClientID; } // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query. if (applicationUser != null && applicationUser.ApplicationUserID != this.CreatedBy) { _createdByProperty = applicationUser.ApplicationUserID; } // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query. if (applicationUser != null && applicationUser.ApplicationUserID != this.UpdatedBy) { _updatedByProperty = applicationUser.ApplicationUserID; } // Update the original non-identity primary key value. _originalFinAdministratorIDProperty = this.FinAdministratorID; } // A child relationship exists on this Business Object but its type is not a child type (E.G. EditableChild). // TODO: Please override OnChildInserted() and insert this child manually. // UpdateChildren(this, connection); OnChildInserted(); }
public void Child_Insert(ApplicationUser applicationUser, BSBDetail bSBDetail, SqlConnection connection, SqlTransaction trans) { bool cancel = false; OnChildInserting(applicationUser, bSBDetail, connection, ref cancel, trans); if (cancel) { return; } if (connection.State != ConnectionState.Open) { connection.Open(); } using (var command = new SqlCommand("[dbo].[spCFM_BankAccount_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_BankAccountID", this.BankAccountID); command.Parameters["@p_BankAccountID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_BSBNumber", this.BSBNumber); command.Parameters.AddWithValue("@p_AccountNumber", this.AccountNumber); command.Parameters.AddWithValue("@p_AccountName", this.AccountName); command.Parameters.AddWithValue("@p_BSBDetailID", ADOHelper.NullCheck(bSBDetail != null ? bSBDetail.BSBDetailID : this.BSBDetailID)); command.Parameters.AddWithValue("@p_IsActive", this.IsActive); command.Parameters.AddWithValue("@p_CreatedBy", applicationUser != null ? applicationUser.ApplicationUserID : this.CreatedBy); command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn); command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(applicationUser != null ? applicationUser.ApplicationUserID : this.UpdatedBy)); command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn)); command.ExecuteNonQuery(); // Update identity primary key value. _bankAccountIDProperty = (System.Int32)command.Parameters["@p_BankAccountID"].Value; // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query. if (bSBDetail != null && bSBDetail.BSBDetailID != this.BSBDetailID) { _bSBDetailIDProperty = bSBDetail.BSBDetailID; } // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query. if (applicationUser != null && applicationUser.ApplicationUserID != this.CreatedBy) { _createdByProperty = applicationUser.ApplicationUserID; } // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query. if (applicationUser != null && applicationUser.ApplicationUserID != this.UpdatedBy) { _updatedByProperty = applicationUser.ApplicationUserID; } } // A child relationship exists on this Business Object but its type is not a child type (E.G. EditableChild). // TODO: Please override OnChildInserted() and insert this child manually. // UpdateChildren(this, null, connection); OnChildInserted(); }
/// <summary> /// Inserts data into the data base using the information in the current /// CSLA editable child business object of type <see cref="BusinessArea"/> /// </summary> /// <returns></returns> public void Child_Insert(SqlConnection connection, SqlTransaction trans) { bool cancel = false; OnChildInserting(connection, ref cancel, trans); if (cancel) { return; } if (connection.State != ConnectionState.Open) { connection.Open(); } using (var command = new SqlCommand("[dbo].[spCFM_BusinessArea_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_BusinessAreaID", this.BusinessAreaID); command.Parameters["@p_BusinessAreaID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_Code", this.Code); command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name)); command.Parameters.AddWithValue("@p_BusinessDivisionID", this.BusinessDivisionID); command.ExecuteNonQuery(); // Update identity primary key value. _businessAreaIDProperty = (System.Int32)command.Parameters["@p_BusinessAreaID"].Value; } UpdateChildren(this, connection, trans); OnChildInserted(); }
/// <summary> /// Updates the corresponding record in the data base with the information in the current /// CSLA editable child business object of type <see cref="Gl"/> /// </summary> /// <returns></returns> public void Child_Update(SqlConnection connection, SqlTransaction trans) { bool cancel = false; OnChildUpdating(connection, ref cancel, trans); if (cancel) { return; } if (connection.State != ConnectionState.Open) { connection.Open(); } using (var command = new SqlCommand("[dbo].[spCFM_Gl_Update]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_GLID", this.Glid); command.Parameters.AddWithValue("@p_JournalDate", this.JournalDate); command.Parameters.AddWithValue("@p_PostingDate", ADOHelper.NullCheck(this.PostingDate)); command.Parameters.AddWithValue("@p_GLAccountID", this.GLAccountID); command.Parameters.AddWithValue("@p_TransactionTypeID", this.TransactionTypeID); command.Parameters.AddWithValue("@p_GLCostCentreEntityID", ADOHelper.NullCheck(this.GLCostCentreEntityID)); command.Parameters.AddWithValue("@p_BankTransactionID", ADOHelper.NullCheck(this.BankTransactionID)); command.Parameters.AddWithValue("@p_CategoryID", ADOHelper.NullCheck(this.CategoryID)); command.Parameters.AddWithValue("@p_JournalNumber", this.JournalNumber); command.Parameters.AddWithValue("@p_Narration", this.Narration); command.Parameters.AddWithValue("@p_DocRef", this.DocRef); command.Parameters.AddWithValue("@p_CurrencyCode", this.CurrencyCode); command.Parameters.AddWithValue("@p_ExGstAMount", ADOHelper.NullCheck(this.ExGstAMount)); command.Parameters.AddWithValue("@p_GSTAmount", ADOHelper.NullCheck(this.GSTAmount)); command.Parameters.AddWithValue("@p_DRAmount", ADOHelper.NullCheck(this.DRAmount)); command.Parameters.AddWithValue("@p_CRAmount", ADOHelper.NullCheck(this.CRAmount)); command.Parameters.AddWithValue("@p_HouseBudgetID", ADOHelper.NullCheck(this.HouseBudgetID)); command.Parameters.AddWithValue("@p_ClientBudgetID", ADOHelper.NullCheck(this.ClientBudgetID)); 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)); //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."); } } UpdateChildren(this, connection, trans); OnChildUpdated(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Insert() { bool cancel = false; OnInserting(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_Client_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_ClientID", this.ClientID); command.Parameters["@p_ClientID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_GLEntityID", this.GLEntityID); command.Parameters.AddWithValue("@p_RefCode", this.RefCode); command.Parameters.AddWithValue("@p_NDISNumber", ADOHelper.NullCheck(this.NDISNumber)); command.Parameters.AddWithValue("@p_FirstName", this.FirstName); command.Parameters.AddWithValue("@p_LastName", this.LastName); command.Parameters.AddWithValue("@p_DOB", this.Dob); command.Parameters.AddWithValue("@p_Email", ADOHelper.NullCheck(this.Email)); command.Parameters.AddWithValue("@p_AddressID", ADOHelper.NullCheck(this.AddressID)); command.Parameters.AddWithValue("@p_IsHomeAddress", this.IsHomeAddress); command.Parameters.AddWithValue("@p_StatementDelOptID", this.StatementDelOptID); 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.ExecuteNonQuery(); _clientIDProperty = (System.Int32)command.Parameters["@p_ClientID"].Value; } UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnInserted(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Update() { bool cancel = false; OnUpdating(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_Client_Update]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_ClientID", this.ClientID); command.Parameters.AddWithValue("@p_GLEntityID", this.GLEntityID); command.Parameters.AddWithValue("@p_RefCode", this.RefCode); command.Parameters.AddWithValue("@p_NDISNumber", ADOHelper.NullCheck(this.NDISNumber)); command.Parameters.AddWithValue("@p_FirstName", this.FirstName); command.Parameters.AddWithValue("@p_LastName", this.LastName); command.Parameters.AddWithValue("@p_DOB", this.Dob); command.Parameters.AddWithValue("@p_Email", ADOHelper.NullCheck(this.Email)); command.Parameters.AddWithValue("@p_AddressID", ADOHelper.NullCheck(this.AddressID)); command.Parameters.AddWithValue("@p_IsHomeAddress", this.IsHomeAddress); command.Parameters.AddWithValue("@p_StatementDelOptID", this.StatementDelOptID); 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)); //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."); } } UpdateChildren(this, connection, trans); //FieldManager.UpdateChildren(this, connection); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnUpdated(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Update() { bool cancel = false; OnUpdating(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_Home_Update]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_HomeID", this.HomeID); command.Parameters.AddWithValue("@p_GLEntityID", this.GLEntityID); command.Parameters.AddWithValue("@p_BusinessAreaID", this.BusinessAreaID); command.Parameters.AddWithValue("@p_HomeCostCentreCode", this.HomeCostCentreCode); command.Parameters.AddWithValue("@p_HomeName", this.HomeName); command.Parameters.AddWithValue("@p_Parcel", this.Parcel); command.Parameters.AddWithValue("@p_SILTarget", this.SILTarget); command.Parameters.AddWithValue("@p_NoofBeds", this.NoofBeds); command.Parameters.AddWithValue("@p_AccommodationTypeId", this.AccommodationTypeId); command.Parameters.AddWithValue("@p_isGST", this.IsGST); command.Parameters.AddWithValue("@p_AddressID", ADOHelper.NullCheck(this.AddressID)); 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)); //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."); } } UpdateChildren(this, connection, trans); //FieldManager.UpdateChildren(this, connection); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnUpdated(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Insert() { bool cancel = false; OnInserting(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_Budget_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_BudgetID", this.BudgetID); command.Parameters["@p_BudgetID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_BudgetTypeID", this.BudgetTypeID); command.Parameters.AddWithValue("@p_ClientID", ADOHelper.NullCheck(this.ClientID)); command.Parameters.AddWithValue("@p_HomeID", ADOHelper.NullCheck(this.HomeID)); command.Parameters.AddWithValue("@p_BudgetCode", this.BudgetCode); command.Parameters.AddWithValue("@p_EffectiveDate", this.EffectiveDate); command.Parameters.AddWithValue("@p_TemplateName", ADOHelper.NullCheck(this.TemplateName)); 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_EnteredMonthly", this.EnteredMonthly); command.Parameters.AddWithValue("@p_ScopeContribution", this.ScopeContribution); command.Parameters.AddWithValue("@p_NumberOfBeds", this.NumberOfBeds); command.Parameters.AddWithValue("@p_Vacancies", this.Vacancies); command.ExecuteNonQuery(); _budgetIDProperty = (System.Int32)command.Parameters["@p_BudgetID"].Value; } UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnInserted(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Insert() { bool cancel = false; OnInserting(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_Home_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_HomeID", this.HomeID); command.Parameters["@p_HomeID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_GLEntityID", this.GLEntityID); command.Parameters.AddWithValue("@p_BusinessAreaID", this.BusinessAreaID); command.Parameters.AddWithValue("@p_HomeCostCentreCode", this.HomeCostCentreCode); command.Parameters.AddWithValue("@p_HomeName", this.HomeName); command.Parameters.AddWithValue("@p_Parcel", this.Parcel); command.Parameters.AddWithValue("@p_SILTarget", this.SILTarget); command.Parameters.AddWithValue("@p_NoofBeds", this.NoofBeds); command.Parameters.AddWithValue("@p_AccommodationTypeId", this.AccommodationTypeId); command.Parameters.AddWithValue("@p_isGST", this.IsGST); command.Parameters.AddWithValue("@p_AddressID", ADOHelper.NullCheck(this.AddressID)); 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.ExecuteNonQuery(); _homeIDProperty = (System.Int32)command.Parameters["@p_HomeID"].Value; } UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnInserted(); }
/// <summary> /// Inserts data into the data base using the information in the current /// CSLA editable child business object of type <see cref="Gl"/> /// </summary> /// <returns></returns> public void Child_Insert(SqlConnection connection, SqlTransaction trans) { bool cancel = false; OnChildInserting(connection, ref cancel, trans); if (cancel) { return; } if (connection.State != ConnectionState.Open) { connection.Open(); } using (var command = new SqlCommand("[dbo].[spCFM_Gl_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_GLID", this.Glid); command.Parameters["@p_GLID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_JournalDate", this.JournalDate); command.Parameters.AddWithValue("@p_PostingDate", ADOHelper.NullCheck(this.PostingDate)); command.Parameters.AddWithValue("@p_GLAccountID", this.GLAccountID); command.Parameters.AddWithValue("@p_TransactionTypeID", this.TransactionTypeID); command.Parameters.AddWithValue("@p_GLCostCentreEntityID", ADOHelper.NullCheck(this.GLCostCentreEntityID)); command.Parameters.AddWithValue("@p_BankTransactionID", ADOHelper.NullCheck(this.BankTransactionID)); command.Parameters.AddWithValue("@p_CategoryID", ADOHelper.NullCheck(this.CategoryID)); command.Parameters.AddWithValue("@p_JournalNumber", this.JournalNumber); command.Parameters.AddWithValue("@p_Narration", this.Narration); command.Parameters.AddWithValue("@p_DocRef", this.DocRef); command.Parameters.AddWithValue("@p_CurrencyCode", this.CurrencyCode); command.Parameters.AddWithValue("@p_ExGstAMount", ADOHelper.NullCheck(this.ExGstAMount)); command.Parameters.AddWithValue("@p_GSTAmount", ADOHelper.NullCheck(this.GSTAmount)); command.Parameters.AddWithValue("@p_DRAmount", ADOHelper.NullCheck(this.DRAmount)); command.Parameters.AddWithValue("@p_CRAmount", ADOHelper.NullCheck(this.CRAmount)); command.Parameters.AddWithValue("@p_HouseBudgetID", ADOHelper.NullCheck(this.HouseBudgetID)); command.Parameters.AddWithValue("@p_ClientBudgetID", ADOHelper.NullCheck(this.ClientBudgetID)); 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.ExecuteNonQuery(); // Update identity primary key value. _glidProperty = (System.Int32)command.Parameters["@p_GLID"].Value; } UpdateChildren(this, connection, trans); OnChildInserted(); }
public void Child_Insert(ApplicationUser applicationUser, SqlConnection connection, SqlTransaction trans) { bool cancel = false; OnChildInserting(applicationUser, connection, ref cancel, trans); if (cancel) { return; } if (connection.State != ConnectionState.Open) { connection.Open(); } using (var command = new SqlCommand("[dbo].[spCFM_MailingTemplate_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_MailingTemplateID", this.MailingTemplateID); command.Parameters.AddWithValue("@p_Description", ADOHelper.NullCheck(this.Description)); command.Parameters.AddWithValue("@p_MailingText", ADOHelper.NullCheck(this.MailingText)); command.Parameters.AddWithValue("@p_MailingSubject", ADOHelper.NullCheck(this.MailingSubject)); command.Parameters.AddWithValue("@p_MailingFrom", ADOHelper.NullCheck(this.MailingFrom)); command.Parameters.AddWithValue("@p_CreatedBy", applicationUser != null ? applicationUser.ApplicationUserID : this.CreatedBy); command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn); command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(applicationUser != null ? applicationUser.ApplicationUserID : this.UpdatedBy)); command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn)); command.ExecuteNonQuery(); // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query. if (applicationUser != null && applicationUser.ApplicationUserID != this.CreatedBy) { _createdByProperty = applicationUser.ApplicationUserID; } // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query. if (applicationUser != null && applicationUser.ApplicationUserID != this.UpdatedBy) { _updatedByProperty = applicationUser.ApplicationUserID; } // Update the original non-identity primary key value. _originalMailingTemplateIDProperty = this.MailingTemplateID; } // A child relationship exists on this Business Object but its type is not a child type (E.G. EditableChild). // TODO: Please override OnChildInserted() and insert this child manually. // UpdateChildren(this, connection); OnChildInserted(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Insert() { bool cancel = false; OnInserting(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_DataOption_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_DataOptionID", this.DataOptionID); command.Parameters["@p_DataOptionID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_DataOptionTypeID", this.DataOptionTypeID); command.Parameters.AddWithValue("@p_Code", ADOHelper.NullCheck(this.Code)); command.Parameters.AddWithValue("@p_DisplayValue", ADOHelper.NullCheck(this.DisplayValue)); command.Parameters.AddWithValue("@p_ParentID", ADOHelper.NullCheck(this.ParentID)); command.Parameters.AddWithValue("@p_SortID", this.SortID); command.Parameters.AddWithValue("@p_IsSystem", this.IsSystem); command.Parameters.AddWithValue("@p_AdditionalConfigData", ADOHelper.NullCheck(this.AdditionalConfigData)); command.Parameters.AddWithValue("@p_ActiveFrom", this.ActiveFrom); command.Parameters.AddWithValue("@p_ActiveTo", ADOHelper.NullCheck(this.ActiveTo)); command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn); command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy); command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn)); command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy)); command.ExecuteNonQuery(); _dataOptionIDProperty = (System.Int32)command.Parameters["@p_DataOptionID"].Value; } UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnInserted(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Update() { bool cancel = false; OnUpdating(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_DataOption_Update]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_DataOptionID", this.DataOptionID); command.Parameters.AddWithValue("@p_DataOptionTypeID", this.DataOptionTypeID); command.Parameters.AddWithValue("@p_Code", ADOHelper.NullCheck(this.Code)); command.Parameters.AddWithValue("@p_DisplayValue", ADOHelper.NullCheck(this.DisplayValue)); command.Parameters.AddWithValue("@p_ParentID", ADOHelper.NullCheck(this.ParentID)); command.Parameters.AddWithValue("@p_SortID", this.SortID); command.Parameters.AddWithValue("@p_IsSystem", this.IsSystem); command.Parameters.AddWithValue("@p_AdditionalConfigData", ADOHelper.NullCheck(this.AdditionalConfigData)); command.Parameters.AddWithValue("@p_ActiveFrom", this.ActiveFrom); command.Parameters.AddWithValue("@p_ActiveTo", ADOHelper.NullCheck(this.ActiveTo)); command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn); command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy); command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn)); command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy)); //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."); } } UpdateChildren(this, connection, trans); //FieldManager.UpdateChildren(this, connection); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnUpdated(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Insert() { bool cancel = false; OnInserting(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_FinAdministrator_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_FinAdministratorID", this.FinAdministratorID); command.Parameters["@p_FinAdministratorID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_GLEntityID", this.GLEntityID); command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name)); command.Parameters.AddWithValue("@p_isOrganisation", this.IsOrganisation); command.Parameters.AddWithValue("@p_Email", ADOHelper.NullCheck(this.Email)); command.Parameters.AddWithValue("@p_AddressID", ADOHelper.NullCheck(this.AddressID)); command.Parameters.AddWithValue("@p_HasDirectDebit", this.HasDirectDebit); command.Parameters.AddWithValue("@p_BankAccountID", ADOHelper.NullCheck(this.BankAccountID)); 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.ExecuteNonQuery(); _finAdministratorIDProperty = (System.Int32)command.Parameters["@p_FinAdministratorID"].Value; } UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnInserted(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Insert() { bool cancel = false; OnInserting(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_ApplicationPermission_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_ApplicationPermissionID", this.ApplicationPermissionID); command.Parameters["@p_ApplicationPermissionID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_ApplicationRoleID", ADOHelper.NullCheck(this.ApplicationRoleID)); command.Parameters.AddWithValue("@p_ApplicationUserID", ADOHelper.NullCheck(this.ApplicationUserID)); command.Parameters.AddWithValue("@p_BusinessAreaID", ADOHelper.NullCheck(this.BusinessAreaID)); command.Parameters.AddWithValue("@p_BusinessDivisionID", ADOHelper.NullCheck(this.BusinessDivisionID)); command.Parameters.AddWithValue("@p_BusinessEntityID", ADOHelper.NullCheck(this.BusinessEntityID)); command.Parameters.AddWithValue("@p_HomeID", ADOHelper.NullCheck(this.HomeID)); command.Parameters.AddWithValue("@p_ClientID", ADOHelper.NullCheck(this.ClientID)); 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.ExecuteNonQuery(); _applicationPermissionIDProperty = (System.Int32)command.Parameters["@p_ApplicationPermissionID"].Value; } UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnInserted(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Insert() { bool cancel = false; OnInserting(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_BudgetApproval_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_BudgetApprovalID", this.BudgetApprovalID); command.Parameters["@p_BudgetApprovalID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_BudgetID", this.BudgetID); command.Parameters.AddWithValue("@p_AdministratorUserID", ADOHelper.NullCheck(this.AdministratorUserID)); command.Parameters.AddWithValue("@p_OperationsUserID", ADOHelper.NullCheck(this.OperationsUserID)); command.Parameters.AddWithValue("@p_ApprovalDate", ADOHelper.NullCheck(this.ApprovalDate)); command.Parameters.AddWithValue("@p_Status", this.Status); command.Parameters.AddWithValue("@p_ReminderDate", ADOHelper.NullCheck(this.ReminderDate)); command.Parameters.AddWithValue("@p_ApprovalFileID", ADOHelper.NullCheck(this.ApprovalFileID)); 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.ExecuteNonQuery(); _budgetApprovalIDProperty = (System.Int32)command.Parameters["@p_BudgetApprovalID"].Value; } UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnInserted(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Insert() { bool cancel = false; OnInserting(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_BudgetLine_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_BudgetLineID", this.BudgetLineID); command.Parameters["@p_BudgetLineID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_BudgetID", this.BudgetID); command.Parameters.AddWithValue("@p_LineID", this.LineID); command.Parameters.AddWithValue("@p_OrderNo", this.OrderNo); command.Parameters.AddWithValue("@p_CategoryID", this.CategoryID); command.Parameters.AddWithValue("@p_FortnightAmount", ADOHelper.NullCheck(this.FortnightAmount)); command.Parameters.AddWithValue("@p_RequiresReceipt", this.RequiresReceipt); 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.ExecuteNonQuery(); _budgetLineIDProperty = (System.Int32)command.Parameters["@p_BudgetLineID"].Value; } UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnInserted(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Insert() { bool cancel = false; OnInserting(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_BankAccountCard_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_BankAccountCardID", this.BankAccountCardID); command.Parameters["@p_BankAccountCardID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_BankAccountID", this.BankAccountID); command.Parameters.AddWithValue("@p_CardNumber", this.CardNumber); command.Parameters.AddWithValue("@p_ExpDate", this.ExpDate); command.Parameters.AddWithValue("@p_HeldByStaffID", ADOHelper.NullCheck(this.HeldByStaffID)); command.Parameters.AddWithValue("@p_HeldFrom", ADOHelper.NullCheck(this.HeldFrom)); command.Parameters.AddWithValue("@p_HeldTo", ADOHelper.NullCheck(this.HeldTo)); 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.ExecuteNonQuery(); _bankAccountCardIDProperty = (System.Int32)command.Parameters["@p_BankAccountCardID"].Value; } UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnInserted(); }
/// <summary> /// Updates the corresponding record in the data base with the information in the current /// CSLA editable child business object of type <see cref="GLAccountType"/> /// </summary> /// <returns></returns> public void Child_Update(SqlConnection connection, SqlTransaction trans) { bool cancel = false; OnChildUpdating(connection, ref cancel, trans); if (cancel) { return; } if (connection.State != ConnectionState.Open) { connection.Open(); } 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."); } // Update non-identity primary key value. _gLAccountTypeIDProperty = (System.Int32)command.Parameters["@p_GLAccountTypeID"].Value; // Update non-identity primary key value. _originalGLAccountTypeIDProperty = this.GLAccountTypeID; } UpdateChildren(this, connection, trans); OnChildUpdated(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Update() { bool cancel = false; OnUpdating(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_BudgetLine_Update]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_BudgetLineID", this.BudgetLineID); command.Parameters.AddWithValue("@p_BudgetID", this.BudgetID); command.Parameters.AddWithValue("@p_LineID", this.LineID); command.Parameters.AddWithValue("@p_OrderNo", this.OrderNo); command.Parameters.AddWithValue("@p_CategoryID", this.CategoryID); command.Parameters.AddWithValue("@p_FortnightAmount", ADOHelper.NullCheck(this.FortnightAmount)); command.Parameters.AddWithValue("@p_RequiresReceipt", this.RequiresReceipt); 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)); //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."); } } UpdateChildren(this, connection, trans); //FieldManager.UpdateChildren(this, connection); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnUpdated(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Insert() { bool cancel = false; OnInserting(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_Address_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_AddressID", this.AddressID); command.Parameters["@p_AddressID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_Street", ADOHelper.NullCheck(this.Street)); command.Parameters.AddWithValue("@p_Suburb", ADOHelper.NullCheck(this.Suburb)); command.Parameters.AddWithValue("@p_StateID", ADOHelper.NullCheck(this.StateID)); command.Parameters.AddWithValue("@p_CountryID", ADOHelper.NullCheck(this.CountryID)); command.Parameters.AddWithValue("@p_PostCode", ADOHelper.NullCheck(this.PostCode)); 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.ExecuteNonQuery(); _addressIDProperty = (System.Int32)command.Parameters["@p_AddressID"].Value; } UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnInserted(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Insert() { bool cancel = false; OnInserting(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_GLAccountType_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; 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); command.ExecuteNonQuery(); } _originalGLAccountTypeIDProperty = this.GLAccountTypeID; UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnInserted(); }
private void AddAddressParams(SqlCommand command, AddressDTO address, string prefix) { bool hasPhysicalAddress = HasAddress(address); Address physicalAddress = null; if (hasPhysicalAddress) { command.Parameters.AddWithValue("@p_" + prefix + "Street", ADOHelper.NullCheck(address.Street)); command.Parameters.AddWithValue("@p_" + prefix + "Suburb", ADOHelper.NullCheck(address.Suburb)); command.Parameters.AddWithValue("@p_" + prefix + "StateID", ADOHelper.NullCheck(address.StateID)); command.Parameters.AddWithValue("@p_" + prefix + "CountryID", ADOHelper.NullCheck(address.CountryID)); command.Parameters.AddWithValue("@p_" + prefix + "PostCode", ADOHelper.NullCheck(address.PostCode)); command.Parameters.AddWithValue("@p_" + prefix + "AddressID", ADOHelper.NullCheck(address.AddressID)); } }
public void Child_Update(MailingTemplate mailingTemplate, SqlConnection connection, SqlTransaction trans) { bool cancel = false; OnChildUpdating(mailingTemplate, connection, ref cancel, trans); if (cancel) { return; } if (connection.State != ConnectionState.Open) { connection.Open(); } using (var command = new SqlCommand("[dbo].[spCFM_EmailQueue_Update]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_EmailQueueID", this.EmailQueueID); command.Parameters.AddWithValue("@p_MailingTemplateID", ADOHelper.NullCheck(mailingTemplate != null ? mailingTemplate.MailingTemplateID : this.MailingTemplateID)); command.Parameters.AddWithValue("@p_SendTo", ADOHelper.NullCheck(this.SendTo)); command.Parameters.AddWithValue("@p_MailingText", ADOHelper.NullCheck(this.MailingText)); command.Parameters.AddWithValue("@p_MailingSubject", ADOHelper.NullCheck(this.MailingSubject)); command.Parameters.AddWithValue("@p_MailingFrom", ADOHelper.NullCheck(this.MailingFrom)); command.Parameters.AddWithValue("@p_RequestedDate", this.RequestedDate); command.Parameters.AddWithValue("@p_ProcessedDate", ADOHelper.NullCheck(this.ProcessedDate)); command.Parameters.AddWithValue("@p_ProcessResult", ADOHelper.NullCheck(this.ProcessResult)); //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."); } // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query. if (mailingTemplate != null && mailingTemplate.MailingTemplateID != this.MailingTemplateID) { _mailingTemplateIDProperty = mailingTemplate.MailingTemplateID; } } // A child relationship exists on this Business Object but its type is not a child type (E.G. EditableChild). // TODO: Please override OnChildUpdated() and update this child manually. // UpdateChildren(this, connection); OnChildUpdated(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Insert() { bool cancel = false; OnInserting(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_FinAdministratorClient_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_FinAdministratorClientID", this.FinAdministratorClientID); command.Parameters["@p_FinAdministratorClientID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_FinAdministratorID", this.FinAdministratorID); command.Parameters.AddWithValue("@p_ClientId", this.ClientId); command.Parameters.AddWithValue("@p_StartDate", this.StartDate); command.Parameters.AddWithValue("@p_EndDate", ADOHelper.NullCheck(this.EndDate)); 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.ExecuteNonQuery(); } _originalFinAdministratorIDProperty = this.FinAdministratorID; UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnInserted(); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Insert() { bool cancel = false; OnInserting(ref cancel); if (cancel) { return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_EmailQueue_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_EmailQueueID", this.EmailQueueID); command.Parameters["@p_EmailQueueID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_MailingTemplateID", ADOHelper.NullCheck(this.MailingTemplateID)); command.Parameters.AddWithValue("@p_SendTo", ADOHelper.NullCheck(this.SendTo)); command.Parameters.AddWithValue("@p_MailingText", ADOHelper.NullCheck(this.MailingText)); command.Parameters.AddWithValue("@p_MailingSubject", ADOHelper.NullCheck(this.MailingSubject)); command.Parameters.AddWithValue("@p_MailingFrom", ADOHelper.NullCheck(this.MailingFrom)); command.Parameters.AddWithValue("@p_RequestedDate", this.RequestedDate); command.Parameters.AddWithValue("@p_ProcessedDate", ADOHelper.NullCheck(this.ProcessedDate)); command.Parameters.AddWithValue("@p_ProcessResult", ADOHelper.NullCheck(this.ProcessResult)); command.ExecuteNonQuery(); _emailQueueIDProperty = (System.Int32)command.Parameters["@p_EmailQueueID"].Value; } UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnInserted(); }