private void dgvFees_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int  index       = dgvFees.CurrentRow.Index;
            Guid planRkFeeId = new Guid(dgvFees.Rows[index].Cells["PlanRecordKeeperProductFeeId"].Value.ToString());
            PlanRecordKeeperProductFee    planRkPdFee = new PlanRecordKeeperProductFee(planRkFeeId);
            frmPlanRecordKeeperProductFee frmPlanRecordKeeperProductFee = new frmPlanRecordKeeperProductFee(frmMain_Parent, planRkPdFee);

            frmPlanRecordKeeperProductFee.FormClosed += frmPlanRecordKeeperProductFee_FormClosed;
        }
        private void btnDeleteFee_Click(object sender, EventArgs e)
        {
            int  index         = dgvFees.CurrentRow.Index;
            Guid planRkPdFeeId = new Guid(dgvFees.Rows[index].Cells["PlanRecordKeeperProductFeeId"].Value.ToString());
            PlanRecordKeeperProductFee planRkPdFee = new PlanRecordKeeperProductFee(planRkPdFeeId);

            DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected plan record keeper product fee?", "Attention", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                planRkPdFee.DeleteRecordFromDatabase();
                LoadDgvFees();
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="mf"></param>
        /// <param name="planRecordKeeperProduct"></param>
        /// <param name="Close"></param>
        public frmPlanRecordKeeperProductFee(frmMain mf, PlanRecordKeeperProduct planRecordKeeperProduct, 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;

            Plan plan = new Plan(planRecordKeeperProduct.PlanId);
            PlanRecordKeeperProduct rkpd = new PlanRecordKeeperProduct(planRecordKeeperProduct.RecordKeeperProductId);
            Product pd = new Product(rkpd.ProductId);

            txtProduct.Text = pd.Name;

            CurrentPlanRecordKeeperProductFee        = new PlanRecordKeeperProductFee();
            CurrentPlanRecordKeeperProductFee.PlanId = plan.PlanId;
            CurrentPlanRecordKeeperProductFee.RecordKeeperProductId = rkpd.RecordKeeperProductId;

            txtPlan.Text = plan.Name;

            DataIntegrationHub.Business.Entities.RecordKeeper rk = new DataIntegrationHub.Business.Entities.RecordKeeper(pd.RecordKeeperId);
            txtRecordKeeper.Text = rk.Name;

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

            ss.Close();
            this.Show();
        }
        private void LoadDgvFees()
        {
            int currentCellRow = 0;
            int currentCellCol = 0;

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

            DataTable dataTable = new DataTable();

            /// Set the datatable based on the SelectedIndex of <see cref="cboInvestmentViews"/>.
            switch (cboFeeViews.SelectedIndex)
            {
            case 0:
                dataTable = PlanRecordKeeperProductFee.GetAssociatedActive(CurrentPlanRecordKeeperProduct);
                break;

            case 1:
                dataTable = PlanRecordKeeperProductFee.GetAssociatedActive(CurrentPlanRecordKeeperProduct);
                break;

            default:
                return;
            }

            dgvFees.DataSource = dataTable;

            // Display/order the columns.
            dgvFees.Columns["PlanRecordKeeperProductFeeId"].Visible = false;
            dgvFees.Columns["PlanId"].Visible = false;
            dgvFees.Columns["RecordKeeperProductId"].Visible = false;
            dgvFees.Columns["CreatedBy"].Visible             = false;
            dgvFees.Columns["ModifiedBy"].Visible            = false;
            dgvFees.Columns["StateCode"].Visible             = false;
            dgvFees.Columns["Notes"].Visible = false;

            dgvFees.Columns["Fee"].DisplayIndex = 0;

            dgvFees.Columns["Benchmark25Fee"].DisplayIndex = 1;
            dgvFees.Columns["Benchmark25Fee"].HeaderText   = "25% Benchmark";

            dgvFees.Columns["Benchmark50Fee"].DisplayIndex = 2;
            dgvFees.Columns["Benchmark50Fee"].HeaderText   = "50% Benchmark";

            dgvFees.Columns["Benchmark75Fee"].DisplayIndex = 3;
            dgvFees.Columns["Benchmark75Fee"].HeaderText   = "75% Benchmark";

            dgvFees.Columns["RevenueSharingPaid"].DisplayIndex = 4;
            dgvFees.Columns["RevenueSharingPaid"].HeaderText   = "Revenue Sharing Paid";

            dgvFees.Columns["ForfeituresPaid"].DisplayIndex = 5;
            dgvFees.Columns["ForfeituresPaid"].HeaderText   = "Forfeitures Paid";

            dgvFees.Columns["ParticipantsPaid"].DisplayIndex = 6;
            dgvFees.Columns["ParticipantsPaid"].HeaderText   = "Participants Paid";

            dgvFees.Columns["PlanSponsorPaid"].DisplayIndex = 7;
            dgvFees.Columns["PlanSponsorPaid"].HeaderText   = "Plan Sponsor Paid";

            dgvFees.Columns["AsOfDate"].DisplayIndex   = 8;
            dgvFees.Columns["ModifiedOn"].DisplayIndex = 9;
            dgvFees.Columns["CreatedOn"].DisplayIndex  = 10;

            if (dgvFees.RowCount > 0 && dgvFees.ColumnCount > 0)
            {
                DataGridViewCell selectedCell = dgvFees.Rows[currentCellRow].Cells[currentCellCol];
                if (selectedCell != null && selectedCell.Visible)
                {
                    dgvFees.CurrentCell = selectedCell;
                }
                else
                {
                    dgvFees.CurrentCell = dgvFees.FirstDisplayedCell;
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="mf"></param>
        /// <param name="planRecordKeeperProductFee"></param>
        /// <param name="Close"></param>
        public frmPlanRecordKeeperProductFee(frmMain mf, PlanRecordKeeperProductFee planRecordKeeperProductFee, 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;

            Plan plan = new Plan(planRecordKeeperProductFee.PlanId);
            PlanRecordKeeperProduct rkpd = new PlanRecordKeeperProduct(planRecordKeeperProductFee.RecordKeeperProductId);
            Product pd = new Product(rkpd.ProductId);

            DataIntegrationHub.Business.Entities.RecordKeeper rk = new DataIntegrationHub.Business.Entities.RecordKeeper(pd.RecordKeeperId);

            CurrentPlanRecordKeeperProductFee = planRecordKeeperProductFee;
            txtPlan.Text         = plan.Name;
            txtRecordKeeper.Text = rk.Name;
            txtProduct.Text      = pd.Name;
            txtNotes.Text        = CurrentPlanRecordKeeperProductFee.Notes;

            txtNotes.Focus();

            if (CurrentPlanRecordKeeperProductFee.Fee != null)
            {
                txtFee.Text = ((decimal)CurrentPlanRecordKeeperProductFee.Fee).ToString("#,##");
            }

            if (CurrentPlanRecordKeeperProductFee.Benchmark25Fee != null)
            {
                txtBenchmark25Fee.Text = ((decimal)CurrentPlanRecordKeeperProductFee.Benchmark25Fee).ToString("#,##");
            }

            if (CurrentPlanRecordKeeperProductFee.Benchmark50Fee != null)
            {
                txtBenchmark50Fee.Text = ((decimal)CurrentPlanRecordKeeperProductFee.Benchmark50Fee).ToString("#,##");
            }

            if (CurrentPlanRecordKeeperProductFee.Benchmark75Fee != null)
            {
                txtBenchmark75Fee.Text = ((decimal)CurrentPlanRecordKeeperProductFee.Benchmark75Fee).ToString("#,##");
            }

            if (CurrentPlanRecordKeeperProductFee.AsOfDate != null)
            {
                dateAsOfDate.Value   = (DateTime)CurrentPlanRecordKeeperProductFee.AsOfDate;
                dateAsOfDate.Checked = true;
            }
            else
            {
                dateAsOfDate.Checked = false;
            }

            chbxRevenueSharingPaid.Checked = CurrentPlanRecordKeeperProductFee.RevenueSharingPaid;
            chbxForfeituresPaid.Checked    = CurrentPlanRecordKeeperProductFee.ForfeituresPaid;
            chbxParticipantsPaid.Checked   = CurrentPlanRecordKeeperProductFee.ParticipantsPaid;
            chbxPlanSponsorPaid.Checked    = CurrentPlanRecordKeeperProductFee.PlanSponsorPaid;

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

            ss.Close();
            this.Show();
        }