Joey преди 2 месеца
родител
ревизия
cc1277bb24
променени са 1 файла, в които са добавени 25 реда и са изтрити 20 реда
  1. 25 20
      DataManager.cs

+ 25 - 20
DataManager.cs

@@ -596,7 +596,7 @@ namespace DataManager
 
         private void LoadOrphanFund()
         {
-            DataTable dt;
+            DataTable dt = null;
             string providerName = txtOrphanProvider.Text.Trim();
             sbyte isOrphan = 1;
             if (!chkIsOrphan.Checked) isOrphan = 0;
@@ -604,28 +604,33 @@ namespace DataManager
             orphanFundTable = DataAccess.Get_dm_external_fund_mapping(isOrphan, UserId);
 
             if (providerName != string.Empty)
-                dt = orphanFundTable.Select("provider_name LIKE '%" + providerName + "%'", "id DESC").CopyToDataTable();
+            {
+                DataRow[] rows = orphanFundTable.Select("provider_name LIKE '%" + providerName + "%'", "id DESC");
+                if(rows != null && rows.Length > 0) dt = rows.CopyToDataTable();
+            }
             else
                 dt = orphanFundTable;
 
-            grdOrphanFund.DataSource = dt;
-
-            grdOrphanFund.Columns["id"].Visible = false;
-            grdOrphanFund.Columns["fund_id"].HeaderText = "基金ID";
-            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;
-
+            if (dt != null)
+            {
+                grdOrphanFund.DataSource = dt;
+
+                grdOrphanFund.Columns["id"].Visible = false;
+                grdOrphanFund.Columns["fund_id"].HeaderText = "基金ID";
+                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)