Browse Source

fund, company Json数据结构调整

Joey 5 giờ trước cách đây
mục cha
commit
de604f2752
8 tập tin đã thay đổi với 467 bổ sung248 xóa
  1. 14 14
      DDQ.Designer.cs
  2. 61 44
      DDQ.cs
  3. 3 0
      DDQ.resx
  4. 2 8
      DataAccess.cs
  5. 25 70
      FundQ.Designer.cs
  6. 227 93
      FundQ.cs
  7. 17 4
      PersonnelQ.cs
  8. 118 15
      Utility.cs

+ 14 - 14
DDQ.Designer.cs

@@ -44,7 +44,7 @@
             this.panFundList = new System.Windows.Forms.Panel();
             this.grdFundList = new System.Windows.Forms.DataGridView();
             this.panFundsTool = new System.Windows.Forms.Panel();
-            this.cmbFundCategory = new System.Windows.Forms.ComboBox();
+            this.cmbCategoryGroup = new System.Windows.Forms.ComboBox();
             this.label2 = new System.Windows.Forms.Label();
             this.btnSearchFund = new System.Windows.Forms.Button();
             this.txtSearchFund = new System.Windows.Forms.TextBox();
@@ -300,7 +300,7 @@
             // 
             // panFundsTool
             // 
-            this.panFundsTool.Controls.Add(this.cmbFundCategory);
+            this.panFundsTool.Controls.Add(this.cmbCategoryGroup);
             this.panFundsTool.Controls.Add(this.label2);
             this.panFundsTool.Controls.Add(this.btnSearchFund);
             this.panFundsTool.Controls.Add(this.txtSearchFund);
@@ -310,25 +310,25 @@
             this.panFundsTool.Size = new System.Drawing.Size(772, 61);
             this.panFundsTool.TabIndex = 0;
             // 
-            // cmbFundCategory
+            // cmbCategoryGroup
             // 
-            this.cmbFundCategory.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.cmbFundCategory.Enabled = false;
-            this.cmbFundCategory.FormattingEnabled = true;
-            this.cmbFundCategory.Location = new System.Drawing.Point(562, 18);
-            this.cmbFundCategory.Name = "cmbFundCategory";
-            this.cmbFundCategory.Size = new System.Drawing.Size(196, 26);
-            this.cmbFundCategory.TabIndex = 3;
+            this.cmbCategoryGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.cmbCategoryGroup.FormattingEnabled = true;
+            this.cmbCategoryGroup.Location = new System.Drawing.Point(562, 18);
+            this.cmbCategoryGroup.Name = "cmbCategoryGroup";
+            this.cmbCategoryGroup.Size = new System.Drawing.Size(196, 26);
+            this.cmbCategoryGroup.TabIndex = 3;
+            this.cmbCategoryGroup.SelectedIndexChanged += new System.EventHandler(this.cmbCategoryGroup_SelectedIndexChanged);
             // 
             // label2
             // 
             this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.label2.AutoSize = true;
-            this.label2.Location = new System.Drawing.Point(493, 22);
+            this.label2.Location = new System.Drawing.Point(452, 21);
             this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(63, 18);
+            this.label2.Size = new System.Drawing.Size(104, 18);
             this.label2.TabIndex = 2;
-            this.label2.Text = "Category";
+            this.label2.Text = "Category Group";
             // 
             // btnSearchFund
             // 
@@ -946,7 +946,7 @@
         private System.Windows.Forms.TextBox txtSearchFund;
         private System.Windows.Forms.TabPage tabCompany;
         private System.Windows.Forms.DataGridView grdFundList;
-        private System.Windows.Forms.ComboBox cmbFundCategory;
+        private System.Windows.Forms.ComboBox cmbCategoryGroup;
         private System.Windows.Forms.Label label2;
         private System.Windows.Forms.Button btnSearchFund;
         private System.Windows.Forms.DataGridView grdPeopleList;

+ 61 - 44
DDQ.cs

@@ -21,7 +21,7 @@ namespace ddq
     {
 
         // 先hard-code公司ID,以后要按照登录用户来判断它的公司归属
-        private string companyId = "CO000201PR";
+        private string companyId = "CO0002000E";
         private int userId = 123;
 
         private DataTable fundDataTable;
@@ -74,9 +74,18 @@ namespace ddq
         //
         private void LoadFundList(string companyId)
         {
+            BindingSource bs = new BindingSource();
+            Dictionary<int, string> d = new Dictionary<int, string>(Utility.CategoryGroup);
+            bs.DataSource = d;
+            this.cmbCategoryGroup.DataSource = bs;
+
+            this.cmbCategoryGroup.DisplayMember = "Value";
+            this.cmbCategoryGroup.ValueMember = "Key";
+            this.cmbCategoryGroup.SelectedValue = 0;
+
             if (fundDataTable == null)
             {
-                fundDataTable = DataAccess.Get_fund_list_by_company(companyId, 1, 1000);
+                fundDataTable = DataAccess.Get_fund_list_by_company(companyId);
 
                 InitFundListGrid(fundDataTable);
             }
@@ -87,17 +96,20 @@ namespace ddq
             this.grdFundList.DataSource = dt;
 
             this.grdFundList.Columns["fund_id"].Visible = true;
-            this.grdFundList.Columns["company_id"].Visible = false;
 
             this.grdFundList.Columns["fund_short_name"].HeaderText = "Fund Name";
-            this.grdFundList.Columns["fund_status"].HeaderText = "Operating Status";
-            this.grdFundList.Columns["management_start_date"].HeaderText = "Inception Date";
-            this.grdFundList.Columns["management_start_date"].DefaultCellStyle.Format = "yyyy-MM-dd";
-            this.grdFundList.Columns["management_end_date"].HeaderText = "Liquidate Date";
-            this.grdFundList.Columns["management_end_date"].DefaultCellStyle.Format = "yyyy-MM-dd";
-            this.grdFundList.Columns["ret_tenure"].HeaderText = "Return Since Inception";
-            this.grdFundList.Columns["ret_tenure"].DefaultCellStyle.Format = "P1";
 
+            this.grdFundList.Columns["inception_date"].HeaderText = "Inception Date";
+            this.grdFundList.Columns["inception_date"].DefaultCellStyle.Format = "yyyy-MM-dd";
+            
+            this.grdFundList.Columns["strategy_id"].Visible = false;
+            this.grdFundList.Columns["strategy"].HeaderText = "Broad Asset Group";
+            
+            this.grdFundList.Columns["domicile"].HeaderText = "Domicile";
+            this.grdFundList.Columns["base_currency"].HeaderText = "Currency";
+            
+            this.grdFundList.Columns["status_id"].Visible = false;
+            this.grdFundList.Columns["status"].HeaderText = "Operating Status";
         }
 
         private void grdFundList_CellContentClick(object sender, DataGridViewCellEventArgs e)
@@ -120,6 +132,24 @@ namespace ddq
 
         }
 
+        private void cmbCategoryGroup_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            string filter = "";
+
+            if (fundDataTable != null && fundDataTable.Rows != null && fundDataTable.Rows.Count > 0)
+            {
+
+                if (cmbCategoryGroup.SelectedIndex > 0)
+                {
+                    filter = "strategy_id = " + cmbCategoryGroup.SelectedValue;
+
+                    this.fundDataTable.DefaultView.RowFilter = filter;
+                } else
+                {
+                    this.fundDataTable.DefaultView.RowFilter = "";
+                }
+            }
+        }
 
         //
         //  People
@@ -209,26 +239,11 @@ namespace ddq
                     //
                     // General Info
                     //
-                    Utility.DDData dddata = Utility.Json2Text2(root, "foundingDate");
-                    if (dddata != null)
-                    {
-                        bool isDate = DateTime.TryParse(dddata.value.ToString(), out DateTime newDate);
-                        if (isDate)
-                        {
-                            this.dtpIncepionDate.Value = newDate.Date;
-                            this.tspInceptionDate.Text = dddata.updateTime;
-                            this.tspInceptionDate.ForeColor = Utility.IsChangedRecently(dddata.updateTime) ? Color.Red : Color.DarkSlateGray;
-                        }
-                    }
-
-                    this.txtDetailOfAcquired.Text = Utility.Json2Text2(root, "detailOfAcquired").value.ToString();
-                    this.tspDetailOfAcquired.Text = Utility.Json2Text2(root, "detailOfAcquired").updateTime;
-                    this.tspDetailOfAcquired.ForeColor = Utility.IsChangedRecently(this.tspDetailOfAcquired.Text) ? Color.Red : Color.DarkSlateGray;
+                    LoadDateDataFromJson(this.dtpIncepionDate, root, "foundingDate", this.tspInceptionDate);
 
-                    this.txtParentCompanyName.Text = Utility.Json2Text2(root, "parentCompanyName").value.ToString();
-                    this.tspParentCompanyName.Text = Utility.Json2Text2(root, "parentCompanyName").updateTime;
-                    this.tspParentCompanyName.ForeColor = Utility.IsChangedRecently(this.tspParentCompanyName.Text) ? Color.Red : Color.DarkSlateGray;
+                    LoadTextDataFromJson(this.txtDetailOfAcquired, root, "detailOfAcquired", this.tspDetailOfAcquired);
 
+                    LoadTextDataFromJson(this.txtParentCompanyName, root, "parentCompanyName", this.tspParentCompanyName);
 
                     LoadAcqusitionGrid(root);
 
@@ -264,9 +279,9 @@ namespace ddq
 
                 if (dddata != null)
                 {
-                    dt = (DataTable)dddata.value;
+                    dt = (DataTable)dddata.Value;
 
-                    strUpdateTime = dddata.updateTime;
+                    strUpdateTime = dddata.UpdateTime;
                 }
 
             } else
@@ -285,7 +300,7 @@ namespace ddq
             this.grdAcquisiton.Columns["action"].DisplayIndex = 1;
 
             this.tspAcqusition.Text = strUpdateTime;
-            this.tspAcqusition.ForeColor = Utility.IsChangedRecently(strUpdateTime) ? Color.Red : Color.DarkSlateGray;
+            this.tspAcqusition.ForeColor = Utility.IsChangedRecently(strUpdateTime) ? COLOR_MODIFIED : COLOR_NORMAL;
 
         }
 
@@ -317,7 +332,7 @@ namespace ddq
             }
 
             this.tspSupportFromParent.Text = strUpdateTime;
-            this.tspSupportFromParent.ForeColor = Utility.IsChangedRecently(strUpdateTime) ? Color.Red : Color.DarkSlateGray;
+            this.tspSupportFromParent.ForeColor = Utility.IsChangedRecently(strUpdateTime) ? COLOR_MODIFIED : COLOR_NORMAL;
 
         }
 
@@ -339,9 +354,9 @@ namespace ddq
 
                 if (dddata != null)
                 {
-                    dt = (DataTable)dddata.value;
+                    dt = (DataTable)dddata.Value;
 
-                    strUpdateTime = dddata.updateTime;
+                    strUpdateTime = dddata.UpdateTime;
                 }
             }
             else
@@ -378,7 +393,7 @@ namespace ddq
             this.grdFinancialData.Columns["interestCoverageRatio"].DisplayIndex = 3;
 
             this.tspFinancialData.Text = strUpdateTime;
-            this.tspFinancialData.ForeColor = Utility.IsChangedRecently(strUpdateTime) ? Color.Red : Color.DarkSlateGray;
+            this.tspFinancialData.ForeColor = Utility.IsChangedRecently(strUpdateTime) ? COLOR_MODIFIED : COLOR_NORMAL;
 
         }
 
@@ -399,9 +414,9 @@ namespace ddq
 
                 if (dddata != null)
                 {
-                    dt = (DataTable)dddata.value;
+                    dt = (DataTable)dddata.Value;
 
-                    strUpdateTime = dddata.updateTime;
+                    strUpdateTime = dddata.UpdateTime;
                 }
             }
             else
@@ -443,7 +458,7 @@ namespace ddq
             this.grdCreditRating.Columns["preferred"].DisplayIndex = 7;
 
             this.tspCreditRating.Text = strUpdateTime;
-            this.tspCreditRating.ForeColor = Utility.IsChangedRecently(strUpdateTime) ? Color.Red : Color.DarkSlateGray;
+            this.tspCreditRating.ForeColor = Utility.IsChangedRecently(strUpdateTime) ? COLOR_MODIFIED : COLOR_NORMAL;
         }
 
         private void LoadCompanyAUM(JsonElement jsonElement)
@@ -463,9 +478,9 @@ namespace ddq
 
                 if (dddata != null)
                 {
-                    dt = (DataTable)dddata.value;
+                    dt = (DataTable)dddata.Value;
 
-                    strUpdateTime = dddata.updateTime;
+                    strUpdateTime = dddata.UpdateTime;
                 }
             }
             else
@@ -487,7 +502,7 @@ namespace ddq
             }
 
             this.tspAUM.Text = strUpdateTime;
-            this.tspAUM.ForeColor = Utility.IsChangedRecently(strUpdateTime) ? Color.Red : Color.DarkSlateGray;
+            this.tspAUM.ForeColor = Utility.IsChangedRecently(strUpdateTime) ? COLOR_MODIFIED : COLOR_NORMAL;
         }
 
         private void LoadClientBreakdown(JsonElement jsonElement)
@@ -507,9 +522,9 @@ namespace ddq
 
                 if (dddata != null)
                 {
-                    dt = (DataTable)dddata.value;
+                    dt = (DataTable)dddata.Value;
 
-                    strUpdateTime = dddata.updateTime;
+                    strUpdateTime = dddata.UpdateTime;
                 }
             }
             else
@@ -543,7 +558,7 @@ namespace ddq
             }
 
             this.tspClientBreakdown.Text = strUpdateTime;
-            this.tspClientBreakdown.ForeColor = Utility.IsChangedRecently(strUpdateTime) ? Color.Red : Color.DarkSlateGray;
+            this.tspClientBreakdown.ForeColor = Utility.IsChangedRecently(strUpdateTime) ? COLOR_MODIFIED : COLOR_NORMAL;
 
         }
 
@@ -603,5 +618,7 @@ namespace ddq
                 MessageBox.Show($"Error: {ex.Message}", "Error");
             }
         }
+
+
     }
 }

+ 3 - 0
DDQ.resx

@@ -120,4 +120,7 @@
   <metadata name="agent.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="agent.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
 </root>

+ 2 - 8
DataAccess.cs

@@ -47,21 +47,15 @@ namespace ddq
         /// 根据公司搜索基金
         /// </summary>
         /// <param name="companyId"></param>
-        /// <param name="pageNum"></param>
-        /// <param name="pageSize"</param>
         /// <returns></returns>
-        public static DataTable Get_fund_list_by_company(string companyId, int pageNum, int pageSize)
+        public static DataTable Get_fund_list_by_company(string companyId)
         {
             MySqlConnection connection = new MySqlConnection(connectionString);
-            MySqlDataAdapter ad = new MySqlDataAdapter("sp_tamp_get_fund_list_of_companay", connection);
+            MySqlDataAdapter ad = new MySqlDataAdapter("sp_dd_get_fund_list_by_company", connection);
 
             MySqlParameter i_company_id = new MySqlParameter("i_company_id", companyId);
-            MySqlParameter i_page_num = new MySqlParameter("i_page_num", pageNum);
-            MySqlParameter i_page_size = new MySqlParameter("i_page_size", pageSize);
 
             ad.SelectCommand.Parameters.Add(i_company_id);
-            ad.SelectCommand.Parameters.Add(i_page_num);
-            ad.SelectCommand.Parameters.Add(i_page_size);
             ad.SelectCommand.CommandType = CommandType.StoredProcedure;
 
             DataTable dt = new DataTable();

+ 25 - 70
FundQ.Designer.cs

@@ -96,11 +96,8 @@
             this.tspCurrentFee = new System.Windows.Forms.Label();
             this.tspPolicyOfClosingFund = new System.Windows.Forms.Label();
             this.tspFundProcess = new System.Windows.Forms.Label();
-            this.tspAllowDerivatives = new System.Windows.Forms.Label();
-            this.tspUseDerivatives = new System.Windows.Forms.Label();
-            this.tspDerivatesFor = new System.Windows.Forms.Label();
+            this.tspDerivatives = new System.Windows.Forms.Label();
             this.tspPriceTarget = new System.Windows.Forms.Label();
-            this.tspOverrunPriceTarget = new System.Windows.Forms.Label();
             this.panStaticData.SuspendLayout();
             this.tbcFund.SuspendLayout();
             this.tabGeneralInfo.SuspendLayout();
@@ -542,11 +539,8 @@
             // panel2
             // 
             this.panel2.AutoScroll = true;
-            this.panel2.Controls.Add(this.tspOverrunPriceTarget);
             this.panel2.Controls.Add(this.tspPriceTarget);
-            this.panel2.Controls.Add(this.tspDerivatesFor);
-            this.panel2.Controls.Add(this.tspUseDerivatives);
-            this.panel2.Controls.Add(this.tspAllowDerivatives);
+            this.panel2.Controls.Add(this.tspDerivatives);
             this.panel2.Controls.Add(this.tspFundProcess);
             this.panel2.Controls.Add(this.label18);
             this.panel2.Controls.Add(this.txtOverrunPriceTarget);
@@ -582,7 +576,7 @@
             // 
             this.txtOverrunPriceTarget.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
             | System.Windows.Forms.AnchorStyles.Right)));
-            this.txtOverrunPriceTarget.Location = new System.Drawing.Point(18, 566);
+            this.txtOverrunPriceTarget.Location = new System.Drawing.Point(12, 542);
             this.txtOverrunPriceTarget.Multiline = true;
             this.txtOverrunPriceTarget.Name = "txtOverrunPriceTarget";
             this.txtOverrunPriceTarget.Size = new System.Drawing.Size(944, 56);
@@ -591,7 +585,7 @@
             // label17
             // 
             this.label17.AutoSize = true;
-            this.label17.Location = new System.Drawing.Point(18, 545);
+            this.label17.Location = new System.Drawing.Point(12, 521);
             this.label17.Name = "label17";
             this.label17.Size = new System.Drawing.Size(708, 18);
             this.label17.TabIndex = 13;
@@ -601,7 +595,7 @@
             // chkPriceTarget
             // 
             this.chkPriceTarget.AutoSize = true;
-            this.chkPriceTarget.Location = new System.Drawing.Point(18, 510);
+            this.chkPriceTarget.Location = new System.Drawing.Point(15, 486);
             this.chkPriceTarget.Name = "chkPriceTarget";
             this.chkPriceTarget.Size = new System.Drawing.Size(395, 22);
             this.chkPriceTarget.TabIndex = 12;
@@ -612,7 +606,7 @@
             // chkDerivatesForLeverage
             // 
             this.chkDerivatesForLeverage.AutoSize = true;
-            this.chkDerivatesForLeverage.Location = new System.Drawing.Point(257, 471);
+            this.chkDerivatesForLeverage.Location = new System.Drawing.Point(259, 444);
             this.chkDerivatesForLeverage.Name = "chkDerivatesForLeverage";
             this.chkDerivatesForLeverage.Size = new System.Drawing.Size(194, 22);
             this.chkDerivatesForLeverage.TabIndex = 11;
@@ -622,7 +616,7 @@
             // chkDerivativesForMarket
             // 
             this.chkDerivativesForMarket.AutoSize = true;
-            this.chkDerivativesForMarket.Location = new System.Drawing.Point(257, 443);
+            this.chkDerivativesForMarket.Location = new System.Drawing.Point(259, 416);
             this.chkDerivativesForMarket.Name = "chkDerivativesForMarket";
             this.chkDerivativesForMarket.Size = new System.Drawing.Size(113, 22);
             this.chkDerivativesForMarket.TabIndex = 10;
@@ -632,7 +626,7 @@
             // chkDerivatesForHedging
             // 
             this.chkDerivatesForHedging.AutoSize = true;
-            this.chkDerivatesForHedging.Location = new System.Drawing.Point(257, 415);
+            this.chkDerivatesForHedging.Location = new System.Drawing.Point(259, 388);
             this.chkDerivatesForHedging.Name = "chkDerivatesForHedging";
             this.chkDerivatesForHedging.Size = new System.Drawing.Size(78, 22);
             this.chkDerivatesForHedging.TabIndex = 9;
@@ -642,7 +636,7 @@
             // chkDerivativesForEfficent
             // 
             this.chkDerivativesForEfficent.AutoSize = true;
-            this.chkDerivativesForEfficent.Location = new System.Drawing.Point(257, 387);
+            this.chkDerivativesForEfficent.Location = new System.Drawing.Point(259, 360);
             this.chkDerivativesForEfficent.Name = "chkDerivativesForEfficent";
             this.chkDerivativesForEfficent.Size = new System.Drawing.Size(219, 22);
             this.chkDerivativesForEfficent.TabIndex = 8;
@@ -652,7 +646,7 @@
             // label15
             // 
             this.label15.AutoSize = true;
-            this.label15.Location = new System.Drawing.Point(15, 386);
+            this.label15.Location = new System.Drawing.Point(17, 359);
             this.label15.Name = "label15";
             this.label15.Size = new System.Drawing.Size(224, 18);
             this.label15.TabIndex = 7;
@@ -661,7 +655,7 @@
             // chkUseDerivatives
             // 
             this.chkUseDerivatives.AutoSize = true;
-            this.chkUseDerivatives.Location = new System.Drawing.Point(18, 346);
+            this.chkUseDerivatives.Location = new System.Drawing.Point(18, 332);
             this.chkUseDerivatives.Name = "chkUseDerivatives";
             this.chkUseDerivatives.Size = new System.Drawing.Size(319, 22);
             this.chkUseDerivatives.TabIndex = 6;
@@ -679,6 +673,7 @@
             this.chkAllowDerivatives.Text = "Does the fund‘s investment objective/policy/investment restriction allow for the " +
     "use of derivatives?";
             this.chkAllowDerivatives.UseVisualStyleBackColor = true;
+            this.chkAllowDerivatives.CheckedChanged += new System.EventHandler(this.chkAllowDerivatives_CheckedChanged);
             // 
             // btnUploadProcessDiagram
             // 
@@ -804,7 +799,6 @@
             // 
             // tspTER
             // 
-            this.tspTER.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.tspTER.AutoSize = true;
             this.tspTER.Font = new System.Drawing.Font("Calibri", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
             this.tspTER.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
@@ -850,41 +844,17 @@
             this.tspFundProcess.TabIndex = 30;
             this.tspFundProcess.Text = "yyyy-MM-dd hh:mm:ss";
             // 
-            // tspAllowDerivatives
-            // 
-            this.tspAllowDerivatives.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.tspAllowDerivatives.AutoSize = true;
-            this.tspAllowDerivatives.Font = new System.Drawing.Font("Calibri", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-            this.tspAllowDerivatives.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
-            this.tspAllowDerivatives.Location = new System.Drawing.Point(834, 307);
-            this.tspAllowDerivatives.Name = "tspAllowDerivatives";
-            this.tspAllowDerivatives.Size = new System.Drawing.Size(128, 15);
-            this.tspAllowDerivatives.TabIndex = 31;
-            this.tspAllowDerivatives.Text = "yyyy-MM-dd hh:mm:ss";
-            // 
-            // tspUseDerivatives
-            // 
-            this.tspUseDerivatives.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.tspUseDerivatives.AutoSize = true;
-            this.tspUseDerivatives.Font = new System.Drawing.Font("Calibri", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-            this.tspUseDerivatives.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
-            this.tspUseDerivatives.Location = new System.Drawing.Point(834, 349);
-            this.tspUseDerivatives.Name = "tspUseDerivatives";
-            this.tspUseDerivatives.Size = new System.Drawing.Size(128, 15);
-            this.tspUseDerivatives.TabIndex = 32;
-            this.tspUseDerivatives.Text = "yyyy-MM-dd hh:mm:ss";
-            // 
-            // tspDerivatesFor
-            // 
-            this.tspDerivatesFor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.tspDerivatesFor.AutoSize = true;
-            this.tspDerivatesFor.Font = new System.Drawing.Font("Calibri", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-            this.tspDerivatesFor.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
-            this.tspDerivatesFor.Location = new System.Drawing.Point(834, 390);
-            this.tspDerivatesFor.Name = "tspDerivatesFor";
-            this.tspDerivatesFor.Size = new System.Drawing.Size(128, 15);
-            this.tspDerivatesFor.TabIndex = 33;
-            this.tspDerivatesFor.Text = "yyyy-MM-dd hh:mm:ss";
+            // tspDerivatives
+            // 
+            this.tspDerivatives.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.tspDerivatives.AutoSize = true;
+            this.tspDerivatives.Font = new System.Drawing.Font("Calibri", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.tspDerivatives.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
+            this.tspDerivatives.Location = new System.Drawing.Point(834, 307);
+            this.tspDerivatives.Name = "tspDerivatives";
+            this.tspDerivatives.Size = new System.Drawing.Size(128, 15);
+            this.tspDerivatives.TabIndex = 31;
+            this.tspDerivatives.Text = "yyyy-MM-dd hh:mm:ss";
             // 
             // tspPriceTarget
             // 
@@ -892,24 +862,12 @@
             this.tspPriceTarget.AutoSize = true;
             this.tspPriceTarget.Font = new System.Drawing.Font("Calibri", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
             this.tspPriceTarget.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
-            this.tspPriceTarget.Location = new System.Drawing.Point(834, 513);
+            this.tspPriceTarget.Location = new System.Drawing.Point(831, 489);
             this.tspPriceTarget.Name = "tspPriceTarget";
             this.tspPriceTarget.Size = new System.Drawing.Size(128, 15);
             this.tspPriceTarget.TabIndex = 34;
             this.tspPriceTarget.Text = "yyyy-MM-dd hh:mm:ss";
             // 
-            // tspOverrunPriceTarget
-            // 
-            this.tspOverrunPriceTarget.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.tspOverrunPriceTarget.AutoSize = true;
-            this.tspOverrunPriceTarget.Font = new System.Drawing.Font("Calibri", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-            this.tspOverrunPriceTarget.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
-            this.tspOverrunPriceTarget.Location = new System.Drawing.Point(834, 547);
-            this.tspOverrunPriceTarget.Name = "tspOverrunPriceTarget";
-            this.tspOverrunPriceTarget.Size = new System.Drawing.Size(128, 15);
-            this.tspOverrunPriceTarget.TabIndex = 35;
-            this.tspOverrunPriceTarget.Text = "yyyy-MM-dd hh:mm:ss";
-            // 
             // FundQ
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F);
@@ -1010,10 +968,7 @@
         private System.Windows.Forms.Label tspTER;
         private System.Windows.Forms.Label tspPortfolioManager;
         private System.Windows.Forms.Label tspFundProcess;
-        private System.Windows.Forms.Label tspOverrunPriceTarget;
         private System.Windows.Forms.Label tspPriceTarget;
-        private System.Windows.Forms.Label tspDerivatesFor;
-        private System.Windows.Forms.Label tspUseDerivatives;
-        private System.Windows.Forms.Label tspAllowDerivatives;
+        private System.Windows.Forms.Label tspDerivatives;
     }
 }

+ 227 - 93
FundQ.cs

@@ -12,6 +12,11 @@ using System.Text.Json.Serialization;
 using System.Drawing.Text;
 using System.IO;
 
+using static ddq.Utility;
+using static ddq.DataAccess;
+using System.Diagnostics.Eventing.Reader;
+using System.Diagnostics.Metrics;
+using Org.BouncyCastle.Bcpg.OpenPgp;
 
 namespace ddq
 {
@@ -52,11 +57,6 @@ namespace ddq
 
             fundInfoTable = DataAccess.Get_dd_fund_info(fundId, null, 1);
 
-            bool hasPM = false;
-            DataTable dtPM;
-            bool hasTER = false;
-            DataTable dtTER;
-
             if (fundInfoTable != null && fundInfoTable.Rows.Count > 0)
             {
 
@@ -70,96 +70,74 @@ namespace ddq
                     //
                     // General Info
                     //
-                    this.txtInvestmentObjective.Text = Utility.Json2Text(root, "investmentObjective");
-                    this.txtBenchmark.Text = Utility.Json2Text(root, "benchmark");
-                    this.txtInvestmentPhilosophy.Text = Utility.Json2Text(root, "investmentPhilosophy");
-                    this.txtManagementFee.Text = Utility.Json2Text(root, "managementFee");
-                    this.txtSubscriptionFee.Text = Utility.Json2Text(root, "subscriptionFee");
-                    this.txtRedemptionFee.Text = Utility.Json2Text(root, "redemptionFee");
-                    this.txtAdministrationFee.Text = Utility.Json2Text(root, "administrationFee");
-                    this.txtSwitchingFee.Text = Utility.Json2Text(root, "switchingFee");
-                    this.txtTrusteeFee.Text = Utility.Json2Text(root, "trusteeFee");
-                    this.txtPerformanceFee.Text = Utility.Json2Text(root, "performanceFee");
-                    this.txtPolicyOfClosingFund.Text = Utility.Json2Text(root, "policyOfClosingFund");
-
-                    JsonElement elmPM;
-                    hasPM = root.TryGetProperty("portfolioManagers", out elmPM);
+                    LoadTextDataFromJson(this.txtInvestmentObjective, root, "investmentObjective", this.tspInvestmentObjective);
                     
-                    if (hasPM == true)
-                    {
-                        dtPM = Utility.Json2Table(elmPM);
-                        InitPortfolioManagerGrid(dtPM);
-                    }
+                    LoadTextDataFromJson(this.txtBenchmark, root, "benchmark", this.tspBenchmark);
+                    
+                    LoadTextDataFromJson(this.txtInvestmentPhilosophy, root, "investmentPhilosophy", this.tspInvestmentPhilosophy);
 
-                    JsonElement elmTER;
-                    hasTER = root.TryGetProperty("ter", out elmTER);
+                    LoadCurrentFees(root);
 
-                    if (hasTER == true)
-                    {
-                        dtTER = Utility.Json2Table(elmTER);
-                        InitTERGrid(dtTER);
-                    }
+                    LoadTextDataFromJson(this.txtPolicyOfClosingFund, root, "policyOfClosingFund", this.tspPolicyOfClosingFund);
+
+                    LoadPortfolioManager(root);
+
+                    LoadTER(root);
 
                     //
                     // Process
                     //
-                    this.chkAllowDerivatives.Checked = Utility.Json2Text(root, "allowDerivatives").ToLower() == "true" ? true : false;
-                    this.chkUseDerivatives.Checked = Utility.Json2Text(root, "useDerivatives").ToLower() == "true" ? true : false;
-                    this.chkDerivativesForEfficent.Checked = this.chkUseDerivatives.Checked == true ? Utility.Json2Text(root, "drvForEffPM").ToLower() == "true" ? true : false : false;
-                    if (this.chkUseDerivatives.Checked == true)
-                    {
-                        this.chkDerivativesForEfficent.Checked = Utility.Json2Text(root, "drvForEffPM").ToLower() == "true" ? true : false;
-                        this.chkDerivatesForHedging.Checked = Utility.Json2Text(root, "drvForHedging").ToLower() == "true" ? true : false;
-                        this.chkDerivativesForMarket.Checked = Utility.Json2Text(root, "drvForMktAcs").ToLower() == "true" ? true : false;
-                        this.chkDerivatesForLeverage.Checked = Utility.Json2Text(root, "drvForLeverage").ToLower() == "true" ? true : false;
-                    }
-                    this.chkPriceTarget.Checked = Utility.Json2Text(root, "priceTarget").ToLower() == "true" ? true : false;
-                    if (this.chkPriceTarget.Checked == true)
-                    {
-                        this.txtOverrunPriceTarget.Text = Utility.Json2Text(root, "overrunPriceTarget");
-                    }
+                    LoadDerivates(root);
+
+                    LoadPriceTarget(root);
 
                 }
 
             }
 
-            if (hasPM == false) 
-            {
-                dtPM = new DataTable();
+        }
 
-                // 没有基金经理数据时,初始化表
-                dtPM.Columns.Add("personnel_id", typeof(string));
-                dtPM.Columns.Add("name", typeof(string));
-                dtPM.Columns.Add("startDate", typeof(DateTime));
-                dtPM.Columns.Add("endDate", typeof(DateTime));
 
-                InitPortfolioManagerGrid(dtPM); 
-            }
+        private void LoadPortfolioManager(JsonElement jsonElement)
+        {
+            bool hasData = jsonElement.TryGetProperty("portfolioManagers", out JsonElement element);
 
-            if (hasTER == false)
+            string strUpdateTime = "";
+
+            DataTable dt = new DataTable();
+
+            if (hasData == true && element.ValueKind == JsonValueKind.Object)
             {
-                dtTER = new DataTable();
+                hasData &= element.TryGetProperty("v", out JsonElement elm);
 
-                dtTER.Columns.Add("year", typeof(int));
-                dtTER.Columns.Add("ter", typeof(decimal));
+                Utility.DDData dddata = Utility.Json2Table2(element);
 
-                int year = DateTime.Today.Year - 1;
-                for (int i = 0; i < 5; i++)
+                if (dddata != null)
                 {
-                    DataRow row = dtTER.NewRow();
-                    row["year"] = year - i;
-                    dtTER.Rows.Add(row);
+                    dt = (DataTable)dddata.Value;
+
+                    strUpdateTime = dddata.UpdateTime;
                 }
 
-                InitTERGrid(dtTER);
             }
+            else
+            {
+                // 没有基金经理数据时,初始化表
+                dt.Columns.Add("personnel_id", typeof(string));
+                dt.Columns.Add("name", typeof(string));
+                dt.Columns.Add("startDate", typeof(DateTime));
+                dt.Columns.Add("endDate", typeof(DateTime));
 
-        }
+            }
 
+            InitPortfolioManagerGrid(dt, strUpdateTime);
+        }
 
 
-        private void InitPortfolioManagerGrid(DataTable dt)
+        private void InitPortfolioManagerGrid(DataTable dt, string updateTime)
         {
+            if (dt == null && updateTime == null) return;
+
             this.grdPortfolioManager.DataSource = dt;
 
             this.grdPortfolioManager.Columns["personnel_id"].Visible = false;
@@ -168,17 +146,91 @@ namespace ddq
             this.grdPortfolioManager.Columns["name"].DisplayIndex = 0;
 
             this.grdPortfolioManager.Columns["startDate"].HeaderText = "Start Date";
-            this.grdPortfolioManager.Columns["startDate"].DefaultCellStyle.Format = "d";
+            this.grdPortfolioManager.Columns["startDate"].DefaultCellStyle.Format = "yyyy-MM-dd";
             this.grdPortfolioManager.Columns["startDate"].DisplayIndex = 1;
 
             this.grdPortfolioManager.Columns["endDate"].HeaderText = "End Date";
             this.grdPortfolioManager.Columns["endDate"].DefaultCellStyle.Format = "yyyy-MM-dd";
             this.grdPortfolioManager.Columns["endDate"].DisplayIndex = 2;
+
+            this.tspPortfolioManager.Text = updateTime;
+            this.tspPortfolioManager.ForeColor = IsChangedRecently(this.tspPortfolioManager.Text) ? COLOR_MODIFIED : COLOR_NORMAL;
+        }
+
+        private void LoadCurrentFees(JsonElement jsonElement)
+        {
+            if (jsonElement.ValueKind != JsonValueKind.Object) return;
+
+            bool hasData = jsonElement.TryGetProperty("currentFees", out JsonElement element);
+
+            if (hasData)
+            {
+                if (element.ValueKind == JsonValueKind.Object)
+                {
+                    hasData = element.TryGetProperty("v", out JsonElement elm);
+
+                    if (hasData)
+                    {
+                        this.txtManagementFee.Text = Json2Text(elm, "managementFee");
+                        this.txtSubscriptionFee.Text = Json2Text(elm, "subscriptionFee");
+                        this.txtRedemptionFee.Text = Json2Text(elm, "redemptionFee");
+                        this.txtAdministrationFee.Text = Json2Text(elm, "administrationFee");
+                        this.txtSwitchingFee.Text = Json2Text(elm, "switchingFee");
+                        this.txtTrusteeFee.Text = Json2Text(elm, "trusteeFee");
+                        this.txtPerformanceFee.Text = Json2Text(elm, "performanceFee");
+
+                        this.tspCurrentFee.Text = element.GetProperty("t").ToString();
+                        this.tspCurrentFee.ForeColor = IsChangedRecently(this.tspCurrentFee.Text) ? COLOR_MODIFIED : COLOR_NORMAL;
+                    }
+                }
+            }
         }
 
 
-        private void InitTERGrid(DataTable dt)
+        private void LoadTER(JsonElement jsonElement) 
+        {
+            bool hasData = jsonElement.TryGetProperty("totalExpenseRatio", out JsonElement element);
+
+            string strUpdateTime = "";
+
+            DataTable dt = new DataTable();
+
+            if (hasData == true && element.ValueKind == JsonValueKind.Object)
+            {
+                hasData &= element.TryGetProperty("v", out JsonElement elm);
+
+                Utility.DDData dddata = Utility.Json2Table2(element);
+
+                if (dddata != null)
+                {
+                    dt = (DataTable)dddata.Value;
+
+                    strUpdateTime = dddata.UpdateTime;
+                }
+
+            }
+            else
+            {
+                dt.Columns.Add("year", typeof(string));
+                dt.Columns.Add("ter", typeof(string));
+
+                int year = DateTime.Today.Year - 1;
+                for (int i = 0; i < 5; i++)
+                {
+                    DataRow row = dt.NewRow();
+                    row["year"] = year - i;
+                    dt.Rows.Add(row);
+                }
+            }
+
+            InitTERGrid(dt, strUpdateTime);
+
+        }
+
+        private void InitTERGrid(DataTable dt, string updateTime)
         {
+            if (dt == null || updateTime == null) return;
+
             this.grdTER.DataSource = dt;
             this.grdTER.Columns["year"].HeaderText = "Year";
             this.grdTER.Columns["year"].ReadOnly = true;
@@ -189,6 +241,62 @@ namespace ddq
             this.grdTER.Columns["ter"].DefaultCellStyle.Format = "N3";
             this.grdTER.Columns["ter"].DisplayIndex = 1;
 
+            this.tspTER.Text = updateTime;
+            this.tspTER.ForeColor = Utility.IsChangedRecently(updateTime) ? COLOR_MODIFIED : COLOR_NORMAL;
+
+        }
+
+        private void LoadDerivates(JsonElement jsonElement)
+        {
+            if (jsonElement.ValueKind != JsonValueKind.Object) return;
+
+            bool hasData = jsonElement.TryGetProperty("derivatives", out JsonElement element);
+
+            if (hasData)
+            {
+                if (element.ValueKind == JsonValueKind.Object)
+                {
+                    hasData = element.TryGetProperty("v", out JsonElement elm);
+
+                    if (hasData)
+                    {
+                        this.chkAllowDerivatives.Checked = Json2Boolean(elm, "allowed");
+                        this.chkUseDerivatives.Checked = Json2Boolean(elm, "currentUse");
+                        this.chkDerivativesForEfficent.Checked = Json2Boolean(elm, "effectiveManagement");
+                        this.chkDerivatesForHedging.Checked = Json2Boolean(elm, "hedging");
+                        this.chkDerivativesForMarket.Checked = Json2Boolean(elm, "marketAccess");
+                        this.chkDerivatesForLeverage.Checked = Json2Boolean(elm, "leverage");
+
+                        this.tspDerivatives.Text = element.GetProperty("t").ToString();
+                        this.tspDerivatives.ForeColor = IsChangedRecently(this.tspDerivatives.Text) ? COLOR_MODIFIED : COLOR_NORMAL;
+                    }
+                }
+            }
+
+        }
+
+        private void LoadPriceTarget(JsonElement jsonElement)
+        {
+            if (jsonElement.ValueKind != JsonValueKind.Object) return;
+
+            bool hasData = jsonElement.TryGetProperty("priceTarget", out JsonElement element);
+
+            if (hasData)
+            {
+                if (element.ValueKind == JsonValueKind.Object)
+                {
+                    hasData = element.TryGetProperty("v", out JsonElement elm);
+
+                    if (hasData)
+                    {
+                        this.chkPriceTarget.Checked = Json2Boolean(elm, "assigned");
+                        this.txtOverrunPriceTarget.Text = Json2Text(elm, "overrun");
+
+                        this.tspPriceTarget.Text = element.GetProperty("t").ToString();
+                        this.tspPriceTarget.ForeColor = IsChangedRecently(this.tspPriceTarget.Text) ? COLOR_MODIFIED : COLOR_NORMAL;
+                    }
+                }
+            }
         }
 
         private void FundQ_Load(object sender, EventArgs e)
@@ -203,31 +311,43 @@ namespace ddq
                 // 数据对象
                 var textData = new
                 {
-                    fundId = this.fundId,
                     // -- General Info --
-                    investmentObjective = this.txtInvestmentObjective.Text,
-                    benchmark = this.txtBenchmark.Text,
-                    investmentPhilosophy = this.txtInvestmentPhilosophy.Text,
-                    portfolioManagers = Utility.DataTable2List((DataTable)this.grdPortfolioManager.DataSource),
-                    ter = Utility.DataTable2List((DataTable)this.grdTER.DataSource),
-                    managementFee = this.txtManagementFee.Text,
-                    subscriptionFee = this.txtSubscriptionFee.Text,
-                    redemptionFee = this.txtRedemptionFee.Text,
-                    administrationFee = this.txtAdministrationFee.Text,
-                    switchingFee = this.txtSwitchingFee.Text,
-                    trusteeFee = this.txtTrusteeFee.Text,
-                    performanceFee = this.txtPerformanceFee.Text,
-                    policyOfClosingFund = this.txtPolicyOfClosingFund.Text,
+                    investmentObjective = AddInfo(this.txtInvestmentObjective.Text, userId),
+                    benchmark = AddInfo(this.txtBenchmark.Text, userId),
+                    investmentPhilosophy = AddInfo(this.txtInvestmentPhilosophy.Text, userId),
+                    portfolioManagers = AddInfo(Utility.DataTable2List((DataTable)this.grdPortfolioManager.DataSource), userId),
+                    totalExpenseRatio = AddInfo(Utility.DataTable2List((DataTable)this.grdTER.DataSource), userId),
+
+                    currentFees = AddInfo(new 
+                    {
+                        managementFee = this.txtManagementFee.Text,
+                        subscriptionFee = this.txtSubscriptionFee.Text,
+                        redemptionFee = this.txtRedemptionFee.Text,
+                        administrationFee = this.txtAdministrationFee.Text,
+                        switchingFee = this.txtSwitchingFee.Text,
+                        trusteeFee = this.txtTrusteeFee.Text,
+                        performanceFee = this.txtPerformanceFee.Text
+                    }, userId),
+
+                    policyOfClosingFund = AddInfo(this.txtPolicyOfClosingFund.Text, userId),
                     // -- Process --
-                    allowDerivatives = this.chkAllowDerivatives.Checked,
-                    useDerivatives = this.chkUseDerivatives.Checked,
-                    drvForEffPM = this.chkDerivativesForEfficent.Checked,
-                    drvForHedging = this.chkDerivatesForHedging.Checked,
-                    drvForMktAcs = this.chkDerivativesForMarket.Checked,
-                    drvForLeverage = this.chkDerivatesForLeverage.Checked,
-                    priceTarget = this.chkPriceTarget.Checked,
-                    overrunPriceTarget = this.txtOverrunPriceTarget.Text,
-                    updateTime = DateTime.Now
+
+                    derivatives = AddInfo( new
+                    {
+                        allowed = this.chkAllowDerivatives.Checked,
+                        currentUse = this.chkUseDerivatives.Checked,
+                        effectiveManagement = this.chkDerivativesForEfficent.Checked,
+                        hedging = this.chkDerivatesForHedging.Checked,
+                        marketAccess = this.chkDerivativesForMarket.Checked,
+                        leverage = this.chkDerivatesForLeverage.Checked
+                    }, userId),
+
+                    priceTarget = AddInfo( new
+                    {
+                        assigned = this.chkPriceTarget.Checked,
+                        overrun = this.txtOverrunPriceTarget.Text
+                    }, userId)
+
                 };
 
                 // 序列化选项
@@ -299,6 +419,19 @@ namespace ddq
           
         }
 
+
+        private void chkAllowDerivatives_CheckedChanged(object sender, EventArgs e)
+        {
+            bool isChecked = chkAllowDerivatives.Checked;
+
+            this.chkUseDerivatives.Enabled = isChecked;
+
+            if (isChecked == false)
+            {
+                this.chkUseDerivatives.Checked = false;
+            }
+        }
+
         private void chkUseDerivatives_CheckedChanged(object sender, EventArgs e)
         {
 
@@ -407,5 +540,6 @@ namespace ddq
         {
 
         }
+
     }
 }

+ 17 - 4
PersonnelQ.cs

@@ -10,6 +10,9 @@ using System.Text.Json;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 
+using static ddq.DataAccess;
+using static ddq.Utility;
+
 namespace ddq
 {
     public partial class PersonnelQ : Form
@@ -53,10 +56,13 @@ namespace ddq
                 {
 
                     this.txtName.Text = dt.Rows[0]["name"].ToString();
-                    this.txtTitle.Text = dt.Rows[0]["title"].ToString();
-                    this.txtIndustryStartYear.Text = dt.Rows[0]["industry_start_year"].ToString();
-                    this.txtCompanyStartYear.Text = dt.Rows[0]["company_start_year"].ToString();
-                    this.txtBio.Text = dt.Rows[0]["bio"].ToString();
+                    this.txtTitle.Text = Null2Text(dt.Rows[0]["title"]);
+                    this.txtIndustryStartYear.Text = Null2Text(dt.Rows[0]["industry_start_year"]);
+                    this.txtCompanyStartYear.Text = Null2Text(dt.Rows[0]["company_start_year"]);
+                    this.txtBio.Text = Null2Text(dt.Rows[0]["bio"]);
+
+                    this.tspManagerInfo.Text = DateTime.Parse(dt.Rows[0]["updatetime"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
+                    this.tspManagerInfo.ForeColor = IsChangedRecently(this.tspManagerInfo.Text) ? COLOR_MODIFIED : COLOR_NORMAL;
 
                     string strRole = dt.Rows[0]["role"].ToString();
                     int.TryParse(strRole, out int role);
@@ -69,6 +75,13 @@ namespace ddq
 
         }
 
+        private string Null2Text(object o)
+        {
+            if (o == null) return "";
+
+            return o.ToString();
+        }
+
 
         private void btnSavePersonnel_Click(object sender, EventArgs e)
         {

+ 118 - 15
Utility.cs

@@ -1,10 +1,13 @@
 using System;
 using System.Collections.Generic;
 using System.Data;
+using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
+using System.Windows.Forms;
+using static ddq.Utility;
 
 namespace ddq
 {
@@ -26,13 +29,48 @@ namespace ddq
 
         };
 
+        public static readonly Dictionary<int, string> CategoryGroup = new Dictionary<int, string>
+        {
+            {   0, "All" },
+            { 101, "Equity" },
+            { 102, "Allocaiton" },
+            { 103, "Bond" },
+            { 104, "Moeny Market" },
+            { 105, "Commodity" },
+            { 111, "Convertable" },
+            { 112, "Alternative" }
+        };
+
+
+        public static Color COLOR_NORMAL = Color.DarkSlateGray;
+        public static Color COLOR_MODIFIED = Color.Red;
+        public static Color COLOR_REVIEWED = Color.Green;
+
+
         public class DDData
         {
-            public object value { get; set; }
 
-            public string userId { get; set; }
+            private object value = null;
+            private string userId = null;
+            private string updateTime = null;
+
+            public object Value 
+            { 
+                get { return this.value; }
+                set { this.value = value; } 
+            }
+
+            public string UserId 
+            {
+                get { return this.userId; }
+                set { this.userId = value; }
+            }
 
-            public string updateTime { get; set; }
+            public string UpdateTime 
+            { 
+                get { return this.updateTime; }
+                set { this.updateTime = value; }
+            }
         };
 
 
@@ -70,19 +108,23 @@ namespace ddq
 
             DDData ret = new DDData();
 
-            JsonElement elm;
+            JsonElement element;
 
             if (propertyName == null) return ret;
 
-            bool hasProperty = jsonElement.TryGetProperty(propertyName, out elm);
+            bool hasProperty = jsonElement.TryGetProperty(propertyName, out element);
 
-            if (hasProperty == true && elm.ValueKind != JsonValueKind.Undefined)
+            if (hasProperty == true && element.ValueKind == JsonValueKind.Object)
             {
+                bool hasData = element.TryGetProperty("v", out JsonElement elmV);
 
-                ret.value = elm.GetProperty("v").ToString();
-                ret.userId = elm.GetProperty("u").ToString();
-                ret.updateTime = elm.GetProperty("t").ToString();
-                
+                if (hasData)
+                {
+                    ret.Value = element.GetProperty("v").ToString();
+                    ret.UserId = element.GetProperty("u").ToString();
+                    ret.UpdateTime = element.GetProperty("t").ToString();
+
+                }
             }
 
             return ret;
@@ -109,12 +151,15 @@ namespace ddq
         public static DataTable Json2Table(JsonElement jsonElement)
         {
 
-            bool hasData = jsonElement.TryGetProperty("v", out JsonElement elm);
 
-            if (!hasData) return null;
+            if (jsonElement.ValueKind != JsonValueKind.Object) return null;
+
+            bool hasData = jsonElement.TryGetProperty("v", out JsonElement elm);
 
             DataTable dataTable = new DataTable();
 
+            if (!hasData) return null;
+
             // 如果解析出的是数组
             if (elm.ValueKind == JsonValueKind.Array)
             {
@@ -181,9 +226,9 @@ namespace ddq
                 }
             }
 
-            ret.value = dataTable;
-            ret.userId = jsonElement.GetProperty("u").ToString();
-            ret.updateTime = jsonElement.GetProperty("t").ToString();
+            ret.Value = dataTable;
+            ret.UserId = jsonElement.GetProperty("u").ToString();
+            ret.UpdateTime = jsonElement.GetProperty("t").ToString();
 
             return ret;
 
@@ -246,6 +291,64 @@ namespace ddq
             return ret;
 
         }
+
+        /// <summary>
+        /// 将Json数据提取放入对应的TextBox及时间戳Label
+        /// </summary>
+        /// <param name="textBox"></param>
+        /// <param name="jsonElement"></param>
+        /// <param name="properyName"></param>
+        /// <param name="labelUpdateTime"></param>
+        public static void LoadTextDataFromJson(TextBox textBox, JsonElement jsonElement, string properyName, Label labelUpdateTime)
+        {
+            if (textBox == null || labelUpdateTime == null) return;
+
+            bool hasData = jsonElement.TryGetProperty(properyName, out JsonElement element);
+
+            if (hasData)
+            {
+                DDData dddata = Json2Text2(jsonElement, properyName);
+
+                if (dddata.Value != null)
+                {
+                    textBox.Text = dddata.Value.ToString();
+                    labelUpdateTime.Text = dddata.UpdateTime;
+                    labelUpdateTime.ForeColor = IsChangedRecently(dddata.Value.ToString()) ? COLOR_MODIFIED : COLOR_NORMAL;
+                }
+            }
+        }
+
+        /// <summary>
+        /// 将Json数据提取放入对应的DateTimePicker及时间戳Label
+        /// </summary>
+        /// <param name="dateTimePicker"></param>
+        /// <param name="jsonElement"></param>
+        /// <param name="properyName"></param>
+        /// <param name="labelUpdateTime"></param>
+        public static void LoadDateDataFromJson(DateTimePicker dateTimePicker, JsonElement jsonElement, string properyName, Label labelUpdateTime)
+        {
+            if (dateTimePicker == null || labelUpdateTime == null) return;
+
+            bool hasData = jsonElement.TryGetProperty(properyName, out JsonElement element);
+
+            if (hasData)
+            {
+                DDData dddata = Utility.Json2Text2(jsonElement, properyName);
+
+                if (dddata.Value != null)
+                {
+
+                    bool isDate = DateTime.TryParse(dddata.Value.ToString(), out DateTime newDate);
+
+                    if (isDate)
+                    {
+                        dateTimePicker.Value = newDate;
+                        labelUpdateTime.Text = dddata.UpdateTime;
+                        labelUpdateTime.ForeColor = IsChangedRecently(dddata.Value.ToString()) ? COLOR_MODIFIED : COLOR_NORMAL;
+                    }
+                }
+            }
+        }
     }