//按行政区域 public void Query(string str ) { // ds.Merge() ArcGISFoundation.QueryForm m_qf = new ArcGISFoundation.QueryForm(true); System.Windows.Forms.ListView listView_data = m_qf.nw_getListView(); listView_data.Items.Clear(); listView_data.Clear(); //MessageBox.Show("clear完成"); listView_data.Columns.Clear(); listView_data.Columns.Add("行政区域名", 120, HorizontalAlignment.Left);//省名,, listView_data.Columns.Add("牧草名", 120, HorizontalAlignment.Left);//省名,, listView_data.Columns.Add("适宜面积比", 120, HorizontalAlignment.Left); listView_data.Columns.Add("适宜面积", 120, HorizontalAlignment.Left); listView_data.Columns.Add("次适宜面积比", 120, HorizontalAlignment.Left); listView_data.Columns.Add("次适宜面积", 120, HorizontalAlignment.Left); m_qf.QueryForm_SetText(str); //MessageBox.Show(str); DataRow[] rows = ds.Tables[0].Select("行政区名称 like '%"+str+"%'"); //MessageBox.Show("ds查询完成"); foreach (DataRow mDr in rows) { ListViewItem lvi = new ListViewItem();//null; lvi.Text = mDr[1].ToString();//ds.Tables[0].Columns[0].ToString();//str; try { lvi.SubItems.Add(mDr[0].ToString());//ds.Tables[0].Columns[2].ToString() lvi.SubItems.Add(mDr[3].ToString());//ds.Tables[0].Columns[2].ToString() lvi.SubItems.Add(mDr[2].ToString());//ds.Tables[0].Columns[3].ToString() lvi.SubItems.Add(mDr[5].ToString());//ds.Tables[0].Columns[2].ToString() lvi.SubItems.Add(mDr[4].ToString());//ds.Tables[0].Columns[3].ToString() } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } finally { listView_data.Items.Add(lvi); } } //MessageBox.Show("插入列表完成"); // m_conn.Close(); if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show("暂无数据"); return; } // ds.Clear(); m_qf.Show(); return; /*m_conn.Open(); da.SelectCommand = new OleDbCommand(String.Format(m_sql, str), m_conn); da.Fill(ds, "sheet1"); // ds.Merge() System.Windows.Forms.ListView listView_data = m_qf.nw_getListView(); listView_data.Items.Clear(); listView_data.Columns.Clear(); listView_data.Columns.Add("行政区域名", 120, HorizontalAlignment.Left);//省名,, listView_data.Columns.Add("牧草名", 120, HorizontalAlignment.Left);//省名,, listView_data.Columns.Add("适宜面积比", 120, HorizontalAlignment.Left); listView_data.Columns.Add("适宜面积", 120, HorizontalAlignment.Left); listView_data.Columns.Add("次适宜面积比", 120, HorizontalAlignment.Left); listView_data.Columns.Add("次适宜面积", 120, HorizontalAlignment.Left); m_qf.QueryForm_SetText(str); //MessageBox.Show(str); foreach (DataRow mDr in ds.Tables[0].Rows) { ListViewItem lvi = new ListViewItem();//null; lvi.Text = mDr[1].ToString();//ds.Tables[0].Columns[0].ToString();//str; try { lvi.SubItems.Add(mDr[0].ToString());//ds.Tables[0].Columns[2].ToString() lvi.SubItems.Add(mDr[3].ToString());//ds.Tables[0].Columns[2].ToString() lvi.SubItems.Add(mDr[2].ToString());//ds.Tables[0].Columns[3].ToString() lvi.SubItems.Add(mDr[5].ToString());//ds.Tables[0].Columns[2].ToString() lvi.SubItems.Add(mDr[4].ToString());//ds.Tables[0].Columns[3].ToString() } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } finally { listView_data.Items.Add(lvi); } } m_conn.Close(); if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show("暂无数据"); return; } ds.Clear(); m_qf.Show();*/ }
//按牧草查询yy public void Query2(string str ) { ArcGISFoundation.QueryForm m_qf = new ArcGISFoundation.QueryForm(true); System.Windows.Forms.ListView listView_data = m_qf.nw_getListView(); listView_data.Items.Clear(); listView_data.Columns.Clear(); listView_data.Columns.Add("牧草名", 120, HorizontalAlignment.Left); listView_data.Columns.Add("行政区域名", 120, HorizontalAlignment.Left);//省名,, listView_data.Columns.Add("适宜面积比", 120, HorizontalAlignment.Left); listView_data.Columns.Add("适宜面积", 120, HorizontalAlignment.Left); listView_data.Columns.Add("次适宜面积比", 120, HorizontalAlignment.Left); listView_data.Columns.Add("次适宜面积", 120, HorizontalAlignment.Left); m_qf.QueryForm_SetText(str); //MessageBox.Show(str); DataRow[] rows = ds.Tables[0].Select("牧草名称 like '%"+str+"%'"); foreach (DataRow mDr in rows) { ListViewItem lvi = new ListViewItem();//null; lvi.Text = mDr[0].ToString();//ds.Tables[0].Columns[0].ToString();//str; try { lvi.SubItems.Add(mDr[1].ToString());//ds.Tables[0].Columns[2].ToString() lvi.SubItems.Add(mDr[3].ToString());//ds.Tables[0].Columns[2].ToString() lvi.SubItems.Add(mDr[2].ToString());//ds.Tables[0].Columns[3].ToString() lvi.SubItems.Add(mDr[5].ToString());//ds.Tables[0].Columns[2].ToString() lvi.SubItems.Add(mDr[4].ToString());//ds.Tables[0].Columns[3].ToString() } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } finally { listView_data.Items.Add(lvi); } } if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show("暂无数据"); return; } m_qf.Show(); }