public CffCustomer GetCffCustomerByClientIdAndCustomerId(int clientId, int customerId) { CffCustomer customer = null; using (SqlConnection connection = CreateConnection()) { using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, "Customers_GetCustomerByClientAndCustomerID", CreateClientAndCustomerIdParameters(clientId, customerId))) { CleverReader cleverReader = new CleverReader(dataReader); if (!cleverReader.IsNull && cleverReader.Read()) { customer = new CffCustomerBuilder(cleverReader).Build(); } } } return(customer); }
public ClientAndCustomerInformation GetMatchedCustomerInfo(int customerId, int clientId) { if (customerId == int.MinValue || customerId == 0) { return(null); } ClientAndCustomerInformation clientAndCustomerInformation = null; using (SqlConnection connection = CreateConnection()) { //DataTable schema = null; //using (var schemaCommand = new SqlCommand("exec GetCustomerInfo 910823", connection)) //{ // connection.Open(); // using (var reader = schemaCommand.ExecuteReader(CommandBehavior.SchemaOnly)) // { // reader.NextResult(); // reader.Read(); // schema = reader.GetSchemaTable(); // reader.NextResult(); // reader.Read(); // schema = reader.GetSchemaTable(); // reader.NextResult(); // reader.Read(); // schema = reader.GetSchemaTable(); // } //} //DataTable schema = null; using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, "GetCustomerInfo", CreateCustomerIdParameter(customerId, false))) { CleverReader reader = new CleverReader(dataReader); if (!reader.IsNull && reader.Read()) { IDate lastPaid = reader.ToNullableDate("lastRecDt"); decimal lastAmount = reader.ToDecimal("lastRecAmt"); reader.NextResult(); AgeingBalances ageingBalances = new AgeingBalancesBuilder(reader).Build(); reader.NextResult(); reader.Read(); CffClient client = new CffClientBuilder(reader).Build(); //CffClient client = new CffClientBuilderCleverReader(reader).Build(); CffClientInformation cffClientInformation = new CffClientInformationBuilder(reader).Build(client); ClientCustomerTerm clientCustomerTerm = new ClientCustomerTermBuilder(reader).Build(); CffCustomer customer = new CffCustomerBuilder(reader).Build(customerId); CffCustomerInformation customerInformation = new CffCustomerInformationBuilder(reader).Build(customer, lastPaid, lastAmount, clientCustomerTerm, ageingBalances); //MSarza [20151001] reader.NextResult(); reader.Read(); CffCustomerContact defaultCustContact = new CffCustomerContactBuilder(reader).Build(); //MSarza [20150731] reader.NextResult(); reader.Read(); CffMgtDetails cffMgtDetails = new CffMgtDetailsBuilder(reader).Build(); clientAndCustomerInformation = new ClientAndCustomerInformation(customerInformation, cffClientInformation, defaultCustContact, //MSarza [20150731] cffMgtDetails); //MSarza [20150731] } } } return(clientAndCustomerInformation); }