public void CheckTopic() { if (imputTopics == null) { alert("Excel中没有题目"); } int count = 0; //有问题的题目数量 int flag = 0; List <ImputTopic> dataBase = topicBll.GetAllTopics(); foreach (var item in imputTopics) { item.ErrorInfo = ""; //初始化错误信息 //判断题库是否存在 if (!topicBll.IsHaveTopicSource(item.TopicSourceName)) { item.ErrorInfo += "该题库不存在 "; flag = 1; } //判断知识点是否存在 if (pointBll.IsHasFist(item.FirstPointName) == 0 || pointBll.IsHasSecond(item.SecondPointName) == 0) { item.ErrorInfo += "该题目的知识点不存在 "; flag = 1; } foreach (var dataItem in dataBase) { if (Public.Convert(item.TopicTitle) == dataItem.TopicTitle) { item.ErrorInfo += "此题在题库中已存在 "; flag = 1; } } if (flag == 1) { count++; } flag = 0; } Panel1.Visible = false; Panel2.Visible = true; //显示要上传的题目 if (count > 0) { ConfirmInput.Enabled = false; TableHead.Text = "文档中存在" + imputTopics.Count() + "题 其中" + count.ToString() + "题存在问题"; } else { ConfirmInput.Enabled = true; } }