Пример #1
0
 public Group()
     : base(new List<Project>(), OClientTypes.Group)
 {
     _members = new List<Member>();
     _historyMembers = new List<Member>();
     _leader = new Member();
     TotalContractAmount = 0;
 }
Пример #2
0
        public void Copy_MembersAreCopied()
        {
            Person person = new Person {Id = 1, Active = true, BadClient = true};
            Member member = new Member {Tiers = person, IsLeader = true, CurrentlyIn = true};
            Group group = new Group {Id = 3,BadClient = false, Active = true, Members = new List<Member> {member}};

            Group clonedGroup = (Group)group.Copy();
            Assert.AreEqual(3, clonedGroup.Id);

            clonedGroup.Id = 7;
            Assert.AreEqual(3,group.Id);

            Assert.AreEqual(true, clonedGroup.Members[0].Tiers.BadClient);
            clonedGroup.Members[0].Tiers.BadClient = false;
            Assert.AreEqual(true, group.Members[0].Tiers.BadClient);
        }
Пример #3
0
        public void TestSaveGroupWhenNoEnoughMembers()
        {
            ApplicationSettings dataParam = GetDataBaseParam(4, true);

            ClientServices services = new ClientServices(dataParam);
            Member leader = new Member {Tiers = {Id = 1}};
            Group group = AddGroup(true, "Dushambe", new District(1, "district", new Province(1, "province")), "Nicolas", leader, 0);

            services.SaveSolidarityGroup(ref group);
        }
Пример #4
0
        public void TestSaveGroupWhenDistrictIsNull()
        {
            ApplicationSettings dataParam = GetDataBaseParam(4, true);

            ClientServices services = new ClientServices(dataParam);

            Member leader = new Member {Tiers = {Id = 1}};
            Group group = AddGroup(true, "Dushambe", null, "Nicolas", leader, 4);

            services.SaveSolidarityGroup(ref group);
        }
Пример #5
0
        public void TestUpdateGroupWhenNeedToRemovePersonsFromGroup()
        {
            _person.Id = _cltManagement.AddPerson(_person);
            Member member = new Member { Tiers = _person, LoanShareAmount = 1000, CurrentlyIn = true, IsLeader = false, JoinedDate = TimeProvider.Today };

            Person firstPersonToAdd = new Person
                                          {
                                              Active = true,
                                              City = "Dushambe",
                                              District = _district,
                                              FirstName = "Nicolas",
                                              LastName = "MANGIN",
                                              Sex = 'M',
                                              IdentificationData = "145VK133",
                                              HouseHoldHead = false,
                                              Branch = _branch
                                          };
            firstPersonToAdd.Id = _cltManagement.AddPerson(firstPersonToAdd);
            Member firstMemberToAdd = new Member { Tiers = firstPersonToAdd, LoanShareAmount = 1000, CurrentlyIn = true, IsLeader = false, JoinedDate = TimeProvider.Today };

            Person secondPersonToAdd = new Person
                                           {
                                               Active = true,
                                               City = "Dushambe",
                                               District = _district,
                                               FirstName = "Philippe",
                                               LastName = "BARON",
                                               Sex = 'M',
                                               IdentificationData = "2334KGHT",
                                               HouseHoldHead = false,
                                               Branch = _branch
                                           };
            secondPersonToAdd.Id = _cltManagement.AddPerson(secondPersonToAdd);
            Member secondMemberToAdd = new Member { Tiers = secondPersonToAdd, LoanShareAmount = 1000, CurrentlyIn = true, IsLeader = false, JoinedDate = TimeProvider.Today };

            _group.AddMember(member);
            _group.AddMember(firstMemberToAdd);
            _group.AddMember(secondMemberToAdd);

            _group.Id = _cltManagement.AddNewGroup(_group);

            Group selectedGroup = _cltManagement.SelectGroupById(_group.Id);
            Assert.AreEqual(3,selectedGroup.GetNumberOfMembers);

            _group.DeleteMember(member);
            _group.DeleteMember(secondMemberToAdd);

            _cltManagement.UpdateGroup(_group);

            selectedGroup = _cltManagement.SelectGroupById(_group.Id);
            Assert.AreEqual(1,selectedGroup.GetNumberOfMembers);

            Assert.IsFalse(SelectCurrentlyIn(_person.Id));
            Assert.IsFalse(SelectCurrentlyIn(secondPersonToAdd.Id));
        }
Пример #6
0
        public void TwoMembers_AreEgals()
        {
            Member a = new Member { Tiers = new Person { IdentificationData = "1234" } };
            Member b = new Member { Tiers = new Person { IdentificationData = "12346555" } };
            Member c = new Member { Tiers = new Person { IdentificationData = "1234" } };

            Assert.IsTrue(a == c);
            Assert.IsFalse(a == b);
        }
        private void ViewPerson(Member pMember, bool leader)
        {
            var personForm = new ClientForm((Person)pMember.Tiers, _mdiParent, ExtensionActivator);
            personForm.ShowDialog();

            if (leader && personForm.DialogResult == DialogResult.OK)
                group.Leader.Tiers = personForm.Person;

            group.IsBadClient();
            InitializeGroup();
            DisplayMembers();
        }
Пример #8
0
 public void DeleteMember(Member pMember)
 {
     _badClient = false;
     foreach (Member member in _members)
     {
         if (member == pMember)
         {
             member.CurrentlyIn = false;
             member.LeftDate = TimeProvider.Today;
         }
         else 
         {
             if (member.Tiers.BadClient) _badClient = true;
         }
     }
 }
Пример #9
0
        private void buttonSelectAGroupPerson_Click(object sender, EventArgs e)
        {
            List<Member> members =
                ServicesProvider.GetInstance().GetClientServices().FindHistoryPersonsByContract(((Group) _client).Id, _loan.Id);

            MembersOfGroup frmMembersOfTheGroup = new MembersOfGroup(members, _loan, dtpRepaymentDate.Value.Date);
            frmMembersOfTheGroup.ShowDialog();
            OCurrency memberRemainingAmount = frmMembersOfTheGroup.MemberRemainingAmount;

            if (memberRemainingAmount != 0)
            {
                _loan.EscapedMember = frmMembersOfTheGroup.Member;
                _escapedMember = frmMembersOfTheGroup.Member;
                _rbKeepInitialSchedule.Checked = false;
                _keepExpectedInstallment = false;
                _rbKeepNotInitialSchedule.Checked = true;

                gbTypeOfRepayment.Enabled = false;
                checkBoxTotalAmount.Enabled = false;
                nudICAmount.Enabled = false;
                nudECAmount.Enabled = false;
                checkBoxInterests.Enabled = false;
                _keepExpectedInstallment = false;
                nudICAmount.Value = memberRemainingAmount.Value;

                _principal = _repaymentEvent.Principal;
                _interest = _repaymentEvent.Interests;
                _commission = _repaymentEvent.Commissions;
            }
            else
            {
                _loan.EscapedMember = null;
            }
        }
Пример #10
0
 public void AddMember(Member pMember)
 {
     if (pMember.CurrentlyIn)
     {
         _members.Add(pMember);
         if (pMember.Tiers.BadClient)
         {
             _badClient = true;
         }
     }
     else
     {
         _historyMembers.Add(pMember);
     }
 }
Пример #11
0
        private void UpdatePersonToGroup(Member pMember, int groupId, bool leader, SqlTransaction sqlTransac)
        {
            string q = @"UPDATE [PersonGroupBelonging]
                               SET [is_leader]= @isLeader,
                                 [currently_in]= @currentlyIn,
                                 [left_date] = @leftDate
                               WHERE [person_id]= @personId
                               AND [group_id]= @groupId";

            using (OpenCbsCommand c = new OpenCbsCommand(q, sqlTransac.Connection, sqlTransac))
            {
                c.AddParam("@personId", pMember.Tiers.Id);
                c.AddParam("@groupId", groupId);
                c.AddParam("@isLeader", leader);
                c.AddParam("@leftDate", null);
                c.AddParam("@currentlyIn", true);

                c.ExecuteNonQuery();
            }
        }
Пример #12
0
        private List<Member> SelectPersonIdsByGroupId(int groupId, SqlTransaction transac, bool? currentlyIn)
        {
            List<Member> idsList = new List<Member>();

            string q = @"SELECT person_id,
                                             is_leader,
                                             currently_in,
                                             joined_date,
                                             left_date
                                           FROM [PersonGroupBelonging]
                                           WHERE group_id = @id";

            if (currentlyIn.HasValue)
            {
                if (currentlyIn.Value)
                {
                    q += " AND currently_in = 1";
                }
                else
                {
                    q += " AND currently_in = 0";
                }
            }

            using (OpenCbsCommand c = new OpenCbsCommand(q, transac.Connection, transac))
            {
                c.AddParam("@id", groupId);
                using (OpenCbsReader r = c.ExecuteReader())
                {
                    if (r != null)
                    {
                        while (r.Read())
                        {
                            Member member = new Member
                            {
                                Tiers = { Id = r.GetInt("person_id") },
                                CurrentlyIn = r.GetBool("currently_in"),
                                IsLeader = r.GetBool("is_leader"),
                                JoinedDate = r.GetDateTime("joined_date"),
                                LeftDate = r.GetNullDateTime("left_date"),
                            };
                            idsList.Add(member);
                        }
                    }
                }
            }
            return idsList;
        }
Пример #13
0
        private void AddMemberToGroup(Member pMember, Group group, bool leader, SqlTransaction sqlTransac)
        {
            string q = @"INSERT INTO [PersonGroupBelonging]
                                    (
                                         [person_id]
                                        ,[group_id]
                                        ,[is_leader]
                                        ,[currently_in]
                                        ,[joined_date]
                                        ,[left_date]
                                    )
                                VALUES
                                    (
                                        @personId
                                        ,@groupId
                                        ,@isLeader
                                        ,@currentlyIn
                                        ,@joinedDate
                                        ,@leftDate
                                    )";

            using (OpenCbsCommand c = new OpenCbsCommand(q, sqlTransac.Connection, sqlTransac))
            {
                c.AddParam("@personId", pMember.Tiers.Id);
                c.AddParam("@groupId", group.Id);
                c.AddParam("@isLeader", leader);
                c.AddParam("@currentlyIn", true);
                c.AddParam("@joinedDate", TimeProvider.Today);
                c.AddParam("@leftDate", null);

                c.ExecuteNonQuery();
            }
        }
Пример #14
0
        public List<Member> SelectHistoryPersonsInAGroup(int pGroupId, int pContractId)
        {
            List<Member> members = new List<Member>();

            string q = @"SELECT
                                  p.person_id,
                                  p.group_id,
                                  p.is_leader,
                                  p.currently_in,
                                  p.joined_date,
                                  p.left_date
                                FROM LoanShareAmounts l
                                INNER JOIN PersonGroupBelonging p
                                  ON l.person_id = p.person_id
                                    AND l.group_id = p.group_id
                                WHERE contract_id = @contract_id
                                  AND l.group_id = @group_id";

            using (SqlConnection conn = GetConnection())
            using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
            {
                c.AddParam("@group_id", pGroupId);
                c.AddParam("@contract_id", pContractId);

                using (OpenCbsReader r = c.ExecuteReader())
                {
                    if (r != null)
                    {
                        while (r.Read())
                        {
                            Member member = new Member
                                                {
                                                    Tiers = { Id = r.GetInt("person_id") },
                                                    CurrentlyIn = r.GetBool("currently_in"),
                                                    IsLeader = r.GetBool("is_leader"),
                                                    JoinedDate = r.GetDateTime("joined_date"),
                                                    LeftDate = r.GetNullDateTime("left_date"),
                                                };
                            members.Add(member);
                        }
                    }
                }
            }

            foreach (Member entry in members)
            {
                entry.Tiers = SelectPersonById(entry.Tiers.Id);
            }

            return members;
        }
Пример #15
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (listViewMembers.SelectedItems.Count > 0)
            {
                Member member = (Member) listViewMembers.SelectedItems[0].Tag;

                if (!member.IsLeader && member.CurrentlyIn)
                {
                    OCurrency loanShareAmount = 0;

                    foreach (LoanShare loanShare in _loan.LoanShares)
                    {
                        if (loanShare.PersonId == member.Tiers.Id)
                        {
                            loanShareAmount = loanShare.Amount;
                        }
                    }

                    member.LoanShareAmount = loanShareAmount;
                    member.CurrentlyIn = false;
                    _loan.EscapedMember = member;
                    _memberAmount =
                        _loan.CalculateMaximumAmountForEscapedMember(
                            _loan.NbOfInstallments - _loan.NbOfInstallmentsNotRepaid + 1,
                            _paymentDate, false, 0, 0, false, 0, false, loanShareAmount);
                    
                    Member = member;
                    Close();
                }
            }
        }
Пример #16
0
        public void TestSaveGroupWhenOtherOrganizationDebtsIsBadlyInformed()
        {
            ApplicationSettings dataParam = GetDataBaseParam(4, true);

            ClientServices services = new ClientServices(dataParam);

            Member leader = new Member {Tiers = {Id = 1}};
            Group group = AddGroup(true, "Dushambe", new District(1, "district", new Province(1, "province")), "Nicolas", leader, 4);
            group.OtherOrgAmount = 100;
            group.OtherOrgDebts = ERRORVALUE;

            services.SaveSolidarityGroup(ref group);
        }
Пример #17
0
        private static Group AddGroup(bool active, string city, District district, string name, Member leader, int NbOfMembers)
        {
            Group group = new Group {Active = active, City = city, District = district, Name = name, Leader = leader};

            for (int i = 0; i < NbOfMembers; i++)
            {
                group.AddMember(new Member { Tiers = new Person(), LoanShareAmount = 1000 + i, CurrentlyIn = true, IsLeader = true, JoinedDate = TimeProvider.Today });
            }
            return group;
        }
Пример #18
0
 public bool IsLeader(Member pMember)
 {
     return ((Person)_leader.Tiers).IdentificationData == ((Person)pMember.Tiers).IdentificationData;
 }
Пример #19
0
        public void AddMember(Member pMember)
        {
            _members.Add(pMember);

            if (pMember.Tiers.BadClient) _badClient = true;
        }
Пример #20
0
 public void DeleteMember(Member pMember)
 {
     Member tempMember = _members.FirstOrDefault(member => ((Person)member.Tiers).IdentificationData == ((Person)pMember.Tiers).IdentificationData);
     if (tempMember != null)
     {
         _members.Remove(tempMember);
         pMember.LeftDate = TimeProvider.Today;
         pMember.Tiers.Active = false;
     }
     IsBadClient();
 }
Пример #21
0
        private void SelectAMember()
        {
            if (GroupHasActiveContracts())
            {
                using (SearchClientForm searchClientForm = SearchClientForm.GetInstance(OClientTypes.Person, true))
                {
                    searchClientForm.ShowDialog();
                    try
                    {
                        if (group.Id != 0)
                            ServicesProvider.GetInstance().GetClientServices().CheckMaxNumberOfMembers(group);
                        if (ServicesProvider.GetInstance().GetClientServices().ClientIsAPerson(searchClientForm.Client))
                        {
                            Member pers = new Member
                                              {
                                                  Tiers = searchClientForm.Client,
                                                  LoanShareAmount = 0,
                                                  CurrentlyIn = true,
                                                  IsLeader = false,
                                                  JoinedDate = TimeProvider.Today
                                              };

                            if (ServicesProvider.GetInstance().GetClientServices().ClientCanBeAddToAGroup(searchClientForm.Client, group))
                            {
                                group.AddMember(pers);
                                DisplayMembers();
                                if (group.Id != 0)
                                    ServicesProvider.GetInstance().GetContractServices().DeleteLoanShareAmountWhereNotDisbursed(group.Id);
                                if (MembersChanged != null) MembersChanged(this, null);
                                if (group.Id != 0)
                                    buttonSave_Click(this, null);

                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
                    }
                }
            }
        }
Пример #22
0
        public void TestIsLeaderWhenTrue()
        {
            _person.Id = _cltManagement.AddPerson(_person);
            Member member = new Member { Tiers = _person, LoanShareAmount = 1000, CurrentlyIn = true, IsLeader = true, JoinedDate = TimeProvider.Today };
            _group.AddMember(member);
            _group.Leader = member;

            _group.Id = _cltManagement.AddNewGroup(_group);

            Assert.IsTrue(_cltManagement.IsLeader(_person.Id, _group.Id));
        }
Пример #23
0
 private void _ChangeLeader(Member newLeader)
 {
     group.Leader = newLeader;
     DisplayMembers();
 }
Пример #24
0
        public void TwoMembers_NotEgals_NullValues()
        {
            Member a = new Member { Tiers = new Person { IdentificationData = "1234" } };
            Member b = null;

            Assert.IsTrue(a != b);
        }