C# 将两个不同的dataTable合并到一个自定义的dataTable中
其他
2018-12-06 23:38:33
阅读次数: 0
-
- for (int i = 0; i < dataTable_yh.Rows.Count; i++)
- {
- string vin = dataTable_yh.Rows[i]["VIN"].ToString();
- string clxh = dataTable_yh.Rows[i]["CLXH"].ToString();
- string rllx = dataTable_yh.Rows[i]["RLLX"].ToString();
- DataRow[] dr = dataTable_tg.Select("CLXH='" + clxh + "' AND RLLX='" + rllx + "'");
-
- if (dr.Length < 1)
- {
- dtTable_error.Rows.Add(new object[] { vin, clxh, rllx });
- }
- else
- {
- string yh_zczbzl = dataTable_yh.Rows[i]["ZCZBZL"].ToString();
- string yh_zhgk = dataTable_yh.Rows[i]["ZHGK"].ToString();
-
- if (!yh_zczbzl.Equals(dr[0]["ZCZBZL"]))
- {
- string tg_zczbzl = dr[0]["ZCZBZL"].ToString();
- dtTable_zczbzl.Rows.Add(new object[] { vin, clxh, rllx, yh_zczbzl, tg_zczbzl });
- }
-
- if (!yh_zhgk.Equals(dr[0]["ZHGK"]))
- {
- string tg_zhgk = dr[0]["ZHGK"].ToString();
- dtTable_zhgk.Rows.Add(new object[] { vin, clxh, rllx, yh_zhgk, tg_zhgk });
- }
- }
- }
-
- this.gcTable1.DataSource = dtTable_zczbzl;
- this.gcTable2.DataSource = dtTable_zhgk;
- this.gcTable3.DataSource = dtTable_error;
-
- int selectTabIndex = 1;
- if (dtTable_zczbzl.Rows.Count < 1)
- {
- selectTabIndex = 2;
- if (dtTable_zhgk.Rows.Count < 1)
- {
- selectTabIndex = 3;
- if (dtTable_error.Rows.Count < 1)
- {
- MessageBox.Show("数据一致");
- return;
- }
- }
- }
- xtraTabControl1.SelectedTabPageIndex = selectTabIndex;
转载自blog.csdn.net/shan1774965666/article/details/78050339