PersonSelection.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace ddq
  11. {
  12. public partial class PersonSelectionDialog : Form
  13. {
  14. private string companyId;
  15. public string PersonnelId { get; private set; }
  16. public string PersonnelName { get; private set; }
  17. public DateTime StartDate { get; private set; }
  18. private DataTable peopleDataTable;
  19. public PersonSelectionDialog(string companyId)
  20. {
  21. InitializeComponent();
  22. this.companyId = companyId;
  23. InitializeData();
  24. }
  25. private void InitializeData()
  26. {
  27. LoadPeopleList(companyId);
  28. }
  29. private void LoadPeopleList(string companyId)
  30. {
  31. peopleDataTable = DataAccess.Get_dd_personnel_info(null, companyId);
  32. InitPeopleListGrid(peopleDataTable);
  33. }
  34. private void InitPeopleListGrid(DataTable dataTable)
  35. {
  36. if (dataTable == null || dataTable.Rows.Count == 0)
  37. {
  38. this.lblMessageForNoStaff.Visible = true;
  39. return;
  40. }
  41. DataView dw = new DataView(dataTable);
  42. string filter = null;
  43. if (chkPM.Checked)
  44. {
  45. filter = "role = 'Portfolio Manager'";
  46. if (chkResearcher.Checked) { filter += "or role = 'Researcher'"; }
  47. } else if (chkResearcher.Checked) { filter = "role = 'Researcher'"; }
  48. dw.RowFilter = filter;
  49. this.grdStaffList.DataSource = dw;
  50. this.grdStaffList.Columns["personnel_id"].Visible = false;
  51. this.grdStaffList.Columns["company_id"].Visible = false;
  52. this.grdStaffList.Columns["name"].HeaderText = "Name";
  53. this.grdStaffList.Columns["role"].Visible = false;
  54. this.grdStaffList.Columns["title"].HeaderText = "Title";
  55. this.grdStaffList.Columns["industry_start_year"].Visible = false;
  56. this.grdStaffList.Columns["company_start_year"].HeaderText = "Company Start Year";
  57. this.grdStaffList.Columns["bio"].Visible = false;
  58. }
  59. private void btnOK_Click(object sender, EventArgs e)
  60. {
  61. this.DialogResult = DialogResult.OK;
  62. }
  63. private void chkAll_CheckedChanged(object sender, EventArgs e)
  64. {
  65. this.chkPM.Checked = this.chkAll.Checked;
  66. this.chkResearcher.Checked = chkAll.Checked;
  67. InitPeopleListGrid(peopleDataTable);
  68. }
  69. private void chkPM_CheckedChanged(object sender, EventArgs e)
  70. {
  71. InitPeopleListGrid(peopleDataTable);
  72. }
  73. private void chkResearcher_CheckedChanged(object sender, EventArgs e)
  74. {
  75. InitPeopleListGrid(peopleDataTable);
  76. }
  77. private void grdStaffList_CellContentClick(object sender, DataGridViewCellEventArgs e)
  78. {
  79. }
  80. private void grdStaffList_CellClick(object sender, DataGridViewCellEventArgs e)
  81. {
  82. int rowIndex = e.RowIndex;
  83. if (rowIndex < 0) return;
  84. DataRow row = ((DataView)this.grdStaffList.DataSource).Table.Rows[rowIndex];
  85. PersonnelId = row["personnel_id"].ToString();
  86. PersonnelName = row["name"].ToString();
  87. StartDate = DateTime.Today.AddDays(-1);
  88. }
  89. }
  90. }