using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace ddq { public partial class PersonSelectionDialog : Form { private string companyId; public string PersonnelId { get; private set; } public string PersonnelName { get; private set; } public DateTime StartDate { get; private set; } private DataTable peopleDataTable; public PersonSelectionDialog(string companyId) { InitializeComponent(); this.companyId = companyId; InitializeData(); } private void InitializeData() { LoadPeopleList(companyId); } private void LoadPeopleList(string companyId) { peopleDataTable = DataAccess.Get_dd_personnel_info(null, companyId); InitPeopleListGrid(peopleDataTable); } private void InitPeopleListGrid(DataTable dataTable) { if (dataTable == null || dataTable.Rows.Count == 0) { this.lblMessageForNoStaff.Visible = true; return; } DataView dw = new DataView(dataTable); string filter = null; if (chkPM.Checked) { filter = "role = 'Portfolio Manager'"; if (chkResearcher.Checked) { filter += "or role = 'Researcher'"; } } else if (chkResearcher.Checked) { filter = "role = 'Researcher'"; } dw.RowFilter = filter; this.grdStaffList.DataSource = dw; this.grdStaffList.Columns["personnel_id"].Visible = false; this.grdStaffList.Columns["company_id"].Visible = false; this.grdStaffList.Columns["name"].HeaderText = "Name"; this.grdStaffList.Columns["role"].Visible = false; this.grdStaffList.Columns["title"].HeaderText = "Title"; this.grdStaffList.Columns["industry_start_year"].Visible = false; this.grdStaffList.Columns["company_start_year"].HeaderText = "Company Start Year"; this.grdStaffList.Columns["bio"].Visible = false; } private void btnOK_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; } private void chkAll_CheckedChanged(object sender, EventArgs e) { this.chkPM.Checked = this.chkAll.Checked; this.chkResearcher.Checked = chkAll.Checked; InitPeopleListGrid(peopleDataTable); } private void chkPM_CheckedChanged(object sender, EventArgs e) { InitPeopleListGrid(peopleDataTable); } private void chkResearcher_CheckedChanged(object sender, EventArgs e) { InitPeopleListGrid(peopleDataTable); } private void grdStaffList_CellContentClick(object sender, DataGridViewCellEventArgs e) { } private void grdStaffList_CellClick(object sender, DataGridViewCellEventArgs e) { int rowIndex = e.RowIndex; if (rowIndex < 0) return; DataRow row = ((DataView)this.grdStaffList.DataSource).Table.Rows[rowIndex]; PersonnelId = row["personnel_id"].ToString(); PersonnelName = row["name"].ToString(); StartDate = DateTime.Today.AddDays(-1); } } }