public IList <CustomerContact> LoadAllClientsCustomerContactsWithCustomerNameStartWith(string letter)
        {
            IList <CustomerContact> contacts = GetAllCustomersAndTheirContacts().AsQueryable()
                                               .Where(customerContact =>
                                                      DoesStartWith(customerContact.CustomerName, letter))
                                               .OrderBy(customerContact => customerContact.CustomerName)
                                               .ToList();

            return(RecordLimiter.ReturnMaximumRecords(contacts));
        }
        public IList <CustomerContact> LoadCustomerContactsForACustomerWithCustomerNameStartWith(string letter, int customerId)
        {
            IList <CustomerContact> contacts = GetAllCustomersAndTheirContacts().AsQueryable()
                                               .Where(customerContact =>
                                                      DoesStartWith(customerContact.CustomerName, letter) && customerContact.CustomerId.Equals(customerId))
                                               .OrderBy(customerContact => customerContact.CustomerName)
                                               .ToList();

            return(RecordLimiter.ReturnMaximumRecords(contacts));
        }
        public IList <TransactionSearchResult> SearchTransactions(DateRange dateRange, string invoiceNumber, TransactionSearchType transactionType, SearchScope searchScope, CffCustomer customer, ICffClient client, string batchFrom, string batchTo)
        {
            if (invoiceNumber.Length < 3)
            {
                throw new ArgumentException("You need more than 3 invoice number to search ");
            }
            SqlParameter[] queryBuilder = CreateSqlBuilder(dateRange, invoiceNumber,
                                                           transactionType, searchScope, customer, client, batchFrom, batchTo);
            IList <TransactionSearchResult> transactionSearchResults = new List <TransactionSearchResult>();

            using (SqlConnection connection = CreateConnection())
            {
                try
                {
                    using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                              CommandType.StoredProcedure,
                                                                              "stGetCustomersSearchAll",
                                                                              queryBuilder))
                    {
                        CleverReader cleverReader = new CleverReader(dataReader);
                        while (!cleverReader.IsNull && cleverReader.Read())
                        {
                            var transactionSearchResult =
                                new TransactionSearchResult(cleverReader.ToDate("Transdate"),
                                                            cleverReader.ToDate("factorDate"),
                                                            cleverReader.ToString("TransRef"),
                                                            cleverReader.ToDecimal("TransAmount"),
                                                            cleverReader.ToDecimal("TransBalance"),
                                                            cleverReader.FromBigInteger("BatchID"),
                                                            cleverReader.FromBigInteger("CustNum"),
                                                            cleverReader.FromBigInteger("CustomerID"),
                                                            cleverReader.ToString("Customer"),
                                                            cleverReader.FromBigInteger("ClientID"),
                                                            cleverReader.ToString("ClientName"),
                                                            cleverReader.ToString("Title"),
                                                            cleverReader.ToDecimal("Balance"),
                                                            cleverReader.ToString("BatchFrom"),
                                                            cleverReader.ToString("BatchTo"));
                            transactionSearchResults.Add(transactionSearchResult);
                        }
                    }
                }
                catch (SqlException exception)
                {
                    if (exception.Message.Contains("Timeout expired"))
                    {
                        throw new CffTimeoutException(exception.Message, exception);
                    }
                    throw;
                }
            }
            Console.WriteLine(transactionSearchResults.Count);
            return(RecordLimiter.ReturnMaximumRecords(transactionSearchResults));
        }
        public IList <CustomerContact> LoadMatchedAllClientsCustomerContact(string textToMatch)
        {
            IList <CustomerContact> contacts;

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "dbo.CustomerContactsView_GetMatchedCustomerContacts", GenerateTextToSearchParameters(textToMatch)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    contacts = new CustomerContactBuilder(cleverReader).BuildAll();
                }
            }
            return(RecordLimiter.ReturnMaximumRecords(contacts));
        }
Beispiel #5
0
        public IList <RetentionSchedule> LoadRetentionSchedulesForAllClients(Date date)
        {
            IList <RetentionSchedule> retentionSchedules = new List <RetentionSchedule>();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader reader = SqlHelper.ExecuteReader(connection,
                                                                      "stGetRetentionScheduleForAllClients",
                                                                      CreateRetentionScheduleForAllClientsParameter(date)))
                {
                    CleverReader cleverReader = new CleverReader(reader);
                    while (cleverReader.Read())
                    {
                        retentionSchedules.Add(new RetentionScheduleBuilder(cleverReader).Build());
                    }
                }
            }
            return(RecordLimiter.ReturnMaximumRecords(retentionSchedules));
        }
Beispiel #6
0
        public IList <InvoiceBatch> LoadInvoiceBatchesForDateRange(int clientId, BatchType batchType, DateRange dateRange)
        {
            ArgumentChecker.ThrowIfNull(batchType, "batchType");
            ArgumentChecker.ThrowIfNull(dateRange, "dateRange");
            if (!batchType.IsDateRangeDependant)
            {
                throw new InvalidOperationException("Batch type is not date range dependent");
            }

            //start ref: mariper
            //we should be able to implement call back of event functions here to somehow tell the client that the DB is still fetching as this bit of code takes too long when records exceeds 2K+
            if (StartDataFetchEvent != null)
            {
                StartDataFetchEvent(this, (EventArgs)(new CEventArgs(200, "start")));
            }

            DataSet theDS = batches.LoadBatches(Action,
                                                batchType.Id,
                                                string.Empty,
                                                dateRange.StartDate.Value.DateTime,
                                                dateRange.EndDate.Value.DateTime,
                                                ref clientId,
                                                7);

            if (theDS == null)
            {
                return(null);
            }

            DataTableCollection tables = theDS.Tables;
            int rowCount = (tables == null)?0:(tables["Batches"] == null)?0:(tables["Batches"].Rows.Count);

            if (EndDataFetchEvent != null)
            {
                EndDataFetchEvent(this, (EventArgs)(new CEventArgs(rowCount, "stop")));
            }

            IList <InvoiceBatch> invoiceBatches = new InvoiceBatchBuilder().Build(tables["Batches"]);

            //end ref: mariper
            return(RecordLimiter.ReturnMaximumRecords(invoiceBatches));
        }
Beispiel #7
0
        public IList <InvoiceBatch> LoadInvoiceBatchesFor(int clientId, BatchType batchType)
        {
            ArgumentChecker.ThrowIfNull(batchType, "batchType");
            if (batchType.IsDateRangeDependant)
            {
                throw new InvalidOperationException("Batch type is date range dependent");
            }

            try
            {
                DataSet theDS = batches.LoadBatches(Action, batchType.Id, string.Empty, Date.MinimumDate.DateTime, Date.MinimumDate.DateTime, ref clientId, 7);
                if (theDS != null)
                {
                    DataTableCollection  tables         = theDS.Tables;
                    IList <InvoiceBatch> invoiceBatches = new InvoiceBatchBuilder().Build(tables["Batches"]);
                    return(RecordLimiter.ReturnMaximumRecords(invoiceBatches));
                }
            }
            catch { }
            return(null);
        }
        public IList <CustomerContact> LoadAllCustomersContactsForAClient(int clientId)
        {
            IList <CustomerContact> contacts = GetAllCustomersContactsForAClient(clientId);

            return(RecordLimiter.ReturnMaximumRecords(contacts));
        }
        public IList <CustomerContact> LoadAllCustomersAndTheirContacts()
        {
            IList <CustomerContact> contacts = GetAllCustomersAndTheirContacts();

            return(RecordLimiter.ReturnMaximumRecords(contacts));
        }
        public IList <CustomerContact> LoadACustomersContacts(int customerId)
        {
            IList <CustomerContact> contacts = GetACustomersContacts(customerId);

            return(RecordLimiter.ReturnMaximumRecords(contacts));
        }
        public IList <ClientContact> LoadAClientsContacts(int clientId, string sAction)
        {
            IList <ClientContact> contacts = GetAClientsContacts(clientId, sAction);

            return(RecordLimiter.ReturnMaximumRecords(contacts));
        }