private void button1_Click(object sender, EventArgs e) { Object[,] _data=null; IList<string> zs = new List<string>(); if(this.m_comSelect==0) { IList<string> year=new List<string>(); string kqName = ""; for (int i = 0; i < checkedListBox1.Items.Count; i++) { if (checkedListBox1.GetItemChecked(i)) { year.Add(checkedListBox1.Items[i].ToString()); } } for (int i = 0; i < checkedListBox2.Items.Count; i++) { if (checkedListBox2.GetItemChecked(i)) { kqName = checkedListBox2.Items[i].ToString(); } } for (int i = 0; i < checkedListBox3.Items.Count; i++) { if (checkedListBox3.GetItemChecked(i)) { zs.Add(checkedListBox3.Items[i].ToString()); } } _data = new Object[year.Count, zs.Count]; for (int i = 0; i < zs.Count;i++) { _data[0, i] = zs[i].ToString(); for (int j = 0; j < year.Count;j++ ) { m_oraCmd.CommandText = "select " + zsList[zs[i].ToString()].ToString() + " from [INDEX] WHERE [PLACE]='" + kqName.Trim() + "' and [YEARTIME]='" + year[j].ToString().Trim()+"'"; OleDbDataReader dr = m_oraCmd.ExecuteReader(); while (dr.Read()) { _data[j,i] = dr.GetValue(0).ToString(); } dr.Close(); } } } if (this.m_comSelect == 1) { IList<string> kq = new List<string>(); string yearName = ""; for (int i = 0; i < checkedListBox1.Items.Count; i++) { if (checkedListBox1.GetItemChecked(i)) { yearName = checkedListBox1.Items[i].ToString(); } } for (int i = 0; i < checkedListBox2.Items.Count; i++) { if (checkedListBox2.GetItemChecked(i)) { kq.Add(checkedListBox2.Items[i].ToString()); } } for (int i = 0; i < checkedListBox3.Items.Count; i++) { if (checkedListBox3.GetItemChecked(i)) { zs.Add(checkedListBox3.Items[i].ToString()); } } _data = new Object[kq.Count, zs.Count]; for (int i = 0; i < zs.Count; i++) { _data[0,i] = zs[i].ToString(); for (int j = 0; j < kq.Count; j++) { m_oraCmd.CommandText = "select " + zsList[zs[i].ToString()].ToString() + " from [INDEX] WHERE [PLACE]='" + kq[j].ToString() + "' and [YEARTIME]='" + yearName.Trim() + "'"; OleDbDataReader dr = m_oraCmd.ExecuteReader(); while (dr.Read()) { _data[j,i] = dr.GetValue(0).ToString(); } dr.Close(); } } } if (_data==null) { return; } frmShowChart chart = new frmShowChart(_data,zs.Count); chart.ShowDialog(); }
private void button1_Click(object sender, EventArgs e) { Object[,] _data = null; IList <string> zs = new List <string>(); if (this.m_comSelect == 0) { IList <string> year = new List <string>(); string kqName = ""; for (int i = 0; i < checkedListBox1.Items.Count; i++) { if (checkedListBox1.GetItemChecked(i)) { year.Add(checkedListBox1.Items[i].ToString()); } } for (int i = 0; i < checkedListBox2.Items.Count; i++) { if (checkedListBox2.GetItemChecked(i)) { kqName = checkedListBox2.Items[i].ToString(); } } for (int i = 0; i < checkedListBox3.Items.Count; i++) { if (checkedListBox3.GetItemChecked(i)) { zs.Add(checkedListBox3.Items[i].ToString()); } } _data = new Object[year.Count, zs.Count]; for (int i = 0; i < zs.Count; i++) { _data[0, i] = zs[i].ToString(); for (int j = 0; j < year.Count; j++) { m_oraCmd.CommandText = "select " + zsList[zs[i].ToString()].ToString() + " from [INDEX] WHERE [PLACE]='" + kqName.Trim() + "' and [YEARTIME]='" + year[j].ToString().Trim() + "'"; OleDbDataReader dr = m_oraCmd.ExecuteReader(); while (dr.Read()) { _data[j, i] = dr.GetValue(0).ToString(); } dr.Close(); } } } if (this.m_comSelect == 1) { IList <string> kq = new List <string>(); string yearName = ""; for (int i = 0; i < checkedListBox1.Items.Count; i++) { if (checkedListBox1.GetItemChecked(i)) { yearName = checkedListBox1.Items[i].ToString(); } } for (int i = 0; i < checkedListBox2.Items.Count; i++) { if (checkedListBox2.GetItemChecked(i)) { kq.Add(checkedListBox2.Items[i].ToString()); } } for (int i = 0; i < checkedListBox3.Items.Count; i++) { if (checkedListBox3.GetItemChecked(i)) { zs.Add(checkedListBox3.Items[i].ToString()); } } _data = new Object[kq.Count, zs.Count]; for (int i = 0; i < zs.Count; i++) { _data[0, i] = zs[i].ToString(); for (int j = 0; j < kq.Count; j++) { m_oraCmd.CommandText = "select " + zsList[zs[i].ToString()].ToString() + " from [INDEX] WHERE [PLACE]='" + kq[j].ToString() + "' and [YEARTIME]='" + yearName.Trim() + "'"; OleDbDataReader dr = m_oraCmd.ExecuteReader(); while (dr.Read()) { _data[j, i] = dr.GetValue(0).ToString(); } dr.Close(); } } } if (_data == null) { return; } frmShowChart chart = new frmShowChart(_data, zs.Count); chart.ShowDialog(); }