示例#1
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);
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ViewState.Add("ViewID", QueryString.ViewIDValue);

            targetName = "";
            ISearchScopeManager searchScopeManager = SearchScopeManagerFactory.Create(this.CurrentScope(), Context.User as CffPrincipal);

            presenter = new TransactionSearchPresenter(this, RepositoryFactory.CreateTransactionSearchRepository(), searchScopeManager);

            ConfigureGrids();
            if (!IsPostBack)
            {
                PopulateTransactionTypeDropDownList();
                presenter.PopulateSearchScopeDropDownList();
                ShowHideTabNavigations();
                transactionSearchGridView.Visible = false;
                creditSearchGridView.Visible      = false;
            }
            else
            {
                SearchLabel.Visible = false;
                TransactionSearchType transactionSearchType =
                    ((TransactionSearchType)
                     Enum.Parse(typeof(TransactionSearchType), TransactionTypeDropDownList.SelectedValue));

                if (transactionSearchType == TransactionSearchType.Invoices)
                {
                    DisplayMatchedTransactions(ViewState["transactions"] as IList <TransactionSearchResult>);
                }
                else
                {
                    DisplayMatchedCreditNotesTransactions(
                        ViewState["creditNotesTransactions"] as IList <CreditNoteSearchResult>);
                }
            }

            currentTransactionsLink.InnerHtml = "<a href=\"Transactions.aspx" + Server.HtmlDecode(QueryStringParameters) + "\">Current</a>";
            transactionArchiveLink.InnerHtml  = "<a href=\"TransactionArchive.aspx" + Server.HtmlDecode(QueryStringParameters) + "\">Archive</a>";
            transactionHistoryLink.InnerHtml  = "<a href=\"TransactionHistory.aspx" + Server.HtmlDecode(QueryStringParameters) + "\">History</a>";
        }
示例#3
0
        private void ConfigureGrids()
        {
            Scope currentScope = this.CurrentScope();

            transactionSearchGridView.Columns.Clear();
            if (currentScope == Scope.AllClientsScope)
            {
                transactionSearchGridView.InsertBoundHyperLinkColumn("Client", "ClientName", "ClientId", "12%", "cffGGV_leftAlignedCell", HorizontalAlign.Left, HorizontalAlign.Left);
            }

            transactionSearchGridView.InsertDataColumn("#", "CustomerNumber", CffGridViewColumnType.Text, "3%", "cffGGV_leftAlignedCell", HorizontalAlign.Left, HorizontalAlign.Left, false);
            transactionSearchGridView.InsertBoundHyperLinkColumn("Customer", "CustomerName", "CustomerId", "30%", "cffGGV_leftAlignedCell", HorizontalAlign.Left, HorizontalAlign.Left);
            transactionSearchGridView.InsertDataColumn("Title", "Title", CffGridViewColumnType.Text, "5%", "cffGGV_leftAlignedCell", HorizontalAlign.Left, HorizontalAlign.Left, false);
            transactionSearchGridView.InsertDataColumn("Invoice", "InvoiceNumber", CffGridViewColumnType.Text, "4%", "cffGGV_leftAlignedCell", HorizontalAlign.Left, HorizontalAlign.Left, false);
            transactionSearchGridView.InsertDataColumn("Dated", "InvoiceDate", CffGridViewColumnType.Date, "4%", "cffGGV_leftAlignedCell", HorizontalAlign.Left, HorizontalAlign.Left, false);
            transactionSearchGridView.InsertCurrencyColumn("Amount", "InvoiceAmount", "7%", "cffGGV_currencyCell", true, HorizontalAlign.Right, HorizontalAlign.Right);

            transactionSearchGridView.InsertCurrencyColumn("Balance", "InvoiceBalance", "7%", "cffGGV_currencyCell", true, HorizontalAlign.Right, HorizontalAlign.Right);
            transactionSearchGridView.InsertDataColumn("Processed", "Processed", CffGridViewColumnType.Date, "4%", "cffGGV_centerAlignedCell", HorizontalAlign.Center, HorizontalAlign.Center, false);
            transactionSearchGridView.InsertBoundHyperLinkColumn("Batch", "Batch", "Batch", "5%", "cffGGV_centerAlignedCell", HorizontalAlign.Center, HorizontalAlign.Center);
            transactionSearchGridView.InsertCurrencyColumn("Cust.Balance", "CustomerBalance", "7%", "cffGGV_currencyCell", true, HorizontalAlign.Right, HorizontalAlign.Right);

            creditSearchGridView.Columns.Clear();
            if (currentScope == Scope.AllClientsScope)
            {
                creditSearchGridView.InsertBoundHyperLinkColumn("Client", "ClientName", "ClientId", "15%", "cffGGV_centerAlignedCell", HorizontalAlign.Left, HorizontalAlign.Left);
            }

            creditSearchGridView.InsertDataColumn("#", "CustomerNumber", CffGridViewColumnType.Text, "3%", "cffGGV_centerAlignedCell", HorizontalAlign.Left, HorizontalAlign.Left, false);
            creditSearchGridView.InsertBoundHyperLinkColumn("Customer", "CustomerName", "CustomerId", "30%", "cffGGV_leftAlignedCell", HorizontalAlign.Left, HorizontalAlign.Left);
            creditSearchGridView.InsertDataColumn("Title", "Title", CffGridViewColumnType.Text, "4%", "cffGGV_centerAlignedCell", HorizontalAlign.Left, HorizontalAlign.Center, false);
            creditSearchGridView.InsertDataColumn("Transaction", "TransactionNumber", CffGridViewColumnType.Text, "4%", "cffGGV_leftAlignedCell", HorizontalAlign.Left, HorizontalAlign.Left, false);
            creditSearchGridView.InsertDataColumn("Dated", "Dated", CffGridViewColumnType.Date, "4%", "cffGGV_centerAlignedCell", HorizontalAlign.Left, HorizontalAlign.Left, false);
            creditSearchGridView.InsertCurrencyColumn("Credit Note", "CreditNoteAmount", "10%", "cffGGV_currencyCell", true, HorizontalAlign.Right, HorizontalAlign.Right);
            creditSearchGridView.InsertDataColumn("Processed", "Processed", CffGridViewColumnType.Date, "7%", "cffGGV_centerAlignedCell", HorizontalAlign.Center, HorizontalAlign.Center, false);
            creditSearchGridView.InsertDataColumn("Batch", "Batch", CffGridViewColumnType.Text, "5%", "cffGGV_centerAlignedCell", HorizontalAlign.Left, HorizontalAlign.Center, false);  //do not enable hyperlink for credits batch columns
            creditSearchGridView.InsertCurrencyColumn("Customer Balance", "CustomerBalance", "7%", "cffGGV_currencyCell", true, HorizontalAlign.Right, HorizontalAlign.Right);


            transactionSearchGridView.Columns[0].ControlStyle.BorderWidth = Unit.Pixel(1);
            transactionSearchGridView.BorderWidth = Unit.Pixel(1);
            creditSearchGridView.Columns[0].ControlStyle.BorderWidth = Unit.Pixel(1);
            creditSearchGridView.BorderWidth = Unit.Pixel(1);


            if (TransactionTypeDropDownList.Items.Count == 0)
            {
                PopulateTransactionTypeDropDownList();
                TransactionTypeDropDownList.SelectedIndex = 0;
            }

            TransactionSearchType transactionSearchType = ((TransactionSearchType)Enum.Parse(typeof(TransactionSearchType), TransactionTypeDropDownList.SelectedValue));

            if (transactionSearchType == TransactionSearchType.Invoices)
            {
                transactionSearchGridView.Visible = true;
                creditSearchGridView.Visible      = false;
            }
            else
            {
                transactionSearchGridView.Visible = false;
                creditSearchGridView.Visible      = true;
            }
        }
        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());
        }