private void btnAdd_Click(object sender, RoutedEventArgs e) { var selectedStandList = standList.FindAll(x => x.IsChecked == true); if (selectedStandList.Count > 0) { foreach (Model.TB_StandardInfo standInfo in selectedStandList) { foreach (Model.TestInfoModel testInfoModel in testInfoModelList) { if (!refeBLL.Exists(testInfoModel.TestID, standInfo.ID)) { Model.TB_StandTestRefe refeModel = new Model.TB_StandTestRefe(); refeModel.StandID = standInfo.ID; refeModel.TestID = testInfoModel.TestID; refeBLL.Add(refeModel); } } } MessageBox.Show("添加成功!", "系统信息"); this.Close(); } else { MessageBox.Show("添加失败,请至少选择一个测试参考值!", "系统信息"); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { List <int> athIDs = new List <int>(); foreach (var item in athInfoListDict.Values) { foreach (var item1 in item) { if (item1.IsChecked) { athIDs.Add(item1.ID); } } } StringBuilder caseStringBuilder = new StringBuilder(); caseStringBuilder.Append("ath_id in(" + string.Join(",", athIDs.ToArray()) + ")"); if (standParam != null) { if (standParam?.Joint.Equals("-1") == false) { caseStringBuilder.Append(" and joint='" + standParam.Joint + "'"); } if (standParam?.Joint_Side.Equals("-1") == false) { caseStringBuilder.Append(" and joint_side='" + standParam.Joint_Side + "'"); } if (standParam?.Plane.Equals("-1") == false) { caseStringBuilder.Append(" and plane='" + standParam.Plane + "'"); } if (standParam?.Test_Mode.Equals("-1") == false) { caseStringBuilder.Append(" and test_mode='" + standParam.Test_Mode + "'"); } if (standParam?.Speed1 != "-1" && standParam?.Speed2 != "-1") { caseStringBuilder.Append(" and CInt(speed1)>=" + standParam.Speed1 + " and CInt(speed2)<=" + standParam.Speed2); } } List <Model.TB_TestInfo> testInfoList = testInfoBLL.GetModelList(caseStringBuilder.ToString()); //List<Model.TB_TestInfo> willAddedTestInfoList = new List<Model.TB_TestInfo>(); int count = 0; foreach (var item in testInfoList) { if (!standTestRefeBLL.Exists(item.ID, StandInfo.ID)) { Model.TB_StandTestRefe refe = new Model.TB_StandTestRefe(); refe.StandID = StandInfo.ID; refe.TestID = item.ID; standTestRefeBLL.Add(refe); count++; } } if (count == 0) { MessageBox.Show("没有找到测试数据!", "系统信息", MessageBoxButton.OK, MessageBoxImage.Information); } else { DialogResult = true; MessageBox.Show("添加了" + count + "条测试数据!", "系统信息", MessageBoxButton.OK, MessageBoxImage.Information); this.Close(); } }