| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- 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;
- using System.Text.Json;
- using System.Text.Json.Serialization;
- namespace ddq
- {
- public partial class FundQ : Form
- {
- private string fundId;
- private int userId = 123;
- private DataTable fundInfoTable;
- public FundQ(string fundId)
- {
- InitializeComponent();
- this.fundId = fundId;
- InitializeData();
-
- }
- private void InitializeData()
- {
- DataTable dt = DataAccess.Get_fund_info(fundId, null);
- if (dt == null || dt.Rows.Count <= 0) return;
- this.lblFundName.Text = dt.Rows[0].Field<string>("fund_short_name");
- this.lblMainCode.Text = "Code: " + dt.Rows[0].Field<string>("register_number");
- this.lblCategory.Text = "Category: " + dt.Rows[0].Field<string>("strategy");
- this.lblInceptionDate.Text = "Launched: " + dt.Rows[0].Field<DateTime?>("inception_date")?.ToString("yyyy-MM-dd");
- this.lblDomicile.Text = "Domicile: ";
- fundInfoTable = DataAccess.Get_dd_fund_info(fundId, null, 1);
- if (fundInfoTable == null || fundInfoTable.Rows.Count <= 0) return;
- string jsonString = fundInfoTable.Rows[0].Field<string>("info").Trim();
- JsonDocument document = JsonDocument.Parse(jsonString);
- JsonElement root = document.RootElement;
- this.txtInvestmentObjective.Text = root.GetProperty("investmentObjective").ToString();
- this.txtBenchmark.Text = root.GetProperty("benchmark").ToString();
- this.txtInvestmentPhilosophy.Text = root.GetProperty("investmentPhilosophy").ToString();
- }
- private void FundQ_Load(object sender, EventArgs e)
- {
- }
- private void btnSaveGeneralInfo_Click(object sender, EventArgs e)
- {
- try
- {
- // 数据对象
- var textData = new
- {
- FundId = this.fundId,
- InvestmentObjective = this.txtInvestmentObjective.Text,
- Benchmark = this.txtBenchmark.Text,
- InvestmentPhilosophy = this.txtInvestmentPhilosophy.Text,
- UpdateTime = DateTime.Now
- };
- // 序列化选项
- var options = new JsonSerializerOptions
- {
- WriteIndented = true,
- PropertyNamingPolicy = JsonNamingPolicy.CamelCase
- };
- string jsonString = JsonSerializer.Serialize(textData, options);
- //MessageBox.Show($"Save JSON: \n{jsonString}", "Json Result");
- int ret = DataAccess.Set_dd_fund_info(this.fundId, DateTime.Today, jsonString, 1, 1, userId);
- if (ret == 1)
- {
- this.Close();
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show($"Error: {ex.Message}", "Error");
- }
- }
- }
- }
|