/// <summary>
        ///
        /// </summary>
        /// <param name="mf"></param>
        /// <param name="accountId"></param>
        /// <param name="Close"></param>
        public frmSearchFund(frmMain mf, SearchFund searchFund, FormClosedEventHandler Close = null)
        {
            frmSplashScreen ss = new frmSplashScreen();

            ss.Show();
            Application.DoEvents();

            InitializeComponent();

            frmMain_Parent = mf;

            this.MaximumSize = Screen.PrimaryScreen.WorkingArea.Size;

            Application.AddMessageFilter(this);
            controlsToMove.Add(this.pnlSummaryTabHeader);
            controlsToMove.Add(this.panel16);
            controlsToMove.Add(this.label1);
            controlsToMove.Add(this.label23);

            FormClosed += Close;

            CurrentSearchFund = searchFund;
            txtTicker.Text    = CurrentSearchFund.Ticker;
            txtFundName.Text  = CurrentSearchFund.FundName;

            CurrentTabLabel = label46; // Summary tab label
            highlightSelectedTabLabel(CurrentTabLabel);

            ss.Close();
            this.Show();
        }
        private void dgvFunds_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int           index         = dgvFunds.CurrentRow.Index;
            Guid          searchFundId  = new Guid(dgvFunds.Rows[index].Cells["SearchFundId"].Value.ToString());
            SearchFund    searchFund    = new SearchFund(searchFundId);
            frmSearchFund frmSearchFund = new frmSearchFund(frmMain_Parent, searchFund);

            frmSearchFund.FormClosed += frmSearchFund_FormClosed;
        }
Esempio n. 3
0
    private void LoadSearchFunds(Search search)
    {
        DataTable dataTable = SearchFund.GetAssociated(search);

        foreach (DataRow dr in dataTable.Rows)
        {
            var searchFundId = new Guid(dr["SearchFundId"].ToString());
            var searchFund   = new SearchFund(searchFundId);
            SearchFunds.Add(searchFund);
        }
    }
Esempio n. 4
0
 public IActionResult Export(SearchFund searchFund)
 {
     try
     {
         var fileContent = _fundService.ExportFund(searchFund);
         return(File(fileContent?.Result, "application/ms-excel", $"Funds.xlsx"));
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
        private void btnDeleteFund_Click(object sender, EventArgs e)
        {
            int        index        = dgvFunds.CurrentRow.Index;
            Guid       searchFundId = new Guid(dgvFunds.Rows[index].Cells["SearchFundId"].Value.ToString());
            SearchFund searchFund   = new SearchFund(searchFundId);

            DialogResult result = MessageBox.Show("Are you sure you wish to delete " + searchFund.FundName + "?", "Attention", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                searchFund.DeleteRecordFromDatabase();
                LoadDgvFunds();
            }
        }
        private void LoadDgvFunds()
        {
            DataTable dataTable     = SearchFund.GetAssociated(CurrentSearch);
            var       dataTableEnum = dataTable.AsEnumerable();

            /// Set the datatable based on the SelectedIndex of <see cref="cboResultsView"/>.
            switch (cboFundViews.SelectedIndex)
            {
            case 0:
                dataTableEnum = dataTableEnum.Where(x => x.Field <int>("StateCode") == 0);
                break;

            case 1:
                dataTableEnum = dataTableEnum.Where(x => x.Field <int>("StateCode") == 1);
                break;

            default:
                return;
            }

            if (dataTableEnum.Any())
            {
                dataTable = dataTableEnum.CopyToDataTable();
            }
            else
            {
                dataTable.Rows.Clear();
            }

            dgvFunds.DataSource = dataTable;

            // Display/order the columns.
            dgvFunds.Columns["SearchFundId"].Visible = false;
            dgvFunds.Columns["SearchId"].Visible     = false;
            dgvFunds.Columns["ModifiedBy"].Visible   = false;
            dgvFunds.Columns["ModifiedOn"].Visible   = false;
            dgvFunds.Columns["CreatedBy"].Visible    = false;
            dgvFunds.Columns["CreatedOn"].Visible    = false;
            dgvFunds.Columns["StateCode"].Visible    = false;

            dgvFunds.Columns["Ticker"].DisplayIndex   = 0;
            dgvFunds.Columns["FundName"].DisplayIndex = 1;
        }
Esempio n. 7
0
 public async Task <byte[]> ExportFund(SearchFund searchFund = null)
 {
     return(await _fundManager.ExportFund(searchFund));
 }
        private void LoadDgvFunds()
        {
            int currentCellRow = 0;
            int currentCellCol = 0;

            if (dgvFunds.CurrentCell != null)
            {
                currentCellRow = dgvFunds.CurrentCell.RowIndex;
                currentCellCol = dgvFunds.CurrentCell.ColumnIndex;
            }

            DataTable dataTable     = SearchFund.GetAssociated(CurrentSearch);
            var       dataTableEnum = dataTable.AsEnumerable();

            /// Set the datatable based on the SelectedIndex of <see cref="cboResultsView"/>.
            switch (cboFundViews.SelectedIndex)
            {
            case 0:
                dataTableEnum = dataTableEnum.Where(x => x.Field <int>("StateCode") == 0);
                break;

            case 1:
                dataTableEnum = dataTableEnum.Where(x => x.Field <int>("StateCode") == 1);
                break;

            default:
                return;
            }

            if (dataTableEnum.Any())
            {
                dataTable = dataTableEnum.CopyToDataTable();
            }
            else
            {
                dataTable.Rows.Clear();
            }

            dgvFunds.DataSource = dataTable;

            // Display/order the columns.
            dgvFunds.Columns["SearchFundId"].Visible = false;
            dgvFunds.Columns["SearchId"].Visible     = false;
            dgvFunds.Columns["ModifiedBy"].Visible   = false;
            dgvFunds.Columns["ModifiedOn"].Visible   = false;
            dgvFunds.Columns["CreatedBy"].Visible    = false;
            dgvFunds.Columns["CreatedOn"].Visible    = false;
            dgvFunds.Columns["StateCode"].Visible    = false;

            dgvFunds.Columns["Ticker"].DisplayIndex   = 0;
            dgvFunds.Columns["FundName"].DisplayIndex = 1;

            if (dgvFunds.RowCount > 0 && dgvFunds.ColumnCount > 0)
            {
                DataGridViewCell selectedCell = dgvFunds.Rows[currentCellRow].Cells[currentCellCol];
                if (selectedCell != null && selectedCell.Visible)
                {
                    dgvFunds.CurrentCell = selectedCell;
                }
                else
                {
                    dgvFunds.CurrentCell = dgvFunds.FirstDisplayedCell;
                }
            }
        }
Esempio n. 9
0
        public async Task <byte[]> ExportFund(SearchFund searchFund = null)
        {
            try
            {
                var comlumHeadrs = new string[]
                {
                    Model.Resources.Common.FundName,
                    Model.Resources.Common.FundCode,
                    Model.Resources.Common.NAV,
                    Model.Resources.Common.FundContent,
                    Model.Resources.Common.FundUseBy,
                    Model.Resources.Common.LastUpdatedDate
                };

                var predicate = PredicateBuilder.New <Fund>(true);

                if (searchFund != null)
                {
                    if (!string.IsNullOrWhiteSpace(searchFund.FundName))
                    {
                        predicate = predicate.And(u => !string.IsNullOrWhiteSpace(u.Title) && u.Title.Contains(searchFund.FundName));
                    }
                    if (!string.IsNullOrWhiteSpace(searchFund.FundCode))
                    {
                        predicate = predicate.And(u => !string.IsNullOrWhiteSpace(u.Code) && u.Title.Contains(searchFund.FundCode));
                    }
                    if (!string.IsNullOrWhiteSpace(searchFund.FundContent))
                    {
                        predicate = predicate.And(u => !string.IsNullOrWhiteSpace(u.Content) && u.Content.Contains(searchFund.FundContent));
                    }
                    if (!string.IsNullOrWhiteSpace(searchFund.PortfolioName))
                    {
                        predicate = predicate.And(u => u.PortfolioFunds != null &&
                                                  u.PortfolioFunds.Any() &&
                                                  u.PortfolioFunds.First().Portfolio != null &&
                                                  !string.IsNullOrWhiteSpace(u.PortfolioFunds.First().Portfolio.Title) &&
                                                  u.PortfolioFunds.First().Portfolio.Title.Contains(searchFund.PortfolioName));
                    }
                }

                var listFund = _unitOfWork.FundRepository.GetAllFund().Where(predicate).ToList();

                using (var package = new ExcelPackage())
                {
                    var worksheet = package.Workbook.Worksheets.Add("Funds");
                    using (var cells = worksheet.Cells[1, 1, 1, 6])
                    {
                        cells.Style.Font.Bold = true;
                    }

                    for (var i = 0; i < comlumHeadrs.Count(); i++)
                    {
                        worksheet.Cells[1, i + 1].Value = comlumHeadrs[i];
                    }

                    var j = 2;
                    foreach (var fund in listFund)
                    {
                        worksheet.Cells["A" + j].Value = fund.Title;
                        worksheet.Cells["B" + j].Value = fund.Code;
                        worksheet.Cells["C" + j].Style.Numberformat.Format = "#,##0.00";
                        worksheet.Cells["C" + j].Value = fund.NAV;
                        worksheet.Cells["D" + j].Value = fund.Content;

                        var portfolio = string.Empty;
                        if (fund.PortfolioFunds != null && fund.PortfolioFunds.Any())
                        {
                            foreach (var portfolioFund in fund.PortfolioFunds)
                            {
                                portfolio += portfolioFund.Portfolio.Title + ", ";
                            }

                            portfolio = portfolio.Substring(0, portfolio.Length - 2);
                        }

                        worksheet.Cells["E" + j].Value = portfolio;
                        worksheet.Cells["F" + j].Value = fund.DateLastApproved.ToString("dd/MM/yyyy HH:mm:ss");
                        j++;
                    }

                    return(package.GetAsByteArray());
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Export Fund: " + ex.Message);
            }
        }