예제 #1
0
        public StatusReport LoadStatusReportForCustomer(Date endDate, int clientId, CffCustomer customer, TransactionStatus status, int ClientFacilityType)
        {
            ArgumentChecker.ThrowIfNull(endDate, "endDate");
            ArgumentChecker.ThrowIfNull(status, "status");

            return(repository.LoadStatusReportForCustomer(endDate, clientId, customer, status, ClientFacilityType));
        }
        public void SelectCustomer(int customerId)
        {
            if (securityManager.CanChangeSelectedCustomer())
            {
                if (securityManager.CanChangeSelectedClient())
                {
                    CffClient   client   = clientRepository.GetCffClientByCustomerId(customerId);
                    CffCustomer customer = customerRepository.GetCffCustomerByCustomerId(customerId);

                    if (client != null && customer != null)
                    {
                        // view.Client = client;
                        // view.Customer = customer;
                    }
                }
                else
                {
                    CffCustomer customer = customerRepository.GetCffCustomerByClientIdAndCustomerId(view.Client.Id, customerId);
                    if (customer != null)
                    {
                        // view.Customer = customer;
                    }
                }
            }
        }
        public void SelectClientCustomerAndRedirectToInvoiceBatches(int clientId, int customerId, int batch)
        {
            if (securityManager.CanViewReleaseTab())
            {
                ICffClient  client   = clientRepository.GetCffClientByClientId(clientId);
                CffCustomer customer = customerRepository.GetCffCustomerByCustomerId(customerId);

                view.Client   = client;
                view.Customer = (ICffCustomer)customer;
                RedirectToInvoiceBatchesWithClientCustomer(clientId, customerId, batch);
            }
        }
        public void SelectClientCustomerAndRedirectToDashboard(int clientId, int customerId)
        {
            if (securityManager.CanChangeSelectedCustomer())
            {
                ICffClient  client   = clientRepository.GetCffClientByClientId(clientId);
                CffCustomer customer = customerRepository.GetCffCustomerByCustomerId(customerId);

                view.Client   = client;
                view.Customer = (ICffCustomer)customer;
                view.RedirectTo(DashboardUrl + "?Client=" + clientId + "&Customer=" + customerId + "&ViewID=" + QueryString.ViewIDValue);
            }
        }
        public void CheckClientAndCustomerMatchAndSelectCustomer(int clientId, int customerId)
        {
            if (securityManager.CanChangeSelectedCustomer())
            {
                if (securityManager.CanChangeSelectedClient())
                {
                    ICffClient client             = clientRepository.GetCffClientByClientId(clientId);
                    CffClient  clientBycustomerId = clientRepository.GetCffClientByCustomerId(customerId);


                    if (SessionWrapper.Instance.Get != null)
                    {
                        if (SessionWrapper.Instance.Get.UserIdentity == 1)
                        {
                            if (SessionWrapper.Instance.Get.ClientFromQueryString != null)
                            {
                                System.Web.HttpContext.Current.Response.Redirect(DashBoardUri + "?Client=" + SessionWrapper.Instance.Get.ClientFromQueryString.Id + "&Customer=" + customerId);
                                return;
                            }
                        }
                        else
                        {
                            if (client != null && clientBycustomerId != null)
                            {
                                if (client.Id != clientBycustomerId.Id)
                                {
                                    System.Web.HttpContext.Current.Response.Redirect(DashBoardUri + "?Client=" + clientBycustomerId.Id + "&Customer=" + customerId);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (client != null && clientBycustomerId != null)
                        {
                            if (client.Id != clientBycustomerId.Id)
                            {
                                System.Web.HttpContext.Current.Response.Redirect(DashBoardUri + "?Client=" + clientBycustomerId.Id + "&Customer=" + customerId);
                            }
                        }
                    }
                }
                else
                {
                    CffCustomer customer = customerRepository.GetCffCustomerByClientIdAndCustomerId(view.Client.Id, customerId);
                    if (customer != null)
                    {
                        // view.Customer = customer;
                    }
                }
            }
        }
        public CffCustomer LoadCffCustomerAssociatedWith(ICffUser user)
        {
            ArgumentChecker.ThrowIfNull(user, "user");

            CffCustomer  customer     = null;
            CustomerUser customerUser = user as CustomerUser;

            if (customerUser != null)
            {
                customer = customerRepository.GetCffCustomerByCustomerId((int)customerUser.CustomerId);
            }
            return(customer);
        }
예제 #7
0
        private readonly Date notifydate;               //MSarza [20150820]

        public CffCustomerInformation(CffCustomer customer, short stopCredit, decimal creditLimit, Date listDate, Date nextCall,
                                      short customerNoCalls, IDate lastPaid, decimal lastAmount, ClientCustomerTerm clientCustomerTerm, AgeingBalances ageingBalances)
        {
            this.customer           = customer;
            this.stopCredit         = stopCredit;
            this.creditLimit        = creditLimit;
            this.listDate           = listDate;
            NextCall                = nextCall;
            noCalls                 = customerNoCalls;
            this.lastPaid           = lastPaid;
            this.lastAmount         = lastAmount;
            this.clientCustomerTerm = clientCustomerTerm;
            this.ageingBalances     = ageingBalances;
        }
 public void SelectCustomerClientAtCustomerScope(int clientId, int customerId)
 {
     if (securityManager.CanChangeSelectedClient())
     {
         ICffClient  client   = clientRepository.GetCffClientByClientId(clientId);
         CffCustomer customer = customerRepository.GetCffCustomerByCustomerId(customerId);
         if (client != null)
         {
             view.Client = client;
             CffCustomerExt xC = new CffCustomerExt(customer.Name, customer.Id, customer.Number);
             view.Customer = (ICffCustomer)xC;
         }
     }
 }
 public CffCustomerInformation Build(CffCustomer customer, IDate lastPaid, decimal lastAmount, 
     ClientCustomerTerm clientCustomerTerm, AgeingBalances ageingBalances)
 {
     return new CffCustomerInformation(customer,
                                       reader.ToSmallInteger("StopCredit"),
                                       reader.ToDecimal("CreditLimit"),
                                       reader.ToDate("Created"),
                                       reader.ToDate("NextCall"),
                                       reader.ToSmallInteger("customerNoCalls"),
                                       lastPaid, lastAmount,
                                       clientCustomerTerm, ageingBalances,
                                       reader.ToString("Address1"),
                                       reader.ToString("Address2"),
                                       reader.ToString("Address3"),
                                       reader.ToString("Address4"),
                                       reader.ToString("EmailStatmentsAddr"),
                                       reader.ToDate("NotifyDate")
                                       );
 }
        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);
        }
예제 #11
0
        public void SearchTransactions(DateRange dateRange, string invoiceNumber, TransactionSearchType transactionType,
                                       SearchScope searchScope, CffCustomer customer, ICffClient client, string batchFrom, string batchTo)
        {
            if (transactionType == TransactionSearchType.Invoices)
            {
                SearchingStatus = 1;
                if (CallBackHandler != null)
                {
                    this.CallBackHandler(this, new EventArgs());
                }

                IList <TransactionSearchResult> transactions = transactionSearchRepository.SearchTransactions(dateRange,
                                                                                                              invoiceNumber,
                                                                                                              transactionType,
                                                                                                              searchScope,
                                                                                                              customer,
                                                                                                              client,
                                                                                                              batchFrom,
                                                                                                              batchTo);

                SearchingStatus = 2;
                if (CallBackHandler != null)
                {
                    this.CallBackHandler(this, new EventArgs());
                }

                view.DisplayMatchedTransactions(transactions);
            }
            else
            {
                IList <CreditNoteSearchResult> transactions =
                    transactionSearchRepository.SearchCreditNotesTransactions(dateRange,
                                                                              invoiceNumber,
                                                                              transactionType,
                                                                              searchScope, customer,
                                                                              client,
                                                                              batchFrom,
                                                                              batchTo);
                view.DisplayMatchedCreditNotesTransactions(transactions);
            }
        }
예제 #12
0
 public CffCustomerInformation(CffCustomer customer, short stopCredit, decimal creditLimit, Date listDate, Date nextCall,
                               short customerNoCalls, IDate lastPaid, decimal lastAmount, ClientCustomerTerm clientCustomerTerm, AgeingBalances ageingBalances,
                               string addr1, string addr2, string addr3, string addr4, string emailStatmentsAddr, Date notifydate)
 {
     this.customer           = customer;
     this.stopCredit         = stopCredit;
     this.creditLimit        = creditLimit;
     this.listDate           = listDate;
     NextCall                = nextCall;
     noCalls                 = customerNoCalls;
     this.lastPaid           = lastPaid;
     this.lastAmount         = lastAmount;
     this.clientCustomerTerm = clientCustomerTerm;
     this.ageingBalances     = ageingBalances;
     this.address1           = addr1;
     this.address2           = addr2;
     this.address3           = addr3;
     this.address4           = addr4;
     this.emailStatmentsAddr = emailStatmentsAddr;
     this.notifydate         = notifydate;               //MSarza [20150820]
 }
예제 #13
0
        public string SelectCustomerFromAutoCompleteDropDown(string customerId)
        {
            //assign new customer instance here based from retrieved customer number and existing clientid
            Scope          xScope    = Scope.AllClientsScope;
            CffCustomerExt xCustomer = null;
            CffCustomer    cCustomer = null;

            if (SessionWrapper.Instance.Get != null)
            {
                if (SessionWrapper.Instance.Get.EmptyWindowHit == 0)
                {
                    SessionWrapper.Instance.Get.EmptyWindowHit = 1;
                }
                if (xCustomer == null)
                {
                    if (customerId.Contains("("))
                    { //this is customer number! we should be able to retrieve correct customer id + client id
                        customerId = customerId.Substring(customerId.IndexOf("(") + 1);
                        customerId = customerId.Replace(")", "");
                    }

                    if (!string.IsNullOrEmpty(customerId))
                    {
                        cCustomer = (RepositoryFactory.CreateCustomerRepository().GetMatchedCustomerInfo(Convert.ToInt32(customerId),
                                                                                                         SessionWrapper.Instance.Get.ClientFromQueryString.Id).CffCustomerInformation.Customer);
                        xCustomer = new CffCustomerExt(cCustomer.Name, cCustomer.Id, cCustomer.Number);
                    }
                }

                if (xCustomer != null)
                {
                    SessionWrapper.Instance.Get.CustomerFromQueryString = (ICffCustomer)xCustomer;
                    if (SessionWrapper.Instance.Get.CurrentUserID != (System.Web.HttpContext.Current.User as CffPrincipal).CffUser.UserId.ToString())
                    {
                        SessionWrapper.Instance.Get.CurrentUserID = (System.Web.HttpContext.Current.User as CffPrincipal).CffUser.UserId.ToString();
                    }
                }
            }
            else if (!string.IsNullOrEmpty(QueryString.ViewIDValue))
            {
                if (SessionWrapper.Instance.GetSession(QueryString.ViewIDValue) != null)
                {
                    xScope = SessionWrapper.Instance.GetSession(QueryString.ViewIDValue).Scope;
                    if (SessionWrapper.Instance.GetSession(QueryString.ViewIDValue).EmptyWindowHit == 0)
                    {
                        SessionWrapper.Instance.GetSession(QueryString.ViewIDValue).EmptyWindowHit = 1;
                    }

                    cCustomer = (RepositoryFactory.CreateCustomerRepository().GetMatchedCustomerInfo(Convert.ToInt32(customerId),
                                                                                                     SessionWrapper.Instance.GetSession(QueryString.ViewIDValue).ClientFromQueryString.Id).CffCustomerInformation.Customer);
                    xCustomer = new CffCustomerExt(cCustomer.Name, cCustomer.Id, cCustomer.Number);
                    if (xCustomer != null)
                    {
                        SessionWrapper.Instance.GetSession(QueryString.ViewIDValue).CustomerFromQueryString = (ICffCustomer)xCustomer;
                    }

                    if (SessionWrapper.Instance.GetSession(QueryString.ViewIDValue).CurrentUserID != (System.Web.HttpContext.Current.User as CffPrincipal).CffUser.UserId.ToString())
                    {
                        SessionWrapper.Instance.GetSession(QueryString.ViewIDValue).CurrentUserID = (System.Web.HttpContext.Current.User as CffPrincipal).CffUser.UserId.ToString();
                    }
                }
            }


            IScopeService scopeService = new ScopeService(this,
                                                          SecurityManagerFactory.Create(Context.User as CffPrincipal, xScope),
                                                          RepositoryFactory.CreateClientRepository(),
                                                          RepositoryFactory.CreateCustomerRepository());

            string jSon = string.Empty;

            if (!string.IsNullOrEmpty(customerId))
            {
                try
                {
                    scopeService.SelectCustomer(int.Parse(customerId));
                    using (MemoryStream stream = new MemoryStream())
                    {
                        serializer.WriteObject(stream, Client);
                        jSon = Encoding.Default.GetString(stream.ToArray());
                    }
                }
                catch (FormatException)
                {
                }
            }

            return(jSon);
        }
        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);
        }
        public IList <CreditNoteSearchResult> SearchCreditNotesTransactions(DateRange dateRange, string transactionNumber, TransactionSearchType transactionSearchType, SearchScope searchScope, CffCustomer customer, ICffClient client, string batchFrom, string batchTo)
        {
            if (transactionNumber.Length < 3)
            {
                throw new ArgumentException("You need more than 3 transaction Number to search ");
            }
            SqlParameter[] queryBuilder = CreateSqlBuilder(dateRange, transactionNumber,
                                                           transactionSearchType, searchScope, customer, client, batchFrom, batchTo);
            IList <CreditNoteSearchResult> creditNoteSearchResults = new List <CreditNoteSearchResult>();

            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 CreditNoteSearchResult(
                                    cleverReader.ToDecimal("Amount"),
                                    cleverReader.ToInteger("BatchID"),
                                    cleverReader.ToDate("datereceived"),
                                    cleverReader.ToString("Reference"),
                                    cleverReader.ToDate("Created"),
                                    cleverReader.FromBigInteger("CustomerID"),
                                    cleverReader.ToString("Customer"),
                                    cleverReader.FromBigInteger("ClientID"),
                                    cleverReader.ToString("ClientName"),
                                    cleverReader.FromBigInteger("CustNum"),
                                    cleverReader.ToString("Title"),
                                    cleverReader.ToDecimal("Balance"),
                                    cleverReader.ToString("BatchFrom"),
                                    cleverReader.ToString("BatchTo"));
                            creditNoteSearchResults.Add(transactionSearchResult);
                        }
                    }
                }
                catch (SqlException exception)
                {
                    if (exception.Message.Contains("Timeout expired"))
                    {
                        throw new CffTimeoutException(exception.Message, exception);
                    }
                    throw;
                }
            }
            return(RecordLimiter.ReturnMaximumRecords(creditNoteSearchResults));
        }
        private static SqlParameter[] CreateSqlBuilder(DateRange dateRange, string invoiceNumber, TransactionSearchType transactionSearchType, SearchScope searchScope, CffCustomer customer, ICffClient client, string batchFrom, string batchTo)
        {
            List <SqlParameter> sqlParameterList = new List <SqlParameter>();

            if (!string.IsNullOrEmpty(invoiceNumber))
            {
                SqlParameter invoiceNumberParameter = new SqlParameter("@Seek", SqlDbType.NVarChar, 40);
                invoiceNumberParameter.Value = invoiceNumber + "%";
                sqlParameterList.Add(invoiceNumberParameter);
            }
            SqlParameter clientIdParameter   = new SqlParameter("@ClientID", SqlDbType.Int);
            SqlParameter customerIdParameter = new SqlParameter("@CustID ", SqlDbType.Int);

            switch (searchScope)
            {
            case SearchScope.AllClients:
                clientIdParameter.Value   = -1;
                customerIdParameter.Value = -1;
                break;

            case SearchScope.AllCustomers:
                clientIdParameter.Value   = client.Id;
                customerIdParameter.Value = -1;
                break;

            case SearchScope.CurrentCustomer:
                clientIdParameter.Value   = client.Id;
                customerIdParameter.Value = customer.Id;
                break;
            }
            sqlParameterList.Add(clientIdParameter);
            sqlParameterList.Add(customerIdParameter);
            SqlParameter transactionSearchTypeParameter = new SqlParameter("@SearchBy", SqlDbType.VarChar, 20);

            switch (transactionSearchType)
            {
            case TransactionSearchType.Invoices:
                transactionSearchTypeParameter.Value = "Invoice";
                sqlParameterList.Add(transactionSearchTypeParameter);
                break;

            case TransactionSearchType.CreditNotes:
                transactionSearchTypeParameter.Value = "CreditEtc";
                sqlParameterList.Add(transactionSearchTypeParameter);
                break;
            }
            SqlParameter startDateParameter = new SqlParameter("@dtFrom", SqlDbType.DateTime);

            startDateParameter.Value = dateRange.StartDate.Value.DateTime;
            sqlParameterList.Add(startDateParameter);
            SqlParameter endDateParameter = new SqlParameter("@dtTo", SqlDbType.DateTime);

            endDateParameter.Value = dateRange.EndDate.Value.DateTime;
            sqlParameterList.Add(endDateParameter);
            SqlParameter btFrom = new SqlParameter("@BatchFrom", SqlDbType.VarChar);

            btFrom.Value = batchFrom;
            sqlParameterList.Add(btFrom);
            SqlParameter btTo = new SqlParameter("@BatchTo", SqlDbType.VarChar);

            btTo.Value = batchTo;
            sqlParameterList.Add(btTo);
            return(sqlParameterList.ToArray());
        }