| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- 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);
- }
- }
- }
|