public ClientAndCustomerContacts GetCustomerClientContact(int customerId) { if (customerId == int.MinValue || customerId == 0) { return(null); } ClientAndCustomerContacts clientAndCustomerContacts = null; using (SqlConnection connection = CreateConnection()) { using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, "GetCustomerAndClientContact", CreateCustomerIdParameter(customerId, true))) { CleverReader cleverReader = new CleverReader(dataReader); if (!cleverReader.IsNull && cleverReader.Read()) { ClientContact clientContact = new ClientContactBuilder(cleverReader).Build(); cleverReader.NextResult(); cleverReader.Read(); CustomerContact customerContact = new CustomerContactBuilder(cleverReader).Build(); clientAndCustomerContacts = new ClientAndCustomerContacts(clientContact, customerContact); } } } return(clientAndCustomerContacts); }
public void LoadClientAndCustomerContact(CffCustomer customer, ICffClient client) { if (customer == null) { view.ClearCffCustomerContactAndLeftInfomationPanel(); view.DisplayCustomerNameAndClientNameInSearchBox(); return; } ClientAndCustomerContacts clientAndCustomerContacts = customerRepository.GetCustomerClientContact(customer.Id); int clientID = (client == null) ? clientAndCustomerContacts.ClientContact.ClientId : client.Id; ClientAndCustomerInformation cffCustomer = customerRepository.GetMatchedCustomerInfo(customer.Id, clientID); ClientInformation clientInfo = customerRepository.GetMatchedClientInfo(clientID).ClientInformation; if (clientAndCustomerContacts != null) { //MSarza [20150901] //if (clientInfo.AdministeredBy.ToLower() == "no") //{ clientAndCustomerContacts.isClientAdministeredByCFF = false; } //else //{ // clientAndCustomerContacts.isClientAdministeredByCFF = true; //} if (clientInfo.IsClientDebtorAdmin) { clientAndCustomerContacts.ClientIsDebtorAdmin = false; } else { clientAndCustomerContacts.ClientIsDebtorAdmin = true; } if (clientInfo.IsCffDebtorAdminForClient) { clientAndCustomerContacts.CffIsDebtorAdminForClient = false; } else { clientAndCustomerContacts.CffIsDebtorAdminForClient = true; } } view.SetFocusToForm(); if (clientAndCustomerContacts == null) { clientAndCustomerContacts = new ClientAndCustomerContacts(customerRepository.GetClientContactDetails(clientID), null); } view.DisplayClientAndCustomerContacts(clientAndCustomerContacts); //view.DisplayCustomerInformation(cffCustomer); decimal limit = 0; decimal available = 0; if (clientInfo.FacilityType == "Current A/c") { limit = GetCurrentACLimitFromDrMgt(client.Id, System.DateTime.Today); if (cffCustomer.CffCustomerInformation.CreditLimit <= limit) { available = (cffCustomer.CffCustomerInformation.CreditLimit - cffCustomer.CffCustomerInformation.AgeingBalances.Balance); } else { available = (limit - cffCustomer.CffCustomerInformation.AgeingBalances.Balance); } } view.DisplayCustomerInformation(cffCustomer, clientInfo.FacilityType, limit, available); }