Beispiel #1
0
        private void BtnSelectContactClick(object sender, EventArgs e)
        {
            using (SearchClientForm searchClientForm = SearchClientForm.GetInstance(OClientTypes.Person, true))
            {
                searchClientForm.ShowDialog();
                var contact = new Contact();
                try
                {
                    if (searchClientForm.Client != null)
                        contact.Tiers = searchClientForm.Client;

                    if (!ServicesProvider.GetInstance().GetClientServices().ClientCanBeAddToCorporate(
                        searchClientForm.Client, Corporate)) return;

                    if (contact.Tiers != null)
                        Corporate.Contacts.Add(contact);

                    DisplayListContactCorporate(Corporate.Contacts);
                }
                catch (Exception ex)
                {
                    new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
                }
            }
        }
Beispiel #2
0
        public void AddBodyCorporatePerson(int pCorporateId, Contact contact, SqlTransaction sqlTransac)
        {
            string q = "INSERT INTO [CorporatePersonBelonging] (corporate_id, person_id, position) VALUES (@corporate_id, @person_id, @position)";

            using (OpenCbsCommand c = new OpenCbsCommand(q, sqlTransac.Connection, sqlTransac))
            {
                c.AddParam("@corporate_id", pCorporateId);
                c.AddParam("@person_id", contact.Tiers.Id);
                c.AddParam("@position", contact.Position);
                c.ExecuteScalar();
            }
        }
Beispiel #3
0
 private void BtnAddContactClick(object sender, EventArgs e)
 {
     var personForm = new ClientForm(OClientTypes.Person, _mdifrom, true, _applicationController);
     personForm.ShowDialog();
     Contact contact = new Contact {Tiers = personForm.Person};
     if (contact.Tiers != null)
         Corporate.Contacts.Add(contact);
     DisplayListContactCorporate(Corporate.Contacts);
 }
Beispiel #4
0
        public Corporate SelectBodyCorporateById(int id)
        {
            int? activityId = null;
            int? districtId = null;
            int? secondaryDistrictId = null;

            Corporate body = null;
            const string q = @" SELECT * FROM Tiers
            INNER JOIN Corporates ON Tiers.id = Corporates.id
            WHERE [deleted] = 0 AND Tiers.id=@id";

            using (SqlConnection conn = GetConnection())
            using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
            {
                c.AddParam("@id", id);

                using (OpenCbsReader r = c.ExecuteReader())
                {
                    if (r != null && !r.Empty)
                    {
                        r.Read();
                        body = new Corporate
                                   {
                                       Id = r.GetInt("id"),
                                       Name = r.GetString("name"),
                                       Status = (OClientStatus)r.GetSmallInt("status"),
                                       IsDeleted = r.GetBool("deleted"),
                                       CashReceiptIn = r.GetNullInt("cash_input_voucher_number"),
                                       CashReceiptOut =
                                           r.GetNullInt("cash_output_voucher_number"),
                                       Type = r.GetChar("client_type_code") == 'I'
                                                  ? OClientTypes.Person
                                                  : r.GetChar("client_type_code") == 'G'
                                                        ? OClientTypes.Group
                                                        : OClientTypes.Corporate,
                                       Scoring = r.GetNullDouble("scoring"),
                                       LoanCycle = r.GetInt("loan_cycle"),
                                       Active = r.GetBool("active"),
                                       BadClient = r.GetBool("bad_client"),
                                       OtherOrgName = r.GetString("other_org_name"),
                                       OtherOrgAmount = r.GetMoney("other_org_amount"),
                                       OtherOrgDebts = r.GetMoney("other_org_debts"),
                                       City = r.GetString("city"),
                                       Address = r.GetString("address"),
                                       SecondaryCity = r.GetString("secondary_city"),
                                       SecondaryAddress = r.GetString("secondary_address"),
                                       HomePhone = r.GetString("home_phone"),
                                       PersonalPhone = r.GetString("personal_phone"),
                                       SecondaryHomePhone = r.GetString("secondary_home_phone"),
                                       SecondaryPersonalPhone = r.GetString("secondary_personal_phone"),
                                       VolunteerCount = r.GetNullInt("volunteer_count"),
                                       EmployeeCount = r.GetNullInt("employee_count"),
                                       Sigle = r.GetString("sigle"),
                                       Siret = r.GetString("siret"),
                                       SmallName = r.GetString("small_name"),
                                       CreationDate = r.GetDateTime("creation_date"),
                                       AgrementDate = r.GetNullDateTime("agrement_date"),
                                       FollowUpComment = r.GetString("follow_up_comment"),
                                       HomeType = r.GetString("home_type"),
                                       SecondaryHomeType = r.GetString("secondary_hometype"),
                                       ZipCode = r.GetString("zipCode"),
                                       SecondaryZipCode = r.GetString("secondary_zipCode"),
                                       Sponsor1 = r.GetString("sponsor1"),
                                       Sponsor2 = r.GetString("sponsor2"),
                                       Sponsor1Comment = r.GetString("sponsor1_Comment"),
                                       Sponsor2Comment = r.GetString("sponsor2_comment"),
                                       FiscalStatus = r.GetString("fiscal_status"),
                                       Registre = r.GetString("registre"),
                                       LegalForm = r.GetString("legalForm"),
                                       InsertionType = r.GetString("insertionType"),
                                       Email = r.GetString("e_mail"),
                                       FavouriteLoanOfficerId = r.GetNullInt("loan_officer_id"),
                                       Branch = new Branch { Id = r.GetInt("branch_id") },
                                       RegistrationDate = r.GetNullDateTime("date_create") ?? TimeProvider.Today
                                   };

                        districtId = r.GetNullInt("district_id");
                        secondaryDistrictId = r.GetNullInt("secondary_district_id");
                        activityId = r.GetNullInt("activity_id");
                    }
                }
            }
            if (body != null)
            {
                if (body.FavouriteLoanOfficerId != null)
                {
                    UserManager userManager = new UserManager(User.CurrentUser);
                    body.FavouriteLoanOfficer = userManager.SelectUser((int)body.FavouriteLoanOfficerId, true);
                }
            }

            if (districtId.HasValue) body.District = _locations.SelectDistrictById(districtId.Value);

            if (secondaryDistrictId.HasValue) body.SecondaryDistrict = _locations.SelectDistrictById(secondaryDistrictId.Value);

            if (activityId.HasValue) body.Activity = _doam.SelectEconomicActivity(activityId.Value);

            if (body != null)
            {
                if (_projectManager != null)
                    body.AddProjects(_projectManager.SelectProjectsByClientId(body.Id));
                if (_savingManager != null)
                    body.AddSavings(_savingManager.SelectSavings(body.Id));
            }

            // Selecting Corporate contacts - Not very logical, but asked by Julien M.
            const string sqlContactText = @"
                                 SELECT Persons.id,
                                        Persons.first_name,
                                        Persons.last_name,
                                        Tiers.home_phone,
                                        Tiers.personal_phone,
                                        CorporatePersonBelonging.position
                                 FROM Tiers
                                 INNER JOIN CorporatePersonBelonging ON Tiers.id = CorporatePersonBelonging.person_id
                                 INNER JOIN Persons ON Tiers.id = Persons.id
                                 WHERE CorporatePersonBelonging.corporate_id = @id";

            Person person = null;
            Contact contact = null;
            List<Contact> contacts = new List<Contact>();

            using (SqlConnection conn = GetConnection())
            using (OpenCbsCommand c = new OpenCbsCommand(sqlContactText, conn))
            {
                c.AddParam("@id", id);

                using (OpenCbsReader r = c.ExecuteReader())
                {
                    if (r != null && !r.Empty)
                    {
                        while (r.Read())
                        {
                            person = new Person()
                                         {
                                             Id = r.GetInt("id"),
                                             FirstName = r.GetString("first_name"),
                                             LastName = r.GetString("last_name"),
                                             PersonalPhone = r.GetString("personal_phone"),
                                             HomePhone = r.GetString("home_phone")
                                         };

                            contact = new Contact()
                                          {
                                              Tiers = person,
                                              Position = r.GetString("position")
                                          };
                            contacts.Add(contact);
                        }
                    }
                }
            }

            body.Contacts = contacts;

            OnClientSelected(body);

            return body;
        }