DDQ.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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.Text.RegularExpressions;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace ddq
  12. {
  13. public partial class frmMain : Form
  14. {
  15. // 先hard-code公司ID,以后要按照登录用户来判断它的公司归属
  16. private string companyId = "CO000201PR";
  17. private int userId = 123;
  18. private DataTable fundDataTable;
  19. private DataTable peopleDataTable;
  20. public frmMain()
  21. {
  22. InitializeComponent();
  23. InitializeData();
  24. }
  25. private void InitializeData()
  26. {
  27. }
  28. private void tbcMain_SelectedIndexChanged(object sender, EventArgs e)
  29. {
  30. // Request
  31. if (tbcMain.SelectedIndex == 0) { }
  32. // Data
  33. else if (tbcMain.SelectedIndex == 1) {
  34. LoadFundList(companyId);
  35. }
  36. // Setting
  37. else { };
  38. }
  39. private void LoadFundList(string companyId)
  40. {
  41. if (fundDataTable == null)
  42. {
  43. fundDataTable = DataAccess.Get_fund_list_by_company(companyId, 1, 1000);
  44. InitFundListGrid(fundDataTable);
  45. }
  46. }
  47. private void InitFundListGrid(DataTable dt)
  48. {
  49. this.grdFundList.DataSource = dt;
  50. this.grdFundList.Columns["fund_id"].Visible = true;
  51. this.grdFundList.Columns["company_id"].Visible = false;
  52. this.grdFundList.Columns["fund_short_name"].HeaderText = "Fund Name";
  53. this.grdFundList.Columns["fund_status"].HeaderText = "Operating Status";
  54. this.grdFundList.Columns["management_start_date"].HeaderText = "Inception Date";
  55. this.grdFundList.Columns["management_start_date"].DefaultCellStyle.Format = "yyyy-MM-dd";
  56. this.grdFundList.Columns["management_end_date"].HeaderText = "Liquidate Date";
  57. this.grdFundList.Columns["management_end_date"].DefaultCellStyle.Format = "yyyy-MM-dd";
  58. this.grdFundList.Columns["ret_tenure"].HeaderText = "Return Since Inception";
  59. this.grdFundList.Columns["ret_tenure"].DefaultCellStyle.Format = "P1";
  60. }
  61. private void grdFundList_CellContentClick(object sender, DataGridViewCellEventArgs e)
  62. {
  63. int rowIndex = e.RowIndex;
  64. int columnIndex = e.ColumnIndex;
  65. if (columnIndex < 0 || rowIndex < 0) return;
  66. DataRow row = fundDataTable.Rows[rowIndex];
  67. // 弹出基金页面
  68. string entityId = row["fund_id"].ToString();
  69. if (entityId.Length == 10 && Regex.Match(entityId, "^[HM]F").Success)
  70. {
  71. FundQ fundQ = new FundQ(entityId, companyId, userId);
  72. fundQ.Show();
  73. }
  74. }
  75. private void LoadPeopleList(string companyId)
  76. {
  77. if (peopleDataTable == null)
  78. {
  79. peopleDataTable = DataAccess.Get_dd_personnel_info(null, companyId);
  80. InitPeopleListGrid(peopleDataTable);
  81. }
  82. }
  83. private void InitPeopleListGrid(DataTable dt)
  84. {
  85. this.grdPeopleList.DataSource = dt;
  86. this.grdPeopleList.Columns["personnel_id"].Visible = false;
  87. this.grdPeopleList.Columns["company_id"].Visible = false;
  88. this.grdPeopleList.Columns["role"].Visible = false;
  89. this.grdPeopleList.Columns["name"].HeaderText = "Name";
  90. this.grdPeopleList.Columns["role_desc"].HeaderText = "Role";
  91. this.grdPeopleList.Columns["title"].HeaderText = "Title";
  92. this.grdPeopleList.Columns["industry_start_year"].HeaderText = "Industry Start Year";
  93. this.grdPeopleList.Columns["company_start_year"].HeaderText = "Company Start Year";
  94. this.grdPeopleList.Columns["bio"].HeaderText = "Bio";
  95. }
  96. private void tbcData_SelectedIndexChanged(object sender, EventArgs e)
  97. {
  98. if (tbcData.SelectedIndex == 0)
  99. {
  100. LoadFundList(companyId);
  101. }
  102. else if (tbcData.SelectedIndex == 1)
  103. {
  104. LoadPeopleList(companyId);
  105. }
  106. else { }
  107. }
  108. //
  109. // People
  110. //
  111. private void btnAddPersonn_Click(object sender, EventArgs e)
  112. {
  113. LoadPersonnelQ(null);
  114. }
  115. private void grdPeopleList_CellClick(object sender, DataGridViewCellEventArgs e)
  116. {
  117. int rowIndex = e.RowIndex;
  118. if (rowIndex < 0) return;
  119. string personnelId = peopleDataTable.Rows[rowIndex]["personnel_id"].ToString();
  120. LoadPersonnelQ(personnelId);
  121. }
  122. private void LoadPersonnelQ(string personnelId)
  123. {
  124. using (PersonnelQ dialog = new PersonnelQ(personnelId, this.companyId, this.userId))
  125. {
  126. dialog.StartPosition = FormStartPosition.CenterParent;
  127. DialogResult result = dialog.ShowDialog(this);
  128. if (result == DialogResult.OK)
  129. {
  130. peopleDataTable = DataAccess.Get_dd_personnel_info(null, this.companyId);
  131. this.grdPeopleList.DataSource = peopleDataTable;
  132. }
  133. }
  134. }
  135. }
  136. }