private void SearchProductInfoBtn_Click(object sender, RoutedEventArgs e) { string datePicker1 = DatePicker1.Text.Trim(); string datePicker2 = DatePicker2.Text.Trim(); if (datePicker1 == "" || datePicker2 == "") { MessageBox.Show("时间不可以为空!"); } else { name.Clear(); output.Clear(); Qualified.Clear(); DataTable dt = DB_Product.searchProductInfo(datePicker1, datePicker2); if (dt != null) { ProductInfo_DgSource.ItemsSource = dt.DefaultView; ProductInfo_Page.ShowPages(ProductInfo_DgSource, dt, 9); } for (int i = 0; i < dt.Rows.Count; i++) { name.Add(dt.Rows[i][1].ToString().Trim()); output.Add(Convert.ToDouble(dt.Rows[i][2])); Qualified.Add(Convert.ToDouble(dt.Rows[i][3])); } myaxis.Labels = name.ToArray(); outputline.Values = new ChartValues <double>(output); Qualifiedline.Values = new ChartValues <double>(Qualified); } }