public void UpdateAccountingRule(IAccountingRule rule) { const string sqlText = @"UPDATE [AccountingRules] SET [debit_account_number_id] = @debit_account_number_id, [credit_account_number_id] = @credit_account_number_id, [booking_direction] = @booking_direction, [event_type] = @event_type, [event_attribute_id] = @event_attribute_id, [order] = @order, [description] = @description WHERE id = @id"; using (SqlConnection conn = GetConnection()) { using (OpenCbsCommand cmd = new OpenCbsCommand(sqlText, conn)) { cmd.AddParam("@id", rule.Id); cmd.AddParam("@debit_account_number_id", rule.DebitAccount.Id); cmd.AddParam("@credit_account_number_id", rule.CreditAccount.Id); cmd.AddParam("@event_type", rule.EventType.EventCode); cmd.AddParam("@event_attribute_id", rule.EventAttribute.Id); cmd.AddParam("@booking_direction", (int)rule.BookingDirection); cmd.AddParam("@order", rule.Order); cmd.AddParam("@description", rule.Description); cmd.ExecuteNonQuery(); } } if (rule is ContractAccountingRule) { UpdateContractAccountingRule(rule as ContractAccountingRule); } }
public void DeleteAccountingRule(IAccountingRule pRule) { const string sqlText = @"UPDATE [AccountingRules] SET [deleted] = 1 WHERE id = @id"; using (SqlConnection conn = GetConnection()) { using (OpenCbsCommand delete = new OpenCbsCommand(sqlText, conn)) { delete.AddParam("@id", pRule.Id); delete.ExecuteNonQuery(); } } }
public int AddAccountingRule(IAccountingRule pRule) { const string sqlText = @"INSERT INTO [AccountingRules] ( [debit_account_number_id], [credit_account_number_id], [rule_type], [booking_direction], [event_type], [event_attribute_id], [order], [description]) VALUES (@debit_account_number_id, @credit_account_number_id, @rule_type, @booking_direction, @event_type, @event_attribute_id, @order, @description) SELECT SCOPE_IDENTITY()"; using (SqlConnection conn = GetConnection()) { using (OpenCbsCommand insert = new OpenCbsCommand(sqlText, conn)) { insert.AddParam("@debit_account_number_id", pRule.DebitAccount.Id); insert.AddParam("@credit_account_number_id", pRule.CreditAccount.Id); insert.AddParam("@rule_type", pRule is ContractAccountingRule ? 'C' : 'F'); insert.AddParam("@booking_direction", (int)pRule.BookingDirection); insert.AddParam("@event_type", pRule.EventType.EventCode); insert.AddParam("@event_attribute_id", pRule.EventAttribute.Id); insert.AddParam("@order", pRule.Order); insert.AddParam("@description", pRule.Description); pRule.Id = Convert.ToInt32(insert.ExecuteScalar()); } } if (pRule is ContractAccountingRule) { AddContractAccountingRule(pRule as ContractAccountingRule); } return(pRule.Id); }
private void ValidateAccountingRule(IAccountingRule pRule) { if (!_validateAccount(pRule.DebitAccount)) { throw new OpenCbsAccountingRuleException(OpenCbsAccountingRuleExceptionEnum.GenericAccountIsInvalid); } if (!_validateAccount(pRule.CreditAccount)) { throw new OpenCbsAccountingRuleException(OpenCbsAccountingRuleExceptionEnum.SpecificAccountIsInvalid); } if (pRule.DebitAccount.Id == pRule.CreditAccount.Id) { throw new OpenCbsAccountingRuleException(OpenCbsAccountingRuleExceptionEnum.GenericAndSpecificAccountsAreIdentical); } if (pRule is ContractAccountingRule) { ValidateContractAccountingRule(pRule as ContractAccountingRule); } }
public void DeleteAccountingRule(IAccountingRule pRule) { _accountingRuleManager.DeleteAccountingRule(pRule); }
public void UpdateAccountingRule(IAccountingRule pRule) { ValidateAccountingRule(pRule); _accountingRuleManager.UpdateAccountingRule(pRule); }
public int SaveAccountingRule(IAccountingRule pRule) { ValidateAccountingRule(pRule); return(_accountingRuleManager.AddAccountingRule(pRule)); }
public int SaveAccountingRule(IAccountingRule pRule) { ValidateAccountingRule(pRule); return _accountingRuleManager.AddAccountingRule(pRule); }
private void ValidateAccountingRule(IAccountingRule pRule) { if (!_validateAccount(pRule.DebitAccount)) throw new OpenCbsAccountingRuleException(OpenCbsAccountingRuleExceptionEnum.GenericAccountIsInvalid); if (!_validateAccount(pRule.CreditAccount)) throw new OpenCbsAccountingRuleException(OpenCbsAccountingRuleExceptionEnum.SpecificAccountIsInvalid); if (pRule.DebitAccount.Id == pRule.CreditAccount.Id) throw new OpenCbsAccountingRuleException(OpenCbsAccountingRuleExceptionEnum.GenericAndSpecificAccountsAreIdentical); if (pRule is ContractAccountingRule) ValidateContractAccountingRule(pRule as ContractAccountingRule); }
public int AddAccountingRule(IAccountingRule pRule) { const string sqlText = @"INSERT INTO [AccountingRules] ( [debit_account_number_id], [credit_account_number_id], [rule_type], [booking_direction], [event_type], [event_attribute_id], [order], [description]) VALUES (@debit_account_number_id, @credit_account_number_id, @rule_type, @booking_direction, @event_type, @event_attribute_id, @order, @description) SELECT SCOPE_IDENTITY()"; using (SqlConnection conn = GetConnection()) { using (OpenCbsCommand insert = new OpenCbsCommand(sqlText, conn)) { insert.AddParam("@debit_account_number_id", pRule.DebitAccount.Id); insert.AddParam("@credit_account_number_id", pRule.CreditAccount.Id); insert.AddParam("@rule_type", pRule is ContractAccountingRule ? 'C' : 'F'); insert.AddParam("@booking_direction", (int)pRule.BookingDirection); insert.AddParam("@event_type", pRule.EventType.EventCode); insert.AddParam("@event_attribute_id", pRule.EventAttribute.Id); insert.AddParam("@order", pRule.Order); insert.AddParam("@description", pRule.Description); pRule.Id = Convert.ToInt32(insert.ExecuteScalar()); } } if (pRule is ContractAccountingRule) AddContractAccountingRule(pRule as ContractAccountingRule); return pRule.Id; }
public void UpdateAccountingRule(IAccountingRule rule) { const string sqlText = @"UPDATE [AccountingRules] SET [debit_account_number_id] = @debit_account_number_id, [credit_account_number_id] = @credit_account_number_id, [booking_direction] = @booking_direction, [event_type] = @event_type, [event_attribute_id] = @event_attribute_id, [order] = @order, [description] = @description WHERE id = @id"; using (SqlConnection conn = GetConnection()) { using (OpenCbsCommand cmd = new OpenCbsCommand(sqlText, conn)) { cmd.AddParam("@id", rule.Id); cmd.AddParam("@debit_account_number_id", rule.DebitAccount.Id); cmd.AddParam("@credit_account_number_id", rule.CreditAccount.Id); cmd.AddParam("@event_type", rule.EventType.EventCode); cmd.AddParam("@event_attribute_id", rule.EventAttribute.Id); cmd.AddParam("@booking_direction", (int)rule.BookingDirection); cmd.AddParam("@order", rule.Order); cmd.AddParam("@description", rule.Description); cmd.ExecuteNonQuery(); } } if (rule is ContractAccountingRule) UpdateContractAccountingRule(rule as ContractAccountingRule); }