예제 #1
0
        public void AddEconomicActivityLoanHistory(EconomicActivityLoanHistory activityLoanHistory, SqlTransaction sqlTransaction)
        {
            const string sqlText = @"INSERT INTO EconomicActivityLoanHistory
                                    ([contract_id],[person_id],[group_id],[economic_activity_id],[deleted])
                                    VALUES (@contract_id, @person_id, @group_id, @economic_activity_id, @deleted)";

            using (OpenCbsCommand insert = new OpenCbsCommand(sqlText, sqlTransaction.Connection, sqlTransaction))
            {
                insert.AddParam("@contract_id",  activityLoanHistory.Contract.Id);
                insert.AddParam("@person_id",  activityLoanHistory.Person.Id);
                if (activityLoanHistory.Group != null)
                    insert.AddParam("@group_id", activityLoanHistory.Group.Id);
                else
                    insert.AddParam("@group_id", null);
                insert.AddParam("@economic_activity_id", activityLoanHistory.EconomicActivity.Id);
                insert.AddParam("@deleted",  activityLoanHistory.Deleted);

                insert.ExecuteNonQuery();
            }
        }
예제 #2
0
        private void SetEconomicActivity(Loan pLoan, SqlTransaction sqlTransaction)
        {
            // Write EconomicActivityLoanHistory object
            EconomicActivityLoanHistory activityLoanHistory;

            if (pLoan.Project.Client is Person)
            {
                if (
                    !_econimcActivityServices.EconomicActivityLoanHistoryExists(pLoan.Id, pLoan.Project.Client.Id,
                                                                                sqlTransaction))
                {
                    activityLoanHistory = new EconomicActivityLoanHistory
                        {
                            Contract = pLoan,
                            Deleted = false,
                            Group = null,
                            Person = pLoan.Project.Client,
                            EconomicActivity = ((Person) pLoan.Project.Client).Activity
                        };
                    _econimcActivityServices.AddEconomicActivityLoanHistory(activityLoanHistory, sqlTransaction);
                }
                else
                {
                    if (_econimcActivityServices.EconomicActivityLoanHistoryDeleted(pLoan.Id,
                                                                                    pLoan.Project.Client.Id,
                                                                                    sqlTransaction))
                        _econimcActivityServices.UpdateDeletedEconomicActivityLoanHistory(pLoan.Id,
                                                                                          pLoan.Project.Client.Id,
                                                                                          ((Person)
                                                                                           pLoan.Project.Client).
                                                                                              Activity.Id,
                                                                                          sqlTransaction, false);
                }
            }
            else if (pLoan.Project.Client is Group)
            {
                foreach (Member member in ((Group) pLoan.Project.Client).Members)
                {
                    if (
                        !_econimcActivityServices.EconomicActivityLoanHistoryExists(pLoan.Id, member.Tiers.Id,
                                                                                    sqlTransaction))
                    {
                        activityLoanHistory = new EconomicActivityLoanHistory
                            {
                                Contract = pLoan,
                                Deleted = false,
                                Group = (Group) pLoan.Project.Client,
                                Person = member.Tiers,
                                EconomicActivity = ((Person) member.Tiers).Activity
                            };
                        _econimcActivityServices.AddEconomicActivityLoanHistory(activityLoanHistory, sqlTransaction);
                    }
                    else
                    {
                        if (_econimcActivityServices.EconomicActivityLoanHistoryDeleted(pLoan.Id, member.Tiers.Id,
                                                                                        sqlTransaction))
                            _econimcActivityServices.UpdateDeletedEconomicActivityLoanHistory(pLoan.Id,
                                                                                              member.Tiers.Id,
                                                                                              ((Person) member.Tiers)
                                                                                                  .Activity.Id,
                                                                                              sqlTransaction, false);
                    }
                }
            }
            else if (pLoan.Project.Client is Corporate)
            {
                if (((Corporate) pLoan.Project.Client).Activity == null)
                    throw new OpenCbsTiersSaveException(OpenCbsTiersSaveExceptionEnum.EconomicActivityIsNull);

                if (
                    !_econimcActivityServices.EconomicActivityLoanHistoryExists(pLoan.Id,
                                                                                pLoan.Project.Client.Id,
                                                                                sqlTransaction))
                {
                    activityLoanHistory = new EconomicActivityLoanHistory
                        {
                            Contract = pLoan,
                            Deleted = false,
                            Group = null,
                            Person = pLoan.Project.Client,
                            EconomicActivity = ((Corporate) pLoan.Project.Client).Activity
                        };
                    _econimcActivityServices.AddEconomicActivityLoanHistory(activityLoanHistory, sqlTransaction);
                }
                else
                {
                    if (_econimcActivityServices.EconomicActivityLoanHistoryDeleted(pLoan.Id,
                                                                                    pLoan.Project.Client.Id,
                                                                                    sqlTransaction))
                        _econimcActivityServices.UpdateDeletedEconomicActivityLoanHistory(pLoan.Id,
                                                                                          pLoan.Project.Client.
                                                                                                Id,
                                                                                          ((Corporate)
                                                                                           pLoan.Project.Client)
                                                                                              .Activity.Id,
                                                                                          sqlTransaction, false);
                }
            }
        }
예제 #3
0
 public void AddEconomicActivityLoanHistory(EconomicActivityLoanHistory activityLoanHistory, SqlTransaction sqlTransaction)
 {
     _doam.AddEconomicActivityLoanHistory(activityLoanHistory, sqlTransaction);
 }