UIFund.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace DataManager
  12. {
  13. public partial class UIFund : Form
  14. {
  15. private string fundId = string.Empty;
  16. private DataTable fundInfo = new DataTable();
  17. private DataTable tbNav;
  18. public UIFund()
  19. {
  20. InitializeComponent();
  21. InitializeData();
  22. }
  23. public UIFund(string fundId)
  24. {
  25. this.fundId = fundId;
  26. InitializeComponent();
  27. InitializeData();
  28. }
  29. public string FundId { get { return fundId; } }
  30. private void InitializeData()
  31. {
  32. txtFundId.Text = fundId;
  33. if (fundId != string.Empty)
  34. {
  35. fundInfo = DataAccess.Get_dm_fund_information(fundId, null);
  36. if (fundInfo == null || fundInfo.Rows.Count <= 0)
  37. {
  38. lblFundName.Text = string.Format("基金{0}不存在,得跟管理员说一下", fundId);
  39. lblFundName.ForeColor = Color.Red;
  40. return;
  41. }
  42. lblFundName.Text = fundInfo.Rows[0]["fund_name"].ToString();
  43. txtFundId.ReadOnly = true;
  44. txtRegisterCode.Text = fundInfo.Rows[0]["register_number"].ToString();
  45. txtRegisterCode.ReadOnly = true;
  46. lblInceptionDate.Text = fundInfo.Rows[0]["inception_date"].ToString();
  47. string s = fundInfo.Rows[0]["fund_type"].ToString();
  48. if (s != string.Empty)
  49. lblFundType.Text = UIConstants.FundType[int.Parse(s)];
  50. else
  51. lblFundType.Text = "";
  52. lblCompany.Text = fundInfo.Rows[0]["company_name"].ToString();
  53. lblRegisteDate.Text = fundInfo.Rows[0]["register_date"].ToString();
  54. s = fundInfo.Rows[0]["manager_type"].ToString();
  55. if (s != string.Empty)
  56. lblManagementType.Text = UIConstants.ManagerType[int.Parse(s)];
  57. else
  58. lblManagementType.Text = "";
  59. s = fundInfo.Rows[0]["base_currency"].ToString();
  60. if (s != string.Empty)
  61. lblCurrency.Text = UIConstants.Currency[int.Parse(s)];
  62. else
  63. lblCurrency.Text = "";
  64. s = fundInfo.Rows[0]["fund_status"].ToString();
  65. if (s != String.Empty)
  66. lblStatus.Text = UIConstants.FundStatus[int.Parse(s)];
  67. else
  68. lblStatus.Text = "";
  69. lblCustodian.Text = fundInfo.Rows[0]["custodian_name"].ToString();
  70. lblAmacUpdateDate.Text = fundInfo.Rows[0]["zjx_last_info_update_time"].ToString();
  71. txtFundShortName.Text = fundInfo.Rows[0]["fund_short_name"].ToString();
  72. BindingSource bs1 = new BindingSource();
  73. bs1.DataSource = UIConstants.HedgeFundStrategy;
  74. cmbStrategy.DataSource = bs1;
  75. cmbStrategy.DisplayMember = "Value";
  76. cmbStrategy.ValueMember = "Key";
  77. cmbStrategy.SelectedValue = int.Parse(fundInfo.Rows[0]["strategy"].ToString());
  78. // 净值频率
  79. string navFreq = fundInfo.Rows[0]["nav_frequency"].ToString().Trim();
  80. if (string.IsNullOrEmpty(navFreq)) navFreq = "未知";
  81. cmbNavFrequency.SelectedIndex = cmbNavFrequency.Items.IndexOf(navFreq);
  82. chkRating.Checked = fundInfo.Rows[0]["is_rating"].ToString() == "1" ? true : false;
  83. chkRanking.Checked = fundInfo.Rows[0]["is_ranking"].ToString() == "1" ? true : false;
  84. chkAuthorized.Checked = fundInfo.Rows[0]["is_authorized"].ToString() == "1" ? true : false;
  85. dtpNavStartDate.ShowCheckBox = true;
  86. dtpNavStartDate.Checked = false;
  87. dtpNavStartDate.Value = DateTime.Parse(lblInceptionDate.Text);
  88. dtpNavEndDate.ShowCheckBox = true;
  89. dtpNavEndDate.Checked = false;
  90. LoadNavGrid(null, null);
  91. }
  92. }
  93. private void LoadNavGrid(DateTime? startDate, DateTime? endDate)
  94. {
  95. tbNav = DataAccess.Get_Nav(fundId, startDate, endDate);
  96. grdNav.DataSource = tbNav;
  97. grdNav.Columns["fund_id"].Visible = false;
  98. grdNav.Columns["price_date"].HeaderText = "净值日期";
  99. grdNav.Columns["nav"].HeaderText = "净值";
  100. grdNav.Columns["cumulative_nav_withdrawal"].HeaderText = "现金分红累计净值";
  101. grdNav.Columns["cumulative_nav"].HeaderText = "分红再投累计净值";
  102. grdNav.Columns["cumulative_nav"].DefaultCellStyle.BackColor = Color.AntiqueWhite;
  103. grdNav.Columns["isvalid"].HeaderText = "状态";
  104. grdNav.Columns["creatorid"].HeaderText = "创建";
  105. grdNav.Columns["createtime"].HeaderText = "创建日期";
  106. grdNav.Columns["updaterid"].HeaderText = "更新";
  107. grdNav.Columns["updatetime"].HeaderText = "更新日期";
  108. grdNav.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
  109. grdNav.RowHeadersVisible = false;
  110. }
  111. private void btnDrawNavLineChart_Click(object sender, EventArgs e)
  112. {
  113. NavChart chart = new NavChart(FundId, tbNav);
  114. chart.Show();
  115. }
  116. private void btnSave_Click(object sender, EventArgs e)
  117. {
  118. MessageBox.Show("暂时不做什么事情");
  119. }
  120. private void grdNav_CellContentClick(object sender, DataGridViewCellEventArgs e)
  121. {
  122. //int rowIndex = e.RowIndex;
  123. //int columnIndex = e.ColumnIndex;
  124. //if (rowIndex < 0 || columnIndex < 0) return;
  125. //DataGridViewRow row = grdNav.Rows[rowIndex];
  126. //if(row == null) return;
  127. }
  128. }
  129. }