Pārlūkot izejas kodu

上传文件至 ''

Joey 3 nedēļas atpakaļ
vecāks
revīzija
11f2f1e984
4 mainītis faili ar 391 papildinājumiem un 42 dzēšanām
  1. 46 0
      DataAccess.cs
  2. 137 18
      DataManager.Designer.cs
  3. 88 1
      DataManager.cs
  4. 120 23
      UIFund.cs

+ 46 - 0
DataAccess.cs

@@ -13,6 +13,7 @@ using static DataManager.UIConstants;
 using System.ComponentModel.Design;
 using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
 using System.Xml.Linq;
+using System.Windows;
 
 namespace DataManager
 {
@@ -706,5 +707,50 @@ namespace DataManager
 
             return dt;
         }
+
+        public static DataTable Get_dm_report_orphan_fund(int? userId)
+        {
+            MySqlConnection connection = new MySqlConnection(connectionString);
+            MySqlDataAdapter ad = new MySqlDataAdapter("sp_get_dm_report_orphan_fund", connection);
+
+            MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
+
+            ad.SelectCommand.Parameters.Add(i_userid);
+
+            ad.SelectCommand.CommandType = CommandType.StoredProcedure;
+
+            DataTable dt = new DataTable();
+            ad.Fill(dt);
+
+            connection.Close();
+
+            return dt;
+        }
+
+        public static void Set_dm_external_fund_mapping(string providerId, string externalId, string fundId, int userId)
+        {
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
+            {
+
+                connection.Open();
+
+                MySqlCommand cmd = new MySqlCommand("sp_set_dm_external_fund_mapping", connection);
+
+                MySqlParameter i_provider_id = new MySqlParameter("i_provider_id", providerId);
+                MySqlParameter i_external_id = new MySqlParameter("i_external_id", externalId);
+                MySqlParameter i_fund_id = new MySqlParameter("i_fund_id", fundId);
+                MySqlParameter i_userid = new MySqlParameter("i_userid", userId);
+
+                cmd.Parameters.Add(i_provider_id);
+                cmd.Parameters.Add(i_external_id);
+                cmd.Parameters.Add(i_fund_id);
+                cmd.Parameters.Add(i_userid);
+
+                cmd.CommandType = CommandType.StoredProcedure;
+
+                cmd.Connection = connection;
+                cmd.ExecuteNonQuery();
+            }
+        }
     }
 }

+ 137 - 18
DataManager.Designer.cs

@@ -28,7 +28,7 @@
         /// </summary>
         private void InitializeComponent()
         {
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
             this.ctnDataCollection = new System.Windows.Forms.SplitContainer();
             this.dtpCollectionTaskDate = new System.Windows.Forms.DateTimePicker();
             this.btnCollectionSearch = new System.Windows.Forms.Button();
@@ -89,6 +89,14 @@
             this.grdCompanyList = new System.Windows.Forms.DataGridView();
             this.tbpPeople = new System.Windows.Forms.TabPage();
             this.sstData = new System.Windows.Forms.StatusStrip();
+            this.tbpReport = new System.Windows.Forms.TabPage();
+            this.tabControl2 = new System.Windows.Forms.TabControl();
+            this.tbpOrphanFund = new System.Windows.Forms.TabPage();
+            this.grdOrphanFund = new System.Windows.Forms.DataGridView();
+            this.panel2 = new System.Windows.Forms.Panel();
+            this.btnOrphanFundSearch = new System.Windows.Forms.Button();
+            this.txtOrphanProvider = new System.Windows.Forms.TextBox();
+            this.label13 = new System.Windows.Forms.Label();
             ((System.ComponentModel.ISupportInitialize)(this.ctnDataCollection)).BeginInit();
             this.ctnDataCollection.Panel1.SuspendLayout();
             this.ctnDataCollection.Panel2.SuspendLayout();
@@ -117,6 +125,11 @@
             this.splitContainer3.Panel2.SuspendLayout();
             this.splitContainer3.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.grdCompanyList)).BeginInit();
+            this.tbpReport.SuspendLayout();
+            this.tabControl2.SuspendLayout();
+            this.tbpOrphanFund.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.grdOrphanFund)).BeginInit();
+            this.panel2.SuspendLayout();
             this.SuspendLayout();
             // 
             // ctnDataCollection
@@ -158,7 +171,7 @@
             this.dtpCollectionTaskDate.Location = new System.Drawing.Point(306, 24);
             this.dtpCollectionTaskDate.Name = "dtpCollectionTaskDate";
             this.dtpCollectionTaskDate.Size = new System.Drawing.Size(121, 23);
-            this.dtpCollectionTaskDate.TabIndex = 33;
+            this.dtpCollectionTaskDate.TabIndex = 3;
             // 
             // btnCollectionSearch
             // 
@@ -272,14 +285,14 @@
             this.grdCollectionTask.AllowUserToDeleteRows = false;
             this.grdCollectionTask.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
             this.grdCollectionTask.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
-            dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
-            dataGridViewCellStyle4.BackColor = System.Drawing.Color.WhiteSmoke;
-            dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.ControlText;
-            dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
-            dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
-            dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
-            this.grdCollectionTask.DefaultCellStyle = dataGridViewCellStyle4;
+            dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle3.BackColor = System.Drawing.Color.WhiteSmoke;
+            dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.ControlText;
+            dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+            dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
+            this.grdCollectionTask.DefaultCellStyle = dataGridViewCellStyle3;
             this.grdCollectionTask.Dock = System.Windows.Forms.DockStyle.Fill;
             this.grdCollectionTask.Location = new System.Drawing.Point(0, 53);
             this.grdCollectionTask.Name = "grdCollectionTask";
@@ -287,7 +300,7 @@
             this.grdCollectionTask.RowHeadersVisible = false;
             this.grdCollectionTask.RowTemplate.Height = 23;
             this.grdCollectionTask.Size = new System.Drawing.Size(913, 386);
-            this.grdCollectionTask.TabIndex = 0;
+            this.grdCollectionTask.TabIndex = 2;
             this.grdCollectionTask.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.grdCollectionTask_CellClick);
             // 
             // panel1
@@ -327,7 +340,7 @@
             this.btnAddCollectionTask.Location = new System.Drawing.Point(774, 13);
             this.btnAddCollectionTask.Name = "btnAddCollectionTask";
             this.btnAddCollectionTask.Size = new System.Drawing.Size(121, 28);
-            this.btnAddCollectionTask.TabIndex = 4;
+            this.btnAddCollectionTask.TabIndex = 1;
             this.btnAddCollectionTask.Text = "添 加 任 务";
             this.btnAddCollectionTask.UseVisualStyleBackColor = false;
             this.btnAddCollectionTask.Click += new System.EventHandler(this.btnAddCollectionTask_Click);
@@ -337,6 +350,7 @@
             this.tbcMain.Controls.Add(this.tbpContact);
             this.tbcMain.Controls.Add(this.tbpCollection);
             this.tbcMain.Controls.Add(this.tbpData);
+            this.tbcMain.Controls.Add(this.tbpReport);
             this.tbcMain.Dock = System.Windows.Forms.DockStyle.Fill;
             this.tbcMain.Font = new System.Drawing.Font("微软雅黑", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.tbcMain.ItemSize = new System.Drawing.Size(100, 28);
@@ -404,14 +418,14 @@
             this.dtpContactFollowUpDate.Location = new System.Drawing.Point(79, 64);
             this.dtpContactFollowUpDate.Name = "dtpContactFollowUpDate";
             this.dtpContactFollowUpDate.Size = new System.Drawing.Size(121, 23);
-            this.dtpContactFollowUpDate.TabIndex = 33;
+            this.dtpContactFollowUpDate.TabIndex = 22;
             // 
             // dtpContactTaskDate
             // 
             this.dtpContactTaskDate.Location = new System.Drawing.Point(306, 24);
             this.dtpContactTaskDate.Name = "dtpContactTaskDate";
             this.dtpContactTaskDate.Size = new System.Drawing.Size(121, 23);
-            this.dtpContactTaskDate.TabIndex = 32;
+            this.dtpContactTaskDate.TabIndex = 16;
             // 
             // cmbContactCompanySize
             // 
@@ -466,7 +480,7 @@
             this.btnContactSearch.Location = new System.Drawing.Point(771, 96);
             this.btnContactSearch.Name = "btnContactSearch";
             this.btnContactSearch.Size = new System.Drawing.Size(121, 28);
-            this.btnContactSearch.TabIndex = 25;
+            this.btnContactSearch.TabIndex = 35;
             this.btnContactSearch.Text = "搜 索";
             this.btnContactSearch.UseVisualStyleBackColor = false;
             this.btnContactSearch.Click += new System.EventHandler(this.btnContactSearch_Click);
@@ -477,7 +491,7 @@
             this.txtContactCompany.MaxLength = 100;
             this.txtContactCompany.Name = "txtContactCompany";
             this.txtContactCompany.Size = new System.Drawing.Size(348, 23);
-            this.txtContactCompany.TabIndex = 24;
+            this.txtContactCompany.TabIndex = 33;
             // 
             // label1
             // 
@@ -486,7 +500,7 @@
             this.label1.Location = new System.Drawing.Point(29, 107);
             this.label1.Name = "label1";
             this.label1.Size = new System.Drawing.Size(32, 17);
-            this.label1.TabIndex = 23;
+            this.label1.TabIndex = 32;
             this.label1.Text = "公司";
             // 
             // cmbContactTaskStatus
@@ -597,7 +611,7 @@
             this.grdContactTask.RowHeadersVisible = false;
             this.grdContactTask.RowTemplate.Height = 23;
             this.grdContactTask.Size = new System.Drawing.Size(913, 389);
-            this.grdContactTask.TabIndex = 0;
+            this.grdContactTask.TabIndex = 5;
             this.grdContactTask.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.grdContactTask_CellClick);
             // 
             // tbpCollection
@@ -811,6 +825,97 @@
             this.sstData.Size = new System.Drawing.Size(913, 22);
             this.sstData.TabIndex = 1;
             // 
+            // tbpReport
+            // 
+            this.tbpReport.Controls.Add(this.tabControl2);
+            this.tbpReport.Location = new System.Drawing.Point(4, 32);
+            this.tbpReport.Name = "tbpReport";
+            this.tbpReport.Size = new System.Drawing.Size(925, 602);
+            this.tbpReport.TabIndex = 3;
+            this.tbpReport.Text = "质检";
+            this.tbpReport.UseVisualStyleBackColor = true;
+            // 
+            // tabControl2
+            // 
+            this.tabControl2.Alignment = System.Windows.Forms.TabAlignment.Left;
+            this.tabControl2.Controls.Add(this.tbpOrphanFund);
+            this.tabControl2.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.tabControl2.Location = new System.Drawing.Point(0, 0);
+            this.tabControl2.Multiline = true;
+            this.tabControl2.Name = "tabControl2";
+            this.tabControl2.SelectedIndex = 0;
+            this.tabControl2.Size = new System.Drawing.Size(925, 602);
+            this.tabControl2.TabIndex = 0;
+            // 
+            // tbpOrphanFund
+            // 
+            this.tbpOrphanFund.Controls.Add(this.grdOrphanFund);
+            this.tbpOrphanFund.Controls.Add(this.panel2);
+            this.tbpOrphanFund.Location = new System.Drawing.Point(27, 4);
+            this.tbpOrphanFund.Name = "tbpOrphanFund";
+            this.tbpOrphanFund.Padding = new System.Windows.Forms.Padding(3);
+            this.tbpOrphanFund.Size = new System.Drawing.Size(894, 594);
+            this.tbpOrphanFund.TabIndex = 0;
+            this.tbpOrphanFund.Text = "孤儿基金";
+            this.tbpOrphanFund.UseVisualStyleBackColor = true;
+            // 
+            // grdOrphanFund
+            // 
+            this.grdOrphanFund.AllowUserToAddRows = false;
+            this.grdOrphanFund.AllowUserToDeleteRows = false;
+            this.grdOrphanFund.AllowUserToOrderColumns = true;
+            this.grdOrphanFund.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
+            this.grdOrphanFund.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.grdOrphanFund.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.grdOrphanFund.Location = new System.Drawing.Point(3, 56);
+            this.grdOrphanFund.Name = "grdOrphanFund";
+            this.grdOrphanFund.ReadOnly = true;
+            this.grdOrphanFund.RowHeadersVisible = false;
+            this.grdOrphanFund.RowTemplate.Height = 23;
+            this.grdOrphanFund.Size = new System.Drawing.Size(888, 535);
+            this.grdOrphanFund.TabIndex = 1;
+            this.grdOrphanFund.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.grdOrphanFund_CellClick);
+            // 
+            // panel2
+            // 
+            this.panel2.Controls.Add(this.btnOrphanFundSearch);
+            this.panel2.Controls.Add(this.txtOrphanProvider);
+            this.panel2.Controls.Add(this.label13);
+            this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
+            this.panel2.Location = new System.Drawing.Point(3, 3);
+            this.panel2.Name = "panel2";
+            this.panel2.Size = new System.Drawing.Size(888, 53);
+            this.panel2.TabIndex = 0;
+            // 
+            // btnOrphanFundSearch
+            // 
+            this.btnOrphanFundSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.btnOrphanFundSearch.BackColor = System.Drawing.Color.SkyBlue;
+            this.btnOrphanFundSearch.Location = new System.Drawing.Point(746, 11);
+            this.btnOrphanFundSearch.Name = "btnOrphanFundSearch";
+            this.btnOrphanFundSearch.Size = new System.Drawing.Size(121, 28);
+            this.btnOrphanFundSearch.TabIndex = 26;
+            this.btnOrphanFundSearch.Text = "搜 索";
+            this.btnOrphanFundSearch.UseVisualStyleBackColor = false;
+            this.btnOrphanFundSearch.Click += new System.EventHandler(this.btnOrphanFundSearch_Click);
+            // 
+            // txtOrphanProvider
+            // 
+            this.txtOrphanProvider.Location = new System.Drawing.Point(89, 13);
+            this.txtOrphanProvider.Name = "txtOrphanProvider";
+            this.txtOrphanProvider.Size = new System.Drawing.Size(171, 25);
+            this.txtOrphanProvider.TabIndex = 1;
+            this.txtOrphanProvider.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtOrphanProvider_KeyPress);
+            // 
+            // label13
+            // 
+            this.label13.AutoSize = true;
+            this.label13.Location = new System.Drawing.Point(20, 16);
+            this.label13.Name = "label13";
+            this.label13.Size = new System.Drawing.Size(48, 19);
+            this.label13.TabIndex = 0;
+            this.label13.Text = "数据源";
+            // 
             // frmDataManager
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
@@ -856,6 +961,12 @@
             ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit();
             this.splitContainer3.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.grdCompanyList)).EndInit();
+            this.tbpReport.ResumeLayout(false);
+            this.tabControl2.ResumeLayout(false);
+            this.tbpOrphanFund.ResumeLayout(false);
+            ((System.ComponentModel.ISupportInitialize)(this.grdOrphanFund)).EndInit();
+            this.panel2.ResumeLayout(false);
+            this.panel2.PerformLayout();
             this.ResumeLayout(false);
 
         }
@@ -921,6 +1032,14 @@
         private System.Windows.Forms.TextBox txtCompanyKeyword;
         private System.Windows.Forms.Label label12;
         private System.Windows.Forms.DataGridView grdCompanyList;
+        private System.Windows.Forms.TabPage tbpReport;
+        private System.Windows.Forms.TabControl tabControl2;
+        private System.Windows.Forms.TabPage tbpOrphanFund;
+        private System.Windows.Forms.Panel panel2;
+        private System.Windows.Forms.Label label13;
+        private System.Windows.Forms.DataGridView grdOrphanFund;
+        private System.Windows.Forms.TextBox txtOrphanProvider;
+        private System.Windows.Forms.Button btnOrphanFundSearch;
     }
 }
 

+ 88 - 1
DataManager.cs

@@ -20,6 +20,7 @@ namespace DataManager
         private DateTime defaultDatetime = DateTime.Now.AddDays(-30);
         private DataTable collectionTaskTable = new DataTable();
         private DataTable contactTaskTable;
+        private DataTable orphanFundTable;
 
         private static int userId;
 
@@ -557,7 +558,6 @@ namespace DataManager
             LoadCompanyGrid();
         }
 
-        #endregion
 
         private void grdCompanyList_CellClick(object sender, DataGridViewCellEventArgs e)
         {
@@ -577,5 +577,92 @@ namespace DataManager
                 frm.Show();
             }
         }
+        #endregion
+
+
+
+        #region Reports
+
+
+        #region Orphan Fund
+
+        private void LoadOrphanFund(DataTable dt)
+        {
+            if(dt == null)
+                dt = DataAccess.Get_dm_report_orphan_fund(UserId);
+
+            grdOrphanFund.DataSource = dt;
+
+            grdOrphanFund.Columns["id"].Visible = false;
+            grdOrphanFund.Columns["provider_id"].Visible = false;
+            grdOrphanFund.Columns["provider_name"].HeaderText = "数据源";
+            grdOrphanFund.Columns["external_id"].HeaderText = "外部ID";
+            grdOrphanFund.Columns["isvalid"].HeaderText = "状态";
+            grdOrphanFund.Columns["creatorid"].Visible = false;
+            grdOrphanFund.Columns["creator_name"].HeaderText = "创建";
+            grdOrphanFund.Columns["createtime"].HeaderText = "创建时间";
+            grdOrphanFund.Columns["updaterid"].Visible = false;
+            grdOrphanFund.Columns["updater_name"].HeaderText = "更新";
+            grdOrphanFund.Columns["updatetime"].HeaderText = "更新时间";
+
+            grdOrphanFund.Columns["provider_name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
+            grdOrphanFund.Columns["external_id"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
+
+        }
+
+        private void btnOrphanFundSearch_Click(object sender, EventArgs e)
+        {
+            DataTable dt;
+            string providerName = txtOrphanProvider.Text.Trim();
+
+            if(orphanFundTable == null)
+            {
+                LoadOrphanFund(orphanFundTable);
+            }
+            else
+            {
+                if (providerName != string.Empty)
+                    dt = orphanFundTable.Select("provider_name LIKE '%" + providerName + "%'", "id DESC").CopyToDataTable();
+                else
+                    dt = orphanFundTable;
+
+                LoadOrphanFund(dt);
+
+            }
+        }
+
+        #endregion
+
+        private void grdOrphanFund_CellClick(object sender, DataGridViewCellEventArgs e)
+        {
+            int rowIndex = e.RowIndex;
+
+            if (rowIndex < 0) return;
+
+            DataGridViewRow row = grdOrphanFund.Rows[rowIndex];
+
+            // 弹出基金页面
+            string provider_id = row.Cells["provider_id"].Value.ToString();
+            string external_id = row.Cells["external_id"].Value.ToString();
+
+            UIFund frmFund = new UIFund(provider_id, external_id, UserId);
+            frmFund.ShowDialog();
+
+            if (frmFund.DialogResult == DialogResult.OK) 
+            {
+                LoadOrphanFund(null);
+            }
+
+        }
+
+        #endregion
+
+        private void txtOrphanProvider_KeyPress(object sender, KeyPressEventArgs e)
+        {
+            if (e.KeyChar == 13) 
+            {
+                btnOrphanFundSearch_Click(sender, e);
+            }
+        }
     }
 }

+ 120 - 23
UIFund.cs

@@ -15,7 +15,9 @@ namespace DataManager
     public partial class UIFund : Form
     {
         private int userId;
-        private string fundId = string.Empty;
+        private string fundId = null;
+        private string providerId = null;
+        private string externalId = null;
 
         private DataTable fundInfo = new DataTable();
 
@@ -30,15 +32,30 @@ namespace DataManager
             InitializeData();
         }
 
+        public UIFund(string providerId, string externalId, int userId)
+        {
+            this.providerId = providerId;
+            this.externalId = externalId;
+            this.userId = userId;
+
+            InitializeComponent();
+            InitializeData();
+
+        }
+
         public string FundId { get { return fundId; } }
 
         public int UserId { get { return userId; } }
 
+        public string ProviderId { get {return providerId; } }
+
+        public string ExternalId { get {return externalId; } }
+
         private void InitializeData()
         { 
             txtFundId.Text = fundId;
 
-            if (fundId != string.Empty)
+            if (!string.IsNullOrEmpty(fundId))
             {
 
                 fundInfo = DataAccess.Get_dm_fund_information(fundId, null);
@@ -47,11 +64,11 @@ namespace DataManager
 
                 if (fundInfo == null || fundInfo.Rows.Count <= 0)
                 {
-                    lblFundName.Text = string.Format("基金{0}不存在,得跟管理员说一下", fundId);
-                    lblFundName.ForeColor = Color.Red;
+                    txtFundName.Text = string.Format("基金{0}不存在,得跟管理员说一下", fundId);
+                    txtFundName.ForeColor = Color.Red;
                     return;
                 }
-                lblFundName.Text = fundInfo.Rows[0]["fund_name"].ToString();
+                txtFundName.Text = fundInfo.Rows[0]["fund_name"].ToString();
                 txtFundId.ReadOnly = true;
                 txtRegisterCode.Text = fundInfo.Rows[0]["register_number"].ToString();
                 txtRegisterCode.ReadOnly = true;
@@ -117,41 +134,81 @@ namespace DataManager
                 chkRanking.Checked = fundInfo.Rows[0]["is_ranking"].ToString() == "1" ? true : false;
                 chkAuthorized.Checked = fundInfo.Rows[0]["is_authorized"].ToString() == "1" ? true : false;
 
+                lblMatchFund.Visible = false;
+                lblMatchInstrunction.Visible = false;
+                txtMatchFund.Visible = false;
+
+
                 #endregion
 
                 #region Nav
 
                 dtpNavStartDate.ShowCheckBox = true;
-                dtpNavStartDate.Checked = false;
+                dtpNavStartDate.Checked = true;
                 dtpNavStartDate.Value = DateTime.Parse(lblInceptionDate.Text);
 
                 dtpNavEndDate.ShowCheckBox = true;
-                dtpNavEndDate.Checked = false;
+                dtpNavEndDate.Checked = true;
+                dtpNavEndDate.Value = DateTime.Today;
 
                 lblNavFrequency.Text = navFreq;
 
-                LoadNavGrid(null, null);
+                LoadNavGrid(FundId, null, null, null, null);
 
                 #endregion
             }
+            else
+            {
+                txtFundName.Text = ExternalId;
+                txtFundShortName.Enabled = false;
+                cmbStrategy.Enabled = false;
+                cmbSubStrategy.Enabled = false;
+                txtParentFund.Enabled = false;
+                cmbNavFrequency.Enabled = false;
+                chkAuthorized.Enabled = false;
+                chkRanking.Enabled = false;
+                chkRating.Enabled = false;
+
+                LoadNavGrid(null, ProviderId, ExternalId, null, null);
+            }
 
         }
 
         private void btnSave_Click(object sender, EventArgs e)
         {
-            string fundShortName = txtFundShortName.Text.Trim();
-            int? strategyId = int.Parse(cmbStrategy.SelectedValue.ToString());
-            int? subStrategyId = int.Parse(cmbSubStrategy.SelectedValue.ToString());
-            string parentFundId = txtParentFund.Text.Trim();
-            parentFundId = (string.IsNullOrEmpty(parentFundId) ? null : parentFundId);
-            string navFrequency = cmbNavFrequency.SelectedText.ToString();
-            sbyte isAuthorized = (sbyte)(chkAuthorized.Checked ? 1 : 0);
-            sbyte isRanking = (sbyte)(chkRanking.Checked ? 1 : 0);
-            sbyte isRating = (sbyte)(chkRating.Checked ? 1 : 0);
-
-            DataAccess.Set_dm_fund_information(FundId, fundShortName, strategyId, subStrategyId, parentFundId, navFrequency, isAuthorized, isRanking, isRating, UserId);
-
-            MessageBox.Show("所有更新顺利存盘", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
+            if (string.IsNullOrEmpty(FundId))
+            {
+                string matchedFundId = txtMatchFund.Text;
+
+                if (matchedFundId.Length == 10)
+                {
+                    DataAccess.Set_dm_external_fund_mapping(ProviderId, ExternalId, matchedFundId, UserId);
+                    this.DialogResult = DialogResult.OK;
+                    this.Close();
+                }
+                else
+                {
+                    MessageBox.Show("输入的基金ID不大对哦", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    txtMatchFund.Focus();
+                }
+            }
+            else
+            {
+                string fundShortName = txtFundShortName.Text.Trim();
+                int? strategyId = int.Parse(cmbStrategy.SelectedValue.ToString());
+                int? subStrategyId = int.Parse(cmbSubStrategy.SelectedValue.ToString());
+                string parentFundId = txtParentFund.Text.Trim();
+                parentFundId = (string.IsNullOrEmpty(parentFundId) ? null : parentFundId);
+                string navFrequency = cmbNavFrequency.SelectedText.ToString();
+                sbyte isAuthorized = (sbyte)(chkAuthorized.Checked ? 1 : 0);
+                sbyte isRanking = (sbyte)(chkRanking.Checked ? 1 : 0);
+                sbyte isRating = (sbyte)(chkRating.Checked ? 1 : 0);
+
+                DataAccess.Set_dm_fund_information(FundId, fundShortName, strategyId, subStrategyId, parentFundId, navFrequency, isAuthorized, isRanking, isRating, UserId);
+                
+                MessageBox.Show("所有更新顺利存盘", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
+            }
+            
         }
 
         private Dictionary<int, string> LoadSubStrategy(int strategyId)
@@ -226,9 +283,9 @@ namespace DataManager
             }
         }
 
-        private void LoadNavGrid(DateTime? startDate, DateTime? endDate)
+        private void LoadNavGrid(string fundId, string providerId, string externalId, DateTime? startDate, DateTime? endDate)
         {
-            tbNav = DataAccess.Get_dm_nav(fundId, null, null, startDate, endDate);
+            tbNav = DataAccess.Get_dm_nav(fundId, providerId, externalId, startDate, endDate);
             
             grdNav.DataSource = tbNav;
             grdNav.Columns["fund_id"].Visible = false;
@@ -278,6 +335,46 @@ namespace DataManager
 
         }
 
+        private void dtpNavEndDate_ValueChanged(object sender, EventArgs e)
+        {
+            DateTime startDate = dtpNavStartDate.Value;
+            if (!dtpNavStartDate.Checked) startDate = dtpNavStartDate.MinDate;
+            
+            DateTime endDate = dtpNavEndDate.Value;
+            if (!dtpNavEndDate.Checked) endDate = DateTime.Today;
+
+            DataTable dt = FilterDate(tbNav, startDate, endDate);
+
+            if(dt!=null) grdNav.DataSource = dt;
+
+        }
+
+        private DataTable FilterDate(DataTable data, DateTime startDate, DateTime endDate)
+        {
+            DataTable dt = null;
 
+            if (startDate > endDate)
+            {
+                MessageBox.Show("起始日不能大于截止日哦", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                return null;
+            }
+
+            if (data != null && data.Rows.Count > 0)
+            {
+
+                string expression = "price_date <= #" + endDate.ToString() + "# and price_date >= #" + startDate.ToString() + "#";
+                DataRow[] rows = data.Select(expression, "price_date DESC");
+
+                if (rows != null && rows.Length > 0)
+                    dt = rows.CopyToDataTable();
+            }
+
+            return dt;
+        }
+
+        private void dtpNavStartDate_ValueChanged(object sender, EventArgs e)
+        {
+            dtpNavEndDate_ValueChanged(sender, e);
+        }
     }
 }