private void Button_Click(object sender, RoutedEventArgs e) { double h = System.Convert.ToDouble(HistoryData.Highprice); double l = System.Convert.ToDouble(HistoryData.Lowprice); double o = System.Convert.ToDouble(HistoryData.Openprice); double c = System.Convert.ToDouble(HistoryData.Closeprice); if (h < l) { MessageBox.Show("最高价不能小于最低价"); return; } else if (o > h || o < l) { MessageBox.Show("开盘价只能在最高价与最低价之间"); return; } else if (c < l || c > h) { MessageBox.Show("收盘价只能在最高价与最低价之间"); return; } BindingGroup bg = this.gridRoot.BindingGroup; bool isValid = bg.ValidateWithoutUpdate(); if (!isValid) { MessageBox.Show("设置未成功,请检查数据输入"); return; } this.DialogResult = true; this.Close(); }