/// <summary>
        ///
        /// </summary>
        /// <param name="mf"></param>
        /// <param name="Close"></param>
        public frmPlanAuditor(frmMain mf, Plan plan, 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;

            PreloadCbos();

            CurrentPlanAuditor        = new PlanAuditor();
            CurrentPlanAuditor.PlanId = plan.PlanId;

            cboPlan.Text = plan.Name + " - " + plan.Description;

            ss.Close();
            this.Show();
        }
        private void LoadDgvAuditors()
        {
            DataTable dataTable     = PlanAuditor.GetAssociated(CurrentPlan.PlanId);
            var       dataTableEnum = dataTable.AsEnumerable();

            /// Set the datatable based on the SelectedIndex of <see cref="cboRkViews"/>.
            switch (cboAuditorViews.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();
            }

            dataTable.Columns.Add("Name");

            int i = 0;

            foreach (DataRow dr in dataTable.Rows)
            {
                Guid auditorId = new Guid(dr["AuditorId"].ToString());
                DataIntegrationHub.Business.Entities.Auditor auditor = new DataIntegrationHub.Business.Entities.Auditor(auditorId);
                dataTable.Rows[i]["Name"] = auditor.Name;
                i++;
            }

            dgvAuditors.DataSource = dataTable;

            // Display/order the columns.
            dgvAuditors.Columns["PlanAuditorId"].Visible = false;
            dgvAuditors.Columns["AuditorId"].Visible     = false;
            dgvAuditors.Columns["PlanId"].Visible        = false;
            dgvAuditors.Columns["CreatedBy"].Visible     = false;
            dgvAuditors.Columns["CreatedOn"].Visible     = false;
            dgvAuditors.Columns["ModifiedBy"].Visible    = false;
            dgvAuditors.Columns["ModifiedOn"].Visible    = false;
            dgvAuditors.Columns["StateCode"].Visible     = false;

            dgvAuditors.Columns["Name"].DisplayIndex        = 0;
            dgvAuditors.Columns["DateAdded"].DisplayIndex   = 1;
            dgvAuditors.Columns["DateRemoved"].DisplayIndex = 2;
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mf"></param>
        /// <param name="accountId"></param>
        /// <param name="Close"></param>
        public frmPlanAuditor(frmMain mf, PlanAuditor planAuditor, 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;

            CurrentPlanAuditor = planAuditor;

            cboFeeViews.SelectedIndex = 0;
            PreloadCbos();

            if (CurrentPlanAuditor.PlanId != null)
            {
                Plan plan = new Plan(CurrentPlanAuditor.PlanId);
                cboPlan.Text = plan.Name + " - " + plan.Description;
            }

            if (CurrentPlanAuditor.AuditorId != null)
            {
                DataIntegrationHub.Business.Entities.Auditor auditor = new DataIntegrationHub.Business.Entities.Auditor(CurrentPlanAuditor.AuditorId);
                cboAuditor.Text = auditor.Name;
            }

            if (CurrentPlanAuditor.DateAdded != null)
            {
                txtDateAdded.Text = ((DateTime)CurrentPlanAuditor.DateAdded).ToString("MM/dd/yyyy");
            }

            if (CurrentPlanAuditor.DateRemoved != null)
            {
                txtDateRemoved.Text = ((DateTime)CurrentPlanAuditor.DateRemoved).ToString("MM/dd/yyyy");
            }

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

            ss.Close();
            this.Show();
        }
        private void btnDeleteAuditor_Click(object sender, EventArgs e)
        {
            if (dgvAuditors.CurrentRow == null)
            {
                return;
            }

            int         index         = dgvAuditors.CurrentRow.Index;
            Guid        planAuditorId = new Guid(dgvAuditors.Rows[index].Cells[0].Value.ToString());
            PlanAuditor planAuditor   = new PlanAuditor(planAuditorId);

            DialogResult result = MessageBox.Show("Are you sure you wish to permanently delete the selected auditor from the plan?", "Attention", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                planAuditor.DeleteRecordFromDatabase();
                LoadDgvAuditors();
            }
        }